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 @@ -127,11 +127,6 @@ // template using pvec = vector; pvec x; // There's no Decl `pvec`, we must choose `pvec` or `vector` // and both are lossy. We must know upfront what the caller ultimately wants. -// -// FIXME: improve common dependent scope using name lookup in primary templates. -// We currently handle several dependent constructs, but some others remain to -// be handled: -// - UnresolvedUsingTypenameDecl struct TargetFinder { using RelSet = DeclRelationSet; using Rel = DeclRelation; @@ -207,6 +202,10 @@ } } Flags |= Rel::Alias; // continue with the alias + } else if (isa(D)) { + // FIXME: improve common dependent scope using name lookup in primary + // templates. + Flags |= Rel::Alias; } else if (const UsingShadowDecl *USD = dyn_cast(D)) { // Include the Introducing decl, but don't traverse it. This may end up // including *all* shadows, which we don't want. @@ -382,6 +381,9 @@ // TypeLoc never has a deduced type. https://llvm.org/PR42914 Outer.add(DT->getDeducedType(), Flags); } + void VisitUnresolvedUsingType(const UnresolvedUsingType *UUT) { + Outer.add(UUT->getDecl(), Flags); + } void VisitDeducedTemplateSpecializationType( const DeducedTemplateSpecializationType *DTST) { if (const auto *USD = DTST->getTemplateName().getAsUsingShadowDecl()) 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 @@ -268,6 +268,17 @@ EXPECT_DECLS("DeducedTemplateSpecializationTypeLoc", {"using ns::S", Rel::Alias}, {"template class S"}, {"class S", Rel::TemplatePattern}); + + Code = R"cpp( + template + class Foo { public: class foo {}; }; + template class A : public Foo { + using typename Foo::foo; + [[foo]] abc; + }; + )cpp"; + EXPECT_DECLS("UnresolvedUsingTypeLoc", + {"using typename Foo::foo", Rel::Alias}); } TEST_F(TargetDeclTest, BaseSpecifier) {