[PATCH] D69511: [clangd] Do not report anonymous entities in findExplicitReferences
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 28 06:46:14 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c430a7c6f6b: [clangd] Do not report anonymous entities in findExplicitReferences (authored by ilya-biryukov).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69511/new/
https://reviews.llvm.org/D69511
Files:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -852,8 +852,8 @@
};
// delegating initializer
class $10^Foo {
- $11^Foo(int$12^);
- $13^Foo(): $14^Foo(111) {}
+ $11^Foo(int);
+ $12^Foo(): $13^Foo(111) {}
};
}
)cpp",
@@ -869,11 +869,19 @@
"9: targets = {Base}\n"
"10: targets = {Foo}, decl\n"
"11: targets = {foo()::Foo::Foo}, decl\n"
- // FIXME: we should exclude the built-in type.
- "12: targets = {}, decl\n"
- "13: targets = {foo()::Foo::Foo}, decl\n"
- "14: targets = {Foo}\n"},
-
+ "12: targets = {foo()::Foo::Foo}, decl\n"
+ "13: targets = {Foo}\n"},
+ // Anonymous entities should not be reported.
+ {
+ R"cpp(
+ void foo() {
+ class {} $0^x;
+ int (*$1^fptr)(int $2^a, int) = nullptr;
+ }
+ )cpp",
+ "0: targets = {x}, decl\n"
+ "1: targets = {fptr}, decl\n"
+ "2: targets = {a}, decl\n"},
};
for (const auto &C : Cases) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -448,8 +448,15 @@
// FIXME: decide on how to surface destructors when we need them.
if (llvm::isa<CXXDestructorDecl>(ND))
return;
- Refs.push_back(ReferenceLoc{
- getQualifierLoc(*ND), ND->getLocation(), /*IsDecl=*/true, {ND}});
+ // Filter anonymous decls, name location will point outside the name token
+ // and the clients are not prepared to handle that.
+ if (ND->getDeclName().isIdentifier() &&
+ !ND->getDeclName().getAsIdentifierInfo())
+ return;
+ Refs.push_back(ReferenceLoc{getQualifierLoc(*ND),
+ ND->getLocation(),
+ /*IsDecl=*/true,
+ {ND}});
}
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69511.226658.patch
Type: text/x-patch
Size: 2378 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191028/f0dd966e/attachment-0001.bin>
More information about the cfe-commits
mailing list