[PATCH] D66478: [clangd] Ignore implicit conversion-operator nodes in find refs.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 20 07:57:28 PDT 2019
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D66478
Files:
clang-tools-extra/clangd/XRefs.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
@@ -2069,6 +2069,18 @@
using ::[[fo^o]];
}
)cpp",
+
+ R"cpp(
+ struct X {
+ operator bool();
+ };
+
+ int test() {
+ X [[a]];
+ [[a]].operator bool();
+ if ([[a^]]) {} // ignore implicit conversion-operator AST node
+ }
+ )cpp",
};
for (const char *Test : Tests) {
Annotations T(Test);
Index: clang-tools-extra/clangd/XRefs.cpp
===================================================================
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -187,6 +187,11 @@
// experssion is impossible to write down.
if (const auto *CtorExpr = dyn_cast<CXXConstructExpr>(E))
return CtorExpr->getParenOrBraceRange().isInvalid();
+ // Ignore implicit conversion-operator AST node.
+ if (const auto *ME = dyn_cast<MemberExpr>(E)) {
+ if (isa<CXXConversionDecl>(ME->getMemberDecl()))
+ return ME->getMemberLoc().isInvalid();
+ }
return isa<ImplicitCastExpr>(E);
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66478.216149.patch
Type: text/x-patch
Size: 1291 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190820/cebdf120/attachment.bin>
More information about the cfe-commits
mailing list