[PATCH] D90751: [clangd] Use ProjectAwareIndex
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 4 02:23:30 PST 2020
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90751.302792.patch
Type: text/x-patch
Size: 1551 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201104/b6429dae/attachment.bin>
More information about the cfe-commits
mailing list