From df0c8f25145047731fb95b4ce7153ce6fb5b6f5d Mon Sep 17 00:00:00 2001 From: Nathan James Date: Tue, 11 Apr 2023 00:38:37 +0100 Subject: [PATCH] [clang-tidy][NFC] Remove redundant allOf matcher calls Remove calls to the `allOf` matcher in all matchers that are derived from the `VariadicDynCastAllOfMatcher`. --- .../altera/IdDependentBackwardBranchCheck.cpp | 4 +- .../altera/SingleWorkItemBarrierCheck.cpp | 21 +++++----- .../clang-tidy/altera/UnrollLoopsCheck.cpp | 7 ++-- .../bugprone/BadSignalToKillThreadCheck.cpp | 4 +- .../bugprone/NotNullTerminatedResultCheck.cpp | 25 ++++++------ .../bugprone/SpuriouslyWakeUpFunctionsCheck.cpp | 45 +++++++++++----------- .../bugprone/SuspiciousMemoryComparisonCheck.cpp | 6 +-- .../cert/NonTrivialTypesLibcMemoryCallsCheck.cpp | 4 +- .../ThreadCanceltypeAsynchronousCheck.cpp | 4 +- .../cppcoreguidelines/OwningMemoryCheck.cpp | 4 +- .../ProBoundsArrayToPointerDecayCheck.cpp | 6 +-- .../fuchsia/MultipleInheritanceCheck.cpp | 4 +- .../llvm/PreferIsaOrDynCastInConditionalsCheck.cpp | 44 ++++++++++----------- .../llvm/PreferRegisterOverUnsignedCheck.cpp | 13 +++---- .../clang-tidy/misc/ConstCorrectnessCheck.cpp | 10 ++--- .../clang-tidy/modernize/UseNodiscardCheck.cpp | 24 ++++++------ .../clang-tidy/openmp/UseDefaultNoneCheck.cpp | 8 ++-- 17 files changed, 112 insertions(+), 121 deletions(-) diff --git a/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp b/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp index f9225f6..09f7d8c 100644 --- a/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp +++ b/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp @@ -31,12 +31,12 @@ void IdDependentBackwardBranchCheck::registerMatchers(MatchFinder *Finder) { stmt( anyOf(declStmt(hasDescendant(varDecl(hasInitializer(ThreadID)) .bind("tid_dep_var"))), - binaryOperator(allOf( + binaryOperator( isAssignmentOperator(), hasRHS(ThreadID), hasLHS(anyOf( declRefExpr(to(varDecl().bind("tid_dep_var"))), memberExpr(member( - fieldDecl().bind("tid_dep_field"))))))))) + fieldDecl().bind("tid_dep_field")))))))) .bind("straight_assignment"))), this); diff --git a/clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp b/clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp index a4e7cf48..df21c425 100644 --- a/clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp +++ b/clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp @@ -22,17 +22,16 @@ void SingleWorkItemBarrierCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( // Find function declarations... functionDecl( - allOf( - // That are OpenCL kernels... - hasAttr(attr::Kind::OpenCLKernel), - // And call a barrier function (either 1.x or 2.x version)... - forEachDescendant(callExpr(callee(functionDecl(hasAnyName( - "barrier", "work_group_barrier")))) - .bind("barrier")), - // But do not call an ID function. - unless(hasDescendant(callExpr(callee(functionDecl( - hasAnyName("get_global_id", "get_local_id", "get_group_id", - "get_local_linear_id")))))))) + // That are OpenCL kernels... + hasAttr(attr::Kind::OpenCLKernel), + // And call a barrier function (either 1.x or 2.x version)... + forEachDescendant(callExpr(callee(functionDecl(hasAnyName( + "barrier", "work_group_barrier")))) + .bind("barrier")), + // But do not call an ID function. + unless(hasDescendant(callExpr(callee(functionDecl( + hasAnyName("get_global_id", "get_local_id", "get_group_id", + "get_local_linear_id"))))))) .bind("function"), this); } diff --git a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp index 667c1b9..ed3b831 100644 --- a/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp +++ b/clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp @@ -25,14 +25,13 @@ UnrollLoopsCheck::UnrollLoopsCheck(StringRef Name, ClangTidyContext *Context) void UnrollLoopsCheck::registerMatchers(MatchFinder *Finder) { const auto HasLoopBound = hasDescendant( - varDecl(allOf(matchesName("__end*"), - hasDescendant(integerLiteral().bind("cxx_loop_bound"))))); + varDecl(matchesName("__end*"), + hasDescendant(integerLiteral().bind("cxx_loop_bound")))); const auto CXXForRangeLoop = cxxForRangeStmt(anyOf(HasLoopBound, unless(HasLoopBound))); const auto AnyLoop = anyOf(forStmt(), whileStmt(), doStmt(), CXXForRangeLoop); Finder->addMatcher( - stmt(allOf(AnyLoop, unless(hasDescendant(stmt(AnyLoop))))).bind("loop"), - this); + stmt(AnyLoop, unless(hasDescendant(stmt(AnyLoop)))).bind("loop"), this); } void UnrollLoopsCheck::check(const MatchFinder::MatchResult &Result) { diff --git a/clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp index e1baffd..8c13ce5 100644 --- a/clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/BadSignalToKillThreadCheck.cpp @@ -18,8 +18,8 @@ namespace clang::tidy::bugprone { void BadSignalToKillThreadCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( - callExpr(allOf(callee(functionDecl(hasName("::pthread_kill"))), - argumentCountIs(2)), + callExpr(callee(functionDecl(hasName("::pthread_kill"))), + argumentCountIs(2), hasArgument(1, integerLiteral().bind("integer-literal"))) .bind("thread-kill"), this); diff --git a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp index c0c180f..cba29b9 100644 --- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp @@ -528,10 +528,10 @@ AST_MATCHER_P(Expr, hasDefinition, ast_matchers::internal::Matcher, const char *const VarDeclName = "variable-declaration"; auto DREHasDefinition = ignoringImpCasts(declRefExpr( - allOf(to(varDecl().bind(VarDeclName)), - hasAncestor(compoundStmt(hasDescendant(binaryOperator( - hasLHS(declRefExpr(to(varDecl(equalsBoundNode(VarDeclName))))), - hasRHS(ignoringImpCasts(InnerMatcher))))))))); + to(varDecl().bind(VarDeclName)), + hasAncestor(compoundStmt(hasDescendant(binaryOperator( + hasLHS(declRefExpr(to(varDecl(equalsBoundNode(VarDeclName))))), + hasRHS(ignoringImpCasts(InnerMatcher)))))))); if (DREHasDefinition.matches(*SimpleNode, Finder, Builder)) return true; @@ -581,9 +581,8 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) { // - Example: std::string str = "foo"; str.size(); auto SizeOrLength = - cxxMemberCallExpr( - allOf(on(expr(AnyOfStringTy).bind("Foo")), - has(memberExpr(member(hasAnyName("size", "length")))))) + cxxMemberCallExpr(on(expr(AnyOfStringTy).bind("Foo")), + has(memberExpr(member(hasAnyName("size", "length"))))) .bind(WrongLengthExprName); // - Example: char src[] = "foo"; sizeof(src); @@ -641,8 +640,8 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) { // - Example: foo[bar[baz]].qux; (or just ParmVarDecl) auto DestUnknownDecl = - declRefExpr(allOf(to(varDecl(AnyOfCharTy).bind(DestVarDeclName)), - expr().bind(UnknownDestName))) + declRefExpr(to(varDecl(AnyOfCharTy).bind(DestVarDeclName)), + expr().bind(UnknownDestName)) .bind(DestExprName); auto AnyOfDestDecl = ignoringImpCasts( @@ -659,10 +658,10 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) { hasRHS(ignoringImpCasts( anyOf(characterLiteral(equals(0U)), integerLiteral(equals(0)))))); - auto SrcDecl = declRefExpr( - allOf(to(decl().bind(SrcVarDeclName)), - anyOf(hasAncestor(cxxMemberCallExpr().bind(SrcExprName)), - expr().bind(SrcExprName)))); + auto SrcDecl = + declRefExpr(to(decl().bind(SrcVarDeclName)), + anyOf(hasAncestor(cxxMemberCallExpr().bind(SrcExprName)), + expr().bind(SrcExprName))); auto AnyOfSrcDecl = ignoringImpCasts(anyOf(stringLiteral().bind(SrcExprName), diff --git a/clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp index ff1d7da..9bdd167 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SpuriouslyWakeUpFunctionsCheck.cpp @@ -25,30 +25,29 @@ void SpuriouslyWakeUpFunctionsCheck::registerMatchers(MatchFinder *Finder) { auto HasWaitDescendantCpp = hasDescendant( cxxMemberCallExpr( - anyOf( - allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl( - allOf(hasName("::std::condition_variable::wait"), - parameterCountIs(1)))))), - onImplicitObjectArgument( - declRefExpr(to(varDecl(hasType(references(recordDecl( - hasName("::std::condition_variable")))))))), - HasUniqueLock), - allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl( - allOf(hasName("::std::condition_variable::wait_for"), - parameterCountIs(2)))))), - onImplicitObjectArgument( - declRefExpr(to(varDecl(hasType(references(recordDecl( - hasName("::std::condition_variable")))))))), - HasUniqueLock), - allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl( - allOf(hasName("::std::condition_variable::wait_until"), - parameterCountIs(2)))))), - onImplicitObjectArgument( - declRefExpr(to(varDecl(hasType(references(recordDecl( - hasName("::std::condition_variable")))))))), - HasUniqueLock) + anyOf(allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl( + hasName("::std::condition_variable::wait"), + parameterCountIs(1))))), + onImplicitObjectArgument( + declRefExpr(to(varDecl(hasType(references(recordDecl( + hasName("::std::condition_variable")))))))), + HasUniqueLock), + allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl( + hasName("::std::condition_variable::wait_for"), + parameterCountIs(2))))), + onImplicitObjectArgument( + declRefExpr(to(varDecl(hasType(references(recordDecl( + hasName("::std::condition_variable")))))))), + HasUniqueLock), + allOf(hasDescendant(memberExpr(hasDeclaration(functionDecl( + hasName("::std::condition_variable::wait_until"), + parameterCountIs(2))))), + onImplicitObjectArgument( + declRefExpr(to(varDecl(hasType(references(recordDecl( + hasName("::std::condition_variable")))))))), + HasUniqueLock) - )) + )) .bind("wait")); auto HasWaitDescendantC = hasDescendant( diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp index 5f68ba6..84957e0 100644 --- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp @@ -26,9 +26,9 @@ static std::optional tryEvaluateSizeExpr(const Expr *SizeExpr, void SuspiciousMemoryComparisonCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( - callExpr(allOf(callee(namedDecl( - anyOf(hasName("::memcmp"), hasName("::std::memcmp")))), - unless(isInstantiationDependent()))) + callExpr(callee(namedDecl( + anyOf(hasName("::memcmp"), hasName("::std::memcmp")))), + unless(isInstantiationDependent())) .bind("call"), this); } diff --git a/clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp b/clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp index 3fce682..1e52884 100644 --- a/clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp +++ b/clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp @@ -72,8 +72,8 @@ void NonTrivialTypesLibcMemoryCallsCheck::registerMatchers( return expr(unaryOperator( hasOperatorName("&"), hasUnaryOperand(declRefExpr( - allOf(hasType(cxxRecordDecl(Constraint)), - hasType(Bind ? qualType().bind("Record") : qualType())))))); + hasType(cxxRecordDecl(Constraint)), + hasType(Bind ? qualType().bind("Record") : qualType()))))); }; auto IsRecordSizeOf = expr(sizeOfExpr(hasArgumentOfType(equalsBoundNode("Record")))); diff --git a/clang-tools-extra/clang-tidy/concurrency/ThreadCanceltypeAsynchronousCheck.cpp b/clang-tools-extra/clang-tidy/concurrency/ThreadCanceltypeAsynchronousCheck.cpp index 7bd79b2..6ea9884 100644 --- a/clang-tools-extra/clang-tidy/concurrency/ThreadCanceltypeAsynchronousCheck.cpp +++ b/clang-tools-extra/clang-tidy/concurrency/ThreadCanceltypeAsynchronousCheck.cpp @@ -18,8 +18,8 @@ namespace clang::tidy::concurrency { void ThreadCanceltypeAsynchronousCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( callExpr( - allOf(callee(functionDecl(hasName("::pthread_setcanceltype"))), - argumentCountIs(2)), + callee(functionDecl(hasName("::pthread_setcanceltype"))), + argumentCountIs(2), hasArgument(0, isExpandedFromMacro("PTHREAD_CANCEL_ASYNCHRONOUS"))) .bind("setcanceltype"), this); diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp index 4c18297..9215b83 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp @@ -123,8 +123,8 @@ void OwningMemoryCheck::registerMatchers(MatchFinder *Finder) { // Matching on initialization operations where the initial value is a newly // created owner, but the LHS is not an owner. Finder->addMatcher( - traverse(TK_AsIs, namedDecl(varDecl(allOf(hasInitializer(CreatesOwner), - unless(IsOwnerType))) + traverse(TK_AsIs, namedDecl(varDecl(hasInitializer(CreatesOwner), + unless(IsOwnerType)) .bind("bad_owner_creation_variable"))), this); diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp index 2dfa956..c210cb6 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp @@ -59,9 +59,9 @@ void ProBoundsArrayToPointerDecayCheck::registerMatchers(MatchFinder *Finder) { unless(hasParentIgnoringImpCasts(explicitCastExpr())), unless(isInsideOfRangeBeginEndStmt()), unless(hasSourceExpression(ignoringParens(stringLiteral()))), - unless(hasSourceExpression(ignoringParens(conditionalOperator( - allOf(hasTrueExpression(stringLiteral()), - hasFalseExpression(stringLiteral()))))))) + unless(hasSourceExpression(ignoringParens( + conditionalOperator(hasTrueExpression(stringLiteral()), + hasFalseExpression(stringLiteral())))))) .bind("cast")), this); } diff --git a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp b/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp index 060f3ae..f73667f 100644 --- a/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp +++ b/clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp @@ -87,8 +87,8 @@ bool MultipleInheritanceCheck::isInterface(const CXXRecordDecl *Node) { void MultipleInheritanceCheck::registerMatchers(MatchFinder *Finder) { // Match declarations which have bases. - Finder->addMatcher( - cxxRecordDecl(allOf(hasBases(), isDefinition())).bind("decl"), this); + Finder->addMatcher(cxxRecordDecl(hasBases(), isDefinition()).bind("decl"), + this); } void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) { diff --git a/clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp b/clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp index 2308d77f..9333337 100644 --- a/clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp +++ b/clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp @@ -24,45 +24,41 @@ namespace tidy::llvm_check { void PreferIsaOrDynCastInConditionalsCheck::registerMatchers( MatchFinder *Finder) { auto Condition = hasCondition(implicitCastExpr(has( - callExpr( - allOf(unless(isMacroID()), unless(cxxMemberCallExpr()), - anyOf(callee(namedDecl(hasName("cast"))), - callee(namedDecl(hasName("dyn_cast")).bind("dyn_cast"))))) + callExpr(unless(isMacroID()), unless(cxxMemberCallExpr()), + anyOf(callee(namedDecl(hasName("cast"))), + callee(namedDecl(hasName("dyn_cast")).bind("dyn_cast")))) .bind("call")))); auto Any = anyOf( has(declStmt(containsDeclaration( - 0, - varDecl(hasInitializer( - callExpr(allOf(unless(isMacroID()), unless(cxxMemberCallExpr()), - callee(namedDecl(hasName("cast"))))) - .bind("assign")))))), + 0, varDecl(hasInitializer(callExpr(unless(isMacroID()), + unless(cxxMemberCallExpr()), + callee(namedDecl(hasName("cast")))) + .bind("assign")))))), Condition); auto CallExpression = callExpr( - allOf( - unless(isMacroID()), unless(cxxMemberCallExpr()), - allOf(callee(namedDecl(hasAnyName("isa", "cast", "cast_or_null", - "dyn_cast", "dyn_cast_or_null")) - .bind("func")), - hasArgument( - 0, - mapAnyOf(declRefExpr, cxxMemberCallExpr).bind("arg"))))) + + unless(isMacroID()), unless(cxxMemberCallExpr()), + callee(namedDecl(hasAnyName("isa", "cast", "cast_or_null", "dyn_cast", + "dyn_cast_or_null")) + .bind("func")), + hasArgument(0, mapAnyOf(declRefExpr, cxxMemberCallExpr).bind("arg"))) .bind("rhs"); Finder->addMatcher( - traverse(TK_AsIs, - stmt(anyOf( - ifStmt(Any), whileStmt(Any), doStmt(Condition), - binaryOperator( - allOf(unless(isExpansionInFileMatching( + traverse( + TK_AsIs, + stmt(anyOf( + ifStmt(Any), whileStmt(Any), doStmt(Condition), + binaryOperator(unless(isExpansionInFileMatching( "llvm/include/llvm/Support/Casting.h")), hasOperatorName("&&"), hasLHS(implicitCastExpr().bind("lhs")), hasRHS(anyOf(implicitCastExpr(has(CallExpression)), - CallExpression)))) - .bind("and")))), + CallExpression))) + .bind("and")))), this); } diff --git a/clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp b/clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp index 5d19555..36c6baa 100644 --- a/clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp +++ b/clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp @@ -20,14 +20,13 @@ void PreferRegisterOverUnsignedCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( traverse(TK_AsIs, - valueDecl(allOf( - hasType(qualType(isUnsignedInteger()).bind("varType")), - varDecl(hasInitializer(exprWithCleanups( - has(implicitCastExpr(has(cxxMemberCallExpr( - allOf(on(RegisterClassMatch), + valueDecl(hasType(qualType(isUnsignedInteger()).bind("varType")), + varDecl(hasInitializer(exprWithCleanups( + has(implicitCastExpr(has(cxxMemberCallExpr( + on(RegisterClassMatch), has(memberExpr(hasDeclaration( - cxxConversionDecl()))))))))))) - .bind("var")))), + cxxConversionDecl())))))))))) + .bind("var"))), this); } diff --git a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp index b7c2f28..8b500de 100644 --- a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp @@ -83,11 +83,11 @@ void ConstCorrectnessCheck::registerMatchers(MatchFinder *Finder) { // Match local variables which could be 'const' if not modified later. // Example: `int i = 10` would match `int i`. const auto LocalValDecl = varDecl( - allOf(isLocal(), hasInitializer(anything()), - unless(anyOf(ConstType, ConstReference, TemplateType, - hasInitializer(isInstantiationDependent()), - AutoTemplateType, RValueReference, FunctionPointerRef, - hasType(cxxRecordDecl(isLambda())), isImplicit())))); + isLocal(), hasInitializer(anything()), + unless(anyOf(ConstType, ConstReference, TemplateType, + hasInitializer(isInstantiationDependent()), AutoTemplateType, + RValueReference, FunctionPointerRef, + hasType(cxxRecordDecl(isLambda())), isImplicit()))); // Match the function scope for which the analysis of all local variables // shall be run. diff --git a/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp index 16ea46e..299d453 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp @@ -89,20 +89,20 @@ void UseNodiscardCheck::registerMatchers(MatchFinder *Finder) { // warn on unused result. Finder->addMatcher( cxxMethodDecl( - allOf(isConst(), isDefinitionOrInline(), - unless(anyOf( - returns(voidType()), - returns(hasDeclaration(decl(hasAttr(clang::attr::WarnUnusedResult)))), - isNoReturn(), isOverloadedOperator(), - isVariadic(), hasTemplateReturnType(), - hasClassMutableFields(), isConversionOperator(), - hasAttr(clang::attr::WarnUnusedResult), - hasType(isInstantiationDependentType()), - hasAnyParameter(anyOf( - parmVarDecl(anyOf(hasType(FunctionObj), + isConst(), isDefinitionOrInline(), + unless(anyOf( + returns(voidType()), + returns( + hasDeclaration(decl(hasAttr(clang::attr::WarnUnusedResult)))), + isNoReturn(), isOverloadedOperator(), isVariadic(), + hasTemplateReturnType(), hasClassMutableFields(), + isConversionOperator(), hasAttr(clang::attr::WarnUnusedResult), + hasType(isInstantiationDependentType()), + hasAnyParameter( + anyOf(parmVarDecl(anyOf(hasType(FunctionObj), hasType(references(FunctionObj)))), hasType(isNonConstReferenceOrPointer()), - hasParameterPack())))))) + hasParameterPack()))))) .bind("no_discard"), this); } diff --git a/clang-tools-extra/clang-tidy/openmp/UseDefaultNoneCheck.cpp b/clang-tools-extra/clang-tidy/openmp/UseDefaultNoneCheck.cpp index f886d43..8977a58 100644 --- a/clang-tools-extra/clang-tidy/openmp/UseDefaultNoneCheck.cpp +++ b/clang-tools-extra/clang-tidy/openmp/UseDefaultNoneCheck.cpp @@ -22,10 +22,10 @@ namespace clang::tidy::openmp { void UseDefaultNoneCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( ompExecutableDirective( - allOf(isAllowedToContainClauseKind(llvm::omp::OMPC_default), - anyOf(unless(hasAnyClause(ompDefaultClause())), - hasAnyClause(ompDefaultClause(unless(isNoneKind())) - .bind("clause"))))) + isAllowedToContainClauseKind(llvm::omp::OMPC_default), + anyOf(unless(hasAnyClause(ompDefaultClause())), + hasAnyClause( + ompDefaultClause(unless(isNoneKind())).bind("clause")))) .bind("directive"), this); } -- 2.7.4