hokein updated this revision to Diff 172926.
hokein added a comment.
Fix a typo.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D54202
Files:
clangd/index/SymbolCollector.cpp
clangd/index/SymbolCollector.h
unittests/clangd/SymbolCollectorTests.cpp
Index: unittests/clangd/SymbolCollectorTests.cpp
===================================================================
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -443,6 +443,8 @@
};
class $bar[[Bar]];
void $func[[func]]();
+
+ namespace $ns[[NS]] {} // namespace ref is ignored
)");
Annotations Main(R"(
class $bar[[Bar]] {};
@@ -474,6 +476,7 @@
HaveRanges(Main.ranges("bar")))));
EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "func").ID,
HaveRanges(Main.ranges("func")))));
+ EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(Symbols, "NS").ID, _))));
// Symbols *only* in the main file (a, b, c) had no refs collected.
auto MainSymbols =
TestTU::withHeaderCode(SymbolsOnlyInMainCode.code()).headerSymbols();
Index: clangd/index/SymbolCollector.h
===================================================================
--- clangd/index/SymbolCollector.h
+++ clangd/index/SymbolCollector.h
@@ -56,6 +56,9 @@
bool CountReferences = false;
/// The symbol ref kinds that will be collected.
/// If not set, SymbolCollector will not collect refs.
+ /// Note that references of namespace decls are not collected, as they
+ /// contribute large part of the index, anbd they are less useful compared
+ /// with other decls.
RefKind RefFilter = RefKind::Unknown;
/// If set to true, SymbolCollector will collect all refs (from main file
/// and included headers); otherwise, only refs from main file will be
Index: clangd/index/SymbolCollector.cpp
===================================================================
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -356,7 +356,7 @@
return true;
if (!shouldCollectSymbol(*ND, *ASTCtx, Opts))
return true;
- if (CollectRef &&
+ if (CollectRef && !isa<NamespaceDecl>(ND) &&
(Opts.RefsInHeaders || SM.getFileID(SpellingLoc) == SM.getMainFileID()))
DeclRefs[ND].emplace_back(SpellingLoc, Roles);
// Don't continue indexing if this is a mere reference.
Index: unittests/clangd/SymbolCollectorTests.cpp
===================================================================
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -443,6 +443,8 @@
};
class $bar[[Bar]];
void $func[[func]]();
+
+ namespace $ns[[NS]] {} // namespace ref is ignored
)");
Annotations Main(R"(
class $bar[[Bar]] {};
@@ -474,6 +476,7 @@
HaveRanges(Main.ranges("bar")))));
EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "func").ID,
HaveRanges(Main.ranges("func")))));
+ EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(Symbols, "NS").ID, _))));
// Symbols *only* in the main file (a, b, c) had no refs collected.
auto MainSymbols =
TestTU::withHeaderCode(SymbolsOnlyInMainCode.code()).headerSymbols();
Index: clangd/index/SymbolCollector.h
===================================================================
--- clangd/index/SymbolCollector.h
+++ clangd/index/SymbolCollector.h
@@ -56,6 +56,9 @@
bool CountReferences = false;
/// The symbol ref kinds that will be collected.
/// If not set, SymbolCollector will not collect refs.
+ /// Note that references of namespace decls are not collected, as they
+ /// contribute large part of the index, anbd they are less useful compared
+ /// with other decls.
RefKind RefFilter = RefKind::Unknown;
/// If set to true, SymbolCollector will collect all refs (from main file
/// and included headers); otherwise, only refs from main file will be
Index: clangd/index/SymbolCollector.cpp
===================================================================
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -356,7 +356,7 @@
return true;
if (!shouldCollectSymbol(*ND, *ASTCtx, Opts))
return true;
- if (CollectRef &&
+ if (CollectRef && !isa<NamespaceDecl>(ND) &&
(Opts.RefsInHeaders || SM.getFileID(SpellingLoc) == SM.getMainFileID()))
DeclRefs[ND].emplace_back(SpellingLoc, Roles);
// Don't continue indexing if this is a mere reference.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits