diff --git a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp index 8a1dd77176cdf..ab1476ea09972 100644 --- a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp +++ b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp @@ -95,14 +95,15 @@ class ASTWalker : public RecursiveASTVisitor { // to them doesn't count as uses (generally the type should provide them, so // ignore them). // Unless we're using an operator defined as a member, in such cases treat - // this as a regular reference. + // these as regular member references. bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *S) { if (!WalkUpFromCXXOperatorCallExpr(S)) return false; if (auto *CD = S->getCalleeDecl()) { if (llvm::isa(CD)) { // Treat this as a regular member reference. - report(S->getOperatorLoc(), getMemberProvider(S->getArg(0)->getType())); + report(S->getOperatorLoc(), getMemberProvider(S->getArg(0)->getType()), + RefType::Implicit); } else { report(S->getOperatorLoc(), llvm::dyn_cast(CD), RefType::Implicit); diff --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp index fceec670076c9..ac2085d82c1d8 100644 --- a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp @@ -296,12 +296,12 @@ TEST(WalkAST, Operator) { testWalk( "struct string { friend int $implicit^operator+(string, string); }; ", "int k = string() ^+ string();"); - // Unless they're members, we treat them as regular member expr calls. - testWalk("struct $explicit^string {int operator+(string); }; ", + // Treat member operators as regular member expr calls. + testWalk("struct $implicit^string {int operator+(string); }; ", "int k = string() ^+ string();"); // Make sure usage is attributed to the alias. testWalk( - "struct string {int operator+(string); }; using $explicit^foo = string;", + "struct string {int operator+(string); }; using $implicit^foo = string;", "int k = foo() ^+ string();"); }