kadircet created this revision. kadircet added a reviewer: sammccall. Herald added subscribers: cfe-commits, usaxena95, arphaman. Herald added a project: clang. kadircet requested review of this revision. Herald added subscribers: MaskRay, ilya-biryukov.
Put project-aware-index between command-line specified static index and ClangdServer indexes. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D90751 Files: clang-tools-extra/clangd/tool/ClangdMain.cpp Index: clang-tools-extra/clangd/tool/ClangdMain.cpp =================================================================== --- clang-tools-extra/clangd/tool/ClangdMain.cpp +++ 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 <mutex> #include <string> #include <thread> +#include <vector> #ifndef _WIN32 #include <unistd.h> @@ -726,6 +730,7 @@ Opts.ResourceDir = ResourceDir; Opts.BuildDynamicSymbolIndex = EnableIndex; Opts.CollectMainFileRefs = CollectMainFileRefs; + std::vector<std::unique_ptr<SymbolIndex>> IdxStack; std::unique_ptr<SymbolIndex> StaticIdx; std::future<void> AsyncIndexLoad; // Block exit while loading the index. if (EnableIndex && !IndexFile.empty()) { @@ -757,7 +762,15 @@ } #endif Opts.BackgroundIndex = EnableBackgroundIndex; - Opts.StaticIndex = StaticIdx.get(); + ProjectAwareIndex PAI; + if (StaticIdx) { + IdxStack.emplace_back(std::move(StaticIdx)); + IdxStack.emplace_back( + std::make_unique<MergedIndex>(&PAI, IdxStack.back().get())); + Opts.StaticIndex = IdxStack.back().get(); + } else { + Opts.StaticIndex = &PAI; + } Opts.AsyncThreadsCount = WorkerThreadsCount; Opts.BuildRecoveryAST = RecoveryAST; Opts.PreserveRecoveryASTType = RecoveryASTType;
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp =================================================================== --- clang-tools-extra/clangd/tool/ClangdMain.cpp +++ 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 <mutex> #include <string> #include <thread> +#include <vector> #ifndef _WIN32 #include <unistd.h> @@ -726,6 +730,7 @@ Opts.ResourceDir = ResourceDir; Opts.BuildDynamicSymbolIndex = EnableIndex; Opts.CollectMainFileRefs = CollectMainFileRefs; + std::vector<std::unique_ptr<SymbolIndex>> IdxStack; std::unique_ptr<SymbolIndex> StaticIdx; std::future<void> AsyncIndexLoad; // Block exit while loading the index. if (EnableIndex && !IndexFile.empty()) { @@ -757,7 +762,15 @@ } #endif Opts.BackgroundIndex = EnableBackgroundIndex; - Opts.StaticIndex = StaticIdx.get(); + ProjectAwareIndex PAI; + if (StaticIdx) { + IdxStack.emplace_back(std::move(StaticIdx)); + IdxStack.emplace_back( + std::make_unique<MergedIndex>(&PAI, IdxStack.back().get())); + Opts.StaticIndex = IdxStack.back().get(); + } else { + Opts.StaticIndex = &PAI; + } Opts.AsyncThreadsCount = WorkerThreadsCount; Opts.BuildRecoveryAST = RecoveryAST; Opts.PreserveRecoveryASTType = RecoveryASTType;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits