diff --git a/clang-tools-extra/clangd/tool/ClangdMain.cpp b/clang-tools-extra/clangd/tool/ClangdMain.cpp --- a/clang-tools-extra/clangd/tool/ClangdMain.cpp +++ b/clang-tools-extra/clangd/tool/ClangdMain.cpp @@ -13,6 +13,9 @@ #include "Protocol.h" #include "Transport.h" #include "index/Background.h" +#include "index/Index.h" +#include "index/Merge.h" +#include "index/ProjectAware.h" #include "index/Serialization.h" #include "index/remote/Client.h" #include "refactor/Rename.h" @@ -40,6 +43,7 @@ #include #include #include +#include #ifndef _WIN32 #include @@ -726,6 +730,7 @@ Opts.ResourceDir = ResourceDir; Opts.BuildDynamicSymbolIndex = EnableIndex; Opts.CollectMainFileRefs = CollectMainFileRefs; + std::vector> IdxStack; std::unique_ptr StaticIdx; std::future AsyncIndexLoad; // Block exit while loading the index. if (EnableIndex && !IndexFile.empty()) { @@ -757,7 +762,15 @@ } #endif Opts.BackgroundIndex = EnableBackgroundIndex; - Opts.StaticIndex = StaticIdx.get(); + auto PAI = createProjectAwareIndex(); + if (StaticIdx) { + IdxStack.emplace_back(std::move(StaticIdx)); + IdxStack.emplace_back( + std::make_unique(PAI.get(), IdxStack.back().get())); + Opts.StaticIndex = IdxStack.back().get(); + } else { + Opts.StaticIndex = PAI.get(); + } Opts.AsyncThreadsCount = WorkerThreadsCount; Opts.BuildRecoveryAST = RecoveryAST; Opts.PreserveRecoveryASTType = RecoveryASTType;