-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clangd] Index reserved symbols from *intrin.h
system headers
#119735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang-tools-extra @llvm/pr-subscribers-clangd Author: Joseph Huber (jhuber6) ChangesSummary: Fixes: #118684 Full diff: https://github.com/llvm/llvm-project/pull/119735.diff 1 Files Affected:
diff --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 81125dbb1aeafc..6d0af20e31260c 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -550,9 +550,14 @@ bool SymbolCollector::shouldCollectSymbol(const NamedDecl &ND,
// Avoid indexing internal symbols in protobuf generated headers.
if (isPrivateProtoDecl(ND))
return false;
+
+ // System headers that end with `intrin.h` likely contain useful symbols.
if (!Opts.CollectReserved &&
(hasReservedName(ND) || hasReservedScope(*ND.getDeclContext())) &&
- ASTCtx.getSourceManager().isInSystemHeader(ND.getLocation()))
+ ASTCtx.getSourceManager().isInSystemHeader(ND.getLocation()) &&
+ !ASTCtx.getSourceManager()
+ .getFilename(ND.getLocation())
+ .ends_with("intrin.h"))
return false;
return true;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch. I thought about whether it makes sense to have an additional check for the *intrin.h
header being inside the resource directory specifically, but I don't see any headers with that name ending in any other system include directories, so I don't think we need to bother.
Would you mind adding a test case to SymbolCollectorTests.cpp
as well? Here's an example of a test customizing a header file name, and here of exercising the "is system header" codepath.
Summary: `clangd` intentionally suppresses indexing symbols from system headers as these are likely implementation details the user does not want. Howver, there are plenty of system headers that provide extensions that we want to index, such as vector intrinsic headers. This patch adds an extra check for these commonly-named '*intrin.h' headers. This is not fully inclusive for all symbols the user might want, but it's a good start. Fixes: llvm#118684
46e5548
to
89b8a34
Compare
89b8a34
to
d320cbb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (I made a small tweak to the test name)
Summary:
clangd
intentionally suppresses indexing symbols from system headersas these are likely implementation details the user does not want.
Howver, there are plenty of system headers that provide extensions that
we want to index, such as vector intrinsic headers. This patch adds an
extra check for these commonly-named '*intrin.h' headers. This is not
fully inclusive for all symbols the user might want, but it's a good
start.
Fixes: #118684