41 if (StringLikeClasses.empty()) {
44 const auto StrCompare = cxxMemberCallExpr(
45 callee(cxxMethodDecl(hasName(
"compare"), ofClass(cxxRecordDecl(hasAnyName(
46 StringLikeClasses))))),
47 hasArgument(0, expr().bind(
"str2")), argumentCountIs(1),
48 callee(memberExpr().bind(
"str1")));
53 implicitCastExpr(hasImplicitDestinationType(booleanType()),
60 binaryOperator(hasAnyOperatorName(
"==",
"!="),
61 hasOperands(StrCompare.bind(
"compare"),
62 integerLiteral(equals(0)).bind(
"zero")))
68 if (
const auto *Matched = Result.Nodes.getNodeAs<Stmt>(
"match1")) {
73 if (
const auto *Matched = Result.Nodes.getNodeAs<Stmt>(
"match2")) {
74 const ASTContext &Ctx = *Result.Context;
76 if (
const auto *Zero = Result.Nodes.getNodeAs<Stmt>(
"zero")) {
77 const auto *Str1 = Result.Nodes.getNodeAs<MemberExpr>(
"str1");
78 const auto *Str2 = Result.Nodes.getNodeAs<Stmt>(
"str2");
79 const auto *Compare = Result.Nodes.getNodeAs<Stmt>(
"compare");
84 Diag << FixItHint::CreateInsertion(Str1->getBeginLoc(),
"*");
86 Diag << tooling::fixit::createReplacement(*Zero, *Str2, Ctx)
87 << tooling::fixit::createReplacement(*Compare, *Str1->getBase(),
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.