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);
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);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits