31 has(ignoringParenImpCasts(integerLiteral().bind(
"literal"))),
32 hasImplicitDestinationType(qualType(booleanType())),
33 unless(isInTemplateInstantiation()),
34 optionally(hasParent(explicitCastExpr().bind(
"cast"))))),
40 hasParent(implicitCastExpr(
41 hasImplicitDestinationType(qualType(booleanType())),
42 unless(isInTemplateInstantiation()))),
43 eachOf(hasTrueExpression(ignoringParenImpCasts(
44 integerLiteral().bind(
"literal"))),
45 hasFalseExpression(ignoringParenImpCasts(
46 integerLiteral().bind(
"literal")))))),
51 const auto *Literal = Result.Nodes.getNodeAs<IntegerLiteral>(
"literal");
52 const auto *Cast = Result.Nodes.getNodeAs<Expr>(
"cast");
53 bool LiteralBooleanValue = Literal->getValue().getBoolValue();
55 if (Literal->isInstantiationDependent())
58 const Expr *Expression = Cast ? Cast : Literal;
60 bool InMacro = Expression->getBeginLoc().isMacroID();
62 if (InMacro && IgnoreMacros)
66 diag(Expression->getExprLoc(),
67 "converting integer literal to bool, use bool literal instead");
70 Diag << FixItHint::CreateReplacement(
71 Expression->getSourceRange(), LiteralBooleanValue ?
"true" :
"false");
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.