File tree Expand file tree Collapse file tree 5 files changed +28
-35
lines changed Expand file tree Collapse file tree 5 files changed +28
-35
lines changed Original file line number Diff line number Diff line change @@ -702,17 +702,16 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
702702 return hasArgument (
703703 CC.LengthPos ,
704704 allOf (
705- anyOf (
706- ignoringImpCasts (integerLiteral ().bind (WrongLengthExprName)),
707- allOf (unless (hasDefinition (SizeOfCharExpr)),
708- allOf (CC.WithIncrease
709- ? ignoringImpCasts (hasDefinition (HasIncOp))
710- : ignoringImpCasts (allOf (
711- unless (hasDefinition (HasIncOp)),
712- anyOf (hasDefinition (binaryOperator ().bind (
713- UnknownLengthName)),
714- hasDefinition (anything ())))),
715- AnyOfWrongLengthInit))),
705+ anyOf (ignoringImpCasts (integerLiteral ().bind (WrongLengthExprName)),
706+ allOf (unless (hasDefinition (SizeOfCharExpr)),
707+ allOf (CC.WithIncrease
708+ ? ignoringImpCasts (hasDefinition (HasIncOp))
709+ : ignoringImpCasts (
710+ allOf (unless (hasDefinition (HasIncOp)),
711+ hasDefinition (optionally (
712+ binaryOperator ().bind (
713+ UnknownLengthName))))),
714+ AnyOfWrongLengthInit))),
716715 expr ().bind (LengthExprName)));
717716 };
718717
Original file line number Diff line number Diff line change @@ -24,14 +24,12 @@ void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) {
2424 isSameOrDerivedFrom (hasName (" ::std::exception" )))))))))),
2525 // This condition is always true, but will bind to the
2626 // template value if the thrown type is templated.
27- anyOf (has (expr (
28- hasType (substTemplateTypeParmType ().bind (" templ_type" )))),
29- anything ()),
27+ optionally (has (
28+ expr (hasType (substTemplateTypeParmType ().bind (" templ_type" ))))),
3029 // Bind to the declaration of the type of the value that
31- // is thrown. 'anything()' is necessary to always succeed
32- // in the 'eachOf' because builtin types are not
33- // 'namedDecl'.
34- eachOf (has (expr (hasType (namedDecl ().bind (" decl" )))), anything ()))
30+ // is thrown. 'optionally' is necessary because builtin types
31+ // are not 'namedDecl'.
32+ optionally (has (expr (hasType (namedDecl ().bind (" decl" ))))))
3533 .bind (" bad_throw" ),
3634 this );
3735}
Original file line number Diff line number Diff line change @@ -38,8 +38,7 @@ void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
3838 binaryOperator (
3939 hasAnyOperatorName (" &&" , " ==" ),
4040 hasEitherOperand (ignoringImpCasts (stringLiteral ().bind (" assertMSG" ))),
41- anyOf (binaryOperator (hasEitherOperand (IsAlwaysFalseWithCast)),
42- anything ()))
41+ optionally (binaryOperator (hasEitherOperand (IsAlwaysFalseWithCast))))
4342 .bind (" assertExprRoot" ),
4443 IsAlwaysFalse);
4544 auto NonConstexprFunctionCall =
@@ -52,12 +51,10 @@ void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
5251 auto NonConstexprCode =
5352 expr (anyOf (NonConstexprFunctionCall, NonConstexprVariableReference));
5453 auto AssertCondition =
55- expr (
56- anyOf (expr (ignoringParenCasts (anyOf (
57- AssertExprRoot, unaryOperator (hasUnaryOperand (
58- ignoringParenCasts (AssertExprRoot)))))),
59- anything ()),
60- unless (NonConstexprCode), unless (hasDescendant (NonConstexprCode)))
54+ expr (optionally (expr (ignoringParenCasts (anyOf (
55+ AssertExprRoot, unaryOperator (hasUnaryOperand (
56+ ignoringParenCasts (AssertExprRoot))))))),
57+ unless (NonConstexprCode), unless (hasDescendant (NonConstexprCode)))
6158 .bind (" condition" );
6259 auto Condition =
6360 anyOf (ignoringParenImpCasts (callExpr (
Original file line number Diff line number Diff line change @@ -26,13 +26,12 @@ void UseBoolLiteralsCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
2626
2727void UseBoolLiteralsCheck::registerMatchers (MatchFinder *Finder) {
2828 Finder->addMatcher (
29- traverse (
30- TK_AsIs,
31- implicitCastExpr (
32- has (ignoringParenImpCasts (integerLiteral ().bind (" literal" ))),
33- hasImplicitDestinationType (qualType (booleanType ())),
34- unless (isInTemplateInstantiation ()),
35- anyOf (hasParent (explicitCastExpr ().bind (" cast" )), anything ()))),
29+ traverse (TK_AsIs,
30+ implicitCastExpr (
31+ has (ignoringParenImpCasts (integerLiteral ().bind (" literal" ))),
32+ hasImplicitDestinationType (qualType (booleanType ())),
33+ unless (isInTemplateInstantiation ()),
34+ optionally (hasParent (explicitCastExpr ().bind (" cast" ))))),
3635 this );
3736
3837 Finder->addMatcher (
Original file line number Diff line number Diff line change @@ -348,8 +348,8 @@ void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
348348 implicitCastExpr ().bind (" implicitCastFromBool" ),
349349 unless (hasParent (BitfieldConstruct)),
350350 // Check also for nested casts, for example: bool -> int -> float.
351- anyOf ( hasParent ( implicitCastExpr (). bind ( " furtherImplicitCast " )),
352- anything ( )),
351+ optionally (
352+ hasParent ( implicitCastExpr (). bind ( " furtherImplicitCast " ) )),
353353 unless (isInTemplateInstantiation ()),
354354 unless (IsInCompilerGeneratedFunction))),
355355 this );
You can’t perform that action at this time.
0 commit comments