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()));
130 if (BO->getOpcode() == BO_AddAssign || BO->getOpcode() == BO_SubAssign)
131 return resolveExpr(BO->getLHS());
132 if (BO->getOpcode() == BO_Assign)
133 return (resolveExpr(BO->getLHS()) || resolveExpr(BO->getRHS()));
135 return resolveExpr(BO->getRHS());
139 if (
const auto *PE = dyn_cast<ParenExpr>(E))
140 return resolveExpr(PE->getSubExpr());
142 if (
const auto *UO = dyn_cast<UnaryOperator>(E)) {
143 if (UO->getOpcode() == UO_AddrOf || UO->isIncrementDecrementOp())
144 return resolveExpr(UO->getSubExpr());
147 if (
const auto *ICE = dyn_cast<ImplicitCastExpr>(E)) {
151 if (
kind == CK_LValueToRValue ||
kind == CK_DerivedToBase ||
152 kind == CK_UncheckedDerivedToBase ||
kind == CK_NoOp ||
154 return resolveExpr(ICE->getSubExpr());
158 if (
const auto *ACE = dyn_cast<AbstractConditionalOperator>(E))
159 return resolve(ACE->getTrueExpr()) || resolve(ACE->getFalseExpr());
165 ExprPointeeResolve(
const Expr *T) : T(T) {}
166 bool resolve(
const Expr *S) {
return resolveExpr(S); }
170 auto *Exp = dyn_cast<Expr>(&Node);
173 auto *
Target = dyn_cast<Expr>(
T);
176 return ExprPointeeResolve{
Target}.resolve(Exp);
183 for (
const Expr *Arg : Node.inits()) {
186 ast_matchers::internal::BoundNodesTreeBuilder
Result(*Builder);
187 if (InnerMatcher.matches(*Arg, Finder, &
Result)) {
188 *Builder = std::move(
Result);
195const ast_matchers::internal::VariadicDynCastAllOfMatcher<Stmt, CXXTypeidExpr>
199 return Node.isPotentiallyEvaluated();
203 const Decl *CalleeDecl = Node.getCalleeDecl();
204 const auto *VD = dyn_cast_or_null<ValueDecl>(CalleeDecl);
207 const QualType T = VD->getType().getCanonicalType();
208 const auto *MPT = dyn_cast<MemberPointerType>(
T);
217 ast_matchers::internal::Matcher<Expr>, InnerMatcher) {
218 if (Node.isTypePredicate())
220 return InnerMatcher.matches(*Node.getControllingExpr(), Finder, Builder);
224ast_matchers::internal::Matcher<T>
225findFirst(
const ast_matchers::internal::Matcher<T> &Matcher) {
229const auto nonConstReferenceType = [] {
230 return hasUnqualifiedDesugaredType(
234const auto constReferenceToPointerWithNonConstPointeeType = [] {
236 isConstQualified(), hasUnqualifiedDesugaredType(
pointerType(
237 pointee(
unless(isConstQualified()))))))));
240const auto nonConstPointerType = [] {
241 return hasUnqualifiedDesugaredType(
245const auto isMoveOnly = [] {
255template <
class T>
struct NodeID;
256template <>
struct NodeID<
Expr> {
257 static constexpr StringRef value =
"expr";
259template <>
struct NodeID<
Decl> {
260 static constexpr StringRef value =
"decl";
267 const StringRef
ID = NodeID<T>::value;
268 for (
const auto &Nodes : Matches) {
269 if (
const Stmt *S = (Analyzer->*Finder)(Nodes.getNodeAs<
T>(ID)))
278 return findMutationMemoized(
280 {&ExprMutationAnalyzer::Analyzer::findDirectMutation,
281 &ExprMutationAnalyzer::Analyzer::findMemberMutation,
282 &ExprMutationAnalyzer::Analyzer::findArrayElementMutation,
283 &ExprMutationAnalyzer::Analyzer::findCastMutation,
284 &ExprMutationAnalyzer::Analyzer::findRangeLoopMutation,
285 &ExprMutationAnalyzer::Analyzer::findReferenceMutation,
286 &ExprMutationAnalyzer::Analyzer::findFunctionArgMutation},
296 return findMutationMemoized(
299 &ExprMutationAnalyzer::Analyzer::findPointeeValueMutation,
300 &ExprMutationAnalyzer::Analyzer::findPointeeMemberMutation,
301 &ExprMutationAnalyzer::Analyzer::findPointeeToNonConst,
303 Memorized.PointeeResults);
308 return tryEachDeclRef(Dec,
312const Stmt *ExprMutationAnalyzer::Analyzer::findMutationMemoized(
316 auto [
Memoized, Inserted] = MemoizedResults.try_emplace(Exp);
323 for (
const auto &Finder : Finders) {
324 if (
const Stmt *S = (this->*Finder)(Exp))
325 return MemoizedResults[Exp] = S;
332ExprMutationAnalyzer::Analyzer::tryEachDeclRef(
const Decl *Dec,
333 MutationFinder Finder) {
334 const auto Refs =
match(
338 anyOf(equalsNode(Dec),
342 .bind(NodeID<Expr>::value)),
344 for (
const auto &RefNodes : Refs) {
345 const auto *E = RefNodes.getNodeAs<Expr>(NodeID<Expr>::value);
346 if ((this->*Finder)(E))
367 cxxTypeidExpr(
unless(isPotentiallyEvaluated())),
379 return tryEachMatch<Expr>(Matches,
this,
385 return tryEachMatch<Decl>(Matches,
this,
389const Stmt *ExprMutationAnalyzer::Analyzer::findExprPointeeMutation(
390 ArrayRef<ast_matchers::BoundNodes> Matches) {
391 return tryEachMatch<Expr>(
395const Stmt *ExprMutationAnalyzer::Analyzer::findDeclPointeeMutation(
396 ArrayRef<ast_matchers::BoundNodes> Matches) {
397 return tryEachMatch<Decl>(
402ExprMutationAnalyzer::Analyzer::findDirectMutation(
const Expr *Exp) {
404 const auto AsAssignmentLhs =
405 binaryOperator(isAssignmentOperator(), hasLHS(canResolveToExpr(Exp)));
408 const auto AsIncDecOperand =
410 hasUnaryOperand(canResolveToExpr(Exp)));
420 on(canResolveToExpr(Exp)),
424 hasArgument(0, canResolveToExpr(Exp))),
430 hasEitherOperand(ignoringImpCasts(canResolveToExpr(Exp)))),
434 cxxFoldExpr(hasFoldInit(ignoringImpCasts(canResolveToExpr(Exp)))),
441 hasObjectExpression(canResolveToExpr(Exp))))))),
447 hasObjectExpression(canResolveToExpr(Exp))))))));
453 const auto AsAmpersandOperand =
457 hasUnaryOperand(canResolveToExpr(Exp)));
458 const auto AsPointerFromArrayDecay =
castExpr(
459 hasCastKind(CK_ArrayToPointerDecay),
467 cxxMethodDecl(ofClass(isMoveOnly()), returns(nonConstPointerType()))),
468 argumentCountIs(1), hasArgument(0, canResolveToExpr(Exp)));
475 const auto NonConstRefParam = forEachArgumentWithParamType(
476 anyOf(canResolveToExpr(Exp),
478 hasObjectExpression(ignoringImpCasts(canResolveToExpr(Exp))))),
479 nonConstReferenceType());
482 const auto AsNonConstRefArg =
488 callExpr(isTypeDependent(), hasAnyArgument(canResolveToExpr(Exp))),
504 const auto AsLambdaRefCaptureInit =
lambdaExpr(hasCaptureInit(Exp));
511 const auto AsNonConstRefReturn =
512 returnStmt(hasReturnValue(canResolveToExpr(Exp)));
516 allOf(canResolveToExpr(Exp), hasType(nonConstReferenceType())))));
518 const auto Matches =
match(
521 findFirst(
stmt(
anyOf(AsAssignmentLhs, AsIncDecOperand, AsNonConstThis,
522 AsAmpersandOperand, AsPointerFromArrayDecay,
523 AsOperatorArrowThis, AsNonConstRefArg,
524 AsLambdaRefCaptureInit, AsNonConstRefReturn,
525 AsNonConstRefRangeInit))
532ExprMutationAnalyzer::Analyzer::findMemberMutation(
const Expr *Exp) {
534 const auto MemberExprs =
match(
537 hasObjectExpression(canResolveToExpr(Exp))),
539 hasLHS(equalsNode(Exp)))))
540 .bind(NodeID<Expr>::value)),
542 return findExprMutation(MemberExprs);
546ExprMutationAnalyzer::Analyzer::findArrayElementMutation(
const Expr *Exp) {
548 const auto SubscriptExprs =
match(
550 anyOf(hasBaseConservative(canResolveToExpr(Exp)),
552 hasCastKind(CK_ArrayToPointerDecay),
553 hasSourceExpression(canResolveToExpr(Exp)))))))
554 .bind(NodeID<Expr>::value)),
556 return findExprMutation(SubscriptExprs);
559const Stmt *ExprMutationAnalyzer::Analyzer::findCastMutation(
const Expr *Exp) {
562 const auto ExplicitCast =
565 nonConstReferenceType()))))
573 const auto Casts =
match(
576 nonConstReferenceType())),
578 nonConstReferenceType())))))
579 .bind(NodeID<Expr>::value)),
582 if (
const Stmt *S = findExprMutation(Casts))
587 hasAnyName(
"::std::move",
"::std::forward"))),
588 hasArgument(0, canResolveToExpr(Exp)))
591 return findExprMutation(Calls);
595ExprMutationAnalyzer::Analyzer::findRangeLoopMutation(
const Expr *Exp) {
602 const auto DeclStmtToNonRefToArray =
declStmt(hasSingleDecl(
varDecl(hasType(
604 const auto RefToArrayRefToElements =
match(
608 hasType(nonConstPointerType())))
609 .bind(NodeID<Decl>::value)),
610 hasRangeStmt(DeclStmtToNonRefToArray),
611 hasRangeInit(canResolveToExpr(Exp))))
615 if (
const auto *BadRangeInitFromArray =
617 return BadRangeInitFromArray;
626 const auto HasAnyNonConstIterator =
632 const auto DeclStmtToNonConstIteratorContainer =
declStmt(
636 const auto RefToContainerBadIterators =
match(
638 hasRangeStmt(DeclStmtToNonConstIteratorContainer),
639 hasRangeInit(canResolveToExpr(Exp)))))
643 if (
const auto *BadIteratorsContainer =
645 return BadIteratorsContainer;
649 const auto LoopVars =
651 hasLoopVariable(
varDecl(hasType(nonConstReferenceType()))
652 .bind(NodeID<Decl>::value)),
653 hasRangeInit(canResolveToExpr(Exp)))),
655 return findDeclMutation(LoopVars);
659ExprMutationAnalyzer::Analyzer::findReferenceMutation(
const Expr *Exp) {
663 const auto Ref =
match(
667 returns(nonConstReferenceType()))),
668 argumentCountIs(1), hasArgument(0, canResolveToExpr(Exp)))
669 .bind(NodeID<Expr>::value)),
671 if (
const Stmt *S = findExprMutation(Ref))
675 const auto Refs =
match(
677 varDecl(hasType(nonConstReferenceType()),
678 hasInitializer(
anyOf(
679 canResolveToExpr(Exp),
680 memberExpr(hasObjectExpression(canResolveToExpr(Exp))))),
685 hasRangeStmt(equalsBoundNode(
"stmt"))))))))
686 .bind(NodeID<Decl>::value))),
688 return findDeclMutation(Refs);
692ExprMutationAnalyzer::Analyzer::findFunctionArgMutation(
const Expr *Exp) {
693 const auto NonConstRefParam = forEachArgumentWithParam(
694 canResolveToExpr(Exp),
695 parmVarDecl(hasType(nonConstReferenceType())).bind(
"parm"));
698 const auto Matches =
match(
704 "::std::move",
"::std::forward"))))),
707 .bind(NodeID<Expr>::value))),
709 for (
const auto &Nodes : Matches) {
710 const auto *Exp = Nodes.getNodeAs<Expr>(NodeID<Expr>::value);
711 const auto *
Func = Nodes.getNodeAs<FunctionDecl>(
"func");
712 if (!
Func->getBody() || !
Func->getPrimaryTemplate())
715 const auto *Parm = Nodes.getNodeAs<ParmVarDecl>(
"parm");
716 const ArrayRef<ParmVarDecl *> AllParams =
717 Func->getPrimaryTemplate()->getTemplatedDecl()->parameters();
719 AllParams[std::min<size_t>(Parm->getFunctionScopeIndex(),
720 AllParams.size() - 1)]
722 if (
const auto *
T = ParmType->
getAs<PackExpansionType>())
723 ParmType =
T->getPattern();
727 if (
const auto *RefType = ParmType->getAs<RValueReferenceType>()) {
728 if (!RefType->getPointeeType().getQualifiers() &&
730 RefType->getPointeeType().getCanonicalType())) {
733 *
Func, Context, Memorized);
746ExprMutationAnalyzer::Analyzer::findPointeeValueMutation(
const Expr *Exp) {
747 const auto Matches =
match(
752 hasUnaryOperand(canResolveToExprPointee(Exp))),
755 hasBaseConservative(canResolveToExprPointee(Exp)))))
756 .bind(NodeID<Expr>::value))),
758 return findExprMutation(Matches);
762ExprMutationAnalyzer::Analyzer::findPointeeMemberMutation(
const Expr *Exp) {
770 return MemberCallExpr;
771 const auto Matches =
match(
774 hasObjectExpression(canResolveToExprPointee(Exp))),
776 hasLHS(canResolveToExprPointee(Exp)))))
777 .bind(NodeID<Expr>::value))),
779 return findExprMutation(Matches);
783ExprMutationAnalyzer::Analyzer::findPointeeToNonConst(
const Expr *Exp) {
784 const auto NonConstPointerOrNonConstRefOrDependentType =
type(
anyOf(
785 nonConstPointerType(), nonConstReferenceType(),
786 constReferenceToPointerWithNonConstPointeeType(), isDependentType()));
789 const auto InitToNonConst =
790 varDecl(hasType(NonConstPointerOrNonConstRefOrDependentType),
791 hasInitializer(
expr(canResolveToExprPointee(Exp)).bind(
"stmt")));
793 hasOperatorName(
"="),
794 hasLHS(
expr(hasType(NonConstPointerOrNonConstRefOrDependentType))),
795 hasRHS(canResolveToExprPointee(Exp)));
797 const auto ArgOfInstantiationDependent =
allOf(
798 hasAnyArgument(canResolveToExprPointee(Exp)), isInstantiationDependent());
799 const auto ArgOfNonConstParameter =
800 forEachArgumentWithParamType(canResolveToExprPointee(Exp),
801 NonConstPointerOrNonConstRefOrDependentType);
802 const auto CallLikeMatcher =
803 anyOf(ArgOfNonConstParameter, ArgOfInstantiationDependent);
804 const auto PassAsNonConstArg =
expr(
807 ignoringParenImpCasts(canResolveToExprPointee(Exp)))),
810 expr(canResolveToExprPointee(Exp),
811 hasType(NonConstPointerOrNonConstRefOrDependentType)))),
813 expr(canResolveToExprPointee(Exp),
814 hasType(NonConstPointerOrNonConstRefOrDependentType))))));
817 hasSourceExpression(canResolveToExprPointee(Exp)),
818 hasDestinationType(NonConstPointerOrNonConstRefOrDependentType));
822 const auto CaptureNoConst =
lambdaExpr(hasCaptureInit(Exp));
825 hasReturnValue(canResolveToExprPointee(Exp)),
826 forFunction(returns(NonConstPointerOrNonConstRefOrDependentType)));
828 const auto Matches =
match(
830 stmt(
anyOf(AssignToNonConst, PassAsNonConstArg,
831 CastToNonConst, CaptureNoConst, ReturnNoConst))
838FunctionParmMutationAnalyzer::FunctionParmMutationAnalyzer(
839 const FunctionDecl &
Func, ASTContext &Context,
840 ExprMutationAnalyzer::Memoized &Memorized)
841 : BodyAnalyzer(*
Func.getBody(), Context, Memorized) {
842 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(&
Func)) {
845 for (
const CXXCtorInitializer *
Init : Ctor->inits()) {
846 ExprMutationAnalyzer::Analyzer InitAnalyzer(*
Init->getInit(), Context,
848 for (
const ParmVarDecl *Parm : Ctor->parameters()) {
849 if (Results.contains(Parm))
851 if (
const Stmt *S = InitAnalyzer.findMutation(Parm))
860 auto [Place, Inserted] = Results.try_emplace(Parm);
862 return Place->second;
868 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 T * getAs() const
Member-template getAs<specific type>'.
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
Top level wrappers for InstallAPI frontend operations.
bool isa(CodeGen::Address addr)
@ TK_AsIs
Will traverse all child nodes.
@ Result
The result type of a method or function.
const FunctionProtoType * T
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