Remove calls to the `allOf` matcher in all matchers that are derived from the `VariadicDynCastAllOfMatcher`.
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);
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);
}
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) {
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);
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;
// - 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);
// - 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(
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),
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(
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);
}
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"))));
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);
// 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);
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);
}
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) {
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);
}
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);
}
// 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.
// 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);
}
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);
}