[PATCH] D66478: [clangd] Ignore implicit conversion-operator nodes in find refs.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 21 03:54:19 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL369514: [clangd] Ignore implicit conversion-operator nodes in find refs. (authored by hokein, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66478?vs=216149&id=216366#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66478/new/

https://reviews.llvm.org/D66478

Files:
  clang-tools-extra/trunk/clangd/XRefs.cpp
  clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/trunk/clangd/XRefs.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/XRefs.cpp
+++ clang-tools-extra/trunk/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);
       };
 
Index: clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/trunk/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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66478.216366.patch
Type: text/x-patch
Size: 1327 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190821/3fa241b8/attachment.bin>


More information about the cfe-commits mailing list