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 @@ -37,6 +37,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/raw_ostream.h" +#include #include #include @@ -76,6 +77,11 @@ bool IsNonstaticMember) { if (!T) return {}; + if (auto *ET = T->getAs()) { + auto Result = + ET->getDecl()->lookup(NameFactory(ET->getDecl()->getASTContext())); + return {Result.begin(), Result.end()}; + } if (auto *ICNT = T->getAs()) { T = ICNT->getInjectedSpecializationType().getTypePtrOrNull(); } diff --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp b/clang-tools-extra/clangd/unittests/XRefsTests.cpp --- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp +++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp @@ -529,6 +529,14 @@ void test(unique_ptr>& V) { V->fo^o(); } + )cpp", + + R"cpp(// Heuristic resolution of dependent enumerator + template + struct Foo { + enum class E { [[A]], B }; + E e = E::A^; + }; )cpp"}; for (const char *Test : Tests) { Annotations T(Test);