This revision was automatically updated to reflect the committed changes. Closed by commit rGbf71e4fe0a68: [clangd] Collect name references in the index. (authored by hokein).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D69338/new/ https://reviews.llvm.org/D69338 Files: clang-tools-extra/clangd/index/SymbolCollector.cpp clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -626,6 +626,23 @@ EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "c").ID, _)))); } +TEST_F(SymbolCollectorTest, NameReferences) { + CollectorOpts.RefFilter = RefKind::All; + CollectorOpts.RefsInHeaders = true; + Annotations Header(R"( + class [[Foo]] { + public: + [[Foo]]() {} + ~[[Foo]]() {} + }; + )"); + CollectorOpts.RefFilter = RefKind::All; + runSymbolCollector(Header.code(), ""); + // When we find references for class Foo, we expect to see all + // constructor/destructor references. + EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "Foo").ID, + HaveRanges(Header.ranges())))); +} TEST_F(SymbolCollectorTest, HeaderAsMainFile) { CollectorOpts.RefFilter = RefKind::All; Index: clang-tools-extra/clangd/index/SymbolCollector.cpp =================================================================== --- clang-tools-extra/clangd/index/SymbolCollector.cpp +++ clang-tools-extra/clangd/index/SymbolCollector.cpp @@ -263,10 +263,6 @@ Decl::FriendObjectKind::FOK_None) && !(Roles & static_cast<unsigned>(index::SymbolRole::Definition))) return true; - // Skip non-semantic references, we should start processing these when we - // decide to implement renaming with index support. - if ((Roles & static_cast<unsigned>(index::SymbolRole::NameReference))) - return true; // A declaration created for a friend declaration should not be used as the // canonical declaration in the index. Use OrigD instead, unless we've already // picked a replacement for D
Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp +++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp @@ -626,6 +626,23 @@ EXPECT_THAT(Refs, Not(Contains(Pair(findSymbol(MainSymbols, "c").ID, _)))); } +TEST_F(SymbolCollectorTest, NameReferences) { + CollectorOpts.RefFilter = RefKind::All; + CollectorOpts.RefsInHeaders = true; + Annotations Header(R"( + class [[Foo]] { + public: + [[Foo]]() {} + ~[[Foo]]() {} + }; + )"); + CollectorOpts.RefFilter = RefKind::All; + runSymbolCollector(Header.code(), ""); + // When we find references for class Foo, we expect to see all + // constructor/destructor references. + EXPECT_THAT(Refs, Contains(Pair(findSymbol(Symbols, "Foo").ID, + HaveRanges(Header.ranges())))); +} TEST_F(SymbolCollectorTest, HeaderAsMainFile) { CollectorOpts.RefFilter = RefKind::All; Index: clang-tools-extra/clangd/index/SymbolCollector.cpp =================================================================== --- clang-tools-extra/clangd/index/SymbolCollector.cpp +++ clang-tools-extra/clangd/index/SymbolCollector.cpp @@ -263,10 +263,6 @@ Decl::FriendObjectKind::FOK_None) && !(Roles & static_cast<unsigned>(index::SymbolRole::Definition))) return true; - // Skip non-semantic references, we should start processing these when we - // decide to implement renaming with index support. - if ((Roles & static_cast<unsigned>(index::SymbolRole::NameReference))) - return true; // A declaration created for a friend declaration should not be used as the // canonical declaration in the index. Use OrigD instead, unless we've already // picked a replacement for D
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits