[clang-tools-extra] r369514 - [clangd] Ignore implicit conversion-operator nodes in find refs.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 21 03:54:20 PDT 2019
Author: hokein
Date: Wed Aug 21 03:54:19 2019
New Revision: 369514
URL: http://llvm.org/viewvc/llvm-project?rev=369514&view=rev
Log:
[clangd] Ignore implicit conversion-operator nodes in find refs.
Reviewers: ilya-biryukov
Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66478
Modified:
clang-tools-extra/trunk/clangd/XRefs.cpp
clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp
Modified: clang-tools-extra/trunk/clangd/XRefs.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=369514&r1=369513&r2=369514&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/XRefs.cpp (original)
+++ clang-tools-extra/trunk/clangd/XRefs.cpp Wed Aug 21 03:54:19 2019
@@ -187,6 +187,11 @@ public:
// 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);
};
Modified: clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp?rev=369514&r1=369513&r2=369514&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp Wed Aug 21 03:54:19 2019
@@ -2069,6 +2069,18 @@ TEST(FindReferences, ExplicitSymbols) {
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);
More information about the cfe-commits
mailing list