Skip to content

Commit 04757e7

Browse files
committed
[clangd] Index reserved symbols from *intrin.h system headers
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: #118684
1 parent bd40421 commit 04757e7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

clang-tools-extra/clangd/index/SymbolCollector.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,14 @@ bool SymbolCollector::shouldCollectSymbol(const NamedDecl &ND,
550550
// Avoid indexing internal symbols in protobuf generated headers.
551551
if (isPrivateProtoDecl(ND))
552552
return false;
553+
554+
// System headers that end with `intrin.h` likely contain useful symbols.
553555
if (!Opts.CollectReserved &&
554556
(hasReservedName(ND) || hasReservedScope(*ND.getDeclContext())) &&
555-
ASTCtx.getSourceManager().isInSystemHeader(ND.getLocation()))
557+
ASTCtx.getSourceManager().isInSystemHeader(ND.getLocation()) &&
558+
!ASTCtx.getSourceManager()
559+
.getFilename(ND.getLocation())
560+
.ends_with("intrin.h"))
556561
return false;
557562

558563
return true;

0 commit comments

Comments
 (0)