forked from OSchip/llvm-project
[clangd] Extend findTarget()'s dependent name heuristic to handle enumerators
Fixes https://github.com/clangd/clangd/issues/296 Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D76103
This commit is contained in:
parent
a2920c4ea9
commit
31b7f0ed6a
|
@ -37,6 +37,7 @@
|
|||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
|
@ -76,6 +77,11 @@ std::vector<const NamedDecl *> getMembersReferencedViaDependentName(
|
|||
bool IsNonstaticMember) {
|
||||
if (!T)
|
||||
return {};
|
||||
if (auto *ET = T->getAs<EnumType>()) {
|
||||
auto Result =
|
||||
ET->getDecl()->lookup(NameFactory(ET->getDecl()->getASTContext()));
|
||||
return {Result.begin(), Result.end()};
|
||||
}
|
||||
if (auto *ICNT = T->getAs<InjectedClassNameType>()) {
|
||||
T = ICNT->getInjectedSpecializationType().getTypePtrOrNull();
|
||||
}
|
||||
|
|
|
@ -529,6 +529,14 @@ TEST(LocateSymbol, All) {
|
|||
void test(unique_ptr<S<T>>& V) {
|
||||
V->fo^o();
|
||||
}
|
||||
)cpp",
|
||||
|
||||
R"cpp(// Heuristic resolution of dependent enumerator
|
||||
template <typename T>
|
||||
struct Foo {
|
||||
enum class E { [[A]], B };
|
||||
E e = E::A^;
|
||||
};
|
||||
)cpp"};
|
||||
for (const char *Test : Tests) {
|
||||
Annotations T(Test);
|
||||
|
|
Loading…
Reference in New Issue