diff --git a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp index 9fc7f7d36a6b..7c8f4d60dc06 100644 --- a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp +++ b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp @@ -50,7 +50,7 @@ void StringFindStartswithCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( // Match [=!]= with a zero on one side and a string.find on the other. binaryOperator( - anyOf(hasOperatorName("=="), hasOperatorName("!=")), + hasAnyOperatorName("==", "!="), hasEitherOperand(ignoringParenImpCasts(ZeroLiteral)), hasEitherOperand(ignoringParenImpCasts(StringFind.bind("findexpr")))) .bind("expr"), diff --git a/clang-tools-extra/clang-tidy/bugprone/IntegerDivisionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/IntegerDivisionCheck.cpp index 670efe2a7b06..82993cb313ce 100644 --- a/clang-tools-extra/clang-tidy/bugprone/IntegerDivisionCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/IntegerDivisionCheck.cpp @@ -19,15 +19,11 @@ namespace bugprone { void IntegerDivisionCheck::registerMatchers(MatchFinder *Finder) { const auto IntType = hasType(isInteger()); - const auto BinaryOperators = binaryOperator(anyOf( - hasOperatorName("%"), hasOperatorName("<<"), hasOperatorName(">>"), - hasOperatorName("<<"), hasOperatorName("^"), hasOperatorName("|"), - hasOperatorName("&"), hasOperatorName("||"), hasOperatorName("&&"), - hasOperatorName("<"), hasOperatorName(">"), hasOperatorName("<="), - hasOperatorName(">="), hasOperatorName("=="), hasOperatorName("!="))); + const auto BinaryOperators = binaryOperator( + hasAnyOperatorName("%", "<<", ">>", "<<", "^", "|", "&", "||", "&&", "<", + ">", "<=", ">=", "==", "!=")); - const auto UnaryOperators = - unaryOperator(anyOf(hasOperatorName("~"), hasOperatorName("!"))); + const auto UnaryOperators = unaryOperator(hasAnyOperatorName("~", "!")); const auto Exceptions = anyOf(BinaryOperators, conditionalOperator(), binaryConditionalOperator(), diff --git a/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp index c6dc78622851..ca5209448b00 100644 --- a/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/MisplacedPointerArithmeticInAllocCheck.cpp @@ -28,8 +28,7 @@ void MisplacedPointerArithmeticInAllocCheck::registerMatchers( hasInitializer(ignoringParenImpCasts( declRefExpr(hasDeclaration(AllocFunc))))); - const auto AdditiveOperator = - binaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-"))); + const auto AdditiveOperator = binaryOperator(hasAnyOperatorName("+", "-")); const auto IntExpr = expr(hasType(isInteger())); diff --git a/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp index d5f392b592b8..89fcda32a630 100644 --- a/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp @@ -29,9 +29,7 @@ void MisplacedWideningCastCheck::storeOptions( void MisplacedWideningCastCheck::registerMatchers(MatchFinder *Finder) { const auto Calc = - expr(anyOf(binaryOperator( - anyOf(hasOperatorName("+"), hasOperatorName("-"), - hasOperatorName("*"), hasOperatorName("<<"))), + expr(anyOf(binaryOperator(hasAnyOperatorName("+", "-", "*", "<<")), unaryOperator(hasOperatorName("~"))), hasType(isInteger())) .bind("Calc"); diff --git a/clang-tools-extra/clang-tidy/bugprone/PosixReturnCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/PosixReturnCheck.cpp index 4a470e5c9def..076e239826cb 100644 --- a/clang-tools-extra/clang-tidy/bugprone/PosixReturnCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/PosixReturnCheck.cpp @@ -48,8 +48,7 @@ void PosixReturnCheck::registerMatchers(MatchFinder *Finder) { this); Finder->addMatcher( binaryOperator( - anyOf(hasOperatorName("=="), hasOperatorName("!="), - hasOperatorName("<="), hasOperatorName("<")), + hasAnyOperatorName("==", "!=", "<=", "<"), hasLHS(callExpr(callee(functionDecl( anyOf(matchesName("^::posix_"), matchesName("^::pthread_")), unless(hasName("::posix_openpt")))))), diff --git a/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp index 411fe8debab6..d7e69417b39e 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp @@ -28,7 +28,7 @@ void SizeofContainerCheck::registerMatchers(MatchFinder *Finder) { .bind("sizeof"), // Ignore ARRAYSIZE() pattern. unless(hasAncestor(binaryOperator( - anyOf(hasOperatorName("/"), hasOperatorName("%")), + hasAnyOperatorName("/", "%"), hasLHS(ignoringParenCasts(sizeOfExpr(expr()))), hasRHS(ignoringParenCasts(equalsBoundNode("sizeof"))))))), this); diff --git a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp index bb23202197fa..fb0d435a20dc 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp @@ -231,10 +231,7 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( binaryOperator( - anyOf(hasOperatorName("=="), hasOperatorName("!="), - hasOperatorName("<"), hasOperatorName("<="), - hasOperatorName(">"), hasOperatorName(">="), - hasOperatorName("+"), hasOperatorName("-")), + hasAnyOperatorName("==", "!=", "<", "<=", ">", ">=", "+", "-"), hasEitherOperand(expr(anyOf( ignoringParenImpCasts(SizeOfExpr), ignoringParenImpCasts(binaryOperator( diff --git a/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp index e0410335b123..85d99ee76146 100644 --- a/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp @@ -20,8 +20,7 @@ namespace bugprone { void StringIntegerAssignmentCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( cxxOperatorCallExpr( - anyOf(hasOverloadedOperatorName("="), - hasOverloadedOperatorName("+=")), + hasAnyOverloadedOperatorName("=", "+="), callee(cxxMethodDecl(ofClass(classTemplateSpecializationDecl( hasName("::std::basic_string"), hasTemplateArgument(0, refersToType(hasCanonicalType( diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp index 42965a6d962e..192403789472 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp @@ -131,7 +131,7 @@ void SuspiciousEnumUsageCheck::registerMatchers(MatchFinder *Finder) { this); Finder->addMatcher( - binaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("|")), + binaryOperator(hasAnyOperatorName("+", "|"), hasLHS(enumExpr("lhsExpr", "enumDecl")), hasRHS(expr(enumExpr("rhsExpr", ""), ignoringImpCasts(hasType( @@ -139,16 +139,15 @@ void SuspiciousEnumUsageCheck::registerMatchers(MatchFinder *Finder) { this); Finder->addMatcher( - binaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("|")), + binaryOperator(hasAnyOperatorName("+", "|"), hasEitherOperand( expr(hasType(isInteger()), unless(enumExpr("", "")))), hasEitherOperand(enumExpr("enumExpr", "enumDecl"))), this); - Finder->addMatcher( - binaryOperator(anyOf(hasOperatorName("|="), hasOperatorName("+=")), - hasRHS(enumExpr("enumExpr", "enumDecl"))), - this); + Finder->addMatcher(binaryOperator(hasAnyOperatorName("|=", "+="), + hasRHS(enumExpr("enumExpr", "enumDecl"))), + this); } void SuspiciousEnumUsageCheck::checkSuspiciousBitmaskUsage( diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp index cad4072b0849..a939159f45fd 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp @@ -116,9 +116,8 @@ void SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) { whileStmt(hasCondition(StringCompareCallExpr)), doStmt(hasCondition(StringCompareCallExpr)), forStmt(hasCondition(StringCompareCallExpr)), - binaryOperator( - anyOf(hasOperatorName("&&"), hasOperatorName("||")), - hasEitherOperand(StringCompareCallExpr)))) + binaryOperator(hasAnyOperatorName("&&", "||"), + hasEitherOperand(StringCompareCallExpr)))) .bind("missing-comparison"), this); } diff --git a/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp index 6fab9ec60b1d..f2de9fbde2a6 100644 --- a/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp @@ -40,9 +40,9 @@ void UnhandledSelfAssignmentCheck::registerMatchers(MatchFinder *Finder) { // Self-check: Code compares something with 'this' pointer. We don't check // whether it is actually the parameter what we compare. - const auto HasNoSelfCheck = cxxMethodDecl(unless(hasDescendant( - binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")), - has(ignoringParenCasts(cxxThisExpr())))))); + const auto HasNoSelfCheck = cxxMethodDecl(unless( + hasDescendant(binaryOperator(hasAnyOperatorName("==", "!="), + has(ignoringParenCasts(cxxThisExpr())))))); // Both copy-and-swap and copy-and-move method creates a copy first and // assign it to 'this' with swap or move. diff --git a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp index ba946ed6f03c..daefc9eed314 100644 --- a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp @@ -276,13 +276,11 @@ void UseAfterMoveFinder::getDeclRefs( .bind("declref"); addDeclRefs(match(findAll(DeclRefMatcher), *S->getStmt(), *Context)); - addDeclRefs(match( - findAll(cxxOperatorCallExpr(anyOf(hasOverloadedOperatorName("*"), - hasOverloadedOperatorName("->"), - hasOverloadedOperatorName("[]")), - hasArgument(0, DeclRefMatcher)) - .bind("operator")), - *S->getStmt(), *Context)); + addDeclRefs(match(findAll(cxxOperatorCallExpr( + hasAnyOverloadedOperatorName("*", "->", "[]"), + hasArgument(0, DeclRefMatcher)) + .bind("operator")), + *S->getStmt(), *Context)); } } diff --git a/clang-tools-extra/clang-tidy/cert/PostfixOperatorCheck.cpp b/clang-tools-extra/clang-tidy/cert/PostfixOperatorCheck.cpp index dd9efcfe7957..0c4b89632e9d 100644 --- a/clang-tools-extra/clang-tidy/cert/PostfixOperatorCheck.cpp +++ b/clang-tools-extra/clang-tidy/cert/PostfixOperatorCheck.cpp @@ -18,8 +18,7 @@ namespace tidy { namespace cert { void PostfixOperatorCheck::registerMatchers(MatchFinder *Finder) { - Finder->addMatcher(functionDecl(anyOf(hasOverloadedOperatorName("++"), - hasOverloadedOperatorName("--")), + Finder->addMatcher(functionDecl(hasAnyOverloadedOperatorName("++", "--"), unless(isInstantiated())) .bind("decl"), this); diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp index 384c8be907d9..680b33787446 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsPointerArithmeticCheck.cpp @@ -27,16 +27,13 @@ void ProBoundsPointerArithmeticCheck::registerMatchers(MatchFinder *Finder) { // Flag all operators +, -, +=, -=, ++, -- that result in a pointer Finder->addMatcher( binaryOperator( - anyOf(hasOperatorName("+"), hasOperatorName("-"), - hasOperatorName("+="), hasOperatorName("-=")), - AllPointerTypes, + hasAnyOperatorName("+", "-", "+=", "-="), AllPointerTypes, unless(hasLHS(ignoringImpCasts(declRefExpr(to(isImplicit())))))) .bind("expr"), this); Finder->addMatcher( - unaryOperator(anyOf(hasOperatorName("++"), hasOperatorName("--")), - hasType(pointerType())) + unaryOperator(hasAnyOperatorName("++", "--"), hasType(pointerType())) .bind("expr"), this); diff --git a/clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp b/clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp index b9c60772415a..415babe9890d 100644 --- a/clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp @@ -48,9 +48,7 @@ void SignedBitwiseCheck::registerMatchers(MatchFinder *Finder) { // Match binary bitwise operations on signed integer arguments. Finder->addMatcher( - binaryOperator(anyOf(hasOperatorName("^"), hasOperatorName("|"), - hasOperatorName("&"), hasOperatorName("^="), - hasOperatorName("|="), hasOperatorName("&=")), + binaryOperator(hasAnyOperatorName("^", "|", "&", "^=", "|=", "&="), unless(allOf(hasLHS(IsStdBitmask), hasRHS(IsStdBitmask))), @@ -62,8 +60,7 @@ void SignedBitwiseCheck::registerMatchers(MatchFinder *Finder) { // Shifting and complement is not allowed for any signed integer type because // the sign bit may corrupt the result. Finder->addMatcher( - binaryOperator(anyOf(hasOperatorName("<<"), hasOperatorName(">>"), - hasOperatorName("<<="), hasOperatorName(">>=")), + binaryOperator(hasAnyOperatorName("<<", ">>", "<<=", ">>="), hasEitherOperand(SignedIntegerOperand), hasLHS(hasType(isInteger())), hasRHS(hasType(isInteger()))) .bind("binary-sign-interference"), diff --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp index 39776180d9c0..066ba708f265 100644 --- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp @@ -532,14 +532,12 @@ static bool retrieveSymbolicExpr(const MatchFinder::MatchResult &Result, static ast_matchers::internal::Matcher matchBinOpIntegerConstantExpr(StringRef Id) { const auto BinOpCstExpr = - expr( - anyOf(binaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("|"), - hasOperatorName("&")), - hasEitherOperand(matchSymbolicExpr(Id)), - hasEitherOperand(matchIntegerConstantExpr(Id))), - binaryOperator(hasOperatorName("-"), - hasLHS(matchSymbolicExpr(Id)), - hasRHS(matchIntegerConstantExpr(Id))))) + expr(anyOf(binaryOperator(hasAnyOperatorName("+", "|", "&"), + hasEitherOperand(matchSymbolicExpr(Id)), + hasEitherOperand(matchIntegerConstantExpr(Id))), + binaryOperator(hasOperatorName("-"), + hasLHS(matchSymbolicExpr(Id)), + hasRHS(matchIntegerConstantExpr(Id))))) .bind(Id); return ignoringParenImpCasts(BinOpCstExpr); } @@ -594,10 +592,7 @@ matchRelationalIntegerConstantExpr(StringRef Id) { const auto OverloadedOperatorExpr = cxxOperatorCallExpr( - anyOf(hasOverloadedOperatorName("=="), - hasOverloadedOperatorName("!="), hasOverloadedOperatorName("<"), - hasOverloadedOperatorName("<="), hasOverloadedOperatorName(">"), - hasOverloadedOperatorName(">=")), + hasAnyOverloadedOperatorName("==", "!=", "<", "<=", ">", ">="), // Filter noisy false positives. unless(isMacro()), unless(isInTemplateInstantiation())) .bind(OverloadId); @@ -833,11 +828,9 @@ void RedundantExpressionCheck::registerMatchers(MatchFinder *Finder) { // Binary with equivalent operands, like (X != 2 && X != 2). Finder->addMatcher( - binaryOperator(anyOf(hasOperatorName("-"), hasOperatorName("/"), - hasOperatorName("%"), hasOperatorName("|"), - hasOperatorName("&"), hasOperatorName("^"), - isComparisonOperator(), hasOperatorName("&&"), - hasOperatorName("||"), hasOperatorName("=")), + binaryOperator(anyOf(isComparisonOperator(), + hasAnyOperatorName("-", "/", "%", "|", "&", "^", + "&&", "||", "=")), operandsAreEquivalent(), // Filter noisy false positives. unless(isInTemplateInstantiation()), @@ -852,9 +845,7 @@ void RedundantExpressionCheck::registerMatchers(MatchFinder *Finder) { // Logical or bitwise operator with equivalent nested operands, like (X && Y // && X) or (X && (Y && X)) Finder->addMatcher( - binaryOperator(anyOf(hasOperatorName("|"), hasOperatorName("&"), - hasOperatorName("||"), hasOperatorName("&&"), - hasOperatorName("^")), + binaryOperator(hasAnyOperatorName("|", "&", "||", "&&", "^"), nestedOperandsAreEquivalent(), // Filter noisy false positives. unless(isInTemplateInstantiation()), @@ -873,30 +864,20 @@ void RedundantExpressionCheck::registerMatchers(MatchFinder *Finder) { this); // Overloaded operators with equivalent operands. - Finder->addMatcher( - cxxOperatorCallExpr( - anyOf( - hasOverloadedOperatorName("-"), hasOverloadedOperatorName("/"), - hasOverloadedOperatorName("%"), hasOverloadedOperatorName("|"), - hasOverloadedOperatorName("&"), hasOverloadedOperatorName("^"), - hasOverloadedOperatorName("=="), hasOverloadedOperatorName("!="), - hasOverloadedOperatorName("<"), hasOverloadedOperatorName("<="), - hasOverloadedOperatorName(">"), hasOverloadedOperatorName(">="), - hasOverloadedOperatorName("&&"), hasOverloadedOperatorName("||"), - hasOverloadedOperatorName("=")), - parametersAreEquivalent(), - // Filter noisy false positives. - unless(isMacro()), unless(isInTemplateInstantiation())) - .bind("call"), - this); + Finder->addMatcher(cxxOperatorCallExpr( + hasAnyOverloadedOperatorName( + "-", "/", "%", "|", "&", "^", "==", "!=", "<", + "<=", ">", ">=", "&&", "||", "="), + parametersAreEquivalent(), + // Filter noisy false positives. + unless(isMacro()), unless(isInTemplateInstantiation())) + .bind("call"), + this); // Overloaded operators with equivalent operands. Finder->addMatcher( cxxOperatorCallExpr( - anyOf(hasOverloadedOperatorName("|"), hasOverloadedOperatorName("&"), - hasOverloadedOperatorName("||"), - hasOverloadedOperatorName("&&"), - hasOverloadedOperatorName("^")), + hasAnyOverloadedOperatorName("|", "&", "||", "&&", "^"), nestedParametersAreEquivalent(), argumentCountIs(2), // Filter noisy false positives. unless(isMacro()), unless(isInTemplateInstantiation())) @@ -910,9 +891,8 @@ void RedundantExpressionCheck::registerMatchers(MatchFinder *Finder) { has(unaryOperator( hasOperatorName("!"), hasUnaryOperand(ignoringParenImpCasts(binaryOperator( - anyOf(hasOperatorName("|"), hasOperatorName("&")), - hasLHS(anyOf(binaryOperator(anyOf(hasOperatorName("|"), - hasOperatorName("&"))), + hasAnyOperatorName("|", "&"), + hasLHS(anyOf(binaryOperator(hasAnyOperatorName("|", "&")), integerLiteral())), hasRHS(integerLiteral()))))) .bind("logical-bitwise-confusion"))), @@ -971,13 +951,13 @@ void RedundantExpressionCheck::registerMatchers(MatchFinder *Finder) { // Match expressions like: x < 2 && x > 2. const auto ComparisonLeft = matchRelationalIntegerConstantExpr("lhs"); const auto ComparisonRight = matchRelationalIntegerConstantExpr("rhs"); - Finder->addMatcher( - binaryOperator(anyOf(hasOperatorName("||"), hasOperatorName("&&")), - hasLHS(ComparisonLeft), hasRHS(ComparisonRight), - // Already reported as redundant. - unless(operandsAreEquivalent())) - .bind("comparisons-of-symbol-and-const"), - this); + Finder->addMatcher(binaryOperator(hasAnyOperatorName("||", "&&"), + hasLHS(ComparisonLeft), + hasRHS(ComparisonRight), + // Already reported as redundant. + unless(operandsAreEquivalent())) + .bind("comparisons-of-symbol-and-const"), + this); } void RedundantExpressionCheck::checkArithmeticExpr( diff --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp index efb3f20fbd7f..53cebc32bb38 100644 --- a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp @@ -38,7 +38,7 @@ void StaticAssertCheck::registerMatchers(MatchFinder *Finder) { .bind("castExpr"))); auto AssertExprRoot = anyOf( binaryOperator( - anyOf(hasOperatorName("&&"), hasOperatorName("==")), + hasAnyOperatorName("&&", "=="), hasEitherOperand(ignoringImpCasts(stringLiteral().bind("assertMSG"))), anyOf(binaryOperator(hasEitherOperand(IsAlwaysFalseWithCast)), anything())) diff --git a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp index 78ccffdf1314..cb275ab58f1b 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp @@ -192,10 +192,10 @@ void UseDefaultMemberInitCheck::storeOptions( void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) { auto Init = anyOf(stringLiteral(), characterLiteral(), integerLiteral(), - unaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-")), + unaryOperator(hasAnyOperatorName("+", "-"), hasUnaryOperand(integerLiteral())), floatLiteral(), - unaryOperator(anyOf(hasOperatorName("+"), hasOperatorName("-")), + unaryOperator(hasAnyOperatorName("+", "-"), hasUnaryOperand(floatLiteral())), cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(), initListExpr(), declRefExpr(to(enumConstantDecl()))); diff --git a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp index 6f2402416f23..992a3fa11639 100644 --- a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp @@ -85,8 +85,7 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) { expr(hasType(ValidContainer)).bind("STLObject")); Finder->addMatcher( cxxOperatorCallExpr( - anyOf(hasOverloadedOperatorName("=="), - hasOverloadedOperatorName("!=")), + hasAnyOverloadedOperatorName("==", "!="), anyOf(allOf(hasArgument(0, WrongComparend), hasArgument(1, STLArg)), allOf(hasArgument(0, STLArg), hasArgument(1, WrongComparend))), unless(hasAncestor( diff --git a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp index 2d5e24879515..b9573747f636 100644 --- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp @@ -293,12 +293,11 @@ void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) { .bind("implicitCastToBool"), this); - auto boolComparison = binaryOperator( - anyOf(hasOperatorName("=="), hasOperatorName("!=")), - hasLHS(implicitCastFromBool), hasRHS(implicitCastFromBool)); - auto boolOpAssignment = - binaryOperator(anyOf(hasOperatorName("|="), hasOperatorName("&=")), - hasLHS(expr(hasType(booleanType())))); + auto boolComparison = binaryOperator(hasAnyOperatorName("==", "!="), + hasLHS(implicitCastFromBool), + hasRHS(implicitCastFromBool)); + auto boolOpAssignment = binaryOperator(hasAnyOperatorName("|=", "&="), + hasLHS(expr(hasType(booleanType())))); auto bitfieldAssignment = binaryOperator( hasLHS(memberExpr(hasDeclaration(fieldDecl(hasBitWidth(1)))))); auto bitfieldConstruct = cxxConstructorDecl(hasDescendant(cxxCtorInitializer( diff --git a/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp b/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp index 878eab8b9565..9d5a18f93585 100644 --- a/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp @@ -28,8 +28,7 @@ void NonConstParameterCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher(declRefExpr().bind("Ref"), this); // Analyse parameter usage in function. - Finder->addMatcher(stmt(anyOf(unaryOperator(anyOf(hasOperatorName("++"), - hasOperatorName("--"))), + Finder->addMatcher(stmt(anyOf(unaryOperator(hasAnyOperatorName("++", "--")), binaryOperator(), callExpr(), returnStmt(), cxxConstructExpr())) .bind("Mark"), diff --git a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp index 688efc6a988b..9949ab2c4fce 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp @@ -81,7 +81,7 @@ void registerMatchersForGetEquals(MatchFinder *Finder, // Matches against nullptr. Finder->addMatcher( - binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")), + binaryOperator(hasAnyOperatorName("==", "!="), hasEitherOperand(ignoringImpCasts( anyOf(cxxNullPtrLiteralExpr(), gnuNullExpr(), integerLiteral(equals(0))))), diff --git a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp index aa5e0ba767f7..8975f294373c 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp @@ -150,11 +150,7 @@ void RedundantStringCStrCheck::registerMatchers( // Detect: 's == str.c_str()' -> 's == str' Finder->addMatcher( cxxOperatorCallExpr( - anyOf( - hasOverloadedOperatorName("<"), hasOverloadedOperatorName(">"), - hasOverloadedOperatorName(">="), hasOverloadedOperatorName("<="), - hasOverloadedOperatorName("!="), hasOverloadedOperatorName("=="), - hasOverloadedOperatorName("+")), + hasAnyOverloadedOperatorName("<", ">", ">=", "<=", "!=", "==", "+"), anyOf(allOf(hasArgument(0, StringExpr), hasArgument(1, StringCStrCallExpr)), allOf(hasArgument(0, StringCStrCallExpr), @@ -163,11 +159,11 @@ void RedundantStringCStrCheck::registerMatchers( // Detect: 'dst += str.c_str()' -> 'dst += str' // Detect: 's = str.c_str()' -> 's = str' - Finder->addMatcher(cxxOperatorCallExpr(anyOf(hasOverloadedOperatorName("="), - hasOverloadedOperatorName("+=")), - hasArgument(0, StringExpr), - hasArgument(1, StringCStrCallExpr)), - this); + Finder->addMatcher( + cxxOperatorCallExpr(hasAnyOverloadedOperatorName("=", "+="), + hasArgument(0, StringExpr), + hasArgument(1, StringCStrCallExpr)), + this); // Detect: 'dst.append(str.c_str())' -> 'dst.append(str)' Finder->addMatcher( diff --git a/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp b/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp index 2c0df515893d..fcf582071e52 100644 --- a/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp @@ -38,7 +38,7 @@ void StringCompareCheck::registerMatchers(MatchFinder *Finder) { // Third and fourth case: str.compare(str) == 0 and str.compare(str) != 0. Finder->addMatcher( - binaryOperator(anyOf(hasOperatorName("=="), hasOperatorName("!=")), + binaryOperator(hasAnyOperatorName("==", "!="), hasEitherOperand(StrCompare.bind("compare")), hasEitherOperand(integerLiteral(equals(0)).bind("zero"))) .bind("match2"),