[PATCH] D108119: wired up standard library indexing
Christian Kühnel via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 16 04:18:33 PDT 2021
kuhnel created this revision.
kuhnel added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
kuhnel requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.
Only plumbing code to enable standard library indexing
to enable end-to-end testing.
No changes to stdlib indexing behavior.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D108119
Files:
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
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
@@ -484,6 +484,18 @@
init(true),
};
+opt<bool> IndexStandardLibrary{
+ "index-standard-library",
+ cat(Features),
+ desc("Background index should always include the STL headers even if \n"
+ "not used at the moment. This will enable code completion and \n"
+ "include fixer."
+ "WARNING: This option is experimental only, and will be removed "
+ "eventually. Don't rely on it"),
+ init(false),
+ Hidden,
+};
+
std::function<void()> getMemoryCleanupFunction() {
if (!EnableMallocTrim)
return nullptr;
@@ -912,6 +924,7 @@
if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
Opts.Encoding = ForceOffsetEncoding;
+ Opts.IndexStandardLibrary = IndexStandardLibrary;
if (CheckFile.getNumOccurrences()) {
llvm::SmallString<256> Path;
if (auto Error =
Index: clang-tools-extra/clangd/ClangdServer.h
===================================================================
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -167,7 +167,11 @@
FeatureModuleSet *FeatureModules = nullptr;
explicit operator TUScheduler::Options() const;
+
+ // Automatically index the standard library - experimental feature
+ bool IndexStandardLibrary = false;
};
+
// Sensible default options for use in tests.
// Features like indexing must be enabled if desired.
static Options optsForTest();
Index: clang-tools-extra/clangd/ClangdServer.cpp
===================================================================
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -27,6 +27,7 @@
#include "index/CanonicalIncludes.h"
#include "index/FileIndex.h"
#include "index/Merge.h"
+#include "index/StdLib.h"
#include "refactor/Rename.h"
#include "refactor/Tweak.h"
#include "support/Logger.h"
@@ -175,6 +176,13 @@
this->Index = Idx;
}
};
+ if (Opts.IndexStandardLibrary) {
+ auto SLIndex = indexStandardLibrary(TFS);
+ if (!SLIndex || !SLIndex->get()) {
+ log("Unable to build standard library index. Not using it.");
+ }
+ AddIndex(SLIndex->get());
+ }
if (Opts.StaticIndex)
AddIndex(Opts.StaticIndex);
if (Opts.BackgroundIndex) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108119.366587.patch
Type: text/x-patch
Size: 2471 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210816/2c232a05/attachment-0001.bin>
More information about the cfe-commits
mailing list