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) {
702
702
return hasArgument (
703
703
CC.LengthPos ,
704
704
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))),
716
715
expr ().bind (LengthExprName)));
717
716
};
718
717
Original file line number Diff line number Diff line change @@ -24,14 +24,12 @@ void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) {
24
24
isSameOrDerivedFrom (hasName (" ::std::exception" )))))))))),
25
25
// This condition is always true, but will bind to the
26
26
// 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" ))))),
30
29
// 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" ))))))
35
33
.bind (" bad_throw" ),
36
34
this );
37
35
}
Original file line number Diff line number Diff line change @@ -38,8 +38,7 @@ void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
38
38
binaryOperator (
39
39
hasAnyOperatorName (" &&" , " ==" ),
40
40
hasEitherOperand (ignoringImpCasts (stringLiteral ().bind (" assertMSG" ))),
41
- anyOf (binaryOperator (hasEitherOperand (IsAlwaysFalseWithCast)),
42
- anything ()))
41
+ optionally (binaryOperator (hasEitherOperand (IsAlwaysFalseWithCast))))
43
42
.bind (" assertExprRoot" ),
44
43
IsAlwaysFalse);
45
44
auto NonConstexprFunctionCall =
@@ -52,12 +51,10 @@ void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
52
51
auto NonConstexprCode =
53
52
expr (anyOf (NonConstexprFunctionCall, NonConstexprVariableReference));
54
53
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)))
61
58
.bind (" condition" );
62
59
auto Condition =
63
60
anyOf (ignoringParenImpCasts (callExpr (
Original file line number Diff line number Diff line change @@ -26,13 +26,12 @@ void UseBoolLiteralsCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
26
26
27
27
void UseBoolLiteralsCheck::registerMatchers (MatchFinder *Finder) {
28
28
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" ))))),
36
35
this );
37
36
38
37
Finder->addMatcher (
Original file line number Diff line number Diff line change @@ -348,8 +348,8 @@ void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
348
348
implicitCastExpr ().bind (" implicitCastFromBool" ),
349
349
unless (hasParent (BitfieldConstruct)),
350
350
// 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 " ) )),
353
353
unless (isInTemplateInstantiation ()),
354
354
unless (IsInCompilerGeneratedFunction))),
355
355
this );
You can’t perform that action at this time.
0 commit comments