diff options
28 files changed, 198 insertions, 221 deletions
diff --git a/clang-tools-extra/change-namespace/ChangeNamespace.cpp b/clang-tools-extra/change-namespace/ChangeNamespace.cpp index d0eaa306a79..7a7103181f5 100644 --- a/clang-tools-extra/change-namespace/ChangeNamespace.cpp +++ b/clang-tools-extra/change-namespace/ChangeNamespace.cpp @@ -450,8 +450,8 @@ void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) { typeLoc(IsInMovedNs, loc(qualType(hasDeclaration(DeclMatcher.bind("from_decl")))), unless(anyOf(hasParent(typeLoc(loc(qualType( - allOf(hasDeclaration(DeclMatcher), - unless(templateSpecializationType())))))), + hasDeclaration(DeclMatcher), + unless(templateSpecializationType()))))), hasParent(nestedNameSpecifierLoc()), hasAncestor(isImplicit()), hasAncestor(UsingShadowDeclInClass), @@ -505,13 +505,12 @@ void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) { hasAncestor(namespaceDecl(isAnonymous())), hasAncestor(cxxRecordDecl()))), hasParent(namespaceDecl())); - Finder->addMatcher( - expr(allOf(hasAncestor(decl().bind("dc")), IsInMovedNs, - unless(hasAncestor(isImplicit())), - anyOf(callExpr(callee(FuncMatcher)).bind("call"), - declRefExpr(to(FuncMatcher.bind("func_decl"))) - .bind("func_ref")))), - this); + Finder->addMatcher(expr(hasAncestor(decl().bind("dc")), IsInMovedNs, + unless(hasAncestor(isImplicit())), + anyOf(callExpr(callee(FuncMatcher)).bind("call"), + declRefExpr(to(FuncMatcher.bind("func_decl"))) + .bind("func_ref"))), + this); auto GlobalVarMatcher = varDecl( hasGlobalStorage(), hasParent(namespaceDecl()), diff --git a/clang-tools-extra/clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp index 5f33697d6cd..675322dd8f4 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BoolPointerImplicitConversionCheck.cpp @@ -20,11 +20,11 @@ void BoolPointerImplicitConversionCheck::registerMatchers(MatchFinder *Finder) { // condition. Filter negations. Finder->addMatcher( ifStmt(hasCondition(findAll(implicitCastExpr( - allOf(unless(hasParent(unaryOperator(hasOperatorName("!")))), - hasSourceExpression(expr( - hasType(pointerType(pointee(booleanType()))), - ignoringParenImpCasts(declRefExpr().bind("expr")))), - hasCastKind(CK_PointerToBoolean))))), + unless(hasParent(unaryOperator(hasOperatorName("!")))), + hasSourceExpression( + expr(hasType(pointerType(pointee(booleanType()))), + ignoringParenImpCasts(declRefExpr().bind("expr")))), + hasCastKind(CK_PointerToBoolean)))), unless(isInTemplateInstantiation())) .bind("if"), this); diff --git a/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp index c8af1abbb81..3c8a6c5d10b 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp @@ -190,12 +190,12 @@ void ExceptionEscapeCheck::registerMatchers(MatchFinder *Finder) { return; Finder->addMatcher( - functionDecl(allOf(anyOf(isNoThrow(), cxxDestructorDecl(), - cxxConstructorDecl(isMoveConstructor()), - cxxMethodDecl(isMoveAssignmentOperator()), - hasName("main"), hasName("swap"), - isEnabled(FunctionsThatShouldNotThrow)), - throws(unless(isIgnored(IgnoredExceptions))))) + functionDecl(anyOf(isNoThrow(), cxxDestructorDecl(), + cxxConstructorDecl(isMoveConstructor()), + cxxMethodDecl(isMoveAssignmentOperator()), + hasName("main"), hasName("swap"), + isEnabled(FunctionsThatShouldNotThrow)), + throws(unless(isIgnored(IgnoredExceptions)))) .bind("thrower"), this); } diff --git a/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp index 25544a503bf..83ddbcfb703 100644 --- a/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp @@ -29,17 +29,17 @@ void MisplacedOperatorInStrlenInAllocCheck::registerMatchers( const auto BadUse = callExpr(callee(StrLenFunc), hasAnyArgument(ignoringImpCasts( - binaryOperator(allOf(hasOperatorName("+"), - hasRHS(ignoringParenImpCasts( - integerLiteral(equals(1)))))) + binaryOperator( + hasOperatorName("+"), + hasRHS(ignoringParenImpCasts(integerLiteral(equals(1))))) .bind("BinOp")))) .bind("StrLen"); const auto BadArg = anyOf( - allOf(hasDescendant(BadUse), - unless(binaryOperator(allOf( + allOf(unless(binaryOperator( hasOperatorName("+"), hasLHS(BadUse), - hasRHS(ignoringParenImpCasts(integerLiteral(equals(1)))))))), + hasRHS(ignoringParenImpCasts(integerLiteral(equals(1)))))), + hasDescendant(BadUse)), BadUse); const auto Alloc0Func = diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp index 1abad4eb163..53537005fa1 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp @@ -119,30 +119,30 @@ void SuspiciousEnumUsageCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { void SuspiciousEnumUsageCheck::registerMatchers(MatchFinder *Finder) { const auto enumExpr = [](StringRef RefName, StringRef DeclName) { - return allOf(ignoringImpCasts(expr().bind(RefName)), - ignoringImpCasts(hasType(enumDecl().bind(DeclName)))); + return expr(ignoringImpCasts(expr().bind(RefName)), + ignoringImpCasts(hasType(enumDecl().bind(DeclName)))); }; Finder->addMatcher( binaryOperator(hasOperatorName("|"), hasLHS(enumExpr("", "enumDecl")), - hasRHS(allOf(enumExpr("", "otherEnumDecl"), - ignoringImpCasts(hasType(enumDecl( - unless(equalsBoundNode("enumDecl")))))))) + hasRHS(expr(enumExpr("", "otherEnumDecl"), + ignoringImpCasts(hasType(enumDecl( + unless(equalsBoundNode("enumDecl")))))))) .bind("diffEnumOp"), this); Finder->addMatcher( binaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("|")), hasLHS(enumExpr("lhsExpr", "enumDecl")), - hasRHS(allOf(enumExpr("rhsExpr", ""), - ignoringImpCasts(hasType(enumDecl( - equalsBoundNode("enumDecl"))))))), + hasRHS(expr(enumExpr("rhsExpr", ""), + ignoringImpCasts(hasType( + enumDecl(equalsBoundNode("enumDecl"))))))), this); Finder->addMatcher( binaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("|")), hasEitherOperand( - allOf(hasType(isInteger()), unless(enumExpr("", "")))), + expr(hasType(isInteger()), unless(enumExpr("", "")))), hasEitherOperand(enumExpr("enumExpr", "enumDecl"))), this); diff --git a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp index 7245986663d..11799ebf6d2 100644 --- a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp @@ -298,7 +298,7 @@ void UseAfterMoveFinder::getReinits( declStmt(hasDescendant(equalsNode(MovedVariable))), // clear() and assign() on standard containers. cxxMemberCallExpr( - on(allOf(DeclRefMatcher, StandardContainerTypeMatcher)), + on(expr(DeclRefMatcher, StandardContainerTypeMatcher)), // To keep the matcher simple, we check for assign() calls // on all standard containers, even though only vector, // deque, forward_list and list have assign(). If assign() @@ -307,7 +307,7 @@ void UseAfterMoveFinder::getReinits( callee(cxxMethodDecl(hasAnyName("clear", "assign")))), // reset() on standard smart pointers. cxxMemberCallExpr( - on(allOf(DeclRefMatcher, StandardSmartPointerTypeMatcher)), + on(expr(DeclRefMatcher, StandardSmartPointerTypeMatcher)), callee(cxxMethodDecl(hasName("reset")))), // Methods that have the [[clang::reinitializes]] attribute. cxxMemberCallExpr( diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp index f601b2443d7..59993cba345 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/InterfacesGlobalInitCheck.cpp @@ -18,18 +18,18 @@ namespace tidy { namespace cppcoreguidelines { void InterfacesGlobalInitCheck::registerMatchers(MatchFinder *Finder) { - const auto IsGlobal = - allOf(hasGlobalStorage(), - hasDeclContext(anyOf(translationUnitDecl(), // Global scope. - namespaceDecl(), // Namespace scope. - recordDecl())), // Class scope. - unless(isConstexpr())); + const auto GlobalVarDecl = + varDecl(hasGlobalStorage(), + hasDeclContext(anyOf(translationUnitDecl(), // Global scope. + namespaceDecl(), // Namespace scope. + recordDecl())), // Class scope. + unless(isConstexpr())); const auto ReferencesUndefinedGlobalVar = declRefExpr(hasDeclaration( - varDecl(IsGlobal, unless(isDefinition())).bind("referencee"))); + varDecl(GlobalVarDecl, unless(isDefinition())).bind("referencee"))); Finder->addMatcher( - varDecl(IsGlobal, isDefinition(), + varDecl(GlobalVarDecl, isDefinition(), hasInitializer(expr(hasDescendant(ReferencesUndefinedGlobalVar)))) .bind("var"), this); diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp index ebebfda2b08..0b7e0a3d469 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp @@ -87,36 +87,34 @@ void OwningMemoryCheck::registerMatchers(MatchFinder *Finder) { // resources. This check assumes that all pointer arguments of a legacy // functions shall be 'gsl::owner<>'. Finder->addMatcher( - callExpr( - allOf(callee(LegacyOwnerConsumers), - hasAnyArgument(allOf(unless(ignoringImpCasts(ConsideredOwner)), - hasType(pointerType()))))) + callExpr(callee(LegacyOwnerConsumers), + hasAnyArgument(expr(unless(ignoringImpCasts(ConsideredOwner)), + hasType(pointerType())))) .bind("legacy_consumer"), this); // Matching assignment to owners, with the rhs not being an owner nor creating // one. - Finder->addMatcher(binaryOperator(allOf(matchers::isAssignmentOperator(), - hasLHS(IsOwnerType), - hasRHS(unless(ConsideredOwner)))) + Finder->addMatcher(binaryOperator(matchers::isAssignmentOperator(), + hasLHS(IsOwnerType), + hasRHS(unless(ConsideredOwner))) .bind("owner_assignment"), this); // Matching initialization of owners with non-owners, nor creating owners. Finder->addMatcher( - namedDecl( - varDecl(allOf(hasInitializer(unless(ConsideredOwner)), IsOwnerType)) - .bind("owner_initialization")), + namedDecl(varDecl(hasInitializer(unless(ConsideredOwner)), IsOwnerType) + .bind("owner_initialization")), this); const auto HasConstructorInitializerForOwner = has(cxxConstructorDecl(forEachConstructorInitializer( - cxxCtorInitializer(allOf(isMemberInitializer(), forField(IsOwnerType), - withInitializer( - // Avoid templatesdeclaration with - // excluding parenListExpr. - allOf(unless(ConsideredOwner), - unless(parenListExpr()))))) + cxxCtorInitializer( + isMemberInitializer(), forField(IsOwnerType), + withInitializer( + // Avoid templatesdeclaration with + // excluding parenListExpr. + allOf(unless(ConsideredOwner), unless(parenListExpr())))) .bind("owner_member_initializer")))); // Match class member initialization that expects owners, but does not get @@ -125,11 +123,11 @@ void OwningMemoryCheck::registerMatchers(MatchFinder *Finder) { // Matching on assignment operations where the RHS is a newly created owner, // but the LHS is not an owner. - Finder->addMatcher( - binaryOperator(allOf(matchers::isAssignmentOperator(), - hasLHS(unless(IsOwnerType)), hasRHS(CreatesOwner))) - .bind("bad_owner_creation_assignment"), - this); + Finder->addMatcher(binaryOperator(matchers::isAssignmentOperator(), + hasLHS(unless(IsOwnerType)), + hasRHS(CreatesOwner)) + .bind("bad_owner_creation_assignment"), + this); // Matching on initialization operations where the initial value is a newly // created owner, but the LHS is not an owner. @@ -160,10 +158,9 @@ void OwningMemoryCheck::registerMatchers(MatchFinder *Finder) { // Matching on functions, that return an owner/resource, but don't declare // their return type as owner. Finder->addMatcher( - functionDecl( - allOf(hasDescendant(returnStmt(hasReturnValue(ConsideredOwner)) - .bind("bad_owner_return")), - unless(returns(qualType(hasDeclaration(OwnerDecl)))))) + functionDecl(hasDescendant(returnStmt(hasReturnValue(ConsideredOwner)) + .bind("bad_owner_return")), + unless(returns(qualType(hasDeclaration(OwnerDecl))))) .bind("function_decl"), this); @@ -171,10 +168,9 @@ void OwningMemoryCheck::registerMatchers(MatchFinder *Finder) { // destructor to properly release the owner. Finder->addMatcher( cxxRecordDecl( - allOf( - has(fieldDecl(IsOwnerType).bind("undestructed_owner_member")), - anyOf(unless(has(cxxDestructorDecl())), - has(cxxDestructorDecl(anyOf(isDefaulted(), isDeleted())))))) + has(fieldDecl(IsOwnerType).bind("undestructed_owner_member")), + anyOf(unless(has(cxxDestructorDecl())), + has(cxxDestructorDecl(anyOf(isDefaulted(), isDeleted()))))) .bind("non_destructor_class"), this); } diff --git a/clang-tools-extra/clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.cpp b/clang-tools-extra/clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.cpp index e33f90acb1a..c8ffd2e58c6 100644 --- a/clang-tools-extra/clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.cpp +++ b/clang-tools-extra/clang-tidy/fuchsia/StaticallyConstructedObjectsCheck.cpp @@ -34,18 +34,17 @@ void StaticallyConstructedObjectsCheck::registerMatchers(MatchFinder *Finder) { if (!getLangOpts().CPlusPlus11) return; - Finder->addMatcher( - varDecl(allOf( - // Match global, statically stored objects... - isGlobalStatic(), - // ... that have C++ constructors... - hasDescendant(cxxConstructExpr(unless(allOf( - // ... unless it is constexpr ... - hasDeclaration(cxxConstructorDecl(isConstexpr())), - // ... and is statically initialized. - isConstantInitializer())))))) - .bind("decl"), - this); + Finder->addMatcher(varDecl( + // Match global, statically stored objects... + isGlobalStatic(), + // ... that have C++ constructors... + hasDescendant(cxxConstructExpr(unless(allOf( + // ... unless it is constexpr ... + hasDeclaration(cxxConstructorDecl(isConstexpr())), + // ... and is statically initialized. + isConstantInitializer()))))) + .bind("decl"), + this); } void StaticallyConstructedObjectsCheck::check( diff --git a/clang-tools-extra/clang-tidy/fuchsia/TrailingReturnCheck.cpp b/clang-tools-extra/clang-tidy/fuchsia/TrailingReturnCheck.cpp index 4ffa3f79588..71dc47243bb 100644 --- a/clang-tools-extra/clang-tidy/fuchsia/TrailingReturnCheck.cpp +++ b/clang-tools-extra/clang-tidy/fuchsia/TrailingReturnCheck.cpp @@ -34,9 +34,9 @@ void TrailingReturnCheck::registerMatchers(MatchFinder *Finder) { // using decltype specifiers and lambda with otherwise unutterable // return types. Finder->addMatcher( - functionDecl(allOf(hasTrailingReturn(), - unless(anyOf(returns(decltypeType()), - hasParent(cxxRecordDecl(isLambda())))))) + functionDecl(hasTrailingReturn(), + unless(anyOf(returns(decltypeType()), + hasParent(cxxRecordDecl(isLambda()))))) .bind("decl"), this); } diff --git a/clang-tools-extra/clang-tidy/google/OverloadedUnaryAndCheck.cpp b/clang-tools-extra/clang-tidy/google/OverloadedUnaryAndCheck.cpp index ff67b534d0c..57702c76bfb 100644 --- a/clang-tools-extra/clang-tidy/google/OverloadedUnaryAndCheck.cpp +++ b/clang-tools-extra/clang-tidy/google/OverloadedUnaryAndCheck.cpp @@ -33,12 +33,10 @@ void OverloadedUnaryAndCheck::registerMatchers( this); // Also match freestanding unary operator& overloads. Be careful not to match // binary methods. - Finder->addMatcher( - functionDecl(allOf( - unless(cxxMethodDecl()), - functionDecl(parameterCountIs(1), hasOverloadedOperatorName("&")) - .bind("overload"))), - this); + Finder->addMatcher(functionDecl(unless(cxxMethodDecl()), parameterCountIs(1), + hasOverloadedOperatorName("&")) + .bind("overload"), + this); } void OverloadedUnaryAndCheck::check(const MatchFinder::MatchResult &Result) { diff --git a/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp b/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp index b299151ccea..890a56f7b56 100644 --- a/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/ExceptionBaseclassCheck.cpp @@ -23,22 +23,21 @@ void ExceptionBaseclassCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( cxxThrowExpr( - allOf( - unless(has(expr(anyOf(isTypeDependent(), isValueDependent())))), - // The thrown value is not derived from 'std::exception'. - has(expr(unless(hasType( - qualType(hasCanonicalType(hasDeclaration(cxxRecordDecl( - isSameOrDerivedFrom(hasName("::std::exception")))))))))), - // This condition is always true, but will bind to the - // template value if the thrown type is templated. - anyOf(has(expr(hasType( - substTemplateTypeParmType().bind("templ_type")))), - anything()), - // Bind to the declaration of the type of the value that - // is thrown. 'anything()' is necessary to always suceed - // in the 'eachOf' because builtin types are not - // 'namedDecl'. - eachOf(has(expr(hasType(namedDecl().bind("decl")))), anything()))) + unless(has(expr(anyOf(isTypeDependent(), isValueDependent())))), + // The thrown value is not derived from 'std::exception'. + has(expr(unless( + hasType(qualType(hasCanonicalType(hasDeclaration(cxxRecordDecl( + isSameOrDerivedFrom(hasName("::std::exception")))))))))), + // This condition is always true, but will bind to the + // template value if the thrown type is templated. + anyOf(has(expr( + hasType(substTemplateTypeParmType().bind("templ_type")))), + anything()), + // Bind to the declaration of the type of the value that + // is thrown. 'anything()' is necessary to always suceed + // in the 'eachOf' because builtin types are not + // 'namedDecl'. + eachOf(has(expr(hasType(namedDecl().bind("decl")))), anything())) .bind("bad_throw"), this); } diff --git a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp index f4cad2e9394..03f4edba9ee 100644 --- a/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp @@ -26,7 +26,7 @@ void MultiwayPathsCoveredCheck::storeOptions( void MultiwayPathsCoveredCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( switchStmt( - hasCondition(allOf( + hasCondition(expr( // Match on switch statements that have either a bit-field or // an integer condition. The ordering in 'anyOf()' is // important because the last condition is the most general. @@ -43,10 +43,9 @@ void MultiwayPathsCoveredCheck::registerMatchers(MatchFinder *Finder) { // This option is noisy, therefore matching is configurable. if (WarnOnMissingElse) { - Finder->addMatcher( - ifStmt(allOf(hasParent(ifStmt()), unless(hasElse(anything())))) - .bind("else-if"), - this); + Finder->addMatcher(ifStmt(hasParent(ifStmt()), unless(hasElse(anything()))) + .bind("else-if"), + this); } } diff --git a/clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp b/clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp index 5c76b8e5298..9738369375e 100644 --- a/clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp @@ -26,42 +26,40 @@ void SignedBitwiseCheck::registerMatchers(MatchFinder *Finder) { // as signed types. Exclude these types from diagnosing for bitwise or(|) and // bitwise and(&). Shifting and complementing such values is still not // allowed. - const auto BitmaskType = namedDecl(anyOf( - hasName("::std::locale::category"), hasName("::std::ctype_base::mask"), - hasName("::std::ios_base::fmtflags"), hasName("::std::ios_base::iostate"), - hasName("::std::ios_base::openmode"))); + const auto BitmaskType = namedDecl( + hasAnyName("::std::locale::category", "::std::ctype_base::mask", + "::std::ios_base::fmtflags", "::std::ios_base::iostate", + "::std::ios_base::openmode")); const auto IsStdBitmask = ignoringImpCasts(declRefExpr(hasType(BitmaskType))); // Match binary bitwise operations on signed integer arguments. Finder->addMatcher( - binaryOperator( - allOf(anyOf(hasOperatorName("^"), hasOperatorName("|"), - hasOperatorName("&"), hasOperatorName("^="), - hasOperatorName("|="), hasOperatorName("&=")), + binaryOperator(anyOf(hasOperatorName("^"), hasOperatorName("|"), + hasOperatorName("&"), hasOperatorName("^="), + hasOperatorName("|="), hasOperatorName("&=")), - unless(allOf(hasLHS(IsStdBitmask), hasRHS(IsStdBitmask))), + unless(allOf(hasLHS(IsStdBitmask), hasRHS(IsStdBitmask))), - hasEitherOperand(SignedIntegerOperand), - hasLHS(hasType(isInteger())), hasRHS(hasType(isInteger())))) + hasEitherOperand(SignedIntegerOperand), + hasLHS(hasType(isInteger())), hasRHS(hasType(isInteger()))) .bind("binary-no-sign-interference"), this); // Shifting and complement is not allowed for any signed integer type because // the sign bit may corrupt the result. Finder->addMatcher( - binaryOperator( - allOf(anyOf(hasOperatorName("<<"), hasOperatorName(">>"), - hasOperatorName("<<="), hasOperatorName(">>=")), - hasEitherOperand(SignedIntegerOperand), - hasLHS(hasType(isInteger())), hasRHS(hasType(isInteger())))) + binaryOperator(anyOf(hasOperatorName("<<"), hasOperatorName(">>"), + hasOperatorName("<<="), hasOperatorName(">>=")), + hasEitherOperand(SignedIntegerOperand), + hasLHS(hasType(isInteger())), hasRHS(hasType(isInteger()))) .bind("binary-sign-interference"), this); // Match unary operations on signed integer types. - Finder->addMatcher(unaryOperator(allOf(hasOperatorName("~"), - hasUnaryOperand(SignedIntegerOperand))) - .bind("unary-signed"), - this); + Finder->addMatcher( + unaryOperator(hasOperatorName("~"), hasUnaryOperand(SignedIntegerOperand)) + .bind("unary-signed"), + this); } void SignedBitwiseCheck::check(const MatchFinder::MatchResult &Result) { diff --git a/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp b/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp index 273fe7bf410..c0bdbfbfe04 100644 --- a/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp @@ -59,13 +59,6 @@ void NonPrivateMemberVariablesInClassesCheck::registerMatchers( allOf(boolean(IgnoreClassesWithAllMemberVariablesBeingPublic), unless(hasNonPublicMemberVariable())); - // We only want the records that not only contain the mutable data (non-static - // member variables), but also have some logic (non-static member functions). - // We may optionally ignore records where all the member variables are public. - auto RecordIsInteresting = - allOf(anyOf(isStruct(), isClass()), hasMethods(), hasNonStaticMethod(), - unless(ShouldIgnoreRecord)); - // There are three visibility types: public, protected, private. // If we are ok with public fields, then we only want to complain about // protected fields, else we want to complain about all non-private fields. @@ -73,7 +66,12 @@ void NonPrivateMemberVariablesInClassesCheck::registerMatchers( auto InterestingField = fieldDecl( IgnorePublicMemberVariables ? isProtected() : unless(isPrivate())); - Finder->addMatcher(cxxRecordDecl(RecordIsInteresting, + // We only want the records that not only contain the mutable data (non-static + // member variables), but also have some logic (non-static member functions). + // We may optionally ignore records where all the member variables are public. + Finder->addMatcher(cxxRecordDecl(anyOf(isStruct(), isClass()), hasMethods(), + hasNonStaticMethod(), + unless(ShouldIgnoreRecord), forEach(InterestingField.bind("field"))) .bind("record"), this); diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp index 352a403f928..aa11b71a5d7 100644 --- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp @@ -162,7 +162,7 @@ StatementMatcher makeIteratorLoopMatcher() { // reference then the return type is tagged with DerefByValueResultName. internal::Matcher<VarDecl> TestDerefReturnsByValue = hasType(hasUnqualifiedDesugaredType( - recordType(hasDeclaration(cxxRecordDecl(hasMethod(allOf( + recordType(hasDeclaration(cxxRecordDecl(hasMethod(cxxMethodDecl( hasOverloadedOperatorName("*"), anyOf( // Tag the return type if it's by value. diff --git a/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp index 04ecf212873..3281ef664a7 100644 --- a/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp @@ -109,7 +109,7 @@ void ReplaceAutoPtrCheck::registerMatchers(MatchFinder *Finder) { // using std::auto_ptr; // ^~~~~~~~~~~~~~~~~~~ - Finder->addMatcher(usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(allOf( + Finder->addMatcher(usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(namedDecl( hasName("auto_ptr"), isFromStdNamespace())))) .bind(AutoPtrTokenId), this); diff --git a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp index 868716224ed..0fecd24a23c 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp @@ -211,7 +211,7 @@ AST_POLYMORPHIC_MATCHER(hasExplicitTemplateArgs, /// \brief Returns a DeclarationMatcher that matches standard iterators nested /// inside records with a standard container name. DeclarationMatcher standardIterator() { - return allOf( + return decl( namedDecl(hasStdIteratorName()), hasDeclContext(recordDecl(hasStdContainerName(), isFromStdNamespace()))); } @@ -233,7 +233,7 @@ TypeMatcher nestedIterator() { TypeMatcher iteratorFromUsingDeclaration() { auto HasIteratorDecl = hasDeclaration(namedDecl(hasStdIteratorName())); // Types resulting from using declarations are represented by elaboratedType. - return elaboratedType(allOf( + return elaboratedType( // Unwrap the nested name specifier to test for one of the standard // containers. hasQualifier(specifiesType(templateSpecializationType(hasDeclaration( @@ -241,7 +241,7 @@ TypeMatcher iteratorFromUsingDeclaration() { // the named type is what comes after the final '::' in the type. It // should name one of the standard iterator names. namesType( - anyOf(typedefType(HasIteratorDecl), recordType(HasIteratorDecl))))); + anyOf(typedefType(HasIteratorDecl), recordType(HasIteratorDecl)))); } /// \brief This matcher returns declaration statements that contain variable diff --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp index d67bb799e3e..4245bfeafb4 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp @@ -77,12 +77,12 @@ static bool isCopyConstructorAndCanBeDefaulted(ASTContext *Context, if (match( cxxConstructorDecl(forEachConstructorInitializer(cxxCtorInitializer( isBaseInitializer(), - withInitializer(cxxConstructExpr(allOf( + withInitializer(cxxConstructExpr( hasType(equalsNode(Base)), hasDeclaration(cxxConstructorDecl(isCopyConstructor())), argumentCountIs(1), hasArgument( - 0, declRefExpr(to(varDecl(equalsNode(Param))))))))))), + 0, declRefExpr(to(varDecl(equalsNode(Param)))))))))), *Ctor, *Context) .empty()) return false; @@ -98,10 +98,10 @@ static bool isCopyConstructorAndCanBeDefaulted(ASTContext *Context, withInitializer(anyOf( AccessToFieldInParam, initListExpr(has(AccessToFieldInParam)), - cxxConstructExpr(allOf( + cxxConstructExpr( hasDeclaration(cxxConstructorDecl(isCopyConstructor())), argumentCountIs(1), - hasArgument(0, AccessToFieldInParam)))))))), + hasArgument(0, AccessToFieldInParam))))))), *Ctor, *Context) .empty()) return false; @@ -145,21 +145,21 @@ static bool isCopyAssignmentAndCanBeDefaulted(ASTContext *Context, // ((Base*)this)->operator=((Base)Other); // // So we are looking for a member call that fulfills: - if (match(compoundStmt(has(ignoringParenImpCasts(cxxMemberCallExpr(allOf( - // - The object is an implicit cast of 'this' to a pointer to - // a base class. - onImplicitObjectArgument( - implicitCastExpr(hasImplicitDestinationType( - pointsTo(type(equalsNode(Base)))), - hasSourceExpression(cxxThisExpr()))), - // - The called method is the operator=. - callee(cxxMethodDecl(isCopyAssignmentOperator())), - // - The argument is (an implicit cast to a Base of) the - // argument taken by "Operator". - argumentCountIs(1), - hasArgument(0, - declRefExpr(to(varDecl(equalsNode(Param)))))))))), - *Compound, *Context) + if (match( + compoundStmt(has(ignoringParenImpCasts(cxxMemberCallExpr( + // - The object is an implicit cast of 'this' to a pointer to + // a base class. + onImplicitObjectArgument( + implicitCastExpr(hasImplicitDestinationType( + pointsTo(type(equalsNode(Base)))), + hasSourceExpression(cxxThisExpr()))), + // - The called method is the operator=. + callee(cxxMethodDecl(isCopyAssignmentOperator())), + // - The argument is (an implicit cast to a Base of) the + // argument taken by "Operator". + argumentCountIs(1), + hasArgument(0, declRefExpr(to(varDecl(equalsNode(Param))))))))), + *Compound, *Context) .empty()) return false; } diff --git a/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp index 0367b13934a..05b2dd829e5 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp @@ -30,24 +30,22 @@ void UseUncaughtExceptionsCheck::registerMatchers(MatchFinder *Finder) { this); // DeclRefExpr: warning, no fix-it. - Finder->addMatcher(declRefExpr(allOf(to(functionDecl(hasName(MatchText))), - unless(callExpr()))) - .bind("decl_ref_expr"), - this); - - // CallExpr: warning, fix-it. Finder->addMatcher( - callExpr(allOf(hasDeclaration(functionDecl(hasName(MatchText))), - unless(hasAncestor(initListExpr())))) - .bind("call_expr"), + declRefExpr(to(functionDecl(hasName(MatchText))), unless(callExpr())) + .bind("decl_ref_expr"), this); + + // CallExpr: warning, fix-it. + Finder->addMatcher(callExpr(hasDeclaration(functionDecl(hasName(MatchText))), + unless(hasAncestor(initListExpr()))) + .bind("call_expr"), + this); // CallExpr in initialisation list: warning, fix-it with avoiding narrowing // conversions. - Finder->addMatcher( - callExpr(allOf(hasAncestor(initListExpr()), - hasDeclaration(functionDecl(hasName(MatchText))))) - .bind("init_call_expr"), - this); + Finder->addMatcher(callExpr(hasAncestor(initListExpr()), + hasDeclaration(functionDecl(hasName(MatchText)))) + .bind("init_call_expr"), + this); } void UseUncaughtExceptionsCheck::check(const MatchFinder::MatchResult &Result) { diff --git a/clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp b/clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp index 055e4f0a1b5..52283fb2a09 100644 --- a/clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp @@ -35,14 +35,12 @@ void MoveConstructorInitCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( cxxConstructorDecl( - unless(isImplicit()), - allOf(isMoveConstructor(), - hasAnyConstructorInitializer( - cxxCtorInitializer( - withInitializer(cxxConstructExpr(hasDeclaration( - cxxConstructorDecl(isCopyConstructor()) - .bind("ctor"))))) - .bind("move-init")))), + unless(isImplicit()), isMoveConstructor(), + hasAnyConstructorInitializer( + cxxCtorInitializer( + withInitializer(cxxConstructExpr(hasDeclaration( + cxxConstructorDecl(isCopyConstructor()).bind("ctor"))))) + .bind("move-init"))), this); } diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp index ef6bcd6f649..6f31057395c 100644 --- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp +++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp @@ -39,10 +39,6 @@ UnnecessaryCopyInitialization::UnnecessaryCopyInitialization( void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) { auto ConstReference = referenceType(pointee(qualType(isConstQualified()))); - auto ConstOrConstReference = - allOf(anyOf(ConstReference, isConstQualified()), - unless(allOf(pointerType(), unless(pointerType(pointee( - qualType(isConstQualified()))))))); // Match method call expressions where the `this` argument is only used as // const, this will be checked in `check()` part. This returned const @@ -63,11 +59,11 @@ void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) { declStmt( has(varDecl(hasLocalStorage(), hasType(qualType( - allOf(hasCanonicalType( - matchers::isExpensiveToCopy()), - unless(hasDeclaration(namedDecl( - matchers::matchesAnyListedName( - AllowedTypes))))))), + hasCanonicalType( + matchers::isExpensiveToCopy()), + unless(hasDeclaration(namedDecl( + matchers::matchesAnyListedName( + AllowedTypes)))))), unless(isImplicit()), hasInitializer( cxxConstructExpr( diff --git a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp index ac76cea3603..ff3674fee79 100644 --- a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp @@ -79,11 +79,11 @@ void UnnecessaryValueParamCheck::registerMatchers(MatchFinder *Finder) { if (!getLangOpts().CPlusPlus) return; const auto ExpensiveValueParamDecl = parmVarDecl( - hasType(qualType(allOf( + hasType(qualType( hasCanonicalType(matchers::isExpensiveToCopy()), unless(anyOf(hasCanonicalType(referenceType()), hasDeclaration(namedDecl( - matchers::matchesAnyListedName(AllowedTypes)))))))), + matchers::matchesAnyListedName(AllowedTypes))))))), decl().bind("param")); Finder->addMatcher( functionDecl(hasBody(stmt()), isDefinition(), unless(isImplicit()), diff --git a/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp b/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp index d5434cc2e6c..e104368fbcd 100644 --- a/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp +++ b/clang-tools-extra/clang-tidy/portability/SIMDIntrinsicsCheck.cpp @@ -100,9 +100,9 @@ void SIMDIntrinsicsCheck::registerMatchers(MatchFinder *Finder) { if (Std.empty()) Std = getLangOpts().CPlusPlus2a ? "std" : "std::experimental"; - Finder->addMatcher(callExpr(callee(functionDecl(allOf( + Finder->addMatcher(callExpr(callee(functionDecl( matchesName("^::(_mm_|_mm256_|_mm512_|vec_)"), - isVectorFunction()))), + isVectorFunction())), unless(isExpansionInSystemHeader())) .bind("call"), this); diff --git a/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp index 3155be39378..e9ccb17b0e5 100644 --- a/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp @@ -26,11 +26,10 @@ AST_MATCHER(DeclStmt, onlyDeclaresVariables) { } // namespace void IsolateDeclarationCheck::registerMatchers(MatchFinder *Finder) { - Finder->addMatcher( - declStmt(allOf(onlyDeclaresVariables(), unless(isSingleDecl()), - hasParent(compoundStmt()))) - .bind("decl_stmt"), - this); + Finder->addMatcher(declStmt(onlyDeclaresVariables(), unless(isSingleDecl()), + hasParent(compoundStmt())) + .bind("decl_stmt"), + this); } static SourceLocation findStartOfIndirection(SourceLocation Start, diff --git a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp index 3cb26532c83..b565a5fe0ad 100644 --- a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp @@ -491,12 +491,12 @@ void SimplifyBooleanExprCheck::matchCompoundIfReturnsBool(MatchFinder *Finder, bool Value, StringRef Id) { Finder->addMatcher( - compoundStmt(allOf(hasAnySubstatement(ifStmt(hasThen(returnsBool(Value)), - unless(hasElse(stmt())))), - hasAnySubstatement( - returnStmt(has(ignoringParenImpCasts( + compoundStmt( + hasAnySubstatement( + ifStmt(hasThen(returnsBool(Value)), unless(hasElse(stmt())))), + hasAnySubstatement(returnStmt(has(ignoringParenImpCasts( cxxBoolLiteral(equals(!Value))))) - .bind(CompoundReturnId)))) + .bind(CompoundReturnId))) .bind(Id), this); } diff --git a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp index 18eeb9eb1b9..eeaece116ee 100644 --- a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp @@ -196,11 +196,11 @@ void UppercaseLiteralSuffixCheck::registerMatchers(MatchFinder *Finder) { // E.g. i32 suffix still results in 'BuiltinType::Kind::Int'. // And such an info is not stored in the *Literal itself. Finder->addMatcher( - stmt(allOf(eachOf(integerLiteral().bind(IntegerLiteralCheck::Name), - floatLiteral().bind(FloatingLiteralCheck::Name)), - unless(anyOf(hasParent(userDefinedLiteral()), - hasAncestor(isImplicit()), - hasAncestor(substNonTypeTemplateParmExpr()))))), + stmt(eachOf(integerLiteral().bind(IntegerLiteralCheck::Name), + floatLiteral().bind(FloatingLiteralCheck::Name)), + unless(anyOf(hasParent(userDefinedLiteral()), + hasAncestor(isImplicit()), + hasAncestor(substNonTypeTemplateParmExpr())))), this); } diff --git a/clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp b/clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp index 5fff67bb3c8..be2fb83565c 100644 --- a/clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp +++ b/clang-tools-extra/clang-tidy/zircon/TemporaryObjectsCheck.cpp @@ -37,9 +37,9 @@ void TemporaryObjectsCheck::registerMatchers(MatchFinder *Finder) { // Matcher for user-defined constructors. Finder->addMatcher( - cxxConstructExpr(allOf(hasParent(cxxFunctionalCastExpr()), - hasDeclaration(cxxConstructorDecl(hasParent( - cxxRecordDecl(matchesAnyName(Names))))))) + cxxConstructExpr(hasParent(cxxFunctionalCastExpr()), + hasDeclaration(cxxConstructorDecl( + hasParent(cxxRecordDecl(matchesAnyName(Names)))))) .bind("temps"), this); } |