================ @@ -171,10 +182,64 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder *Finder) { hasRHS(lengthExprForStringNode("needle"))))) .bind("expr"), this); + + Finder->addMatcher( + cxxOperatorCallExpr( + hasAnyOperatorName("==", "!="), + anyOf( + hasOperands( + cxxMemberCallExpr( + argumentCountIs(2), hasArgument(0, ZeroLiteral), + hasArgument(1, lengthExprForStringNode("needle")), + callee( + cxxMethodDecl(hasName("substr"), + ofClass(OnClassWithStartsWithFunction)) + .bind("find_fun"))) + .bind("find_expr"), + expr().bind("needle")), + hasOperands(expr().bind("needle"), + cxxMemberCallExpr( + argumentCountIs(2), hasArgument(0, ZeroLiteral), + hasArgument(1, lengthExprForStringNode("needle")), + callee(cxxMethodDecl( + hasName("substr"), + ofClass(OnClassWithStartsWithFunction)) + .bind("find_fun"))) + .bind("find_expr")))) + .bind("expr"), + this); ---------------- hjanuschka wrote:
🙈 i am super impressed, and the more i learn about AST the more i know i know nothing! do you have any good resources to ramp up the knowledge in this area? (trying to sourcegraph search, copy&paste, trial-and-error so far) https://github.com/llvm/llvm-project/pull/116033 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits