15#include "llvm/ADT/STLExtras.h"
27 const auto IgnoreDerivedToBase = [](
const Expr *E,
auto Matcher) {
30 if (
const auto *Cast = dyn_cast<ImplicitCastExpr>(E)) {
31 if ((Cast->getCastKind() == CK_DerivedToBase ||
32 Cast->getCastKind() == CK_UncheckedDerivedToBase) &&
33 Matcher(Cast->getSubExpr()))
39 const auto EvalCommaExpr = [](
const Expr *E,
auto Matcher) {
41 while (
const auto *BOComma =
42 dyn_cast_or_null<BinaryOperator>(
Result->IgnoreParens())) {
43 if (!BOComma->isCommaOp())
45 Result = BOComma->getRHS();
58 const auto ConditionalOperatorM = [
Target](
const Expr *E) {
59 if (
const auto *CO = dyn_cast<AbstractConditionalOperator>(E)) {
60 const auto *TE = CO->getTrueExpr()->IgnoreParens();
63 const auto *FE = CO->getFalseExpr()->IgnoreParens();
71 return IgnoreDerivedToBase(SourceExprP,
73 return E ==
Target || ConditionalOperatorM(E);
75 EvalCommaExpr(SourceExprP, [&](
const Expr *E) {
76 return IgnoreDerivedToBase(
86 ast_matchers::internal::Matcher<Expr>, InnerMatcher) {
87 if (Node.isTypeDependent()) {
88 return InnerMatcher.matches(*Node.getLHS(), Finder, Builder) ||
89 InnerMatcher.matches(*Node.getRHS(), Finder, Builder);
91 return InnerMatcher.matches(*Node.getBase(), Finder, Builder);
97 return llvm::is_contained(Node.capture_inits(), E);
101 ast_matchers::internal::Matcher<DeclStmt>, InnerMatcher) {
103 return InnerMatcher.matches(*Range, Finder, Builder);
107 auto *Exp = dyn_cast<Expr>(&Node);
110 auto *
Target = dyn_cast<Expr>(Inner);
118class ExprPointeeResolve {
121 bool resolveExpr(
const Expr *E) {
127 if (
const auto *BO = dyn_cast<BinaryOperator>(E)) {
128 if (BO->isAdditiveOp())
129 return (resolveExpr(BO->getLHS()) || resolveExpr(BO->getRHS()));
131 return resolveExpr(BO->getRHS());
135 if (
const auto *PE = dyn_cast<ParenExpr>(E))
136 return resolveExpr(PE->getSubExpr());
138 if (
const auto *UO = dyn_cast<UnaryOperator>(E)) {
139 if (UO->getOpcode() == UO_AddrOf)
140 return resolveExpr(UO->getSubExpr());
143 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(E)) {
147 if (
kind == CK_LValueToRValue ||
kind == CK_DerivedToBase ||
148 kind == CK_UncheckedDerivedToBase ||
kind == CK_NoOp ||
150 return resolveExpr(ICE->getSubExpr());
154 if (
const auto *ACE = dyn_cast<AbstractConditionalOperator>(E))
155 return resolve(ACE->getTrueExpr()) || resolve(ACE->getFalseExpr());
161 ExprPointeeResolve(
const Expr *T) : T(T) {}
162 bool resolve(
const Expr *S) {
return resolveExpr(S); }
166 auto *Exp = dyn_cast<Expr>(&Node);
169 auto *
Target = dyn_cast<Expr>(T);
172 return ExprPointeeResolve{
Target}.resolve(Exp);
179 for (
const Expr *Arg : Node.inits()) {
182 ast_matchers::internal::BoundNodesTreeBuilder
Result(*Builder);
183 if (InnerMatcher.matches(*Arg, Finder, &
Result)) {
184 *Builder = std::move(
Result);
191const ast_matchers::internal::VariadicDynCastAllOfMatcher<Stmt, CXXTypeidExpr>
195 return Node.isPotentiallyEvaluated();
199 const Decl *CalleeDecl = Node.getCalleeDecl();
200 const auto *VD = dyn_cast_or_null<ValueDecl>(CalleeDecl);
203 const QualType T = VD->getType().getCanonicalType();
204 const auto *MPT = dyn_cast<MemberPointerType>(T);
213 ast_matchers::internal::Matcher<Expr>, InnerMatcher) {
214 if (Node.isTypePredicate())
216 return InnerMatcher.matches(*Node.getControllingExpr(), Finder, Builder);
220ast_matchers::internal::Matcher<T>
221findFirst(
const ast_matchers::internal::Matcher<T> &Matcher) {
225const auto nonConstReferenceType = [] {
226 return hasUnqualifiedDesugaredType(
230const auto constReferenceToPointerWithNonConstPointeeType = [] {
232 isConstQualified(), hasUnqualifiedDesugaredType(
pointerType(
233 pointee(
unless(isConstQualified()))))))));
236const auto nonConstPointerType = [] {
237 return hasUnqualifiedDesugaredType(
241const auto isMoveOnly = [] {
251template <
class T>
struct NodeID;
252template <>
struct NodeID<
Expr> {
253 static constexpr StringRef value =
"expr";
255template <>
struct NodeID<
Decl> {
256 static constexpr StringRef value =
"decl";
263 const StringRef
ID = NodeID<T>::value;
264 for (
const auto &Nodes : Matches) {
265 if (
const Stmt *S = (Analyzer->*Finder)(Nodes.getNodeAs<T>(ID)))
274 return findMutationMemoized(
276 {&ExprMutationAnalyzer::Analyzer::findDirectMutation,
277 &ExprMutationAnalyzer::Analyzer::findMemberMutation,
278 &ExprMutationAnalyzer::Analyzer::findArrayElementMutation,
279 &ExprMutationAnalyzer::Analyzer::findCastMutation,
280 &ExprMutationAnalyzer::Analyzer::findRangeLoopMutation,
281 &ExprMutationAnalyzer::Analyzer::findReferenceMutation,
282 &ExprMutationAnalyzer::Analyzer::findFunctionArgMutation},
292 return findMutationMemoized(
295 &ExprMutationAnalyzer::Analyzer::findPointeeValueMutation,
296 &ExprMutationAnalyzer::Analyzer::findPointeeMemberMutation,
297 &ExprMutationAnalyzer::Analyzer::findPointeeToNonConst,
299 Memorized.PointeeResults);
304 return tryEachDeclRef(Dec,
308const Stmt *ExprMutationAnalyzer::Analyzer::findMutationMemoized(
312 auto [
Memoized, Inserted] = MemoizedResults.try_emplace(Exp);
319 for (
const auto &Finder : Finders) {
320 if (
const Stmt *S = (this->*Finder)(Exp))
321 return MemoizedResults[Exp] = S;
328ExprMutationAnalyzer::Analyzer::tryEachDeclRef(
const Decl *Dec,
329 MutationFinder Finder) {
330 const auto Refs =
match(
334 anyOf(equalsNode(Dec),
338 .bind(NodeID<Expr>::value)),
340 for (
const auto &RefNodes : Refs) {
341 const auto *E = RefNodes.getNodeAs<Expr>(NodeID<Expr>::value);
342 if ((this->*Finder)(E))
363 cxxTypeidExpr(
unless(isPotentiallyEvaluated())),
375 return tryEachMatch<Expr>(Matches,
this,
381 return tryEachMatch<Decl>(Matches,
this,
385const Stmt *ExprMutationAnalyzer::Analyzer::findExprPointeeMutation(
386 ArrayRef<ast_matchers::BoundNodes> Matches) {
387 return tryEachMatch<Expr>(
391const Stmt *ExprMutationAnalyzer::Analyzer::findDeclPointeeMutation(
392 ArrayRef<ast_matchers::BoundNodes> Matches) {
393 return tryEachMatch<Decl>(
398ExprMutationAnalyzer::Analyzer::findDirectMutation(
const Expr *Exp) {
400 const auto AsAssignmentLhs =
401 binaryOperator(isAssignmentOperator(), hasLHS(canResolveToExpr(Exp)));
404 const auto AsIncDecOperand =
406 hasUnaryOperand(canResolveToExpr(Exp)));
416 on(canResolveToExpr(Exp)),
420 hasArgument(0, canResolveToExpr(Exp))),
426 hasEitherOperand(ignoringImpCasts(canResolveToExpr(Exp)))),
430 cxxFoldExpr(hasFoldInit(ignoringImpCasts(canResolveToExpr(Exp)))),
437 hasObjectExpression(canResolveToExpr(Exp))))))),
443 hasObjectExpression(canResolveToExpr(Exp))))))));
449 const auto AsAmpersandOperand =
453 hasUnaryOperand(canResolveToExpr(Exp)));
454 const auto AsPointerFromArrayDecay =
castExpr(
455 hasCastKind(CK_ArrayToPointerDecay),
463 cxxMethodDecl(ofClass(isMoveOnly()), returns(nonConstPointerType()))),
464 argumentCountIs(1), hasArgument(0, canResolveToExpr(Exp)));
471 const auto NonConstRefParam = forEachArgumentWithParamType(
472 anyOf(canResolveToExpr(Exp),
474 hasObjectExpression(ignoringImpCasts(canResolveToExpr(Exp))))),
475 nonConstReferenceType());
478 const auto AsNonConstRefArg =
484 callExpr(isTypeDependent(), hasAnyArgument(canResolveToExpr(Exp))),
500 const auto AsLambdaRefCaptureInit =
lambdaExpr(hasCaptureInit(Exp));
507 const auto AsNonConstRefReturn =
508 returnStmt(hasReturnValue(canResolveToExpr(Exp)));
512 allOf(canResolveToExpr(Exp), hasType(nonConstReferenceType())))));
514 const auto Matches =
match(
517 findFirst(
stmt(
anyOf(AsAssignmentLhs, AsIncDecOperand, AsNonConstThis,
518 AsAmpersandOperand, AsPointerFromArrayDecay,
519 AsOperatorArrowThis, AsNonConstRefArg,
520 AsLambdaRefCaptureInit, AsNonConstRefReturn,
521 AsNonConstRefRangeInit))
528ExprMutationAnalyzer::Analyzer::findMemberMutation(
const Expr *Exp) {
530 const auto MemberExprs =
match(
533 hasObjectExpression(canResolveToExpr(Exp))),
535 hasLHS(equalsNode(Exp)))))
536 .bind(NodeID<Expr>::value)),
538 return findExprMutation(MemberExprs);
542ExprMutationAnalyzer::Analyzer::findArrayElementMutation(
const Expr *Exp) {
544 const auto SubscriptExprs =
match(
546 anyOf(hasBaseConservative(canResolveToExpr(Exp)),
548 hasCastKind(CK_ArrayToPointerDecay),
549 hasSourceExpression(canResolveToExpr(Exp)))))))
550 .bind(NodeID<Expr>::value)),
552 return findExprMutation(SubscriptExprs);
555const Stmt *ExprMutationAnalyzer::Analyzer::findCastMutation(
const Expr *Exp) {
558 const auto ExplicitCast =
561 nonConstReferenceType()))))
569 const auto Casts =
match(
572 nonConstReferenceType())),
574 nonConstReferenceType())))))
575 .bind(NodeID<Expr>::value)),
578 if (
const Stmt *S = findExprMutation(Casts))
583 hasAnyName(
"::std::move",
"::std::forward"))),
584 hasArgument(0, canResolveToExpr(Exp)))
587 return findExprMutation(Calls);
591ExprMutationAnalyzer::Analyzer::findRangeLoopMutation(
const Expr *Exp) {
598 const auto DeclStmtToNonRefToArray =
declStmt(hasSingleDecl(
varDecl(hasType(
600 const auto RefToArrayRefToElements =
match(
604 hasType(nonConstPointerType())))
605 .bind(NodeID<Decl>::value)),
606 hasRangeStmt(DeclStmtToNonRefToArray),
607 hasRangeInit(canResolveToExpr(Exp))))
611 if (
const auto *BadRangeInitFromArray =
613 return BadRangeInitFromArray;
622 const auto HasAnyNonConstIterator =
628 const auto DeclStmtToNonConstIteratorContainer =
declStmt(
632 const auto RefToContainerBadIterators =
match(
634 hasRangeStmt(DeclStmtToNonConstIteratorContainer),
635 hasRangeInit(canResolveToExpr(Exp)))))
639 if (
const auto *BadIteratorsContainer =
641 return BadIteratorsContainer;
645 const auto LoopVars =
647 hasLoopVariable(
varDecl(hasType(nonConstReferenceType()))
648 .bind(NodeID<Decl>::value)),
649 hasRangeInit(canResolveToExpr(Exp)))),
651 return findDeclMutation(LoopVars);
655ExprMutationAnalyzer::Analyzer::findReferenceMutation(
const Expr *Exp) {
659 const auto Ref =
match(
663 returns(nonConstReferenceType()))),
664 argumentCountIs(1), hasArgument(0, canResolveToExpr(Exp)))
665 .bind(NodeID<Expr>::value)),
667 if (
const Stmt *S = findExprMutation(Ref))
671 const auto Refs =
match(
673 varDecl(hasType(nonConstReferenceType()),
674 hasInitializer(
anyOf(
675 canResolveToExpr(Exp),
676 memberExpr(hasObjectExpression(canResolveToExpr(Exp))))),
681 hasRangeStmt(equalsBoundNode(
"stmt"))))))))
682 .bind(NodeID<Decl>::value))),
684 return findDeclMutation(Refs);
688ExprMutationAnalyzer::Analyzer::findFunctionArgMutation(
const Expr *Exp) {
689 const auto NonConstRefParam = forEachArgumentWithParam(
690 canResolveToExpr(Exp),
691 parmVarDecl(hasType(nonConstReferenceType())).bind(
"parm"));
694 const auto Matches =
match(
700 "::std::move",
"::std::forward"))))),
703 .bind(NodeID<Expr>::value))),
705 for (
const auto &Nodes : Matches) {
706 const auto *Exp = Nodes.getNodeAs<Expr>(NodeID<Expr>::value);
707 const auto *
Func = Nodes.getNodeAs<FunctionDecl>(
"func");
708 if (!
Func->getBody() || !
Func->getPrimaryTemplate())
711 const auto *Parm = Nodes.getNodeAs<ParmVarDecl>(
"parm");
712 const ArrayRef<ParmVarDecl *> AllParams =
713 Func->getPrimaryTemplate()->getTemplatedDecl()->parameters();
715 AllParams[std::min<size_t>(Parm->getFunctionScopeIndex(),
716 AllParams.size() - 1)]
718 if (
const auto *T = ParmType->getAs<PackExpansionType>())
719 ParmType = T->getPattern();
723 if (
const auto *RefType = ParmType->getAs<RValueReferenceType>()) {
724 if (!RefType->getPointeeType().getQualifiers() &&
726 RefType->getPointeeType().getCanonicalType())) {
729 *
Func, Context, Memorized);
742ExprMutationAnalyzer::Analyzer::findPointeeValueMutation(
const Expr *Exp) {
743 const auto Matches =
match(
748 hasUnaryOperand(canResolveToExprPointee(Exp))),
751 hasBaseConservative(canResolveToExprPointee(Exp)))))
752 .bind(NodeID<Expr>::value))),
754 return findExprMutation(Matches);
758ExprMutationAnalyzer::Analyzer::findPointeeMemberMutation(
const Expr *Exp) {
766 return MemberCallExpr;
767 const auto Matches =
match(
770 hasObjectExpression(canResolveToExprPointee(Exp))),
772 hasLHS(canResolveToExprPointee(Exp)))))
773 .bind(NodeID<Expr>::value))),
775 return findExprMutation(Matches);
779ExprMutationAnalyzer::Analyzer::findPointeeToNonConst(
const Expr *Exp) {
780 const auto NonConstPointerOrNonConstRefOrDependentType =
type(
anyOf(
781 nonConstPointerType(), nonConstReferenceType(),
782 constReferenceToPointerWithNonConstPointeeType(), isDependentType()));
785 const auto InitToNonConst =
786 varDecl(hasType(NonConstPointerOrNonConstRefOrDependentType),
787 hasInitializer(
expr(canResolveToExprPointee(Exp)).bind(
"stmt")));
789 hasOperatorName(
"="),
790 hasLHS(
expr(hasType(NonConstPointerOrNonConstRefOrDependentType))),
791 hasRHS(canResolveToExprPointee(Exp)));
793 const auto ArgOfInstantiationDependent =
allOf(
794 hasAnyArgument(canResolveToExprPointee(Exp)), isInstantiationDependent());
795 const auto ArgOfNonConstParameter =
796 forEachArgumentWithParamType(canResolveToExprPointee(Exp),
797 NonConstPointerOrNonConstRefOrDependentType);
798 const auto CallLikeMatcher =
799 anyOf(ArgOfNonConstParameter, ArgOfInstantiationDependent);
800 const auto PassAsNonConstArg =
expr(
803 ignoringParenImpCasts(canResolveToExprPointee(Exp)))),
806 expr(canResolveToExprPointee(Exp),
807 hasType(NonConstPointerOrNonConstRefOrDependentType)))),
809 expr(canResolveToExprPointee(Exp),
810 hasType(NonConstPointerOrNonConstRefOrDependentType))))));
813 hasSourceExpression(canResolveToExprPointee(Exp)),
814 hasDestinationType(NonConstPointerOrNonConstRefOrDependentType));
818 const auto CaptureNoConst =
lambdaExpr(hasCaptureInit(Exp));
821 hasReturnValue(canResolveToExprPointee(Exp)),
822 forFunction(returns(NonConstPointerOrNonConstRefOrDependentType)));
824 const auto Matches =
match(
826 stmt(
anyOf(AssignToNonConst, PassAsNonConstArg,
827 CastToNonConst, CaptureNoConst, ReturnNoConst))
834FunctionParmMutationAnalyzer::FunctionParmMutationAnalyzer(
835 const FunctionDecl &
Func, ASTContext &Context,
836 ExprMutationAnalyzer::Memoized &Memorized)
837 : BodyAnalyzer(*
Func.getBody(), Context, Memorized) {
838 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(&
Func)) {
841 for (
const CXXCtorInitializer *
Init : Ctor->inits()) {
842 ExprMutationAnalyzer::Analyzer InitAnalyzer(*
Init->getInit(), Context,
844 for (
const ParmVarDecl *Parm : Ctor->parameters()) {
845 if (Results.contains(Parm))
847 if (
const Stmt *S = InitAnalyzer.findMutation(Parm))
856 auto [Place, Inserted] = Results.try_emplace(Parm);
858 return Place->second;
864 return Place->second = BodyAnalyzer.findMutation(Parm);
#define AST_MATCHER(Type, DefineMatcher)
AST_MATCHER(Type, DefineMatcher) { ... } defines a zero parameter function named DefineMatcher() that...
#define AST_MATCHER_P(Type, DefineMatcher, ParamType, Param)
AST_MATCHER_P(Type, DefineMatcher, ParamType, Param) { ... } defines a single-parameter function name...
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CXXForRangeStmt - This represents C++0x [stmt.ranged]'s ranged for statement, represented as 'for (ra...
Represents a call to a member function that may be written either with member call syntax (e....
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Decl - This represents one declaration (or definition), e.g.
static bool isUnevaluated(const Stmt *Stm, ASTContext &Context)
check whether stmt is unevaluated.
friend class FunctionParmMutationAnalyzer
This represents one expression.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
static FunctionParmMutationAnalyzer * getFunctionParmMutationAnalyzer(const FunctionDecl &Func, ASTContext &Context, ExprMutationAnalyzer::Memoized &Memorized)
const Stmt * findMutation(const ParmVarDecl *Parm)
Represents a prototype with parameter type info, e.g.
Represents a C11 generic selection.
Describes an C or C++ initializer list.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Represents a parameter to a function.
A (possibly-)qualified type.
Stmt - This represents one statement.
The base class of the type hierarchy.
const internal::VariadicDynCastAllOfMatcher< Decl, VarDecl > varDecl
Matches variable declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclRefExpr > declRefExpr
Matches expressions that refer to declarations.
const internal::VariadicOperatorMatcherFunc< 1, 1 > unless
Matches if the provided matcher does not match.
const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitCastExpr > implicitCastExpr
Matches the implicit cast nodes of Clang's AST.
const internal::ArgumentAdaptingMatcherFunc< internal::HasDescendantMatcher > hasDescendant
Matches AST nodes that have descendant AST nodes that match the provided matcher.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDependentScopeMemberExpr > cxxDependentScopeMemberExpr
Matches member expressions where the actual member referenced could not be resolved because the base ...
const internal::VariadicDynCastAllOfMatcher< Decl, BindingDecl > bindingDecl
Matches binding declarations Example matches foo and bar (matcher = bindingDecl()
const internal::VariadicDynCastAllOfMatcher< Decl, ParmVarDecl > parmVarDecl
Matches parameter variable declarations.
const AstTypeMatcher< VariableArrayType > variableArrayType
const internal::VariadicDynCastAllOfMatcher< Stmt, GenericSelectionExpr > genericSelectionExpr
Matches C11 _Generic expression.
const internal::VariadicDynCastAllOfMatcher< Stmt, ReturnStmt > returnStmt
Matches return statements.
internal::Matcher< NamedDecl > hasName(StringRef Name)
Matches NamedDecl nodes that have the specified name.
const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > callExpr
Matches call expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, LambdaExpr > lambdaExpr
Matches lambda expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryExprOrTypeTraitExpr > unaryExprOrTypeTraitExpr
Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
const internal::ArgumentAdaptingMatcherFunc< internal::ForEachDescendantMatcher > forEachDescendant
Matches AST nodes that have descendant AST nodes that match the provided matcher.
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
const internal::VariadicDynCastAllOfMatcher< Decl, NamedDecl > namedDecl
Matches a declaration of anything that could have a name.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< TypeLoc > typeLoc
Matches TypeLocs in the clang AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, ParenListExpr > parenListExpr
Matches paren list expressions.
const AstTypeMatcher< ArrayType > arrayType
const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryOperator > unaryOperator
Matches unary operator expressions.
const internal::VariadicFunction< internal::Matcher< NamedDecl >, StringRef, internal::hasAnyNameFunc > hasAnyName
Matches NamedDecl nodes that have any of the specified names.
const internal::MapAnyOfMatcher< BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator > binaryOperation
Matches nodes which can be used with binary operators.
const internal::VariadicDynCastAllOfMatcher< Stmt, ArraySubscriptExpr > arraySubscriptExpr
Matches array subscript expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXForRangeStmt > cxxForRangeStmt
Matches range-based for statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXMemberCallExpr > cxxMemberCallExpr
Matches member call expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXConstructorDecl > cxxConstructorDecl
Matches C++ constructor declarations.
internal::BindableMatcher< Stmt > sizeOfExpr(const internal::Matcher< UnaryExprOrTypeTraitExpr > &InnerMatcher)
Same as unaryExprOrTypeTraitExpr, but only matching sizeof.
const internal::VariadicDynCastAllOfMatcher< Stmt, InitListExpr > initListExpr
Matches init list expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNoexceptExpr > cxxNoexceptExpr
Matches noexcept expressions.
const NodeT * selectFirst(StringRef BoundTo, const SmallVectorImpl< BoundNodes > &Results)
Returns the first result of type NodeT bound to BoundTo.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNewExpr > cxxNewExpr
Matches new expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryOperator > binaryOperator
Matches binary operator expressions.
const internal::ArgumentAdaptingMatcherFunc< internal::HasMatcher > has
Matches AST nodes that have child AST nodes that match the provided matcher.
const internal::VariadicDynCastAllOfMatcher< Stmt, ExplicitCastExpr > explicitCastExpr
Matches explicit cast expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstructExpr > cxxConstructExpr
Matches constructor call expressions (including implicit ones).
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXOperatorCallExpr > cxxOperatorCallExpr
Matches overloaded operator calls.
const AstTypeMatcher< PointerType > pointerType
internal::PolymorphicMatcher< internal::HasOverloadedOperatorNameMatcher, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl), std::vector< std::string > > hasOverloadedOperatorName(StringRef Name)
Matches overloaded operator names.
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> allOf
Matches if all given matchers match.
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionDecl > functionDecl
Matches function declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, UnresolvedMemberExpr > unresolvedMemberExpr
Matches unresolved member expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, MemberExpr > memberExpr
Matches member expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXRecordDecl > cxxRecordDecl
Matches C++ class declarations.
internal::Matcher< T > traverse(TraversalKind TK, const internal::Matcher< T > &InnerMatcher)
Causes all nested matchers to be matched with the specified traversal kind.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXUnresolvedConstructExpr > cxxUnresolvedConstructExpr
Matches unresolved constructor call expressions.
internal::Matcher< T > findAll(const internal::Matcher< T > &Matcher)
Matches if the node or any descendant matches.
internal::PolymorphicMatcher< internal::HasDeclarationMatcher, void(internal::HasDeclarationSupportedTypes), internal::Matcher< Decl > > hasDeclaration(const internal::Matcher< Decl > &InnerMatcher)
Matches a node if the declaration associated with that node matches the given matcher.
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclStmt > declStmt
Matches declaration statements.
const internal::VariadicAllOfMatcher< Stmt > stmt
Matches statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXFoldExpr > cxxFoldExpr
Matches C++17 fold expressions.
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> anyOf
Matches if any of the given matchers matches.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXMethodDecl > cxxMethodDecl
Matches method declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang's AST.
const internal::VariadicAllOfMatcher< QualType > qualType
Matches QualTypes in the clang AST.
const internal::ArgumentAdaptingMatcherFunc< internal::HasAncestorMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr > > hasAncestor
Matches AST nodes that have an ancestor that matches the provided matcher.
const internal::ArgumentAdaptingMatcherFunc< internal::HasParentMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr > > hasParent
Matches AST nodes that have a parent that matches the provided matcher.
const AstTypeMatcher< ReferenceType > referenceType
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
@ TK_AsIs
Will traverse all child nodes.
@ Result
The result type of a method or function.
CastKind
CastKind - The kind of operation required for a conversion.
static bool canExprResolveTo(const Expr *Source, const Expr *Target)
U cast(CodeGen::Address addr)
const Stmt * findPointeeMutation(const Expr *Exp)
const Stmt * findMutation(const Expr *Exp)
llvm::DenseMap< const Expr *, const Stmt * > ResultMap