From 65c58a902d00d8523cbe55d6218ba8d23b6dd185 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Wed, 21 Aug 2019 10:54:19 +0000 Subject: [PATCH] [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 llvm-svn: 369514 --- clang-tools-extra/clangd/XRefs.cpp | 5 +++++ clang-tools-extra/clangd/unittests/XRefsTests.cpp | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp index 5dd5186879d0..829fdf43b668 100644 --- a/clang-tools-extra/clangd/XRefs.cpp +++ b/clang-tools-extra/clangd/XRefs.cpp @@ -187,6 +187,11 @@ public: // experssion is impossible to write down. if (const auto *CtorExpr = dyn_cast(E)) return CtorExpr->getParenOrBraceRange().isInvalid(); + // Ignore implicit conversion-operator AST node. + if (const auto *ME = dyn_cast(E)) { + if (isa(ME->getMemberDecl())) + return ME->getMemberLoc().isInvalid(); + } return isa(E); }; diff --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp b/clang-tools-extra/clangd/unittests/XRefsTests.cpp index 1079eeaaa709..877bfaa5c1d4 100644 --- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp +++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp @@ -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);