hokein created this revision. hokein added a reviewer: kadircet. Herald added subscribers: usaxena95, arphaman, ilya-biryukov. Herald added a project: clang.
Currently, we (clangd) are missing this kind of references. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D73109 Files: clang/lib/Index/IndexTypeSourceInfo.cpp clang/unittests/Index/IndexTests.cpp Index: clang/unittests/Index/IndexTests.cpp =================================================================== --- clang/unittests/Index/IndexTests.cpp +++ clang/unittests/Index/IndexTests.cpp @@ -293,6 +293,27 @@ WrittenAt(Position(4, 8))))); } +TEST(IndexTest, InjecatedNameClass) { + std::string Code = R"cpp( + template <typename T> + class Foo { + void f(Foo x); + }; + )cpp"; + auto Index = std::make_shared<Indexer>(); + IndexingOptions Opts; + tooling::runToolOnCode(std::make_unique<IndexAction>(Index, Opts), Code); + EXPECT_THAT( + Index->Symbols, + UnorderedElementsAre( + AllOf(QName("Foo"), Kind(SymbolKind::Class), + WrittenAt(Position(3, 11))), + AllOf(QName("Foo::f"), Kind(SymbolKind::InstanceMethod), + WrittenAt(Position(4, 12))), + AllOf(QName("Foo"), Kind(SymbolKind::Class), + HasRole(SymbolRole::Reference), WrittenAt(Position(4, 14))))); +} + } // namespace } // namespace index } // namespace clang Index: clang/lib/Index/IndexTypeSourceInfo.cpp =================================================================== --- clang/lib/Index/IndexTypeSourceInfo.cpp +++ clang/lib/Index/IndexTypeSourceInfo.cpp @@ -170,6 +170,12 @@ return true; } + bool VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) { + return IndexCtx.handleReference(TL.getDecl(), TL.getNameLoc(), + Parent, ParentDC, SymbolRoleSet(), + Relations); + } + bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) { const DependentNameType *DNT = TL.getTypePtr(); const NestedNameSpecifier *NNS = DNT->getQualifier();
Index: clang/unittests/Index/IndexTests.cpp =================================================================== --- clang/unittests/Index/IndexTests.cpp +++ clang/unittests/Index/IndexTests.cpp @@ -293,6 +293,27 @@ WrittenAt(Position(4, 8))))); } +TEST(IndexTest, InjecatedNameClass) { + std::string Code = R"cpp( + template <typename T> + class Foo { + void f(Foo x); + }; + )cpp"; + auto Index = std::make_shared<Indexer>(); + IndexingOptions Opts; + tooling::runToolOnCode(std::make_unique<IndexAction>(Index, Opts), Code); + EXPECT_THAT( + Index->Symbols, + UnorderedElementsAre( + AllOf(QName("Foo"), Kind(SymbolKind::Class), + WrittenAt(Position(3, 11))), + AllOf(QName("Foo::f"), Kind(SymbolKind::InstanceMethod), + WrittenAt(Position(4, 12))), + AllOf(QName("Foo"), Kind(SymbolKind::Class), + HasRole(SymbolRole::Reference), WrittenAt(Position(4, 14))))); +} + } // namespace } // namespace index } // namespace clang Index: clang/lib/Index/IndexTypeSourceInfo.cpp =================================================================== --- clang/lib/Index/IndexTypeSourceInfo.cpp +++ clang/lib/Index/IndexTypeSourceInfo.cpp @@ -170,6 +170,12 @@ return true; } + bool VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) { + return IndexCtx.handleReference(TL.getDecl(), TL.getNameLoc(), + Parent, ParentDC, SymbolRoleSet(), + Relations); + } + bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) { const DependentNameType *DNT = TL.getTypePtr(); const NestedNameSpecifier *NNS = DNT->getQualifier();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits