[PATCH] D76103: [clangd] Extend findTarget()'s dependent name heuristic to handle enumerators
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 17 12:57:09 PDT 2020
nridge updated this revision to Diff 250863.
nridge marked 2 inline comments as done.
nridge added a comment.
Address review comments
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76103/new/
https://reviews.llvm.org/D76103
Files:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -520,6 +520,14 @@
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);
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ 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 <iterator>
#include <utility>
#include <vector>
@@ -76,6 +77,13 @@
bool IsNonstaticMember) {
if (!T)
return {};
+ if (auto *ET = T->getAs<EnumType>()) {
+ std::vector<const NamedDecl *> Result;
+ llvm::copy(
+ ET->getDecl()->lookup(NameFactory(ET->getDecl()->getASTContext())),
+ std::back_inserter(Result));
+ return Result;
+ }
if (auto *ICNT = T->getAs<InjectedClassNameType>()) {
T = ICNT->getInjectedSpecializationType().getTypePtrOrNull();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76103.250863.patch
Type: text/x-patch
Size: 1452 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200317/fa46a89f/attachment-0001.bin>
More information about the cfe-commits
mailing list