diff --git a/src/clang_tu.cc b/src/clang_tu.cc index 67f4856d..b78adf7c 100644 --- a/src/clang_tu.cc +++ b/src/clang_tu.cc @@ -163,10 +163,16 @@ buildCompilerInvocation(const std::string &main, std::vector args, ci->getFrontendOpts().DisableFree = false; // Enable IndexFrontendAction::shouldSkipFunctionBody. ci->getFrontendOpts().SkipFunctionBodies = true; +#if LLVM_VERSION_MAJOR >= 18 + ci->getLangOpts().SpellChecking = false; + ci->getLangOpts().RecoveryAST = true; + ci->getLangOpts().RecoveryASTType = true; +#else ci->getLangOpts()->SpellChecking = false; #if LLVM_VERSION_MAJOR >= 11 ci->getLangOpts()->RecoveryAST = true; ci->getLangOpts()->RecoveryASTType = true; +#endif #endif auto &isec = ci->getFrontendOpts().Inputs; if (isec.size()) diff --git a/src/indexer.cc b/src/indexer.cc index 83b77a20..50bb299c 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -1294,9 +1294,15 @@ index(SemaManager *manager, WorkingFiles *wfiles, VFS *vfs, ok = false; // -fparse-all-comments enables documentation in the indexer and in // code completion. +#if LLVM_VERSION_MAJOR >= 18 + ci->getLangOpts().CommentOpts.ParseAllComments = + g_config->index.comments > 1; + ci->getLangOpts().RetainCommentsFromSystemHeaders = true; +#else ci->getLangOpts()->CommentOpts.ParseAllComments = g_config->index.comments > 1; ci->getLangOpts()->RetainCommentsFromSystemHeaders = true; +#endif std::string buf = wfiles->getContent(main); std::vector> bufs; if (buf.size()) diff --git a/src/sema_manager.cc b/src/sema_manager.cc index c6f803c3..6be9e60d 100644 --- a/src/sema_manager.cc +++ b/src/sema_manager.cc @@ -368,8 +368,12 @@ void buildPreamble(Session &session, CompilerInvocation &ci, std::unique_ptr buf = llvm::MemoryBuffer::getMemBuffer(content); #if LLVM_VERSION_MAJOR >= 12 +#if LLVM_VERSION_MAJOR >= 18 + auto bounds = ComputePreambleBounds(ci.getLangOpts(), *buf, 0); +#else // llvmorg-12-init-11522-g4c55c3b66de auto bounds = ComputePreambleBounds(*ci.getLangOpts(), *buf, 0); +#endif // llvmorg-12-init-17739-gf4d02fbe418d if (!task.from_diag && oldP && oldP->preamble.CanReuse(ci, *buf, bounds, *fs)) @@ -387,8 +391,13 @@ void buildPreamble(Session &session, CompilerInvocation &ci, ws.erase(std::remove(ws.begin(), ws.end(), "error"), ws.end()); ci.getDiagnosticOpts().IgnoreWarnings = false; ci.getFrontendOpts().SkipFunctionBodies = true; +#if LLVM_VERSION_MAJOR >= 18 + ci.getLangOpts().CommentOpts.ParseAllComments = g_config->index.comments > 1; + ci.getLangOpts().RetainCommentsFromSystemHeaders = true; +#else ci.getLangOpts()->CommentOpts.ParseAllComments = g_config->index.comments > 1; ci.getLangOpts()->RetainCommentsFromSystemHeaders = true; +#endif StoreDiags dc(task.path); IntrusiveRefCntPtr de = @@ -498,12 +507,19 @@ void *completionMain(void *manager_) { fOpts.CodeCompletionAt.FileName = task->path; fOpts.CodeCompletionAt.Line = task->position.line + 1; fOpts.CodeCompletionAt.Column = task->position.character + 1; +#if LLVM_VERSION_MAJOR >= 18 + ci->getLangOpts().CommentOpts.ParseAllComments = true; +#else ci->getLangOpts()->CommentOpts.ParseAllComments = true; +#endif DiagnosticConsumer dc; std::string content = manager->wfiles->getContent(task->path); auto buf = llvm::MemoryBuffer::getMemBuffer(content); -#if LLVM_VERSION_MAJOR >= 12 // llvmorg-12-init-11522-g4c55c3b66de +#if LLVM_VERSION_MAJOR >= 18 + PreambleBounds bounds = + ComputePreambleBounds(ci->getLangOpts(), *buf, 0); +#elif LLVM_VERSION_MAJOR >= 12 // llvmorg-12-init-11522-g4c55c3b66de PreambleBounds bounds = ComputePreambleBounds(*ci->getLangOpts(), *buf, 0); #else @@ -601,7 +617,10 @@ void *diagnosticMain(void *manager_) { if (!rebuild) { std::string content = manager->wfiles->getContent(task.path); auto buf = llvm::MemoryBuffer::getMemBuffer(content); -#if LLVM_VERSION_MAJOR >= 12 // llvmorg-12-init-11522-g4c55c3b66de +#if LLVM_VERSION_MAJOR >= 18 + PreambleBounds bounds = + ComputePreambleBounds(ci->getLangOpts(), *buf, 0); +#elif LLVM_VERSION_MAJOR >= 12 // llvmorg-12-init-11522-g4c55c3b66de PreambleBounds bounds = ComputePreambleBounds(*ci->getLangOpts(), *buf, 0); #else @@ -622,7 +641,11 @@ void *diagnosticMain(void *manager_) { ci->getDiagnosticOpts().Warnings.push_back("no-unused-function"); ci->getDiagnosticOpts().IgnoreWarnings = false; ci->getFrontendOpts().SkipFunctionBodies = false; +#if LLVM_VERSION_MAJOR >= 18 + ci->getLangOpts().SpellChecking = g_config->diagnostics.spellChecking; +#else ci->getLangOpts()->SpellChecking = g_config->diagnostics.spellChecking; +#endif StoreDiags dc(task.path); std::string content = manager->wfiles->getContent(task.path); auto buf = llvm::MemoryBuffer::getMemBuffer(content);