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 @@ -379,6 +379,10 @@ Outer.add(TT->getAsTagDecl(), Flags); } + void VisitElaboratedType(const ElaboratedType* ET) { + Outer.add(ET->desugar(), Flags); + } + void VisitInjectedClassNameType(const InjectedClassNameType *ICNT) { Outer.add(ICNT->getDecl(), Flags); } 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 @@ -241,6 +241,13 @@ )cpp"; EXPECT_DECLS("TypedefTypeLoc", {"typedef S X", Rel::Alias}, {"struct S", Rel::Underlying}); + Code = R"cpp( + namespace ns { struct S{}; } + typedef ns::S X; + [[X]] x; + )cpp"; + EXPECT_DECLS("TypedefTypeLoc", {"typedef ns::S X", Rel::Alias}, + {"struct S", Rel::Underlying}); // FIXME: Auto-completion in a template requires disabling delayed template // parsing.