Skip to content

Commit

Permalink
[clangd] Ignore implicit conversion-operator nodes in find refs.
Browse files Browse the repository at this point in the history
Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66478

llvm-svn: 369514
  • Loading branch information
hokein committed Aug 21, 2019
1 parent 68756a8 commit 65c58a9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clang-tools-extra/clangd/XRefs.cpp
Expand Up @@ -187,6 +187,11 @@ class DeclarationAndMacrosFinder : public index::IndexDataConsumer {
// 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);
};

Expand Down
12 changes: 12 additions & 0 deletions clang-tools-extra/clangd/unittests/XRefsTests.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 65c58a9

Please sign in to comment.