diff --git a/clang/lib/Index/IndexTypeSourceInfo.cpp b/clang/lib/Index/IndexTypeSourceInfo.cpp --- a/clang/lib/Index/IndexTypeSourceInfo.cpp +++ b/clang/lib/Index/IndexTypeSourceInfo.cpp @@ -170,6 +170,11 @@ 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(); diff --git a/clang/unittests/Index/IndexTests.cpp b/clang/unittests/Index/IndexTests.cpp --- a/clang/unittests/Index/IndexTests.cpp +++ b/clang/unittests/Index/IndexTests.cpp @@ -293,6 +293,27 @@ WrittenAt(Position(4, 8))))); } +TEST(IndexTest, InjecatedNameClass) { + std::string Code = R"cpp( + template + class Foo { + void f(Foo x); + }; + )cpp"; + auto Index = std::make_shared(); + IndexingOptions Opts; + tooling::runToolOnCode(std::make_unique(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