diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp --- a/clang-tools-extra/clangd/FindTarget.cpp +++ b/clang-tools-extra/clangd/FindTarget.cpp @@ -374,6 +374,11 @@ void VisitTagType(const TagType *TT) { Outer.add(TT->getAsTagDecl(), Flags); } + + void VisitInjectedClassNameType(const InjectedClassNameType *ICNT) { + Outer.add(ICNT->getDecl(), Flags); + } + void VisitDecltypeType(const DecltypeType *DTT) { Outer.add(DTT->getUnderlyingType(), Flags | Rel::Underlying); } diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp --- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -286,6 +286,14 @@ )cpp"; // FIXME: We don't do a good job printing TemplateTypeParmDecls, apparently! EXPECT_DECLS("SizeOfPackExpr", ""); + + Code = R"cpp( + template + class Foo { + void f([[Foo]] x); + }; + )cpp"; + EXPECT_DECLS("InjectedClassNameTypeLoc", "class Foo"); } TEST_F(TargetDeclTest, ClassTemplate) {