clang 8.0.0

Namespaces | Classes | Typedefs | Functions | Variables
clang::ast_matchers Namespace Reference

## Namespaces
| dynamic
| internal

## Classes
class | BoundNodes
| Maps string IDs to AST nodes matched by parts of a matcher. More...
class | MatchFinder
| A class to allow finding matches over the Clang AST. More...

## Typedefs
template<typename NodeType >
using | AstTypeMatcher = internal::VariadicDynCastAllOfMatcher< Type, NodeType >
using | DeclarationMatcher = internal::Matcher< Decl >
| Types of matchers for the top-level classes in the AST class hierarchy. More...
using | StatementMatcher = internal::Matcher< Stmt >
using | TypeMatcher = internal::Matcher< QualType >
using | TypeLocMatcher = internal::Matcher< TypeLoc >
using | NestedNameSpecifierMatcher = internal::Matcher< NestedNameSpecifier >
using | NestedNameSpecifierLocMatcher = internal::Matcher< NestedNameSpecifierLoc >
using | CXXCtorInitializerMatcher = internal::Matcher< CXXCtorInitializer >

## Functions
template<typename T >
internal::Matcher< T > | id (StringRef ID, const internal::BindableMatcher< T > &InnerMatcher)
| If the provided matcher matches a node, binds the node to `ID`. More...
internal::TrueMatcher | anything ()
| Matches any node. More...
| AST_POLYMORPHIC_MATCHER (isExpansionInMainFile, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc))
| Matches AST nodes that were expanded within the main-file. More...
| AST_POLYMORPHIC_MATCHER (isExpansionInSystemHeader, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc))
| Matches AST nodes that were expanded within system-header-files. More...
| AST_POLYMORPHIC_MATCHER_P (isExpansionInFileMatching, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc), std::string, RegExp)
| Matches AST nodes that were expanded within files whose name is partially matching a given regex. More...
| AST_MATCHER (Decl, isPublic)
| Matches public C++ declarations. More...
| AST_MATCHER (Decl, isProtected)
| Matches protected C++ declarations. More...
| AST_MATCHER (Decl, isPrivate)
| Matches private C++ declarations. More...
| AST_MATCHER (FieldDecl, isBitField)
| Matches non-static data members that are bit-fields. More...
| AST_MATCHER_P (FieldDecl, hasBitWidth, unsigned, Width)
| Matches non-static data members that are bit-fields of the specified bit width. More...
| AST_MATCHER_P (FieldDecl, hasInClassInitializer, internal::Matcher< Expr >, InnerMatcher)
| Matches non-static data members that have an in-class initializer. More...
| AST_MATCHER (FunctionDecl, isMain)
| Determines whether the function is "main", which is the entry point into an executable program. More...
| AST_MATCHER_P (ClassTemplateSpecializationDecl, hasSpecializedTemplate, internal::Matcher< ClassTemplateDecl >, InnerMatcher)
| Matches the specialized template of a specialization declaration. More...
| AST_MATCHER (Decl, isImplicit)
| Matches a declaration that has been implicitly added by the compiler (eg. More...
| AST_POLYMORPHIC_MATCHER_P (hasAnyTemplateArgument, AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl, TemplateSpecializationType, FunctionDecl), internal::Matcher< TemplateArgument >, InnerMatcher)
| Matches classTemplateSpecializations, templateSpecializationType and functionDecl that have at least one TemplateArgument matching the given InnerMatcher. More...
| AST_MATCHER_P (Expr, ignoringImplicit, internal::Matcher< Expr >, InnerMatcher)
| Matches expressions that match InnerMatcher after any implicit AST nodes are stripped off. More...
| AST_MATCHER_P (Expr, ignoringImpCasts, internal::Matcher< Expr >, InnerMatcher)
| Matches expressions that match InnerMatcher after any implicit casts are stripped off. More...
| AST_MATCHER_P (Expr, ignoringParenCasts, internal::Matcher< Expr >, InnerMatcher)
| Matches expressions that match InnerMatcher after parentheses and casts are stripped off. More...
| AST_MATCHER_P (Expr, ignoringParenImpCasts, internal::Matcher< Expr >, InnerMatcher)
| Matches expressions that match InnerMatcher after implicit casts and parentheses are stripped off. More...
| AST_MATCHER_P_OVERLOAD (QualType, ignoringParens, internal::Matcher< QualType >, InnerMatcher, 0)
| Matches types that match InnerMatcher after any parens are stripped. More...
| AST_MATCHER_P_OVERLOAD (Expr, ignoringParens, internal::Matcher< Expr >, InnerMatcher, 1)
| Overload `ignoringParens` for `Expr`. More...
| AST_MATCHER (Expr, isInstantiationDependent)
| Matches expressions that are instantiation-dependent even if it is neither type- nor value-dependent. More...
| AST_MATCHER (Expr, isTypeDependent)
| Matches expressions that are type-dependent because the template type is not yet instantiated. More...
| AST_MATCHER (Expr, isValueDependent)
| Matches expression that are value-dependent because they contain a non-type template parameter. More...
| AST_POLYMORPHIC_MATCHER_P2 (hasTemplateArgument, AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl, TemplateSpecializationType, FunctionDecl), unsigned, N, internal::Matcher< TemplateArgument >, InnerMatcher)
| Matches classTemplateSpecializations, templateSpecializationType and functionDecl where the n'th TemplateArgument matches the given InnerMatcher. More...
| AST_POLYMORPHIC_MATCHER_P (templateArgumentCountIs, AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl, TemplateSpecializationType), unsigned, N)
| Matches if the number of template arguments equals `N`. More...
| AST_MATCHER_P (TemplateArgument, refersToType, internal::Matcher< QualType >, InnerMatcher)
| Matches a TemplateArgument that refers to a certain type. More...
| AST_MATCHER_P (TemplateArgument, refersToTemplate, internal::Matcher< TemplateName >, InnerMatcher)
| Matches a TemplateArgument that refers to a certain template. More...
| AST_MATCHER_P (TemplateArgument, refersToDeclaration, internal::Matcher< Decl >, InnerMatcher)
| Matches a canonical TemplateArgument that refers to a certain declaration. More...
| AST_MATCHER_P (TemplateArgument, isExpr, internal::Matcher< Expr >, InnerMatcher)
| Matches a sugar TemplateArgument that refers to a certain expression. More...
| AST_MATCHER (TemplateArgument, isIntegral)
| Matches a TemplateArgument that is an integral value. More...
| AST_MATCHER_P (TemplateArgument, refersToIntegralType, internal::Matcher< QualType >, InnerMatcher)
| Matches a TemplateArgument that referes to an integral type. More...
| AST_MATCHER_P (TemplateArgument, equalsIntegralValue, std::string, Value)
| Matches a TemplateArgument of integral type with a given value. More...
| AST_MATCHER (CallExpr, usesADL)
| Matches call expressions which were resolved using ADL. More...
| AST_MATCHER_P (InitListExpr, hasSyntacticForm, internal::Matcher< Expr >, InnerMatcher)
| Matches the syntactic form of init list expressions (if expression have it). More...
| AST_MATCHER_P (ForStmt, hasIncrement, internal::Matcher< Stmt >, InnerMatcher)
| Matches the increment statement of a for loop. More...
| AST_MATCHER_P (ForStmt, hasLoopInit, internal::Matcher< Stmt >, InnerMatcher)
| Matches the initialization statement of a for loop. More...
| AST_MATCHER_P (CXXForRangeStmt, hasLoopVariable, internal::Matcher< VarDecl >, InnerMatcher)
| Matches the initialization statement of a for loop. More...
| AST_MATCHER_P (CXXForRangeStmt, hasRangeInit, internal::Matcher< Expr >, InnerMatcher)
| Matches the range initialization statement of a for loop. More...
| AST_MATCHER_P (DesignatedInitExpr, designatorCountIs, unsigned, N)
| Matches designated initializer expressions that contain a specific number of designators. More...
| AST_MATCHER_P (UnaryExprOrTypeTraitExpr, hasArgumentOfType, internal::Matcher< QualType >, InnerMatcher)
| Matches unary expressions that have a specific type of argument. More...
| AST_MATCHER_P (UnaryExprOrTypeTraitExpr, ofKind, UnaryExprOrTypeTrait, Kind)
| Matches unary expressions of a certain kind. More...
internal::Matcher< Stmt > | alignOfExpr (const internal::Matcher< UnaryExprOrTypeTraitExpr > &InnerMatcher)
| Same as unaryExprOrTypeTraitExpr, but only matching alignof. More...
internal::Matcher< Stmt > | sizeOfExpr (const internal::Matcher< UnaryExprOrTypeTraitExpr > &InnerMatcher)
| Same as unaryExprOrTypeTraitExpr, but only matching sizeof. More...
internal::Matcher< NamedDecl > | hasName (const std::string &Name)
| Matches NamedDecl nodes that have the specified name. More...
| AST_MATCHER_P (NamedDecl, matchesName, std::string, RegExp)
| Matches NamedDecl nodes whose fully qualified names contain a substring matched by the given RegExp. More...
internal::PolymorphicMatcherWithParam1< internal::HasOverloadedOperatorNameMatcher, StringRef, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)> | hasOverloadedOperatorName (StringRef Name)
| Matches overloaded operator names. More...
| AST_MATCHER_P (CXXRecordDecl, isDerivedFrom, internal::Matcher< NamedDecl >, Base)
| Matches C++ classes that are directly or indirectly derived from a class matching `Base`. More...
| AST_MATCHER_P_OVERLOAD (CXXRecordDecl, isDerivedFrom, std::string, BaseName, 1)
| Overloaded method as shortcut for `isDerivedFrom`(hasName(...)). More...
| AST_MATCHER_P_OVERLOAD (CXXRecordDecl, isSameOrDerivedFrom, internal::Matcher< NamedDecl >, Base, 0)
| Similar to `isDerivedFrom()`, but also matches classes that directly match `Base`. More...
| AST_MATCHER_P_OVERLOAD (CXXRecordDecl, isSameOrDerivedFrom, std::string, BaseName, 1)
| Overloaded method as shortcut for `isSameOrDerivedFrom`(hasName(...)). More...
| AST_MATCHER_P (CXXRecordDecl, hasMethod, internal::Matcher< CXXMethodDecl >, InnerMatcher)
| Matches the first method of a class or struct that satisfies `InnerMatcher`. More...
| AST_MATCHER (CXXRecordDecl, isLambda)
| Matches the generated class of lambda expressions. More...
template<typename T >
internal::Matcher< T > | findAll (const internal::Matcher< T > &Matcher)
| Matches if the node or any descendant matches. More...
internal::PolymorphicMatcherWithParam1< internal::HasDeclarationMatcher, internal::Matcher< Decl >, void(internal::HasDeclarationSupportedTypes)> | hasDeclaration (const internal::Matcher< Decl > &InnerMatcher)
| Matches a node if the declaration associated with that node matches the given matcher. More...
| AST_MATCHER_P (NamedDecl, hasUnderlyingDecl, internal::Matcher< NamedDecl >, InnerMatcher)
| Matches a `NamedDecl` whose underlying declaration matches the given matcher. More...
| AST_MATCHER_P (CXXMemberCallExpr, on, internal::Matcher< Expr >, InnerMatcher)
| Matches on the implicit object argument of a member call expression. More...
| AST_MATCHER_P (ObjCMessageExpr, hasReceiverType, internal::Matcher< QualType >, InnerMatcher)
| Matches on the receiver of an ObjectiveC Message expression. More...
| AST_MATCHER (ObjCMessageExpr, isInstanceMessage)
| Returns true when the Objective-C message is sent to an instance. More...
| AST_MATCHER_P (ObjCMessageExpr, hasReceiver, internal::Matcher< Expr >, InnerMatcher)
| Matches if the Objective-C message is sent to an instance, and the inner matcher matches on that instance. More...
| AST_MATCHER_P (ObjCMessageExpr, hasSelector, std::string, BaseName)
| Matches when BaseName == Selector.getAsString() More...
| AST_MATCHER_P (ObjCMessageExpr, matchesSelector, std::string, RegExp)
| Matches ObjC selectors whose name contains a substring matched by the given RegExp. More...
| AST_MATCHER (ObjCMessageExpr, hasNullSelector)
| Matches when the selector is the empty selector. More...
| AST_MATCHER (ObjCMessageExpr, hasUnarySelector)
| Matches when the selector is a Unary Selector. More...
| AST_MATCHER (ObjCMessageExpr, hasKeywordSelector)
| Matches when the selector is a keyword selector. More...
| AST_MATCHER_P (ObjCMessageExpr, numSelectorArgs, unsigned, N)
| Matches when the selector has the specified number of arguments. More...
| AST_MATCHER_P (CallExpr, callee, internal::Matcher< Stmt >, InnerMatcher)
| Matches if the call expression's callee expression matches. More...
| AST_MATCHER_P_OVERLOAD (CallExpr, callee, internal::Matcher< Decl >, InnerMatcher, 1)
| Matches if the call expression's callee's declaration matches the given matcher. More...
| AST_POLYMORPHIC_MATCHER_P_OVERLOAD (hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, TypedefNameDecl, ValueDecl), internal::Matcher< QualType >, InnerMatcher, 0)
| Matches if the expression's or declaration's type matches a type matcher. More...
| AST_POLYMORPHIC_MATCHER_P_OVERLOAD (hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl), internal::Matcher< Decl >, InnerMatcher, 1)
| Overloaded to match the declaration of the expression's or value declaration's type. More...
| AST_MATCHER_P (DeclaratorDecl, hasTypeLoc, internal::Matcher< TypeLoc >, Inner)
| Matches if the type location of the declarator decl's type matches the inner matcher. More...
| AST_MATCHER_P (QualType, asString, std::string, Name)
| Matches if the matched type is represented by the given string. More...
| AST_MATCHER_P (QualType, pointsTo, internal::Matcher< QualType >, InnerMatcher)
| Matches if the matched type is a pointer type and the pointee type matches the specified matcher. More...
| AST_MATCHER_P_OVERLOAD (QualType, pointsTo, internal::Matcher< Decl >, InnerMatcher, 1)
| Overloaded to match the pointee type's declaration. More...
| AST_MATCHER_P (Type, hasUnqualifiedDesugaredType, internal::Matcher< Type >, InnerMatcher)
| Matches if the matched type matches the unqualified desugared type of the matched node. More...
| AST_MATCHER_P (QualType, references, internal::Matcher< QualType >, InnerMatcher)
| Matches if the matched type is a reference type and the referenced type matches the specified matcher. More...
| AST_MATCHER_P (QualType, hasCanonicalType, internal::Matcher< QualType >, InnerMatcher)
| Matches QualTypes whose canonical type matches InnerMatcher. More...
| AST_MATCHER_P_OVERLOAD (QualType, references, internal::Matcher< Decl >, InnerMatcher, 1)
| Overloaded to match the referenced type's declaration. More...
| AST_MATCHER_P (CXXMemberCallExpr, onImplicitObjectArgument, internal::Matcher< Expr >, InnerMatcher)
| AST_MATCHER_P_OVERLOAD (CXXMemberCallExpr, thisPointerType, internal::Matcher< QualType >, InnerMatcher, 0)
| Matches if the expression's type either matches the specified matcher, or is a pointer to a type that matches the InnerMatcher. More...
| AST_MATCHER_P_OVERLOAD (CXXMemberCallExpr, thisPointerType, internal::Matcher< Decl >, InnerMatcher, 1)
| Overloaded to match the type's declaration. More...
| AST_MATCHER_P (DeclRefExpr, to, internal::Matcher< Decl >, InnerMatcher)
| Matches a DeclRefExpr that refers to a declaration that matches the specified matcher. More...
| AST_MATCHER_P (DeclRefExpr, throughUsingDecl, internal::Matcher< UsingShadowDecl >, InnerMatcher)
| Matches a `DeclRefExpr` that refers to a declaration through a specific using shadow declaration. More...
| AST_MATCHER_P (OverloadExpr, hasAnyDeclaration, internal::Matcher< Decl >, InnerMatcher)
| Matches an `OverloadExpr` if any of the declarations in the set of overloads matches the given matcher. More...
| AST_MATCHER_P (DeclStmt, hasSingleDecl, internal::Matcher< Decl >, InnerMatcher)
| Matches the Decl of a DeclStmt which has a single declaration. More...
| AST_MATCHER_P (VarDecl, hasInitializer, internal::Matcher< Expr >, InnerMatcher)
| Matches a variable declaration that has an initializer expression that matches the given matcher. More...
| AST_MATCHER (VarDecl, isStaticLocal)
| Matches a static variable with local scope. More...
| AST_MATCHER (VarDecl, hasLocalStorage)
| Matches a variable declaration that has function scope and is a non-static local variable. More...
| AST_MATCHER (VarDecl, hasGlobalStorage)
| Matches a variable declaration that does not have local storage. More...
| AST_MATCHER (VarDecl, hasAutomaticStorageDuration)
| Matches a variable declaration that has automatic storage duration. More...
| AST_MATCHER (VarDecl, hasStaticStorageDuration)
| Matches a variable declaration that has static storage duration. More...
| AST_MATCHER (VarDecl, hasThreadStorageDuration)
| Matches a variable declaration that has thread storage duration. More...
| AST_MATCHER (VarDecl, isExceptionVariable)
| Matches a variable declaration that is an exception variable from a C++ catch block, or an Objective-C @catch statement. More...
| AST_POLYMORPHIC_MATCHER_P (argumentCountIs, AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr, CXXConstructExpr, ObjCMessageExpr), unsigned, N)
| Checks that a call expression or a constructor call expression has a specific number of arguments (including absent default arguments). More...
| AST_POLYMORPHIC_MATCHER_P2 (hasArgument, AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr, CXXConstructExpr, ObjCMessageExpr), unsigned, N, internal::Matcher< Expr >, InnerMatcher)
| Matches the n'th argument of a call expression or a constructor call expression. More...
| AST_MATCHER_P2 (InitListExpr, hasInit, unsigned, N, ast_matchers::internal::Matcher< Expr >, InnerMatcher)
| Matches the n'th item of an initializer list expression. More...
| AST_MATCHER_P (DeclStmt, declCountIs, unsigned, N)
| Matches declaration statements that contain a specific number of declarations. More...
| AST_MATCHER_P2 (DeclStmt, containsDeclaration, unsigned, N, internal::Matcher< Decl >, InnerMatcher)
| Matches the n'th declaration of a declaration statement. More...
| AST_MATCHER (CXXCatchStmt, isCatchAll)
| Matches a C++ catch statement that has a catch-all handler. More...
| AST_MATCHER_P (CXXConstructorDecl, hasAnyConstructorInitializer, internal::Matcher< CXXCtorInitializer >, InnerMatcher)
| Matches a constructor initializer. More...
| AST_MATCHER_P (CXXCtorInitializer, forField, internal::Matcher< FieldDecl >, InnerMatcher)
| Matches the field declaration of a constructor initializer. More...
| AST_MATCHER_P (CXXCtorInitializer, withInitializer, internal::Matcher< Expr >, InnerMatcher)
| Matches the initializer expression of a constructor initializer. More...
| AST_MATCHER (CXXCtorInitializer, isWritten)
| Matches a constructor initializer if it is explicitly written in code (as opposed to implicitly added by the compiler). More...
| AST_MATCHER (CXXCtorInitializer, isBaseInitializer)
| Matches a constructor initializer if it is initializing a base, as opposed to a member. More...
| AST_MATCHER (CXXCtorInitializer, isMemberInitializer)
| Matches a constructor initializer if it is initializing a member, as opposed to a base. More...
| AST_POLYMORPHIC_MATCHER_P (hasAnyArgument, AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr), internal::Matcher< Expr >, InnerMatcher)
| Matches any argument of a call expression or a constructor call expression, or an ObjC-message-send expression. More...
| AST_MATCHER (CXXConstructExpr, isListInitialization)
| Matches a constructor call expression which uses list initialization. More...
| AST_MATCHER (CXXConstructExpr, requiresZeroInitialization)
| Matches a constructor call expression which requires zero initialization. More...
| AST_POLYMORPHIC_MATCHER_P2 (hasParameter, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, ObjCMethodDecl, BlockDecl), unsigned, N, internal::Matcher< ParmVarDecl >, InnerMatcher)
| Matches the n'th parameter of a function or an ObjC method declaration or a block. More...
| AST_POLYMORPHIC_MATCHER_P2 (forEachArgumentWithParam, AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr, CXXConstructExpr), internal::Matcher< Expr >, ArgMatcher, internal::Matcher< ParmVarDecl >, ParamMatcher)
| Matches all arguments and their respective ParmVarDecl. More...
| AST_POLYMORPHIC_MATCHER_P (hasAnyParameter, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, ObjCMethodDecl, BlockDecl), internal::Matcher< ParmVarDecl >, InnerMatcher)
| Matches any parameter of a function or an ObjC method declaration or a block. More...
| AST_POLYMORPHIC_MATCHER_P (parameterCountIs, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, FunctionProtoType), unsigned, N)
| Matches `FunctionDecls` and `FunctionProtoTypes` that have a specific parameter count. More...
| AST_MATCHER (FunctionDecl, isNoReturn)
| Matches `FunctionDecls` that have a noreturn attribute. More...
| AST_MATCHER_P (FunctionDecl, returns, internal::Matcher< QualType >, InnerMatcher)
| Matches the return type of a function declaration. More...
| AST_POLYMORPHIC_MATCHER (isExternC, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, VarDecl))
| Matches extern "C" function or variable declarations. More...
| AST_POLYMORPHIC_MATCHER (isStaticStorageClass, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, VarDecl))
| Matches variable/function declarations that have "static" storage class specifier ("static" keyword) written in the source. More...
| AST_MATCHER (FunctionDecl, isDeleted)
| Matches deleted function declarations. More...
| AST_MATCHER (FunctionDecl, isDefaulted)
| Matches defaulted function declarations. More...
| AST_POLYMORPHIC_MATCHER (hasDynamicExceptionSpec, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, FunctionProtoType))
| Matches functions that have a dynamic exception specification. More...
| AST_POLYMORPHIC_MATCHER (isNoThrow, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, FunctionProtoType))
| Matches functions that have a non-throwing exception specification. More...
| AST_POLYMORPHIC_MATCHER (isConstexpr, AST_POLYMORPHIC_SUPPORTED_TYPES(VarDecl, FunctionDecl, IfStmt))
| Matches constexpr variable and function declarations, and if constexpr. More...
| AST_POLYMORPHIC_MATCHER_P (hasCondition, AST_POLYMORPHIC_SUPPORTED_TYPES(IfStmt, ForStmt, WhileStmt, DoStmt, SwitchStmt, AbstractConditionalOperator), internal::Matcher< Expr >, InnerMatcher)
| Matches the condition expression of an if statement, for loop, switch statement or conditional operator. More...
| AST_MATCHER_P (IfStmt, hasThen, internal::Matcher< Stmt >, InnerMatcher)
| Matches the then-statement of an if statement. More...
| AST_MATCHER_P (IfStmt, hasElse, internal::Matcher< Stmt >, InnerMatcher)
| Matches the else-statement of an if statement. More...
| AST_POLYMORPHIC_MATCHER_P (equalsBoundNode, AST_POLYMORPHIC_SUPPORTED_TYPES(Stmt, Decl, Type, QualType), std::string, ID)
| Matches if a node equals a previously bound node. More...
| AST_MATCHER_P (IfStmt, hasConditionVariableStatement, internal::Matcher< DeclStmt >, InnerMatcher)
| Matches the condition variable statement in an if statement. More...
| AST_MATCHER_P (ArraySubscriptExpr, hasIndex, internal::Matcher< Expr >, InnerMatcher)
| Matches the index expression of an array subscript expression. More...
| AST_MATCHER_P (ArraySubscriptExpr, hasBase, internal::Matcher< Expr >, InnerMatcher)
| Matches the base expression of an array subscript expression. More...
| AST_POLYMORPHIC_MATCHER_P (hasBody, AST_POLYMORPHIC_SUPPORTED_TYPES(DoStmt, ForStmt, WhileStmt, CXXForRangeStmt, FunctionDecl), internal::Matcher< Stmt >, InnerMatcher)
| Matches a 'for', 'while', 'do while' statement or a function definition that has a given body. More...
| AST_POLYMORPHIC_MATCHER_P (hasAnySubstatement, AST_POLYMORPHIC_SUPPORTED_TYPES(CompoundStmt, StmtExpr), internal::Matcher< Stmt >, InnerMatcher)
| Matches compound statements where at least one substatement matches a given matcher. More...
| AST_MATCHER_P (CompoundStmt, statementCountIs, unsigned, N)
| Checks that a compound statement contains a specific number of child statements. More...
template<typename ValueT >
internal::PolymorphicMatcherWithParam1< internal::ValueEqualsMatcher, ValueT > | equals (const ValueT &Value)
| Matches literals that are equal to the given value of type ValueT. More...
| AST_POLYMORPHIC_MATCHER_P_OVERLOAD (equals, AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral, CXXBoolLiteralExpr, IntegerLiteral), bool, Value, 0)
| AST_POLYMORPHIC_MATCHER_P_OVERLOAD (equals, AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral, CXXBoolLiteralExpr, IntegerLiteral), unsigned, Value, 1)
| AST_POLYMORPHIC_MATCHER_P_OVERLOAD (equals, AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral, CXXBoolLiteralExpr, FloatingLiteral, IntegerLiteral), double, Value, 2)
| AST_POLYMORPHIC_MATCHER_P (hasOperatorName, AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, UnaryOperator), std::string, Name)
| Matches the operator Name of operator expressions (binary or unary). More...
| AST_POLYMORPHIC_MATCHER (isAssignmentOperator, AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr))
| Matches all kinds of assignment operators. More...
| AST_POLYMORPHIC_MATCHER_P (hasLHS, AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, ArraySubscriptExpr), internal::Matcher< Expr >, InnerMatcher)
| Matches the left hand side of binary operator expressions. More...
| AST_POLYMORPHIC_MATCHER_P (hasRHS, AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, ArraySubscriptExpr), internal::Matcher< Expr >, InnerMatcher)
| Matches the right hand side of binary operator expressions. More...
internal::Matcher< BinaryOperator > | hasEitherOperand (const internal::Matcher< Expr > &InnerMatcher)
| Matches if either the left hand side or the right hand side of a binary operator matches. More...
| AST_MATCHER_P (UnaryOperator, hasUnaryOperand, internal::Matcher< Expr >, InnerMatcher)
| Matches if the operand of a unary operator matches. More...
| AST_POLYMORPHIC_MATCHER_P (hasSourceExpression, AST_POLYMORPHIC_SUPPORTED_TYPES(CastExpr, OpaqueValueExpr), internal::Matcher< Expr >, InnerMatcher)
| Matches if the cast's source expression or opaque value's source expression matches the given matcher. More...
| AST_MATCHER_P (CastExpr, hasCastKind, CastKind, Kind)
| Matches casts that has a given cast kind. More...
| AST_MATCHER_P (ExplicitCastExpr, hasDestinationType, internal::Matcher< QualType >, InnerMatcher)
| Matches casts whose destination type matches a given matcher. More...
| AST_MATCHER_P (ImplicitCastExpr, hasImplicitDestinationType, internal::Matcher< QualType >, InnerMatcher)
| Matches implicit casts whose destination type matches a given matcher. More...
| AST_MATCHER (RecordDecl, isStruct)
| Matches RecordDecl object that are spelled with "struct.". More...
| AST_MATCHER (RecordDecl, isUnion)
| Matches RecordDecl object that are spelled with "union.". More...
| AST_MATCHER (RecordDecl, isClass)
| Matches RecordDecl object that are spelled with "class.". More...
| AST_MATCHER_P (AbstractConditionalOperator, hasTrueExpression, internal::Matcher< Expr >, InnerMatcher)
| Matches the true branch expression of a conditional operator. More...
| AST_MATCHER_P (AbstractConditionalOperator, hasFalseExpression, internal::Matcher< Expr >, InnerMatcher)
| Matches the false branch expression of a conditional operator (binary or ternary). More...
| AST_POLYMORPHIC_MATCHER (isDefinition, AST_POLYMORPHIC_SUPPORTED_TYPES(TagDecl, VarDecl, ObjCMethodDecl, FunctionDecl))
| Matches if a declaration has a body attached. More...
| AST_MATCHER (FunctionDecl, isVariadic)
| Matches if a function declaration is variadic. More...
| AST_MATCHER_P (CXXMethodDecl, ofClass, internal::Matcher< CXXRecordDecl >, InnerMatcher)
| Matches the class declaration that the given method declaration belongs to. More...
| AST_MATCHER_P (CXXMethodDecl, forEachOverridden, internal::Matcher< CXXMethodDecl >, InnerMatcher)
| Matches each method overridden by the given method. More...
| AST_MATCHER (CXXMethodDecl, isVirtual)
| Matches if the given method declaration is virtual. More...
| AST_MATCHER (CXXMethodDecl, isVirtualAsWritten)
| Matches if the given method declaration has an explicit "virtual". More...
| AST_POLYMORPHIC_MATCHER (isFinal, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, CXXMethodDecl))
| Matches if the given method or class declaration is final. More...
| AST_MATCHER (CXXMethodDecl, isPure)
| Matches if the given method declaration is pure. More...
| AST_MATCHER (CXXMethodDecl, isConst)
| Matches if the given method declaration is const. More...
| AST_MATCHER (CXXMethodDecl, isCopyAssignmentOperator)
| Matches if the given method declaration declares a copy assignment operator. More...
| AST_MATCHER (CXXMethodDecl, isMoveAssignmentOperator)
| Matches if the given method declaration declares a move assignment operator. More...
| AST_MATCHER (CXXMethodDecl, isOverride)
| Matches if the given method declaration overrides another method. More...
| AST_MATCHER (CXXMethodDecl, isUserProvided)
| Matches method declarations that are user-provided. More...
| AST_POLYMORPHIC_MATCHER (isArrow, AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, UnresolvedMemberExpr, CXXDependentScopeMemberExpr))
| Matches member expressions that are called with '->' as opposed to '. More...
| AST_MATCHER (QualType, isInteger)
| Matches QualType nodes that are of integer type. More...
| AST_MATCHER (QualType, isUnsignedInteger)
| Matches QualType nodes that are of unsigned integer type. More...
| AST_MATCHER (QualType, isSignedInteger)
| Matches QualType nodes that are of signed integer type. More...
| AST_MATCHER (QualType, isAnyCharacter)
| Matches QualType nodes that are of character type. More...
| AST_MATCHER (QualType, isAnyPointer)
| Matches QualType nodes that are of any pointer type; this includes the Objective-C object pointer type, which is different despite being syntactically similar. More...
| AST_MATCHER (QualType, isConstQualified)
| Matches QualType nodes that are const-qualified, i.e., that include "top-level" const. More...
| AST_MATCHER (QualType, isVolatileQualified)
| Matches QualType nodes that are volatile-qualified, i.e., that include "top-level" volatile. More...
| AST_MATCHER (QualType, hasLocalQualifiers)
| Matches QualType nodes that have local CV-qualifiers attached to the node, not hidden within a typedef. More...
| AST_MATCHER_P (MemberExpr, member, internal::Matcher< ValueDecl >, InnerMatcher)
| Matches a member expression where the member is matched by a given matcher. More...
| AST_POLYMORPHIC_MATCHER_P (hasObjectExpression, AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, UnresolvedMemberExpr, CXXDependentScopeMemberExpr), internal::Matcher< Expr >, InnerMatcher)
| Matches a member expression where the object expression is matched by a given matcher. More...
| AST_MATCHER_P (UsingDecl, hasAnyUsingShadowDecl, internal::Matcher< UsingShadowDecl >, InnerMatcher)
| Matches any using shadow declaration. More...
| AST_MATCHER_P (UsingShadowDecl, hasTargetDecl, internal::Matcher< NamedDecl >, InnerMatcher)
| Matches a using shadow declaration where the target declaration is matched by the given matcher. More...
| AST_POLYMORPHIC_MATCHER (isTemplateInstantiation, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, VarDecl, CXXRecordDecl))
| Matches template instantiations of function, class, or static member variable template instantiations. More...
| AST_MATCHER_FUNCTION (internal::Matcher< Decl >, isInstantiated)
| Matches declarations that are template instantiations or are inside template instantiations. More...
| AST_MATCHER_FUNCTION (internal::Matcher< Stmt >, isInTemplateInstantiation)
| Matches statements inside of a template instantiation. More...
| AST_POLYMORPHIC_MATCHER (isExplicitTemplateSpecialization, AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, VarDecl, CXXRecordDecl))
| Matches explicit template specializations of function, class, or static member variable template instantiations. More...
| AST_MATCHER_FUNCTION_P_OVERLOAD (internal::BindableMatcher< TypeLoc >, loc, internal::Matcher< QualType >, InnerMatcher, 0)
| Matches `TypeLocs` for which the given inner QualType-matcher matches. More...
| AST_MATCHER (Type, booleanType)
| Matches type `bool`. More...
| AST_MATCHER (Type, voidType)
| Matches type `void`. More...
| AST_MATCHER (Type, realFloatingPointType)
| Matches any real floating-point type (float, double, long double). More...
| AST_TYPELOC_TRAVERSE_MATCHER_DECL (hasElementType, getElement, AST_POLYMORPHIC_SUPPORTED_TYPES(ArrayType, ComplexType))
| Matches arrays and C99 complex types that have a specific element type. More...
| AST_POLYMORPHIC_MATCHER_P (hasSize, AST_POLYMORPHIC_SUPPORTED_TYPES(ConstantArrayType, StringLiteral), unsigned, N)
| Matches nodes that have the specified size. More...
| AST_MATCHER_P (VariableArrayType, hasSizeExpr, internal::Matcher< Expr >, InnerMatcher)
| Matches `VariableArrayType` nodes that have a specific size expression. More...
| AST_TYPELOC_TRAVERSE_MATCHER_DECL (hasValueType, getValue, AST_POLYMORPHIC_SUPPORTED_TYPES(AtomicType))
| Matches atomic types with a specific value type. More...
| AST_TYPE_TRAVERSE_MATCHER (hasDeducedType, getDeducedType, AST_POLYMORPHIC_SUPPORTED_TYPES(AutoType))
| Matches `AutoType` nodes where the deduced type is a specific type. More...
| AST_TYPE_TRAVERSE_MATCHER (hasUnderlyingType, getUnderlyingType, AST_POLYMORPHIC_SUPPORTED_TYPES(DecltypeType))
| Matches `DecltypeType` nodes to find out the underlying type. More...
| AST_TYPE_TRAVERSE_MATCHER (innerType, getInnerType, AST_POLYMORPHIC_SUPPORTED_TYPES(ParenType))
| Matches `ParenType` nodes where the inner type is a specific type. More...
| AST_TYPELOC_TRAVERSE_MATCHER_DECL (pointee, getPointee, AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType, MemberPointerType, PointerType, ReferenceType))
| Narrows PointerType (and similar) matchers to those where the `pointee` matches a given matcher. More...
| AST_MATCHER_P (ElaboratedType, hasQualifier, internal::Matcher< NestedNameSpecifier >, InnerMatcher)
| Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, matches `InnerMatcher` if the qualifier exists. More...
| AST_MATCHER_P (ElaboratedType, namesType, internal::Matcher< QualType >, InnerMatcher)
| Matches ElaboratedTypes whose named type matches `InnerMatcher`. More...
| AST_TYPE_TRAVERSE_MATCHER (hasReplacementType, getReplacementType, AST_POLYMORPHIC_SUPPORTED_TYPES(SubstTemplateTypeParmType))
| Matches template type parameter substitutions that have a replacement type that matches the provided matcher. More...
| AST_MATCHER_P (DecayedType, hasDecayedType, internal::Matcher< QualType >, InnerType)
| Matches the decayed type, whos decayed type matches `InnerMatcher`. More...
| AST_MATCHER_P (Decl, hasDeclContext, internal::Matcher< Decl >, InnerMatcher)
| Matches declarations whose declaration context, interpreted as a Decl, matches `InnerMatcher`. More...
| AST_MATCHER_FUNCTION_P_OVERLOAD (internal::BindableMatcher< NestedNameSpecifierLoc >, loc, internal::Matcher< NestedNameSpecifier >, InnerMatcher, 1)
| Matches `NestedNameSpecifierLocs` for which the given inner NestedNameSpecifier-matcher matches. More...
| AST_MATCHER_P (NestedNameSpecifier, specifiesType, internal::Matcher< QualType >, InnerMatcher)
| Matches nested name specifiers that specify a type matching the given `QualType` matcher without qualifiers. More...
| AST_MATCHER_P (NestedNameSpecifierLoc, specifiesTypeLoc, internal::Matcher< TypeLoc >, InnerMatcher)
| Matches nested name specifier locs that specify a type matching the given `TypeLoc`. More...
| AST_MATCHER_P_OVERLOAD (NestedNameSpecifier, hasPrefix, internal::Matcher< NestedNameSpecifier >, InnerMatcher, 0)
| Matches on the prefix of a `NestedNameSpecifier`. More...
| AST_MATCHER_P_OVERLOAD (NestedNameSpecifierLoc, hasPrefix, internal::Matcher< NestedNameSpecifierLoc >, InnerMatcher, 1)
| Matches on the prefix of a `NestedNameSpecifierLoc`. More...
| AST_MATCHER_P (NestedNameSpecifier, specifiesNamespace, internal::Matcher< NamespaceDecl >, InnerMatcher)
| Matches nested name specifiers that specify a namespace matching the given namespace matcher. More...
| AST_MATCHER_P (SwitchStmt, forEachSwitchCase, internal::Matcher< SwitchCase >, InnerMatcher)
| Matches each case or default statement belonging to the given switch statement. More...
| AST_MATCHER_P (CXXConstructorDecl, forEachConstructorInitializer, internal::Matcher< CXXCtorInitializer >, InnerMatcher)
| Matches each constructor initializer in a constructor definition. More...
| AST_MATCHER (CXXConstructorDecl, isCopyConstructor)
| Matches constructor declarations that are copy constructors. More...
| AST_MATCHER (CXXConstructorDecl, isMoveConstructor)
| Matches constructor declarations that are move constructors. More...
| AST_MATCHER (CXXConstructorDecl, isDefaultConstructor)
| Matches constructor declarations that are default constructors. More...
| AST_MATCHER (CXXConstructorDecl, isDelegatingConstructor)
| Matches constructors that delegate to another constructor. More...
| AST_POLYMORPHIC_MATCHER (isExplicit, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXConstructorDecl, CXXConversionDecl))
| Matches constructor and conversion declarations that are marked with the explicit keyword. More...
| AST_POLYMORPHIC_MATCHER (isInline, AST_POLYMORPHIC_SUPPORTED_TYPES(NamespaceDecl, FunctionDecl))
| Matches function and namespace declarations that are marked with the inline keyword. More...
| AST_MATCHER (NamespaceDecl, isAnonymous)
| Matches anonymous namespace declarations. More...
| AST_MATCHER_P (CaseStmt, hasCaseConstant, internal::Matcher< Expr >, InnerMatcher)
| If the given case statement does not use the GNU case range extension, matches the constant given in the statement. More...
| AST_MATCHER_P (Decl, hasAttr, attr::Kind, AttrKind)
| Matches declaration that has a given attribute. More...
| AST_MATCHER_P (ReturnStmt, hasReturnValue, internal::Matcher< Expr >, InnerMatcher)
| Matches the return value expression of a return statement. More...
| AST_MATCHER_FUNCTION (internal::Matcher< Expr >, nullPointerConstant)
| Matches expressions that resolve to a null pointer constant, such as GNU's __null, C++11's nullptr, or C's NULL macro. More...
| AST_MATCHER_P (Stmt, forFunction, internal::Matcher< FunctionDecl >, InnerMatcher)
| Matches declaration of the function the statement belongs to. More...
| AST_MATCHER (NamedDecl, hasExternalFormalLinkage)
| Matches a declaration that has external formal linkage. More...
| AST_MATCHER (ParmVarDecl, hasDefaultArgument)
| Matches a declaration that has default arguments. More...
| AST_MATCHER (CXXNewExpr, isArray)
| Matches array new expressions. More...
| AST_MATCHER_P (CXXNewExpr, hasArraySize, internal::Matcher< Expr >, InnerMatcher)
| Matches array new expressions with a given array size. More...
| AST_MATCHER (CXXRecordDecl, hasDefinition)
| Matches a class declaration that is defined. More...
| AST_MATCHER (EnumDecl, isScoped)
| Matches C++11 scoped enum declaration. More...
| AST_MATCHER (FunctionDecl, hasTrailingReturn)
| Matches a function declared with a trailing return type. More...
template<typename MatcherT >
SmallVector< BoundNodes, 1 > | match (MatcherT Matcher, ASTContext &Context)
| Returns the results of matching `Matcher` on the translation unit of `Context` and collects the `BoundNodes` of all callback invocations. More...
template<typename NodeT >
const NodeT * | selectFirst (StringRef BoundTo, const SmallVectorImpl< BoundNodes > &Results)
| Returns the first result of type `NodeT` bound to `BoundTo`. More...
| AST_MATCHER_P (ObjCMessageExpr, hasAnySelectorMatcher, std::vector< std::string >, Matches)
| AST_TYPELOC_TRAVERSE_MATCHER_DEF (hasElementType, AST_POLYMORPHIC_SUPPORTED_TYPES(ArrayType, ComplexType))
| AST_TYPELOC_TRAVERSE_MATCHER_DEF (hasValueType, AST_POLYMORPHIC_SUPPORTED_TYPES(AtomicType))
| AST_TYPELOC_TRAVERSE_MATCHER_DEF (pointee, AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType, MemberPointerType, PointerType, ReferenceType))
| AST_MATCHER_P_OVERLOAD (Decl, equalsNode, const Decl *, Other, 0)
| Overloads for the `equalsNode` matcher. More...
| AST_MATCHER_P_OVERLOAD (Stmt, equalsNode, const Stmt *, Other, 1)
| Matches if a node equals another node. More...
| AST_MATCHER_P_OVERLOAD (Type, equalsNode, const Type *, Other, 2)
| Matches if a node equals another node. More...
template<typename MatcherT , typename NodeT >
SmallVector< BoundNodes, 1 > | match (MatcherT Matcher, const NodeT &Node, ASTContext &Context)
| Returns the results of matching `Matcher` on `Node`. More...
template<typename MatcherT >
SmallVector< BoundNodes, 1 > | match (MatcherT Matcher, const ast_type_traits::DynTypedNode &Node, ASTContext &Context)

## Variables
const internal::VariadicDynCastAllOfMatcher< Decl, TranslationUnitDecl > | translationUnitDecl
| Matches the top declaration context. More...
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefDecl > | typedefDecl
| Matches typedef declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefNameDecl > | typedefNameDecl
| Matches typedef name declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, TypeAliasDecl > | typeAliasDecl
| Matches type alias declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, TypeAliasTemplateDecl > | typeAliasTemplateDecl
| Matches type alias template declarations. More...
const internal::VariadicAllOfMatcher< Decl > | decl
| Matches declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, LinkageSpecDecl > | linkageSpecDecl
| Matches a declaration of a linkage specification. More...
const internal::VariadicDynCastAllOfMatcher< Decl, NamedDecl > | namedDecl
| Matches a declaration of anything that could have a name. More...
const internal::VariadicDynCastAllOfMatcher< Decl, LabelDecl > | labelDecl
| Matches a declaration of label. More...
const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceDecl > | namespaceDecl
| Matches a declaration of a namespace. More...
const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceAliasDecl > | namespaceAliasDecl
| Matches a declaration of a namespace alias. More...
const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > | recordDecl
| Matches class, struct, and union declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, CXXRecordDecl > | cxxRecordDecl
| Matches C++ class declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateDecl > | classTemplateDecl
| Matches C++ class template declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateSpecializationDecl > | classTemplateSpecializationDecl
| Matches C++ class template specializations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplatePartialSpecializationDecl > | classTemplatePartialSpecializationDecl
| Matches C++ class template partial specializations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, DeclaratorDecl > | declaratorDecl
| Matches declarator declarations (field, variable, function and non-type template parameter declarations). More...
const internal::VariadicDynCastAllOfMatcher< Decl, ParmVarDecl > | parmVarDecl
| Matches parameter variable declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, AccessSpecDecl > | accessSpecDecl
| Matches C++ access specifier declarations. More...
const internal::VariadicAllOfMatcher< CXXCtorInitializer > | cxxCtorInitializer
| Matches constructor initializers. More...
const internal::VariadicAllOfMatcher< TemplateArgument > | templateArgument
| Matches template arguments. More...
const internal::VariadicAllOfMatcher< TemplateName > | templateName
| Matches template name. More...
const internal::VariadicDynCastAllOfMatcher< Decl, NonTypeTemplateParmDecl > | nonTypeTemplateParmDecl
| Matches non-type template parameter declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, TemplateTypeParmDecl > | templateTypeParmDecl
| Matches template type parameter declarations. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAutoreleasePoolStmt > | autoreleasePoolStmt
| Matches an Objective-C autorelease pool statement. More...
const internal::VariadicDynCastAllOfMatcher< Decl, ValueDecl > | valueDecl
| Matches any value declaration. More...
const internal::VariadicDynCastAllOfMatcher< Decl, CXXConstructorDecl > | cxxConstructorDecl
| Matches C++ constructor declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, CXXDestructorDecl > | cxxDestructorDecl
| Matches explicit C++ destructor declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, EnumDecl > | enumDecl
| Matches enum declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, EnumConstantDecl > | enumConstantDecl
| Matches enum constants. More...
const internal::VariadicDynCastAllOfMatcher< Decl, CXXMethodDecl > | cxxMethodDecl
| Matches method declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, CXXConversionDecl > | cxxConversionDecl
| Matches conversion operator declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, VarDecl > | varDecl
| Matches variable declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, FieldDecl > | fieldDecl
| Matches field declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, IndirectFieldDecl > | indirectFieldDecl
| Matches indirect field declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionDecl > | functionDecl
| Matches function declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionTemplateDecl > | functionTemplateDecl
| Matches C++ function template declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, FriendDecl > | friendDecl
| Matches friend declarations. More...
const internal::VariadicAllOfMatcher< Stmt > | stmt
| Matches statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclStmt > | declStmt
| Matches declaration statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, MemberExpr > | memberExpr
| Matches member expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, UnresolvedMemberExpr > | unresolvedMemberExpr
| Matches unresolved member expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDependentScopeMemberExpr > | cxxDependentScopeMemberExpr
| Matches member expressions where the actual member referenced could not be resolved because the base expression or the member name was dependent. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > | callExpr
| Matches call expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, LambdaExpr > | lambdaExpr
| Matches lambda expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXMemberCallExpr > | cxxMemberCallExpr
| Matches member call expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCMessageExpr > | objcMessageExpr
| Matches ObjectiveC Message invocation expressions. More...
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCInterfaceDecl > | objcInterfaceDecl
| Matches Objective-C interface declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCImplementationDecl > | objcImplementationDecl
| Matches Objective-C implementation declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCProtocolDecl > | objcProtocolDecl
| Matches Objective-C protocol declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCCategoryDecl > | objcCategoryDecl
| Matches Objective-C category declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCCategoryImplDecl > | objcCategoryImplDecl
| Matches Objective-C category definitions. More...
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCMethodDecl > | objcMethodDecl
| Matches Objective-C method declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, BlockDecl > | blockDecl
| Matches block declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCIvarDecl > | objcIvarDecl
| Matches Objective-C instance variable declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCPropertyDecl > | objcPropertyDecl
| Matches Objective-C property declarations. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtThrowStmt > | objcThrowStmt
| Matches Objective-C @throw statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtTryStmt > | objcTryStmt
| Matches Objective-C statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtCatchStmt > | objcCatchStmt
| Matches Objective-C statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtFinallyStmt > | objcFinallyStmt
| Matches Objective-C statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ExprWithCleanups > | exprWithCleanups
| Matches expressions that introduce cleanups to be run at the end of the sub-expression's evaluation. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, InitListExpr > | initListExpr
| Matches init list expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStdInitializerListExpr > | cxxStdInitializerListExpr
| Matches C++ initializer list expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitValueInitExpr > | implicitValueInitExpr
| Matches implicit initializers of init list expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ParenListExpr > | parenListExpr
| Matches paren list expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, SubstNonTypeTemplateParmExpr > | substNonTypeTemplateParmExpr
| Matches substitutions of non-type template parameters. More...
const internal::VariadicDynCastAllOfMatcher< Decl, UsingDecl > | usingDecl
| Matches using declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, UsingDirectiveDecl > | usingDirectiveDecl
| Matches using namespace declarations. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, UnresolvedLookupExpr > | unresolvedLookupExpr
| Matches reference to a name that can be looked up during parsing but could not be resolved to a specific declaration. More...
const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingValueDecl > | unresolvedUsingValueDecl
| Matches unresolved using value declarations. More...
const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingTypenameDecl > | unresolvedUsingTypenameDecl
| Matches unresolved using value declarations that involve the typename. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ConstantExpr > | constantExpr
| Matches a constant expression wrapper. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ParenExpr > | parenExpr
| Matches parentheses used in expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstructExpr > | cxxConstructExpr
| Matches constructor call expressions (including implicit ones). More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXUnresolvedConstructExpr > | cxxUnresolvedConstructExpr
| Matches unresolved constructor call expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThisExpr > | cxxThisExpr
| Matches implicit and explicit this expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBindTemporaryExpr > | cxxBindTemporaryExpr
| Matches nodes where temporaries are created. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, MaterializeTemporaryExpr > | materializeTemporaryExpr
| Matches nodes where temporaries are materialized. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNewExpr > | cxxNewExpr
| Matches new expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDeleteExpr > | cxxDeleteExpr
| Matches delete expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ArraySubscriptExpr > | arraySubscriptExpr
| Matches array subscript expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDefaultArgExpr > | cxxDefaultArgExpr
| Matches the value of a default argument at the call site. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXOperatorCallExpr > | cxxOperatorCallExpr
| Matches overloaded operator calls. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > | expr
| Matches expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclRefExpr > | declRefExpr
| Matches expressions that refer to declarations. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCIvarRefExpr > | objcIvarRefExpr
| Matches a reference to an ObjCIvar. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, BlockExpr > | blockExpr
| Matches a reference to a block. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, IfStmt > | ifStmt
| Matches if statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ForStmt > | forStmt
| Matches for statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXForRangeStmt > | cxxForRangeStmt
| Matches range-based for statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, WhileStmt > | whileStmt
| Matches while statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, DoStmt > | doStmt
| Matches do statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, BreakStmt > | breakStmt
| Matches break statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ContinueStmt > | continueStmt
| Matches continue statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ReturnStmt > | returnStmt
| Matches return statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, GotoStmt > | gotoStmt
| Matches goto statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, LabelStmt > | labelStmt
| Matches label statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, AddrLabelExpr > | addrLabelExpr
| Matches address of label statements (GNU extension). More...
const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchStmt > | switchStmt
| Matches switch statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchCase > | switchCase
| Matches case and default statements inside switch statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CaseStmt > | caseStmt
| Matches case statements inside switch statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, DefaultStmt > | defaultStmt
| Matches default statements inside switch statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundStmt > | compoundStmt
| Matches compound statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXCatchStmt > | cxxCatchStmt
| Matches catch statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTryStmt > | cxxTryStmt
| Matches try statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThrowExpr > | cxxThrowExpr
| Matches throw expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, NullStmt > | nullStmt
| Matches null statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, AsmStmt > | asmStmt
| Matches asm statements. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBoolLiteralExpr > | cxxBoolLiteral
| Matches bool literals. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, StringLiteral > | stringLiteral
| Matches string literals (also matches wide string literals). More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CharacterLiteral > | characterLiteral
| Matches character literals (also matches wchar_t). More...
const internal::VariadicDynCastAllOfMatcher< Stmt, IntegerLiteral > | integerLiteral
| Matches integer literals of all sizes / encodings, e.g. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, FloatingLiteral > | floatLiteral
| Matches float literals of all sizes / encodings, e.g. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ImaginaryLiteral > | imaginaryLiteral
| Matches imaginary literals, which are based on integer and floating point literals e.g. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, UserDefinedLiteral > | userDefinedLiteral
| Matches user defined literal operator call. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundLiteralExpr > | compoundLiteralExpr
| Matches compound (i.e. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNullPtrLiteralExpr > | cxxNullPtrLiteralExpr
| Matches nullptr literal. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, GNUNullExpr > | gnuNullExpr
| Matches GNU __null expression. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, AtomicExpr > | atomicExpr
| Matches atomic builtins. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, StmtExpr > | stmtExpr
| Matches statement expression (GNU extension). More...
const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryOperator > | binaryOperator
| Matches binary operator expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryOperator > | unaryOperator
| Matches unary operator expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ConditionalOperator > | conditionalOperator
| Matches conditional operator expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryConditionalOperator > | binaryConditionalOperator
| Matches binary conditional operator expressions (GNU extension). More...
const internal::VariadicDynCastAllOfMatcher< Stmt, OpaqueValueExpr > | opaqueValueExpr
| Matches opaque value expressions. More...
const internal::VariadicDynCastAllOfMatcher< Decl, StaticAssertDecl > | staticAssertDecl
| Matches a C++ static_assert declaration. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXReinterpretCastExpr > | cxxReinterpretCastExpr
| Matches a reinterpret_cast expression. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStaticCastExpr > | cxxStaticCastExpr
| Matches a C++ static_cast expression. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDynamicCastExpr > | cxxDynamicCastExpr
| Matches a dynamic_cast expression. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstCastExpr > | cxxConstCastExpr
| Matches a const_cast expression. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CStyleCastExpr > | cStyleCastExpr
| Matches a C-style cast expression. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ExplicitCastExpr > | explicitCastExpr
| Matches explicit cast expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitCastExpr > | implicitCastExpr
| Matches the implicit cast nodes of Clang's AST. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > | castExpr
| Matches any cast nodes of Clang's AST. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXFunctionalCastExpr > | cxxFunctionalCastExpr
| Matches functional cast expressions. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTemporaryObjectExpr > | cxxTemporaryObjectExpr
| Matches functional cast expressions having N != 1 arguments. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, PredefinedExpr > | predefinedExpr
| Matches predefined identifier expressions [C99 6.4.2.2]. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, DesignatedInitExpr > | designatedInitExpr
| Matches C99 designated initializer expressions [C99 6.7.8]. More...
const internal::VariadicAllOfMatcher< QualType > | qualType
| Matches `QualTypes` in the clang AST. More...
const internal::VariadicAllOfMatcher< Type > | type
| Matches `Types` in the clang AST. More...
const internal::VariadicAllOfMatcher< TypeLoc > | typeLoc
| Matches `TypeLocs` in the clang AST. More...
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> | eachOf = {internal::DynTypedMatcher::VO_EachOf}
| Matches if any of the given matchers matches. More...
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> | anyOf = {internal::DynTypedMatcher::VO_AnyOf}
| Matches if any of the given matchers matches. More...
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> | allOf = {internal::DynTypedMatcher::VO_AllOf}
| Matches if all given matchers match. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryExprOrTypeTraitExpr > | unaryExprOrTypeTraitExpr
| Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) More...
const internal::VariadicFunction< internal::Matcher< NamedDecl >, StringRef, internal::hasAnyNameFunc > | hasAnyName = {}
| Matches NamedDecl nodes that have any of the specified names. More...
const internal::ArgumentAdaptingMatcherFunc< internal::HasMatcher > | has = {}
| Matches AST nodes that have child AST nodes that match the provided matcher. More...
const internal::ArgumentAdaptingMatcherFunc< internal::HasDescendantMatcher > | hasDescendant = {}
| Matches AST nodes that have descendant AST nodes that match the provided matcher. More...
const internal::ArgumentAdaptingMatcherFunc< internal::ForEachMatcher > | forEach
| Matches AST nodes that have child AST nodes that match the provided matcher. More...
const internal::ArgumentAdaptingMatcherFunc< internal::ForEachDescendantMatcher > | forEachDescendant = {}
| Matches AST nodes that have descendant AST nodes that match the provided matcher. More...
const internal::ArgumentAdaptingMatcherFunc< internal::HasParentMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc > > | hasParent = {}
| Matches AST nodes that have a parent that matches the provided matcher. More...
const internal::ArgumentAdaptingMatcherFunc< internal::HasAncestorMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc > > | hasAncestor = {}
| Matches AST nodes that have an ancestor that matches the provided matcher. More...
const internal::VariadicOperatorMatcherFunc< 1, 1 > | unless
| Matches if the provided matcher does not match. More...
const internal::VariadicFunction< internal::Matcher< ObjCMessageExpr >, StringRef, internal::hasAnySelectorFunc > | hasAnySelector = {}
| Matches when at least one of the supplied string equals to the Selector.getAsString() More...
const AstTypeMatcher< BuiltinType > | builtinType
| Matches builtin Types. More...
const AstTypeMatcher< ArrayType > | arrayType
| Matches all kinds of arrays. More...
const AstTypeMatcher< ComplexType > | complexType
| Matches C99 complex types. More...
const AstTypeMatcher< ConstantArrayType > | constantArrayType
| Matches C arrays with a specified constant size. More...
const AstTypeMatcher< DependentSizedArrayType > | dependentSizedArrayType
| Matches C++ arrays whose size is a value-dependent expression. More...
const AstTypeMatcher< IncompleteArrayType > | incompleteArrayType
| Matches C arrays with unspecified size. More...
const AstTypeMatcher< VariableArrayType > | variableArrayType
| Matches C arrays with a specified size that is not an integer-constant-expression. More...
const AstTypeMatcher< AtomicType > | atomicType
| Matches atomic types. More...
const AstTypeMatcher< AutoType > | autoType
| Matches types nodes representing C++11 auto types. More...
const AstTypeMatcher< DecltypeType > | decltypeType
| Matches types nodes representing C++11 decltype(<expr>) types. More...
const AstTypeMatcher< FunctionType > | functionType
| Matches `FunctionType` nodes. More...
const AstTypeMatcher< FunctionProtoType > | functionProtoType
| Matches `FunctionProtoType` nodes. More...
const AstTypeMatcher< ParenType > | parenType
| Matches `ParenType` nodes. More...
const AstTypeMatcher< BlockPointerType > | blockPointerType
| Matches block pointer types, i.e. More...
const AstTypeMatcher< MemberPointerType > | memberPointerType
| Matches member pointer types. More...
const AstTypeMatcher< PointerType > | pointerType
| Matches pointer types, but does not match Objective-C object pointer types. More...
const AstTypeMatcher< ObjCObjectPointerType > | objcObjectPointerType
| Matches an Objective-C object pointer type, which is different from a pointer type, despite being syntactically similar. More...
const AstTypeMatcher< ReferenceType > | referenceType
| Matches both lvalue and rvalue reference types. More...
const AstTypeMatcher< LValueReferenceType > | lValueReferenceType
| Matches lvalue reference types. More...
const AstTypeMatcher< RValueReferenceType > | rValueReferenceType
| Matches rvalue reference types. More...
const AstTypeMatcher< TypedefType > | typedefType
| Matches typedef types. More...
const AstTypeMatcher< EnumType > | enumType
| Matches enum types. More...
const AstTypeMatcher< TemplateSpecializationType > | templateSpecializationType
| Matches template specialization types. More...
const AstTypeMatcher< UnaryTransformType > | unaryTransformType
| Matches types nodes representing unary type transformations. More...
const AstTypeMatcher< RecordType > | recordType
| Matches record types (e.g. More...
const AstTypeMatcher< TagType > | tagType
| Matches tag types (record and enum types). More...
const AstTypeMatcher< ElaboratedType > | elaboratedType
| Matches types specified with an elaborated type keyword or with a qualified name. More...
const AstTypeMatcher< SubstTemplateTypeParmType > | substTemplateTypeParmType
| Matches types that represent the result of substituting a type for a template type parameter. More...
const AstTypeMatcher< TemplateTypeParmType > | templateTypeParmType
| Matches template type parameter types. More...
const AstTypeMatcher< InjectedClassNameType > | injectedClassNameType
| Matches injected class name types. More...
const AstTypeMatcher< DecayedType > | decayedType
| Matches decayed type Example matches i[] in declaration of f. More...
const internal::VariadicAllOfMatcher< NestedNameSpecifier > | nestedNameSpecifier
| Matches nested name specifiers. More...
const internal::VariadicAllOfMatcher< NestedNameSpecifierLoc > | nestedNameSpecifierLoc
| Same as `nestedNameSpecifier` but matches `NestedNameSpecifierLoc`. More...
const internal::VariadicDynCastAllOfMatcher< Stmt, CUDAKernelCallExpr > | cudaKernelCallExpr
| Matches CUDA kernel call expression. More...

## Typedef Documentation

## ◆ AstTypeMatcher

template<typename NodeType >

using clang::ast_matchers::AstTypeMatcher = typedef internal::VariadicDynCastAllOfMatcher<Type, NodeType>

Definition at line 5150 of file ASTMatchers.h.

## ◆ CXXCtorInitializerMatcher

using clang::ast_matchers::CXXCtorInitializerMatcher = typedef internal::Matcher<CXXCtorInitializer>

Definition at line 151 of file ASTMatchers.h.

## ◆ DeclarationMatcher

using clang::ast_matchers::DeclarationMatcher = typedef internal::Matcher<Decl>

Types of matchers for the top-level classes in the AST class hierarchy.

Definition at line 145 of file ASTMatchers.h.

## ◆ NestedNameSpecifierLocMatcher

using clang::ast_matchers::NestedNameSpecifierLocMatcher = typedef internal::Matcher<NestedNameSpecifierLoc>

Definition at line 150 of file ASTMatchers.h.

## ◆ NestedNameSpecifierMatcher

using clang::ast_matchers::NestedNameSpecifierMatcher = typedef internal::Matcher<NestedNameSpecifier>

Definition at line 149 of file ASTMatchers.h.

## ◆ StatementMatcher

using clang::ast_matchers::StatementMatcher = typedef internal::Matcher<Stmt>

Definition at line 146 of file ASTMatchers.h.

## ◆ TypeLocMatcher

using clang::ast_matchers::TypeLocMatcher = typedef internal::Matcher<TypeLoc>

Definition at line 148 of file ASTMatchers.h.

## ◆ TypeMatcher

using clang::ast_matchers::TypeMatcher = typedef internal::Matcher<QualType>

Definition at line 147 of file ASTMatchers.h.

## Function Documentation

## ◆ alignOfExpr()

internal::Matcher<Stmt> clang::ast_matchers::alignOfExpr | ( | const internal::Matcher< UnaryExprOrTypeTraitExpr > & | InnerMatcher | ) |
| inline

Same as unaryExprOrTypeTraitExpr, but only matching alignof.

Definition at line 2496 of file ASTMatchers.h.

## ◆ anything()

internal::TrueMatcher clang::ast_matchers::anything | ( |  | ) |
| inline

Matches any node.

Useful when another matcher requires a child matcher, but there's no additional constraint. This will often be used with an explicit conversion to an `internal::Matcher<>` type such as `TypeMatcher`.

Example: `DeclarationMatcher(anything())` matches all declarations, e.g.,

"int* p" and "void f()" in
int* p;
void f();

Usable as: Any Matcher

Definition at line 168 of file ASTMatchers.h.

References translationUnitDecl, typeAliasDecl, typeAliasTemplateDecl, typedefDecl, and typedefNameDecl.

## ◆ AST_MATCHER() [1/66]

clang::ast_matchers::AST_MATCHER | ( | Decl | ,
|  | isPublic |
| ) |  |

Matches public C++ declarations.

Given

class C {
public: int a;
protected: int b;
private: int c;
};

fieldDecl(isPublic()) matches 'int a;'

Definition at line 548 of file ASTMatchers.h.

References clang::AS_public, and Node.

## ◆ AST_MATCHER() [2/66]

clang::ast_matchers::AST_MATCHER | ( | Decl | ,
|  | isProtected |
| ) |  |

Matches protected C++ declarations.

Given

class C {
public: int a;
protected: int b;
private: int c;
};

fieldDecl(isProtected()) matches 'int b;'

Definition at line 564 of file ASTMatchers.h.

References clang::AS_protected, and Node.

## ◆ AST_MATCHER() [3/66]

clang::ast_matchers::AST_MATCHER | ( | Decl | ,
|  | isPrivate |
| ) |  |

Matches private C++ declarations.

Given

class C {
public: int a;
protected: int b;
private: int c;
};

fieldDecl(isPrivate()) matches 'int c;'

Definition at line 580 of file ASTMatchers.h.

References clang::AS_private, and Node.

## ◆ AST_MATCHER() [4/66]

clang::ast_matchers::AST_MATCHER | ( | FieldDecl | ,
|  | isBitField |
| ) |  |

Matches non-static data members that are bit-fields.

Given

class C {
int a : 2;
int b;
};

fieldDecl(isBitField()) matches 'int a;' but not 'int b;'.

Definition at line 595 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [5/66]

clang::ast_matchers::AST_MATCHER | ( | FunctionDecl | ,
|  | isMain |
| ) |  |

Determines whether the function is "main", which is the entry point into an executable program.

Definition at line 640 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [6/66]

clang::ast_matchers::AST_MATCHER | ( | Decl | ,
|  | isImplicit |
| ) |  |

Matches a declaration that has been implicitly added by the compiler (eg.

implicit default/copy constructors).

Definition at line 663 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [7/66]

clang::ast_matchers::AST_MATCHER | ( | Expr | ,
|  | isInstantiationDependent |
| ) |  |

Matches expressions that are instantiation-dependent even if it is neither type- nor value-dependent.

In the following example, the expression sizeof(sizeof(T() + T())) is instantiation-dependent (since it involves a template parameter T), but is neither type- nor value-dependent, since the type of the inner sizeof is known (std::size_t) and therefore the size of the outer sizeof is known.

template<typename T>
void f(T x, T y) { sizeof(sizeof(T() + T()); }

expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T())

Definition at line 849 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [8/66]

clang::ast_matchers::AST_MATCHER | ( | Expr | ,
|  | isTypeDependent |
| ) |  |

Matches expressions that are type-dependent because the template type is not yet instantiated.

For example, the expressions "x" and "x + y" are type-dependent in the following code, but "y" is not type-dependent:

template<typename T>
void add(T x, int y) {
x + y;
}

expr(isTypeDependent()) matches x + y

Definition at line 865 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [9/66]

clang::ast_matchers::AST_MATCHER | ( | Expr | ,
|  | isValueDependent |
| ) |  |

Matches expression that are value-dependent because they contain a non-type template parameter.

For example, the array bound of "Chars" in the following example is value-dependent.

template<int Size> int f() { return Size; }

expr(isValueDependent()) matches return Size

Definition at line 876 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [10/66]

clang::ast_matchers::AST_MATCHER | ( | TemplateArgument | ,
|  | isIntegral |
| ) |  |

Matches a TemplateArgument that is an integral value.

Given

template<int T> struct C {};
C<42> c;

classTemplateSpecializationDecl( hasAnyTemplateArgument(isIntegral())) matches the implicit instantiation of C in C<42> with isIntegral() matching 42.

Definition at line 1011 of file ASTMatchers.h.

References clang::TemplateArgument::Integral, and Node.

## ◆ AST_MATCHER() [11/66]

clang::ast_matchers::AST_MATCHER | ( | CallExpr | ,
|  | usesADL |
| ) |  |

Matches call expressions which were resolved using ADL.

Example matches y(x) but not y(42) or NS::y(x).

namespace NS {
struct X {};
void y(X);
}
void y(...);
void test() {
NS::X x;
y(x); // Matches
NS::y(x); // Doesn't match
y(42); // Doesn't match
using NS::y;
y(x); // Found by both unqualified lookup and ADL, doesn't match
// }

Definition at line 1291 of file ASTMatchers.h.

References blockDecl, cxxMemberCallExpr, exprWithCleanups, initListExpr, lambdaExpr, Node, objcCatchStmt, objcCategoryDecl, objcCategoryImplDecl, objcFinallyStmt, objcImplementationDecl, objcInterfaceDecl, objcIvarDecl, objcMessageExpr, objcMethodDecl, objcPropertyDecl, objcProtocolDecl, objcThrowStmt, and objcTryStmt.

## ◆ AST_MATCHER() [12/66]

clang::ast_matchers::AST_MATCHER | ( | CXXRecordDecl | ,
|  | isLambda |
| ) |  |

Matches the generated class of lambda expressions.

Given:

auto x = []{};

`cxxRecordDecl(isLambda())` matches the implicit class declaration of `decltype(x)`

Definition at line 2669 of file ASTMatchers.h.

References forEach, forEachDescendant, has, hasDescendant, and Node.

## ◆ AST_MATCHER() [13/66]

clang::ast_matchers::AST_MATCHER | ( | ObjCMessageExpr | ,
|  | isInstanceMessage |
| ) |  |

Returns true when the Objective-C message is sent to an instance.

Example matcher = objcMessagaeExpr(isInstanceMessage()) matches

NSString *x = @"hello";
[x containsString:@"h"];

but not

[NSString stringWithFormat:@"format"];

Definition at line 2938 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [14/66]

clang::ast_matchers::AST_MATCHER | ( | ObjCMessageExpr | ,
|  | hasNullSelector |
| ) |  |

Matches when the selector is the empty selector.

Matches only when the selector of the objCMessageExpr is NULL. This may represent an error condition in the tree!

Definition at line 3007 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [15/66]

clang::ast_matchers::AST_MATCHER | ( | ObjCMessageExpr | ,
|  | hasUnarySelector |
| ) |  |

Matches when the selector is a Unary Selector.

matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); matches self.bodyView in the code below, but NOT the outer message invocation of "loadHTMLString:baseURL:".

[self.bodyView loadHTMLString:html baseURL:NULL];

Definition at line 3019 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [16/66]

clang::ast_matchers::AST_MATCHER | ( | ObjCMessageExpr | ,
|  | hasKeywordSelector |
| ) |  |

Matches when the selector is a keyword selector.

objCMessageExpr(hasKeywordSelector()) matches the generated setFrame message expression in

UIWebView *webView = ...;
CGRect bodyFrame = webView.frame;
bodyFrame.size.height = self.bodyContentHeight;
webView.frame = bodyFrame;
// ^---- matches here

Definition at line 3035 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [17/66]

clang::ast_matchers::AST_MATCHER | ( | VarDecl | ,
|  | isStaticLocal |
| ) |  |

Matches a static variable with local scope.

Example matches y (matcher = varDecl(isStaticLocal()))

void f() {
int x;
static int y;
}
static int z;

Definition at line 3383 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [18/66]

clang::ast_matchers::AST_MATCHER | ( | VarDecl | ,
|  | hasLocalStorage |
| ) |  |

Matches a variable declaration that has function scope and is a non-static local variable.

Example matches x (matcher = varDecl(hasLocalStorage())

void f() {
int x;
static int y;
}
int z;

Definition at line 3398 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [19/66]

clang::ast_matchers::AST_MATCHER | ( | VarDecl | ,
|  | hasGlobalStorage |
| ) |  |

Matches a variable declaration that does not have local storage.

Example matches y and z (matcher = varDecl(hasGlobalStorage())

void f() {
int x;
static int y;
}
int z;

Definition at line 3412 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [20/66]

clang::ast_matchers::AST_MATCHER | ( | VarDecl | ,
|  | hasAutomaticStorageDuration |
| ) |  |

Matches a variable declaration that has automatic storage duration.

Example matches x, but not y, z, or a. (matcher = varDecl(hasAutomaticStorageDuration())

void f() {
int x;
static int y;
thread_local int z;
}
int a;

Definition at line 3428 of file ASTMatchers.h.

References Node, and clang::SD_Automatic.

## ◆ AST_MATCHER() [21/66]

clang::ast_matchers::AST_MATCHER | ( | VarDecl | ,
|  | hasStaticStorageDuration |
| ) |  |

Matches a variable declaration that has static storage duration.

It includes the variable declared at namespace scope and those declared with "static" and "extern" storage class specifiers.

void f() {
int x;
static int y;
thread_local int z;
}
int a;
static int b;
extern int c;
varDecl(hasStaticStorageDuration())
matches the function declaration y, a, b and c.

Definition at line 3448 of file ASTMatchers.h.

References Node, and clang::SD_Static.

## ◆ AST_MATCHER() [22/66]

clang::ast_matchers::AST_MATCHER | ( | VarDecl | ,
|  | hasThreadStorageDuration |
| ) |  |

Matches a variable declaration that has thread storage duration.

Example matches z, but not x, z, or a. (matcher = varDecl(hasThreadStorageDuration())

void f() {
int x;
static int y;
thread_local int z;
}
int a;

Definition at line 3464 of file ASTMatchers.h.

References Node, and clang::SD_Thread.

## ◆ AST_MATCHER() [23/66]

clang::ast_matchers::AST_MATCHER | ( | VarDecl | ,
|  | isExceptionVariable |
| ) |  |

Matches a variable declaration that is an exception variable from a C++ catch block, or an Objective-C @catch statement.

Example matches x (matcher = varDecl(isExceptionVariable())

void f(int y) {
try {
} catch (int x) {
}
}

Definition at line 3479 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [24/66]

clang::ast_matchers::AST_MATCHER | ( | CXXCatchStmt | ,
|  | isCatchAll |
| ) |  |

Matches a C++ catch statement that has a catch-all handler.

Given

try {
// ...
} catch (int) {
// ...
} catch (...) {
// ...
}

cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).

Definition at line 3587 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [25/66]

clang::ast_matchers::AST_MATCHER | ( | CXXCtorInitializer | ,
|  | isWritten |
| ) |  |

Matches a constructor initializer if it is explicitly written in code (as opposed to implicitly added by the compiler).

Given

struct Foo {
Foo() { }
Foo(int) : foo_("A") { }
string foo_;
};

cxxConstructorDecl(hasAnyConstructorInitializer(isWritten())) will match Foo(int), but not Foo()

Definition at line 3663 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [26/66]

clang::ast_matchers::AST_MATCHER | ( | CXXCtorInitializer | ,
|  | isBaseInitializer |
| ) |  |

Matches a constructor initializer if it is initializing a base, as opposed to a member.

Given

struct B {};
struct D : B {
int I;
D(int i) : I(i) {}
};
struct E : B {
E() : B() {}
};

cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) will match E(), but not match D(int).

Definition at line 3683 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [27/66]

clang::ast_matchers::AST_MATCHER | ( | CXXCtorInitializer | ,
|  | isMemberInitializer |
| ) |  |

Matches a constructor initializer if it is initializing a member, as opposed to a base.

Given

struct B {};
struct D : B {
int I;
D(int i) : I(i) {}
};
struct E : B {
E() : B() {}
};

cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) will match D(int), but not match E().

Definition at line 3703 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [28/66]

clang::ast_matchers::AST_MATCHER | ( | CXXConstructExpr | ,
|  | isListInitialization |
| ) |  |

Matches a constructor call expression which uses list initialization.

Definition at line 3742 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [29/66]

clang::ast_matchers::AST_MATCHER | ( | CXXConstructExpr | ,
|  | requiresZeroInitialization |
| ) |  |

Matches a constructor call expression which requires zero initialization.

Given

void foo() {
struct point { double x; double y; };
point pt[2] = { { 1.0, 2.0 } };
}

initListExpr(has(cxxConstructExpr(requiresZeroInitialization())) will match the implicit array filler for pt[1].

Definition at line 3758 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [30/66]

clang::ast_matchers::AST_MATCHER | ( | FunctionDecl | ,
|  | isNoReturn |
| ) |  |

Matches `FunctionDecls` that have a noreturn attribute.

Given

void nope();
[[noreturn]] void a();
__attribute__((noreturn)) void b();
struct c { [[noreturn]] c(); };

functionDecl(isNoReturn()) matches all of those except

void nope();

Definition at line 3925 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [31/66]

clang::ast_matchers::AST_MATCHER | ( | FunctionDecl | ,
|  | isDeleted |
| ) |  |

Matches deleted function declarations.

Given:

void Func();
void DeletedFunc() = delete;

functionDecl(isDeleted()) matches the declaration of DeletedFunc, but not Func.

Definition at line 3989 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [32/66]

clang::ast_matchers::AST_MATCHER | ( | FunctionDecl | ,
|  | isDefaulted |
| ) |  |

Matches defaulted function declarations.

Given:

class A { ~A(); };
class B { ~B() = default; };

functionDecl(isDefaulted()) matches the declaration of ~B, but not ~A.

Definition at line 4002 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [33/66]

clang::ast_matchers::AST_MATCHER | ( | RecordDecl | ,
|  | isStruct |
| ) |  |

Matches RecordDecl object that are spelled with "struct.".

Example matches S, but not C or U.

struct S {};
class C {};
union U {};

Definition at line 4473 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [34/66]

clang::ast_matchers::AST_MATCHER | ( | RecordDecl | ,
|  | isUnion |
| ) |  |

Matches RecordDecl object that are spelled with "union.".

Example matches U, but not C or S.

struct S {};
class C {};
union U {};

Definition at line 4485 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [35/66]

clang::ast_matchers::AST_MATCHER | ( | RecordDecl | ,
|  | isClass |
| ) |  |

Matches RecordDecl object that are spelled with "class.".

Example matches C, but not S or U.

struct S {};
class C {};
union U {};

Definition at line 4497 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [36/66]

clang::ast_matchers::AST_MATCHER | ( | FunctionDecl | ,
|  | isVariadic |
| ) |  |

Matches if a function declaration is variadic.

Example matches f, but not g or h. The function i will not match, even when compiled in C mode.

void f(...);
void g(int);
template <typename... Ts> void h(Ts...);
void i();

Definition at line 4571 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [37/66]

clang::ast_matchers::AST_MATCHER | ( | CXXMethodDecl | ,
|  | isVirtual |
| ) |  |

Matches if the given method declaration is virtual.

Given

class A {
public:
virtual void x();
};

matches A::x

Definition at line 4650 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [38/66]

clang::ast_matchers::AST_MATCHER | ( | CXXMethodDecl | ,
|  | isVirtualAsWritten |
| ) |  |

Matches if the given method declaration has an explicit "virtual".

Given

class A {
public:
virtual void x();
};
class B : public A {
public:
void x();
};

matches A::x but not B::x

Definition at line 4668 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [39/66]

clang::ast_matchers::AST_MATCHER | ( | CXXMethodDecl | ,
|  | isPure |
| ) |  |

Matches if the given method declaration is pure.

Given

class A {
public:
virtual void x() = 0;
};

matches A::x

Definition at line 4703 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [40/66]

clang::ast_matchers::AST_MATCHER | ( | CXXMethodDecl | ,
|  | isConst |
| ) |  |

Matches if the given method declaration is const.

Given

struct A {
void foo() const;
void bar();
};

cxxMethodDecl(isConst()) matches A::foo() but not A::bar()

Definition at line 4718 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [41/66]

clang::ast_matchers::AST_MATCHER | ( | CXXMethodDecl | ,
|  | isCopyAssignmentOperator |
| ) |  |

Matches if the given method declaration declares a copy assignment operator.

Given

struct A {
A &operator=(const A &);
A &operator=(A &&);
};

cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not the second one.

Definition at line 4735 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [42/66]

clang::ast_matchers::AST_MATCHER | ( | CXXMethodDecl | ,
|  | isMoveAssignmentOperator |
| ) |  |

Matches if the given method declaration declares a move assignment operator.

Given

struct A {
A &operator=(const A &);
A &operator=(A &&);
};

cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not the first one.

Definition at line 4752 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [43/66]

clang::ast_matchers::AST_MATCHER | ( | CXXMethodDecl | ,
|  | isOverride |
| ) |  |

Matches if the given method declaration overrides another method.

Given

class A {
public:
virtual void x();
};
class B : public A {
public:
virtual void x();
};

matches B::x

Definition at line 4770 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [44/66]

clang::ast_matchers::AST_MATCHER | ( | CXXMethodDecl | ,
|  | isUserProvided |
| ) |  |

Matches method declarations that are user-provided.

Given

struct S {
S(); // #1
S(const S &) = default; // #2
S(S &&) = delete; // #3
};

cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.

Definition at line 4785 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [45/66]

clang::ast_matchers::AST_MATCHER | ( | QualType | ,
|  | isInteger |
| ) |  |

Matches QualType nodes that are of integer type.

Given

void a(int);
void b(long);
void c(double);

functionDecl(hasAnyParameter(hasType(isInteger()))) matches "a(int)", "b(long)", but not "c(double)".

Definition at line 4829 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [46/66]

clang::ast_matchers::AST_MATCHER | ( | QualType | ,
|  | isUnsignedInteger |
| ) |  |

Matches QualType nodes that are of unsigned integer type.

Given

void a(int);
void b(unsigned long);
void c(double);

functionDecl(hasAnyParameter(hasType(isUnsignedInteger()))) matches "b(unsigned long)", but not "a(int)" and "c(double)".

Definition at line 4843 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [47/66]

clang::ast_matchers::AST_MATCHER | ( | QualType | ,
|  | isSignedInteger |
| ) |  |

Matches QualType nodes that are of signed integer type.

Given

void a(int);
void b(unsigned long);
void c(double);

functionDecl(hasAnyParameter(hasType(isSignedInteger()))) matches "a(int)", but not "b(unsigned long)" and "c(double)".

Definition at line 4857 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [48/66]

clang::ast_matchers::AST_MATCHER | ( | QualType | ,
|  | isAnyCharacter |
| ) |  |

Matches QualType nodes that are of character type.

Given

void a(char);
void b(wchar_t);
void c(double);

functionDecl(hasAnyParameter(hasType(isAnyCharacter()))) matches "a(char)", "b(wchar_t)", but not "c(double)".

Definition at line 4871 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [49/66]

clang::ast_matchers::AST_MATCHER | ( | QualType | ,
|  | isAnyPointer |
| ) |  |

Matches QualType nodes that are of any pointer type; this includes the Objective-C object pointer type, which is different despite being syntactically similar.

Given

int *i = nullptr;
@interface Foo
@end
Foo *f;
int j;

varDecl(hasType(isAnyPointer())) matches "int *i" and "Foo *f", but not "int j".

Definition at line 4891 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [50/66]

clang::ast_matchers::AST_MATCHER | ( | QualType | ,
|  | isConstQualified |
| ) |  |

Matches QualType nodes that are const-qualified, i.e., that include "top-level" const.

Given

void a(int);
void b(int const);
void c(const int);
void d(const int*);
void e(int const) {};

functionDecl(hasAnyParameter(hasType(isConstQualified()))) matches "void b(int const)", "void c(const int)" and "void e(int const) {}". It does not match d as there is no top-level const on the parameter type "const int *".

Definition at line 4910 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [51/66]

clang::ast_matchers::AST_MATCHER | ( | QualType | ,
|  | isVolatileQualified |
| ) |  |

Matches QualType nodes that are volatile-qualified, i.e., that include "top-level" volatile.

Given

void a(int);
void b(int volatile);
void c(volatile int);
void d(volatile int*);
void e(int volatile) {};

functionDecl(hasAnyParameter(hasType(isVolatileQualified()))) matches "void b(int volatile)", "void c(volatile int)" and "void e(int volatile) {}". It does not match d as there is no top-level volatile on the parameter type "volatile int *".

Definition at line 4929 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [52/66]

clang::ast_matchers::AST_MATCHER | ( | QualType | ,
|  | hasLocalQualifiers |
| ) |  |

Matches QualType nodes that have local CV-qualifiers attached to the node, not hidden within a typedef.

Given

typedef const int const_int;
const_int i;
int *const j;
int *volatile k;
int m;

`varDecl`(hasType(hasLocalQualifiers())) matches only `j` and `k`. `i` is const-qualified but the qualifier is not local.

Definition at line 4946 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [53/66]

clang::ast_matchers::AST_MATCHER | ( | Type | ,
|  | booleanType |
| ) |  |

Matches type `bool`.

Given

struct S { bool func(); };

functionDecl(returns(booleanType())) matches "bool func();"

Definition at line 5133 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [54/66]

clang::ast_matchers::AST_MATCHER | ( | Type | ,
|  | voidType |
| ) |  |

Matches type `void`.

Given

struct S { void func(); };

functionDecl(returns(voidType())) matches "void func();"

Definition at line 5145 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [55/66]

clang::ast_matchers::AST_MATCHER | ( | Type | ,
|  | realFloatingPointType |
| ) |  |

Matches any real floating-point type (float, double, long double).

Given

int i;
float f;

realFloatingPointType() matches "float f" but not "int i"

Definition at line 5197 of file ASTMatchers.h.

References AST_POLYMORPHIC_SUPPORTED_TYPES, AST_TYPELOC_TRAVERSE_MATCHER_DECL(), constantArrayType, and Node.

## ◆ AST_MATCHER() [56/66]

clang::ast_matchers::AST_MATCHER | ( | CXXConstructorDecl | ,
|  | isCopyConstructor |
| ) |  |

Matches constructor declarations that are copy constructors.

Given

struct S {
S(); // #1
S(const S &); // #2
S(S &&); // #3
};

cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.

Definition at line 6003 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [57/66]

clang::ast_matchers::AST_MATCHER | ( | CXXConstructorDecl | ,
|  | isMoveConstructor |
| ) |  |

Matches constructor declarations that are move constructors.

Given

struct S {
S(); // #1
S(const S &); // #2
S(S &&); // #3
};

cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.

Definition at line 6018 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [58/66]

clang::ast_matchers::AST_MATCHER | ( | CXXConstructorDecl | ,
|  | isDefaultConstructor |
| ) |  |

Matches constructor declarations that are default constructors.

Given

struct S {
S(); // #1
S(const S &); // #2
S(S &&); // #3
};

cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.

Definition at line 6033 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [59/66]

clang::ast_matchers::AST_MATCHER | ( | CXXConstructorDecl | ,
|  | isDelegatingConstructor |
| ) |  |

Matches constructors that delegate to another constructor.

Given

struct S {
S(); // #1
S(int) {} // #2
S(S &&) : S() {} // #3
};
S::S() : S(0) {} // #4

cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not #1 or #2.

Definition at line 6050 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [60/66]

clang::ast_matchers::AST_MATCHER | ( | NamespaceDecl | ,
|  | isAnonymous |
| ) |  |

Matches anonymous namespace declarations.

Given

namespace n {
namespace {} // #1
}

namespaceDecl(isAnonymous()) will match #1 but not ::n.

Definition at line 6108 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [61/66]

clang::ast_matchers::AST_MATCHER | ( | NamedDecl | ,
|  | hasExternalFormalLinkage |
| ) |  |

Matches a declaration that has external formal linkage.

Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))

void f() {
int x;
static int y;
}
int z;

Example matches f() because it has external formal linkage despite being unique to the translation unit as though it has internal likage (matcher = functionDecl(hasExternalFormalLinkage()))

namespace {
void f() {}
}

Definition at line 6251 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [62/66]

clang::ast_matchers::AST_MATCHER | ( | ParmVarDecl | ,
|  | hasDefaultArgument |
| ) |  |

Matches a declaration that has default arguments.

Example matches y (matcher = parmVarDecl(hasDefaultArgument()))

void x(int val) {}
void y(int val = 0) {}

Definition at line 6262 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [63/66]

clang::ast_matchers::AST_MATCHER | ( | CXXNewExpr | ,
|  | isArray |
| ) |  |

Matches array new expressions.

Given:

MyClass *p1 = new MyClass[10];

cxxNewExpr(isArray()) matches the expression 'new MyClass[10]'.

Definition at line 6274 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [64/66]

clang::ast_matchers::AST_MATCHER | ( | CXXRecordDecl | ,
|  | hasDefinition |
| ) |  |

Matches a class declaration that is defined.

Example matches x (matcher = cxxRecordDecl(hasDefinition()))

class x {};
class y;

Definition at line 6298 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [65/66]

clang::ast_matchers::AST_MATCHER | ( | EnumDecl | ,
|  | isScoped |
| ) |  |

Matches C++11 scoped enum declaration.

Example matches Y (matcher = enumDecl(isScoped()))

enum X {};
enum class Y {};

Definition at line 6309 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER() [66/66]

clang::ast_matchers::AST_MATCHER | ( | FunctionDecl | ,
|  | hasTrailingReturn |
| ) |  |

Matches a function declared with a trailing return type.

Example matches Y (matcher = functionDecl(hasTrailingReturn()))

int X() {}
auto Y() -> int {}

Definition at line 6320 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER_FUNCTION() [1/3]

clang::ast_matchers::AST_MATCHER_FUNCTION | ( | internal::Matcher< Decl > | ,
|  | isInstantiated |
| ) |  |

Matches declarations that are template instantiations or are inside template instantiations.

Given

template<typename T> void A(T t) { T i; }
A(0);
A(0U);

functionDecl(isInstantiated()) matches 'A(int) {...};' and 'A(unsigned) {...}'.

Definition at line 5073 of file ASTMatchers.h.

References anyOf, cxxRecordDecl, decl, functionDecl, hasAncestor, and clang::isTemplateInstantiation().

## ◆ AST_MATCHER_FUNCTION() [2/3]

clang::ast_matchers::AST_MATCHER_FUNCTION | ( | internal::Matcher< Stmt > | ,
|  | isInTemplateInstantiation |
| ) |  |

Matches statements inside of a template instantiation.

Given

int j;
template<typename T> void A(T t) { T i; j += 42;}
A(0);
A(0U);

declStmt(isInTemplateInstantiation()) matches 'int i;' and 'unsigned i'. unless(stmt(isInTemplateInstantiation())) will NOT match j += 42; as it's shared between the template definition and instantiation.

Definition at line 5093 of file ASTMatchers.h.

References anyOf, cxxRecordDecl, decl, functionDecl, hasAncestor, clang::isTemplateInstantiation(), and stmt.

## ◆ AST_MATCHER_FUNCTION() [3/3]

clang::ast_matchers::AST_MATCHER_FUNCTION | ( | internal::Matcher< Expr > | ,
|  | nullPointerConstant |
| ) |  |

Matches expressions that resolve to a null pointer constant, such as GNU's __null, C++11's nullptr, or C's NULL macro.

Given:

void *v1 = NULL;
void *v2 = nullptr;
void *v3 = __null; // GNU extension
char *cp = (char *)0;
int *ip = 0;
int i = 0;

expr(nullPointerConstant()) matches the initializer for v1, v2, v3, cp, and ip. Does not match the initializer for i.

Definition at line 6187 of file ASTMatchers.h.

References anyOf, cxxNullPtrLiteralExpr, equals(), expr, gnuNullExpr, hasParent, integerLiteral, and pointerType.

## ◆ AST_MATCHER_FUNCTION_P_OVERLOAD() [1/2]

clang::ast_matchers::AST_MATCHER_FUNCTION_P_OVERLOAD | ( | internal::BindableMatcher< TypeLoc > | ,
|  | loc | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher | ,
|  | 0 |
| ) |  |

Matches `TypeLocs` for which the given inner QualType-matcher matches.

Definition at line 5119 of file ASTMatchers.h.

## ◆ AST_MATCHER_FUNCTION_P_OVERLOAD() [2/2]

clang::ast_matchers::AST_MATCHER_FUNCTION_P_OVERLOAD | ( | internal::BindableMatcher< NestedNameSpecifierLoc > | ,
|  | loc | ,
|  | internal::Matcher< NestedNameSpecifier > | ,
|  | InnerMatcher | ,
|  | 1 |
| ) |  |

Matches `NestedNameSpecifierLocs` for which the given inner NestedNameSpecifier-matcher matches.

Definition at line 5813 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [1/82]

clang::ast_matchers::AST_MATCHER_P | ( | ObjCMessageExpr | ,
|  | hasAnySelectorMatcher | ,
|  | std::vector< std::string > | ,
|  | Matches |
| ) |  |

Definition at line 42 of file ASTMatchersInternal.cpp.

## ◆ AST_MATCHER_P() [2/82]

clang::ast_matchers::AST_MATCHER_P | ( | FieldDecl | ,
|  | hasBitWidth | ,
|  | unsigned | ,
|  | Width |
| ) |  |

Matches non-static data members that are bit-fields of the specified bit width.

Given

class C {
int a : 2;
int b : 4;
int c : 2;
};

fieldDecl(hasBitWidth(2)) matches 'int a;' and 'int c;' but not 'int b;'.

Definition at line 612 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER_P() [3/82]

clang::ast_matchers::AST_MATCHER_P | ( | FieldDecl | ,
|  | hasInClassInitializer | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches non-static data members that have an in-class initializer.

Given

class C {
int a = 2;
int b = 3;
int c;
};

fieldDecl(hasInClassInitializer(integerLiteral(equals(2)))) matches 'int a;' but not 'int b;'. fieldDecl(hasInClassInitializer(anything())) matches 'int a;' and 'int b;' but not 'int c;'.

Definition at line 631 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [4/82]

clang::ast_matchers::AST_MATCHER_P | ( | ClassTemplateSpecializationDecl | ,
|  | hasSpecializedTemplate | ,
|  | internal::Matcher< ClassTemplateDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches the specialized template of a specialization declaration.

Given

template<typename T> class A {}; #1
template<> class A<int> {}; #2

classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl())) matches '#2' with classTemplateDecl() matching the class template declaration of 'A' at #1.

Definition at line 654 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [5/82]

clang::ast_matchers::AST_MATCHER_P | ( | Expr | ,
|  | ignoringImplicit | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches expressions that match InnerMatcher after any implicit AST nodes are stripped off.

Parentheses and explicit casts are not discarded. Given

class C {};
C a = C();
C b;
C c = b;

The matchers

varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr())))

would match the declarations for a, b, and c. While

varDecl(hasInitializer(cxxConstructExpr()))

only match the declarations for b and c.

Definition at line 721 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [6/82]

clang::ast_matchers::AST_MATCHER_P | ( | Expr | ,
|  | ignoringImpCasts | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches expressions that match InnerMatcher after any implicit casts are stripped off.

Parentheses and explicit casts are not discarded. Given

int arr[5];
int a = 0;
char b = 0;
const int c = a;
int *d = arr;
long e = (long) 0l;

The matchers

varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))

would match the declarations for a, b, c, and d, but not e. While

varDecl(hasInitializer(integerLiteral()))
varDecl(hasInitializer(declRefExpr()))

only match the declarations for b, c, and d.

Definition at line 751 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [7/82]

clang::ast_matchers::AST_MATCHER_P | ( | Expr | ,
|  | ignoringParenCasts | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches expressions that match InnerMatcher after parentheses and casts are stripped off.

Implicit and non-C Style casts are also discarded. Given

int a = 0;
char b = (0);
void* c = reinterpret_cast<char*>(0);
char d = char(0);

The matcher varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) would match the declarations for a, b, c, and d. while varDecl(hasInitializer(integerLiteral())) only match the declaration for a.

Definition at line 773 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [8/82]

clang::ast_matchers::AST_MATCHER_P | ( | Expr | ,
|  | ignoringParenImpCasts | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches expressions that match InnerMatcher after implicit casts and parentheses are stripped off.

Explicit casts are not discarded. Given

int arr[5];
int a = 0;
char b = (0);
const int c = a;
int *d = (arr);
long e = ((long) 0l);

The matchers varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) would match the declarations for a, b, c, and d, but not e. while varDecl(hasInitializer(integerLiteral())) varDecl(hasInitializer(declRefExpr())) would only match the declaration for a.

Definition at line 798 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [9/82]

clang::ast_matchers::AST_MATCHER_P | ( | TemplateArgument | ,
|  | refersToType | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher |
| ) |  |

Matches a TemplateArgument that refers to a certain type.

Given

struct X {};
template<typename T> struct A {};
A<X> a;

classTemplateSpecializationDecl(hasAnyTemplateArgument( refersToType(class(hasName("X"))))) matches the specialization `A<X>`

Definition at line 937 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [10/82]

clang::ast_matchers::AST_MATCHER_P | ( | TemplateArgument | ,
|  | refersToTemplate | ,
|  | internal::Matcher< TemplateName > | ,
|  | InnerMatcher |
| ) |  |

Matches a TemplateArgument that refers to a certain template.

Given

template<template <typename> class S> class X {};
template<typename T> class Y {};
X<Y> xi;

classTemplateSpecializationDecl(hasAnyTemplateArgument( refersToTemplate(templateName()))) matches the specialization `X<Y>`

Definition at line 955 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [11/82]

clang::ast_matchers::AST_MATCHER_P | ( | TemplateArgument | ,
|  | refersToDeclaration | ,
|  | internal::Matcher< Decl > | ,
|  | InnerMatcher |
| ) |  |

Matches a canonical TemplateArgument that refers to a certain declaration.

Given

struct B { int next; };
template<int(B::*next_ptr)> struct A {};
A<&B::next> a;

classTemplateSpecializationDecl(hasAnyTemplateArgument( refersToDeclaration(fieldDecl(hasName("next"))))) matches the specialization `A<&B::next>` with `fieldDecl`(...) matching `B::next`

Definition at line 975 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [12/82]

clang::ast_matchers::AST_MATCHER_P | ( | TemplateArgument | ,
|  | isExpr | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches a sugar TemplateArgument that refers to a certain expression.

Given

struct B { int next; };
template<int(B::*next_ptr)> struct A {};
A<&B::next> a;

templateSpecializationType(hasAnyTemplateArgument( isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) matches the specialization `A<&B::next>` with `fieldDecl`(...) matching `B::next`

Definition at line 994 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [13/82]

clang::ast_matchers::AST_MATCHER_P | ( | TemplateArgument | ,
|  | refersToIntegralType | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher |
| ) |  |

Matches a TemplateArgument that referes to an integral type.

Given

template<int T> struct C {};
C<42> c;

classTemplateSpecializationDecl( hasAnyTemplateArgument(refersToIntegralType(asString("int")))) matches the implicit instantiation of C in C<42>.

Definition at line 1025 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [14/82]

clang::ast_matchers::AST_MATCHER_P | ( | TemplateArgument | ,
|  | equalsIntegralValue | ,
|  | std::string | ,
|  | Value |
| ) |  |

Matches a TemplateArgument of integral type with a given value.

Note that 'Value' is a string as the template argument's value is an arbitrary precision integer. 'Value' must be euqal to the canonical representation of that integral value in base 10.

Given

template<int T> struct C {};
C<42> c;

classTemplateSpecializationDecl( hasAnyTemplateArgument(equalsIntegralValue("42"))) matches the implicit instantiation of C in C<42>.

Definition at line 1046 of file ASTMatchers.h.

References autoreleasePoolStmt, callExpr, cxxConstructorDecl, cxxConversionDecl, cxxDependentScopeMemberExpr, cxxDestructorDecl, cxxMethodDecl, declStmt, enumConstantDecl, enumDecl, fieldDecl, friendDecl, functionDecl, functionTemplateDecl, indirectFieldDecl, clang::TemplateArgument::Integral, memberExpr, Node, stmt, unresolvedMemberExpr, valueDecl, and varDecl.

## ◆ AST_MATCHER_P() [15/82]

clang::ast_matchers::AST_MATCHER_P | ( | InitListExpr | ,
|  | hasSyntacticForm | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches the syntactic form of init list expressions (if expression have it).

Definition at line 1488 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [16/82]

clang::ast_matchers::AST_MATCHER_P | ( | ForStmt | ,
|  | hasIncrement | ,
|  | internal::Matcher< Stmt > | ,
|  | InnerMatcher |
| ) |  |

Matches the increment statement of a for loop.

Example: forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) matches '++x' in

for (x; x < N; ++x) { }

Definition at line 1845 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [17/82]

clang::ast_matchers::AST_MATCHER_P | ( | ForStmt | ,
|  | hasLoopInit | ,
|  | internal::Matcher< Stmt > | ,
|  | InnerMatcher |
| ) |  |

Matches the initialization statement of a for loop.

Example: forStmt(hasLoopInit(declStmt())) matches 'int x = 0' in

for (int x = 0; x < N; ++x) { }

Definition at line 1860 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [18/82]

clang::ast_matchers::AST_MATCHER_P | ( | CXXForRangeStmt | ,
|  | hasLoopVariable | ,
|  | internal::Matcher< VarDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches the initialization statement of a for loop.

Example: forStmt(hasLoopVariable(anything())) matches 'int x' in

for (int x : a) { }

Definition at line 1884 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [19/82]

clang::ast_matchers::AST_MATCHER_P | ( | CXXForRangeStmt | ,
|  | hasRangeInit | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches the range initialization statement of a for loop.

Example: forStmt(hasRangeInit(anything())) matches 'a' in

for (int x : a) { }

Definition at line 1898 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [20/82]

clang::ast_matchers::AST_MATCHER_P | ( | DesignatedInitExpr | ,
|  | designatorCountIs | ,
|  | unsigned | ,
|  | N |
| ) |  |

Matches designated initializer expressions that contain a specific number of designators.

Example: Given

point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 };

designatorCountIs(2) matches '{ [2].y = 1.0, [0].x = 1.0 }', but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'.

Definition at line 2404 of file ASTMatchers.h.

References allOf, anyOf, eachOf, max(), Node, qualType, type, typeLoc, and unaryExprOrTypeTraitExpr.

## ◆ AST_MATCHER_P() [21/82]

clang::ast_matchers::AST_MATCHER_P | ( | UnaryExprOrTypeTraitExpr | ,
|  | hasArgumentOfType | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher |
| ) |  |

Matches unary expressions that have a specific type of argument.

Given

int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);

unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) matches `sizeof(a)` and `alignof(c)`

Definition at line 2475 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [22/82]

clang::ast_matchers::AST_MATCHER_P | ( | UnaryExprOrTypeTraitExpr | ,
|  | ofKind | ,
|  | UnaryExprOrTypeTrait | ,
|  | Kind |
| ) |  |

Matches unary expressions of a certain kind.

Given

int x;
int s = sizeof(x) + alignof(x)

unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) matches `sizeof(x)`

Definition at line 2490 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER_P() [23/82]

clang::ast_matchers::AST_MATCHER_P | ( | NamedDecl | ,
|  | matchesName | ,
|  | std::string | ,
|  | RegExp |
| ) |  |

Matches NamedDecl nodes whose fully qualified names contain a substring matched by the given RegExp.

Supports specifying enclosing namespaces or classes by prefixing the name with '<enclosing>::'. Does not match typedefs of an underlying type with the given name.

Example matches X (regexp == "::X")

class X;

Example matches X (regexp is one of "::X", "^foo::.*X", among others)

namespace foo { namespace bar { class X; } }

Definition at line 2560 of file ASTMatchers.h.

References AST_POLYMORPHIC_SUPPORTED_TYPES, and Node.

## ◆ AST_MATCHER_P() [24/82]

clang::ast_matchers::AST_MATCHER_P | ( | CXXRecordDecl | ,
|  | isDerivedFrom | ,
|  | internal::Matcher< NamedDecl > | ,
|  | Base |
| ) |  |

Matches C++ classes that are directly or indirectly derived from a class matching `Base`.

Note that a class is not considered to be derived from itself.

Example matches Y, Z, C (Base == hasName("X"))

class X;
class Y : public X {}; // directly derived
class Z : public Y {}; // indirectly derived
typedef X A;
typedef A B;
class C : public B {}; // derived from a typedef of X

In the following example, Bar matches isDerivedFrom(hasName("X")):

class Foo;
typedef Foo X;
class Bar : public Foo {}; // derived from a type that X is a typedef of

Definition at line 2616 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [25/82]

clang::ast_matchers::AST_MATCHER_P | ( | CXXRecordDecl | ,
|  | hasMethod | ,
|  | internal::Matcher< CXXMethodDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches the first method of a class or struct that satisfies `InnerMatcher`.

Given:

class A { void func(); };
class B { void member(); };

`cxxRecordDecl`(hasMethod(hasName("func"))) matches the declaration of `A` but not `B`.

Definition at line 2654 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [26/82]

clang::ast_matchers::AST_MATCHER_P | ( | NamedDecl | ,
|  | hasUnderlyingDecl | ,
|  | internal::Matcher< NamedDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches a `NamedDecl` whose underlying declaration matches the given matcher.

Given

namespace N { template<class T> void f(T t); }
template <class T> void g() { using N::f; f(T()); }

`unresolvedLookupExpr`(hasAnyDeclaration( namedDecl(hasUnderlyingDecl(hasName("::N::f"))))) matches the use of `f` in `g()` .

Definition at line 2882 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [27/82]

clang::ast_matchers::AST_MATCHER_P | ( | CXXMemberCallExpr | ,
|  | on | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches on the implicit object argument of a member call expression.

Example matches y.x() (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))))))

class Y { public: void x(); };
void z() { Y y; y.x(); }

FIXME: Overload to allow directly matching types?

Definition at line 2900 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [28/82]

clang::ast_matchers::AST_MATCHER_P | ( | ObjCMessageExpr | ,
|  | hasReceiverType | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher |
| ) |  |

Matches on the receiver of an ObjectiveC Message expression.

Example matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *"))); matches the [webView ...] message invocation.

NSString *webViewJavaScript = ...
UIWebView *webView = ...
[webView stringByEvaluatingJavaScriptFromString:webViewJavascript];

Definition at line 2919 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [29/82]

clang::ast_matchers::AST_MATCHER_P | ( | ObjCMessageExpr | ,
|  | hasReceiver | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches if the Objective-C message is sent to an instance, and the inner matcher matches on that instance.

For example the method call in

NSString *x = @"hello";
[x containsString:@"h"];

is matched by objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x"))))))

Definition at line 2952 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [30/82]

clang::ast_matchers::AST_MATCHER_P | ( | ObjCMessageExpr | ,
|  | hasSelector | ,
|  | std::string | ,
|  | BaseName |
| ) |  |

Matches when BaseName == Selector.getAsString()

matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); matches the outer message expr in the code below, but NOT the message invocation for self.bodyView.

[self.bodyView loadHTMLString:html baseURL:NULL];

Definition at line 2968 of file ASTMatchers.h.

References clang::Selector::getAsString(), hasAnySelector, clang::ast_matchers::internal::hasAnySelectorFunc(), and Node.

## ◆ AST_MATCHER_P() [31/82]

clang::ast_matchers::AST_MATCHER_P | ( | ObjCMessageExpr | ,
|  | matchesSelector | ,
|  | std::string | ,
|  | RegExp |
| ) |  |

Matches ObjC selectors whose name contains a substring matched by the given RegExp.

matcher = objCMessageExpr(matchesSelector("loadHTMLString\:baseURL?")); matches the outer message expr in the code below, but NOT the message invocation for self.bodyView.

[self.bodyView loadHTMLString:html baseURL:NULL];

Definition at line 2996 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER_P() [32/82]

clang::ast_matchers::AST_MATCHER_P | ( | ObjCMessageExpr | ,
|  | numSelectorArgs | ,
|  | unsigned | ,
|  | N |
| ) |  |

Matches when the selector has the specified number of arguments.

matcher = objCMessageExpr(numSelectorArgs(0)); matches self.bodyView in the code below

matcher = objCMessageExpr(numSelectorArgs(2)); matches the invocation of "loadHTMLString:baseURL:" but not that of self.bodyView

[self.bodyView loadHTMLString:html baseURL:NULL];

Definition at line 3050 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER_P() [33/82]

clang::ast_matchers::AST_MATCHER_P | ( | CallExpr | ,
|  | callee | ,
|  | internal::Matcher< Stmt > | ,
|  | InnerMatcher |
| ) |  |

Matches if the call expression's callee expression matches.

Given

class Y { void x() { this->x(); x(); Y y; y.x(); } };
void f() { f(); }

callExpr(callee(expr())) matches this->x(), x(), y.x(), f() with callee(...) matching this->x, x, y.x, f respectively

Note: Callee cannot take the more general internal::Matcher<Expr> because this introduces ambiguous overloads with calls to Callee taking a internal::Matcher<Decl>, as the matcher hierarchy is purely implemented in terms of implicit casts.

Definition at line 3070 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [34/82]

clang::ast_matchers::AST_MATCHER_P | ( | DeclaratorDecl | ,
|  | hasTypeLoc | ,
|  | internal::Matcher< TypeLoc > | ,
|  | Inner |
| ) |  |

Matches if the type location of the declarator decl's type matches the inner matcher.

Given

int x;

declaratorDecl(hasTypeLoc(loc(asString("int")))) matches int x

Definition at line 3152 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [35/82]

clang::ast_matchers::AST_MATCHER_P | ( | QualType | ,
|  | asString | ,
|  | std::string | ,
|  | Name |
| ) |  |

Matches if the matched type is represented by the given string.

Given

class Y { public: void x(); };
void z() { Y* y; y->x(); }

cxxMemberCallExpr(on(hasType(asString("class Y *")))) matches y->x()

Definition at line 3168 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [36/82]

clang::ast_matchers::AST_MATCHER_P | ( | QualType | ,
|  | pointsTo | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher |
| ) |  |

Matches if the matched type is a pointer type and the pointee type matches the specified matcher.

Example matches y->x() (matcher = cxxMemberCallExpr(on(hasType(pointsTo cxxRecordDecl(hasName("Y")))))))

class Y { public: void x(); };
void z() { Y *y; y->x(); }

Definition at line 3182 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [37/82]

clang::ast_matchers::AST_MATCHER_P | ( | Type | ,
|  | hasUnqualifiedDesugaredType | ,
|  | internal::Matcher< Type > | ,
|  | InnerMatcher |
| ) |  |

Matches if the matched type matches the unqualified desugared type of the matched node.

For example, in:

class A {};
using B = A;

The matcher type(hasUnqualifiedDesugaredType(recordType())) matches both B and A.

Definition at line 3206 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [38/82]

clang::ast_matchers::AST_MATCHER_P | ( | QualType | ,
|  | references | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher |
| ) |  |

Matches if the matched type is a reference type and the referenced type matches the specified matcher.

Example matches X &x and const X &y (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X"))))))

class X {
void a(X b) {
X &x = b;
const X &y = b;
}
};

Definition at line 3225 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [39/82]

clang::ast_matchers::AST_MATCHER_P | ( | QualType | ,
|  | hasCanonicalType | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher |
| ) |  |

Matches QualTypes whose canonical type matches InnerMatcher.

Given:

typedef int &int_ref;
int a;
int_ref b = a;

`varDecl`(hasType(qualType(referenceType()))))) will not match the declaration of b but `varDecl`(hasType(qualType(hasCanonicalType(referenceType())))))) does.

Definition at line 3243 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [40/82]

clang::ast_matchers::AST_MATCHER_P | ( | CXXMemberCallExpr | ,
|  | onImplicitObjectArgument | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Definition at line 3257 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [41/82]

clang::ast_matchers::AST_MATCHER_P | ( | DeclRefExpr | ,
|  | to | ,
|  | internal::Matcher< Decl > | ,
|  | InnerMatcher |
| ) |  |

Matches a DeclRefExpr that refers to a declaration that matches the specified matcher.

Example matches x in if(x) (matcher = declRefExpr(to(varDecl(hasName("x")))))

bool x;
if (x) {}

Definition at line 3290 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [42/82]

clang::ast_matchers::AST_MATCHER_P | ( | DeclRefExpr | ,
|  | throughUsingDecl | ,
|  | internal::Matcher< UsingShadowDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches a `DeclRefExpr` that refers to a declaration through a specific using shadow declaration.

Given

namespace a { void f() {} }
using a::f;
void g() {
f(); // Matches this ..
a::f(); // .. but not this.
}

declRefExpr(throughUsingDecl(anything())) matches `f()`

Definition at line 3311 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [43/82]

clang::ast_matchers::AST_MATCHER_P | ( | OverloadExpr | ,
|  | hasAnyDeclaration | ,
|  | internal::Matcher< Decl > | ,
|  | InnerMatcher |
| ) |  |

Matches an `OverloadExpr` if any of the declarations in the set of overloads matches the given matcher.

Given

template <typename T> void foo(T);
template <typename T> void bar(T);
template <typename T> void baz(T t) {
foo(t);
bar(t);
}

unresolvedLookupExpr(hasAnyDeclaration( functionTemplateDecl(hasName("foo")))) matches `foo` in `foo(t)`; but not `bar` in `bar(t)`;

Definition at line 3334 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [44/82]

clang::ast_matchers::AST_MATCHER_P | ( | DeclStmt | ,
|  | hasSingleDecl | ,
|  | internal::Matcher< Decl > | ,
|  | InnerMatcher |
| ) |  |

Matches the Decl of a DeclStmt which has a single declaration.

Given

int a, b;
int c;

declStmt(hasSingleDecl(anything())) matches 'int c;' but not 'int a, b;'.

Definition at line 3349 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [45/82]

clang::ast_matchers::AST_MATCHER_P | ( | VarDecl | ,
|  | hasInitializer | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches a variable declaration that has an initializer expression that matches the given matcher.

Example matches x (matcher = varDecl(hasInitializer(callExpr())))

bool y() { return true; }
bool x = y();

Definition at line 3365 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [46/82]

clang::ast_matchers::AST_MATCHER_P | ( | DeclStmt | ,
|  | declCountIs | ,
|  | unsigned | ,
|  | N |
| ) |  |

Matches declaration statements that contain a specific number of declarations.

Example: Given

int a, b;
int c;
int d = 2, e;

declCountIs(2) matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.

Definition at line 3541 of file ASTMatchers.h.

References distance(), and Node.

## ◆ AST_MATCHER_P() [47/82]

clang::ast_matchers::AST_MATCHER_P | ( | CXXConstructorDecl | ,
|  | hasAnyConstructorInitializer | ,
|  | internal::Matcher< CXXCtorInitializer > | ,
|  | InnerMatcher |
| ) |  |

Matches a constructor initializer.

Given

struct Foo {
Foo() : foo_(1) { }
int foo_;
};

cxxRecordDecl(has(cxxConstructorDecl( hasAnyConstructorInitializer(anything()) ))) record matches Foo, hasAnyConstructorInitializer matches foo_(1)

Definition at line 3604 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [48/82]

clang::ast_matchers::AST_MATCHER_P | ( | CXXCtorInitializer | ,
|  | forField | ,
|  | internal::Matcher< FieldDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches the field declaration of a constructor initializer.

Given

struct Foo {
Foo() : foo_(1) { }
int foo_;
};

cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( forField(hasName("foo_")))))) matches Foo with forField matching foo_

Definition at line 3623 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [49/82]

clang::ast_matchers::AST_MATCHER_P | ( | CXXCtorInitializer | ,
|  | withInitializer | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches the initializer expression of a constructor initializer.

Given

struct Foo {
Foo() : foo_(1) { }
int foo_;
};

cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( withInitializer(integerLiteral(equals(1))))))) matches Foo with withInitializer matching (1)

Definition at line 3643 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [50/82]

clang::ast_matchers::AST_MATCHER_P | ( | FunctionDecl | ,
|  | returns | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher |
| ) |  |

Matches the return type of a function declaration.

Given:

class X { int f() { return 1; } };

cxxMethodDecl(returns(asString("int"))) matches int f() { return 1; }

Definition at line 3935 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [51/82]

clang::ast_matchers::AST_MATCHER_P | ( | IfStmt | ,
|  | hasThen | ,
|  | internal::Matcher< Stmt > | ,
|  | InnerMatcher |
| ) |  |

Matches the then-statement of an if statement.

Examples matches the if statement (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true)))))

if (false) true; else false;

Definition at line 4105 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [52/82]

clang::ast_matchers::AST_MATCHER_P | ( | IfStmt | ,
|  | hasElse | ,
|  | internal::Matcher< Stmt > | ,
|  | InnerMatcher |
| ) |  |

Matches the else-statement of an if statement.

Examples matches the if statement (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true)))))

if (false) false; else true;

Definition at line 4117 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [53/82]

clang::ast_matchers::AST_MATCHER_P | ( | IfStmt | ,
|  | hasConditionVariableStatement | ,
|  | internal::Matcher< DeclStmt > | ,
|  | InnerMatcher |
| ) |  |

Matches the condition variable statement in an if statement.

Given

if (A* a = GetAPointer()) {}

hasConditionVariableStatement(...) matches 'A* a = GetAPointer()'.

Definition at line 4167 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [54/82]

clang::ast_matchers::AST_MATCHER_P | ( | ArraySubscriptExpr | ,
|  | hasIndex | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches the index expression of an array subscript expression.

Given

int i[5];
void f() { i[1] = 42; }

arraySubscriptExpression(hasIndex(integerLiteral())) matches `i`[1] with the `integerLiteral()` matching `1`

Definition at line 4184 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [55/82]

clang::ast_matchers::AST_MATCHER_P | ( | ArraySubscriptExpr | ,
|  | hasBase | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches the base expression of an array subscript expression.

Given

int i[5];
void f() { i[1] = 42; }

arraySubscriptExpression(hasBase(implicitCastExpr( hasSourceExpression(declRefExpr())))) matches `i`[1] with the `declRefExpr()` matching `i`

Definition at line 4201 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [56/82]

clang::ast_matchers::AST_MATCHER_P | ( | CompoundStmt | ,
|  | statementCountIs | ,
|  | unsigned | ,
|  | N |
| ) |  |

Checks that a compound statement contains a specific number of child statements.

Example: Given

{ for (;;) {} }

compoundStmt(statementCountIs(0))) matches '{}' but does not match the outer compound statement.

Definition at line 4260 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER_P() [57/82]

clang::ast_matchers::AST_MATCHER_P | ( | UnaryOperator | ,
|  | hasUnaryOperand | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches if the operand of a unary operator matches.

Example matches true (matcher = hasUnaryOperand( cxxBoolLiteral(equals(true))))

!true

Definition at line 4403 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [58/82]

clang::ast_matchers::AST_MATCHER_P | ( | CastExpr | ,
|  | hasCastKind | ,
|  | CastKind | ,
|  | Kind |
| ) |  |

Matches casts that has a given cast kind.

Example: matches the implicit cast around `0` (matcher = castExpr(hasCastKind(CK_NullToPointer)))

int *p = 0;

Definition at line 4442 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER_P() [59/82]

clang::ast_matchers::AST_MATCHER_P | ( | ExplicitCastExpr | ,
|  | hasDestinationType | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher |
| ) |  |

Matches casts whose destination type matches a given matcher.

(Note: Clang's AST refers to other conversions as "casts" too, and calls actual casts "explicit" casts.)

Definition at line 4450 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [60/82]

clang::ast_matchers::AST_MATCHER_P | ( | ImplicitCastExpr | ,
|  | hasImplicitDestinationType | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher |
| ) |  |

Matches implicit casts whose destination type matches a given matcher.

FIXME: Unit test this matcher

Definition at line 4460 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [61/82]

clang::ast_matchers::AST_MATCHER_P | ( | AbstractConditionalOperator | ,
|  | hasTrueExpression | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches the true branch expression of a conditional operator.

Example 1 (conditional ternary operator): matches a

condition ? a : b

Example 2 (conditional binary operator): matches opaqueValueExpr(condition)

condition ?: b

Definition at line 4512 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [62/82]

clang::ast_matchers::AST_MATCHER_P | ( | AbstractConditionalOperator | ,
|  | hasFalseExpression | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches the false branch expression of a conditional operator (binary or ternary).

Example matches b

condition ? a : b
condition ?: b

Definition at line 4527 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [63/82]

clang::ast_matchers::AST_MATCHER_P | ( | CXXMethodDecl | ,
|  | ofClass | ,
|  | internal::Matcher< CXXRecordDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches the class declaration that the given method declaration belongs to.

FIXME: Generalize this for other kinds of declarations. FIXME: What other kind of declarations would we need to generalize this to?

Example matches A() in the last line (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl( ofClass(hasName("A"))))))

class A {
public:
A();
};
A a = A();

Definition at line 4592 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [64/82]

clang::ast_matchers::AST_MATCHER_P | ( | CXXMethodDecl | ,
|  | forEachOverridden | ,
|  | internal::Matcher< CXXMethodDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches each method overridden by the given method.

This matcher may produce multiple matches.

Given

class A { virtual void f(); };
class B : public A { void f(); };
class C : public B { void f(); };

cxxMethodDecl(ofClass(hasName("C")), forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") matches once, with "b" binding "A::f" and "d" binding "C::f" (Note that B::f is not overridden by C::f).

The check can produce multiple matches in case of multiple inheritance, e.g.

class A1 { virtual void f(); };
class A2 { virtual void f(); };
class C : public A1, public A2 { void f(); };

cxxMethodDecl(ofClass(hasName("C")), forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and once with "b" binding "A2::f" and "d" binding "C::f".

Definition at line 4623 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [65/82]

clang::ast_matchers::AST_MATCHER_P | ( | MemberExpr | ,
|  | member | ,
|  | internal::Matcher< ValueDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches a member expression where the member is matched by a given matcher.

Given

struct { int first, second; } first, second;
int i(second.first);
int j(first.second);

memberExpr(member(hasName("first"))) matches second.first but not first.second (because the member name there is "second").

Definition at line 4962 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [66/82]

clang::ast_matchers::AST_MATCHER_P | ( | UsingDecl | ,
|  | hasAnyUsingShadowDecl | ,
|  | internal::Matcher< UsingShadowDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches any using shadow declaration.

Given

namespace X { void b(); }
using X::b;

usingDecl(hasAnyUsingShadowDecl(hasName("b")))) matches

using X::b

Definition at line 5002 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [67/82]

clang::ast_matchers::AST_MATCHER_P | ( | UsingShadowDecl | ,
|  | hasTargetDecl | ,
|  | internal::Matcher< NamedDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches a using shadow declaration where the target declaration is matched by the given matcher.

Given

namespace X { int a; void b(); }
using X::a;
using X::b;

usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) matches

using X::b

but not

using X::a

Definition at line 5020 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [68/82]

clang::ast_matchers::AST_MATCHER_P | ( | VariableArrayType | ,
|  | hasSizeExpr | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches `VariableArrayType` nodes that have a specific size expression.

Given

void f(int b) {
int a[b];
}

variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( varDecl(hasName("b"))))))) matches "int a[b]"

Definition at line 5306 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [69/82]

clang::ast_matchers::AST_MATCHER_P | ( | ElaboratedType | ,
|  | hasQualifier | ,
|  | internal::Matcher< NestedNameSpecifier > | ,
|  | InnerMatcher |
| ) |  |

Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, matches `InnerMatcher` if the qualifier exists.

Given

namespace N {
namespace M {
class D {};
}
}
N::M::D d;

`elaboratedType`(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) matches the type of the variable declaration of `d`.

Definition at line 5673 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [70/82]

clang::ast_matchers::AST_MATCHER_P | ( | ElaboratedType | ,
|  | namesType | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher |
| ) |  |

Matches ElaboratedTypes whose named type matches `InnerMatcher`.

Given

namespace N {
namespace M {
class D {};
}
}
N::M::D d;

`elaboratedType`(namesType(recordType( hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable declaration of `d`.

Definition at line 5696 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [71/82]

clang::ast_matchers::AST_MATCHER_P | ( | DecayedType | ,
|  | hasDecayedType | ,
|  | internal::Matcher< QualType > | ,
|  | InnerType |
| ) |  |

Matches the decayed type, whos decayed type matches `InnerMatcher`.

Definition at line 5766 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER_P() [72/82]

clang::ast_matchers::AST_MATCHER_P | ( | Decl | ,
|  | hasDeclContext | ,
|  | internal::Matcher< Decl > | ,
|  | InnerMatcher |
| ) |  |

Matches declarations whose declaration context, interpreted as a Decl, matches `InnerMatcher`.

Given

namespace N {
namespace M {
class D {};
}
}

`cxxRcordDecl`(hasDeclContext(namedDecl(hasName("M")))) matches the declaration of `class` `D`.

Definition at line 5785 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [73/82]

clang::ast_matchers::AST_MATCHER_P | ( | NestedNameSpecifier | ,
|  | specifiesType | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher |
| ) |  |

Matches nested name specifiers that specify a type matching the given `QualType` matcher without qualifiers.

Given

struct A { struct B { struct C {}; }; };
A::B::C c;

nestedNameSpecifier(specifiesType( hasDeclaration(cxxRecordDecl(hasName("A"))) )) matches "A::"

Definition at line 5833 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [74/82]

clang::ast_matchers::AST_MATCHER_P | ( | NestedNameSpecifierLoc | ,
|  | specifiesTypeLoc | ,
|  | internal::Matcher< TypeLoc > | ,
|  | InnerMatcher |
| ) |  |

Matches nested name specifier locs that specify a type matching the given `TypeLoc`.

Given

struct A { struct B { struct C {}; }; };
A::B::C c;

nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( hasDeclaration(cxxRecordDecl(hasName("A"))))))) matches "A::"

Definition at line 5851 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [75/82]

clang::ast_matchers::AST_MATCHER_P | ( | NestedNameSpecifier | ,
|  | specifiesNamespace | ,
|  | internal::Matcher< NamespaceDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches nested name specifiers that specify a namespace matching the given namespace matcher.

Given

namespace ns { struct A {}; }
ns::A a;

nestedNameSpecifier(specifiesNamespace(hasName("ns"))) matches "ns::"

Definition at line 5903 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [76/82]

clang::ast_matchers::AST_MATCHER_P | ( | SwitchStmt | ,
|  | forEachSwitchCase | ,
|  | internal::Matcher< SwitchCase > | ,
|  | InnerMatcher |
| ) |  |

Matches each case or default statement belonging to the given switch statement.

This matcher may produce multiple matches.

Given

switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }

switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") matches four times, with "c" binding each of "case 1:", "case 2:", "case 3:" and "case 4:", and "s" respectively binding "switch (1)", "switch (1)", "switch (2)" and "switch (2)".

Definition at line 5946 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [77/82]

clang::ast_matchers::AST_MATCHER_P | ( | CXXConstructorDecl | ,
|  | forEachConstructorInitializer | ,
|  | internal::Matcher< CXXCtorInitializer > | ,
|  | InnerMatcher |
| ) |  |

Matches each constructor initializer in a constructor definition.

Given

class A { A() : i(42), j(42) {} int i; int j; };

cxxConstructorDecl(forEachConstructorInitializer( forField(decl().bind("x")) )) will trigger two matches, binding for 'i' and 'j' respectively.

Definition at line 5977 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [78/82]

clang::ast_matchers::AST_MATCHER_P | ( | CaseStmt | ,
|  | hasCaseConstant | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

If the given case statement does not use the GNU case range extension, matches the constant given in the statement.

Given

switch (1) { case 1: case 1+1: case 3 ... 4: ; }

caseStmt(hasCaseConstant(integerLiteral())) matches "case 1:"

Definition at line 6121 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [79/82]

clang::ast_matchers::AST_MATCHER_P | ( | Decl | ,
|  | hasAttr | ,
|  | attr::Kind | ,
|  | AttrKind |
| ) |  |

Matches declaration that has a given attribute.

Given

__attribute__((device)) void f() { ... }

decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of f. If the matcher is use from clang-query, attr::Kind parameter should be passed as a quoted string. e.g., hasAttr("attr::CUDADevice").

Definition at line 6138 of file ASTMatchers.h.

References clang::Attr::getKind(), and Node.

## ◆ AST_MATCHER_P() [80/82]

clang::ast_matchers::AST_MATCHER_P | ( | ReturnStmt | ,
|  | hasReturnValue | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches the return value expression of a return statement.

Given

return a + b;

hasReturnValue(binaryOperator()) matches 'return a + b' with binaryOperator() matching 'a + b'

Definition at line 6156 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [81/82]

clang::ast_matchers::AST_MATCHER_P | ( | Stmt | ,
|  | forFunction | ,
|  | internal::Matcher< FunctionDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches declaration of the function the statement belongs to.

Given:

F& operator=(const F& o) {
std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
return *this;
}

returnStmt(forFunction(hasName("operator="))) matches 'return *this' but does match 'return > 0'

Definition at line 6205 of file ASTMatchers.h.

## ◆ AST_MATCHER_P() [82/82]

clang::ast_matchers::AST_MATCHER_P | ( | CXXNewExpr | ,
|  | hasArraySize | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches array new expressions with a given array size.

Given:

MyClass *p1 = new MyClass[10];

cxxNewExpr(hasArraySize(intgerLiteral(equals(10)))) matches the expression 'new MyClass[10]'.

Definition at line 6286 of file ASTMatchers.h.

## ◆ AST_MATCHER_P2() [1/2]

clang::ast_matchers::AST_MATCHER_P2 | ( | InitListExpr | ,
|  | hasInit | ,
|  | unsigned | ,
|  | N | ,
|  | ast_matchers::internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches the n'th item of an initializer list expression.

Example matches y. (matcher = initListExpr(hasInit(0, expr())))

int x{y}.

Definition at line 3524 of file ASTMatchers.h.

## ◆ AST_MATCHER_P2() [2/2]

clang::ast_matchers::AST_MATCHER_P2 | ( | DeclStmt | ,
|  | containsDeclaration | ,
|  | unsigned | ,
|  | N | ,
|  | internal::Matcher< Decl > | ,
|  | InnerMatcher |
| ) |  |

Matches the n'th declaration of a declaration statement.

Note that this does not work for global declarations because the AST breaks up multiple-declaration DeclStmt's into multiple single-declaration DeclStmt's. Example: Given non-global declarations

int a, b = 0;
int c;
int d = 2, e;

declStmt(containsDeclaration( 0, varDecl(hasInitializer(anything())))) matches only 'int d = 2, e;', and declStmt(containsDeclaration(1, varDecl()))

matches 'int a, b = 0' as well as 'int d = 2, e;'
but 'int c;' is not matched.

Definition at line 3564 of file ASTMatchers.h.

## ◆ AST_MATCHER_P_OVERLOAD() [1/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | QualType | ,
|  | ignoringParens | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher | ,
|  | 0 |
| ) |  |

Matches types that match InnerMatcher after any parens are stripped.

Given

void (*fp)(void);

The matcher

varDecl(hasType(pointerType(pointee(ignoringParens(functionType())))))

would match the declaration for fp.

Definition at line 814 of file ASTMatchers.h.

## ◆ AST_MATCHER_P_OVERLOAD() [2/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | Expr | ,
|  | ignoringParens | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher | ,
|  | 1 |
| ) |  |

Overload `ignoringParens` for `Expr`.

Given

const char* str = ("my-string");

The matcher

implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral())))

would match the implicit cast resulting from the assignment.

Definition at line 830 of file ASTMatchers.h.

## ◆ AST_MATCHER_P_OVERLOAD() [3/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | CXXRecordDecl | ,
|  | isDerivedFrom | ,
|  | std::string | ,
|  | BaseName | ,
|  | 1 |
| ) |  |

Overloaded method as shortcut for `isDerivedFrom`(hasName(...)).

Definition at line 2622 of file ASTMatchers.h.

References hasName(), and Node.

## ◆ AST_MATCHER_P_OVERLOAD() [4/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | CXXRecordDecl | ,
|  | isSameOrDerivedFrom | ,
|  | internal::Matcher< NamedDecl > | ,
|  | Base | ,
|  | 0 |
| ) |  |

Similar to `isDerivedFrom()`, but also matches classes that directly match `Base`.

Definition at line 2629 of file ASTMatchers.h.

References anyOf, clang::threadSafety::sx::matches(), and Node.

## ◆ AST_MATCHER_P_OVERLOAD() [5/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | CXXRecordDecl | ,
|  | isSameOrDerivedFrom | ,
|  | std::string | ,
|  | BaseName | ,
|  | 1 |
| ) |  |

Overloaded method as shortcut for `isSameOrDerivedFrom`(hasName(...)).

Definition at line 2637 of file ASTMatchers.h.

References hasName(), and Node.

## ◆ AST_MATCHER_P_OVERLOAD() [6/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | CallExpr | ,
|  | callee | ,
|  | internal::Matcher< Decl > | ,
|  | InnerMatcher | ,
|  | 1 |
| ) |  |

Matches if the call expression's callee's declaration matches the given matcher.

Example matches y.x() (matcher = callExpr(callee( cxxMethodDecl(hasName("x")))))

class Y { public: void x(); };
void z() { Y y; y.x(); }

Definition at line 3086 of file ASTMatchers.h.

## ◆ AST_MATCHER_P_OVERLOAD() [7/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | QualType | ,
|  | pointsTo | ,
|  | internal::Matcher< Decl > | ,
|  | InnerMatcher | ,
|  | 1 |
| ) |  |

Overloaded to match the pointee type's declaration.

Definition at line 3190 of file ASTMatchers.h.

## ◆ AST_MATCHER_P_OVERLOAD() [8/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | QualType | ,
|  | references | ,
|  | internal::Matcher< Decl > | ,
|  | InnerMatcher | ,
|  | 1 |
| ) |  |

Overloaded to match the referenced type's declaration.

Definition at line 3251 of file ASTMatchers.h.

## ◆ AST_MATCHER_P_OVERLOAD() [9/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | CXXMemberCallExpr | ,
|  | thisPointerType | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher | ,
|  | 0 |
| ) |  |

Matches if the expression's type either matches the specified matcher, or is a pointer to a type that matches the InnerMatcher.

Definition at line 3266 of file ASTMatchers.h.

## ◆ AST_MATCHER_P_OVERLOAD() [10/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | CXXMemberCallExpr | ,
|  | thisPointerType | ,
|  | internal::Matcher< Decl > | ,
|  | InnerMatcher | ,
|  | 1 |
| ) |  |

Overloaded to match the type's declaration.

Definition at line 3274 of file ASTMatchers.h.

## ◆ AST_MATCHER_P_OVERLOAD() [11/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | NestedNameSpecifier | ,
|  | hasPrefix | ,
|  | internal::Matcher< NestedNameSpecifier > | ,
|  | InnerMatcher | ,
|  | 0 |
| ) |  |

Matches on the prefix of a `NestedNameSpecifier`.

Given

struct A { struct B { struct C {}; }; };
A::B::C c;

nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and matches "A::"

Definition at line 5866 of file ASTMatchers.h.

## ◆ AST_MATCHER_P_OVERLOAD() [12/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | NestedNameSpecifierLoc | ,
|  | hasPrefix | ,
|  | internal::Matcher< NestedNameSpecifierLoc > | ,
|  | InnerMatcher | ,
|  | 1 |
| ) |  |

Matches on the prefix of a `NestedNameSpecifierLoc`.

Given

struct A { struct B { struct C {}; }; };
A::B::C c;

nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) matches "A::"

Definition at line 5884 of file ASTMatchers.h.

## ◆ AST_MATCHER_P_OVERLOAD() [13/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | Decl | ,
|  | equalsNode | ,
|  | const Decl * | ,
|  | Other | ,
|  | 0 |
| ) |  |

Overloads for the `equalsNode` matcher.

FIXME: Implement for other node types.Matches if a node equals another node.

`Decl` has pointer identity in the AST.

Definition at line 5917 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER_P_OVERLOAD() [14/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | Stmt | ,
|  | equalsNode | ,
|  | const Stmt * | ,
|  | Other | ,
|  | 1 |
| ) |  |

Matches if a node equals another node.

`Stmt` has pointer identity in the AST.

Definition at line 5923 of file ASTMatchers.h.

References Node.

## ◆ AST_MATCHER_P_OVERLOAD() [15/15]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD | ( | Type | ,
|  | equalsNode | ,
|  | const Type * | ,
|  | Other | ,
|  | 2 |
| ) |  |

Matches if a node equals another node.

`Type` has pointer identity in the AST.

Definition at line 5929 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER() [1/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | isExpansionInMainFile | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc) |
| ) |  |

Matches AST nodes that were expanded within the main-file.

Example matches X but not Y (matcher = cxxRecordDecl(isExpansionInMainFile())

#include <Y.h>
class X {};

Y.h:

class Y {};

Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>

Definition at line 244 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER() [2/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | isExpansionInSystemHeader | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc) |
| ) |  |

Matches AST nodes that were expanded within system-header-files.

Example matches Y but not X (matcher = cxxRecordDecl(isExpansionInSystemHeader())

#include <SystemHeader.h>
class X {};

SystemHeader.h:

class Y {};

Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>

Definition at line 265 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER() [3/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | isExternC | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, VarDecl) |
| ) |  |

Matches extern "C" function or variable declarations.

Given:

extern "C" void f() {}
extern "C" { void g() {} }
void h() {}
extern "C" int x = 1;
extern "C" int y = 2;
int z = 3;

functionDecl(isExternC()) matches the declaration of f and g, but not the declaration of h. varDecl(isExternC()) matches the declaration of x and y, but not the declaration of z.

Definition at line 3955 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER() [4/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | isStaticStorageClass | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, VarDecl) |
| ) |  |

Matches variable/function declarations that have "static" storage class specifier ("static" keyword) written in the source.

Given:

static void f() {}
static int i = 0;
extern int j;
int k;

functionDecl(isStaticStorageClass()) matches the function declaration f. varDecl(isStaticStorageClass()) matches the variable declaration i.

Definition at line 3974 of file ASTMatchers.h.

References Node, and clang::SC_Static.

## ◆ AST_POLYMORPHIC_MATCHER() [5/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | hasDynamicExceptionSpec | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, FunctionProtoType) |
| ) |  |

Matches functions that have a dynamic exception specification.

Given:

void f();
void g() noexcept;
void h() noexcept(true);
void i() noexcept(false);
void j() throw();
void k() throw(int);
void l() throw(...);

functionDecl(hasDynamicExceptionSpec()) and functionProtoType(hasDynamicExceptionSpec()) match the declarations of j, k, and l, but not f, g, h, or i.

Definition at line 4021 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER() [6/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | isNoThrow | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, FunctionProtoType) |
| ) |  |

Matches functions that have a non-throwing exception specification.

Given:

void f();
void g() noexcept;
void h() throw();
void i() throw(int);
void j() noexcept(false);

functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) match the declarations of g, and h, but not f, i or j.

Definition at line 4041 of file ASTMatchers.h.

References clang::FunctionProtoType::getExceptionSpecType(), clang::FunctionProtoType::isNothrow(), clang::isUnresolvedExceptionSpec(), and Node.

## ◆ AST_POLYMORPHIC_MATCHER() [7/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | isConstexpr | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(VarDecl, FunctionDecl, IfStmt) |
| ) |  |

Matches constexpr variable and function declarations, and if constexpr.

Given:

constexpr int foo = 42;
constexpr int bar();
void baz() { if constexpr(1 > 0) {} }

varDecl(isConstexpr()) matches the declaration of foo. functionDecl(isConstexpr()) matches the declaration of bar. ifStmt(isConstexpr()) matches the if statement in baz.

Definition at line 4074 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER() [8/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | isAssignmentOperator | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr) |
| ) |  |

Matches all kinds of assignment operators.

Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))

if (a == b)
a += b;

Example 2: matches s1 = s2 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))

struct S { S& operator=(const S&); };
void x() { S s1, s2; s1 = s2; })

Definition at line 4353 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER() [9/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | isDefinition | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(TagDecl, VarDecl, ObjCMethodDecl, FunctionDecl) |
| ) |  |

Matches if a declaration has a body attached.

Example matches A, va, fa

class A {};
class B; // Doesn't match, as it has no body.
int va;
extern int vb; // Doesn't match, as it doesn't define the variable.
void fa() {}
void fb(); // Doesn't match, as it has no body.
@interface X
- (void)ma; // Doesn't match, interface is declaration.
@end
@implementation X
- (void)ma {}
@end

Usable as: Matcher<TagDecl>, Matcher<VarDecl>, Matcher<FunctionDecl>, Matcher<ObjCMethodDecl>

Definition at line 4554 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER() [10/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | isFinal | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, CXXMethodDecl) |
| ) |  |

Matches if the given method or class declaration is final.

Given:

class A final {};
struct B {
virtual void f();
};
struct C : B {
void f() final;
};

matches A and C::f, but not B, C, or B::f

Definition at line 4687 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER() [11/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | isArrow | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, UnresolvedMemberExpr, CXXDependentScopeMemberExpr) |
| ) |  |

Matches member expressions that are called with '->' as opposed to '.

'.

Member calls on the implicit this pointer match as called with '->'.

Given

class Y {
void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
template <class T> void f() { this->f<T>(); f<T>(); }
int a;
static int b;
};
template <class T>
class Z {
void x() { this->m; }
};

memberExpr(isArrow()) matches this->x, x, y.x, a, this->b cxxDependentScopeMemberExpr(isArrow()) matches this->m unresolvedMemberExpr(isArrow()) matches this->f<T>, f<T>

Definition at line 4813 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER() [12/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | isTemplateInstantiation | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, VarDecl, CXXRecordDecl) |
| ) |  |

Matches template instantiations of function, class, or static member variable template instantiations.

Given

template <typename T> class X {}; class A {}; X<A> x;

or

template <typename T> class X {}; class A {}; template class X<A>;

or

template <typename T> class X {}; class A {}; extern template class X<A>;

cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) matches the template instantiation of X.

But given

template <typename T> class X {}; class A {};
template <> class X<A> {}; X<A> x;

cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) does not match, as X is an explicit template specialization.

Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>

Definition at line 5052 of file ASTMatchers.h.

References Node, clang::TSK_ExplicitInstantiationDeclaration, clang::TSK_ExplicitInstantiationDefinition, and clang::TSK_ImplicitInstantiation.

## ◆ AST_POLYMORPHIC_MATCHER() [13/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | isExplicitTemplateSpecialization | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, VarDecl, CXXRecordDecl) |
| ) |  |

Matches explicit template specializations of function, class, or static member variable template instantiations.

Given

template<typename T> void A(T t) { }
template<> void A(int N) { }

functionDecl(isExplicitTemplateSpecialization()) matches the specialization A<int>().

Usable as: Matcher<FunctionDecl>, Matcher<VarDecl>, Matcher<CXXRecordDecl>

Definition at line 5111 of file ASTMatchers.h.

References Node, and clang::TSK_ExplicitSpecialization.

## ◆ AST_POLYMORPHIC_MATCHER() [14/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | isExplicit | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(CXXConstructorDecl, CXXConversionDecl) |
| ) |  |

Matches constructor and conversion declarations that are marked with the explicit keyword.

Given

struct S {
S(int); // #1
explicit S(double); // #2
operator int(); // #3
explicit operator bool(); // #4
};

cxxConstructorDecl(isExplicit()) will match #2, but not #1. cxxConversionDecl(isExplicit()) will match #4, but not #3.

Definition at line 6068 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER() [15/15]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER | ( | isInline | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(NamespaceDecl, FunctionDecl) |
| ) |  |

Matches function and namespace declarations that are marked with the inline keyword.

Given

inline void f();
void g();
namespace n {
inline namespace m {}
}

functionDecl(isInline()) will match ::f(). namespaceDecl(isInline()) will match n::m.

Definition at line 6087 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER_P() [1/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | isExpansionInFileMatching | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc) | ,
|  | std::string | ,
|  | RegExp |
| ) |  |

Matches AST nodes that were expanded within files whose name is partially matching a given regex.

Example matches Y but not X (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))

#include "ASTMatcher.h"
class X {};

ASTMatcher.h:

class Y {};

Usable as: Matcher<Decl>, Matcher<Stmt>, Matcher<TypeLoc>

Definition at line 290 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P() [2/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | hasAnyTemplateArgument | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl, TemplateSpecializationType, FunctionDecl) | ,
|  | internal::Matcher< TemplateArgument > | ,
|  | InnerMatcher |
| ) |  |

Matches classTemplateSpecializations, templateSpecializationType and functionDecl that have at least one TemplateArgument matching the given InnerMatcher.

Given

template<typename T> class A {};
template<> class A<double> {};
A<int> a;
template<typename T> f() {};
void func() { f<int>(); };

classTemplateSpecializationDecl(hasAnyTemplateArgument( refersToType(asString("int")))) matches the specialization `A<int>`

functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) matches the specialization `f<int>`

Definition at line 688 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P() [3/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | templateArgumentCountIs | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl, TemplateSpecializationType) | ,
|  | unsigned | ,
|  | N |
| ) |  |

Matches if the number of template arguments equals `N`.

Given

template<typename T> struct C {};
C<int> c;

classTemplateSpecializationDecl(templateArgumentCountIs(1)) matches C<int>.

Definition at line 918 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER_P() [4/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | argumentCountIs | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr, CXXConstructExpr, ObjCMessageExpr) | ,
|  | unsigned | ,
|  | N |
| ) |  |

Checks that a call expression or a constructor call expression has a specific number of arguments (including absent default arguments).

Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))

void f(int x, int y);
f(0, 0);

Definition at line 3491 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER_P() [5/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | hasAnyArgument | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES( CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr) | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches any argument of a call expression or a constructor call expression, or an ObjC-message-send expression.

Given

void x(int, int, int) { int y; x(1, y, 42); }

callExpr(hasAnyArgument(declRefExpr())) matches x(1, y, 42) with hasAnyArgument(...) matching y

For ObjectiveC, given

@interface I - (void) f:(int) y; @end
void foo(I *i) { [i f:12]; }

objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) matches [i f:12]

Definition at line 3726 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P() [6/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | hasAnyParameter | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, ObjCMethodDecl, BlockDecl) | ,
|  | internal::Matcher< ParmVarDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches any parameter of a function or an ObjC method declaration or a block.

Does not match the 'this' parameter of a method.

Given

class X { void f(int x, int y, int z) {} };

cxxMethodDecl(hasAnyParameter(hasName("y"))) matches f(int x, int y, int z) {} with hasAnyParameter(...) matching int y

For ObjectiveC, given

@interface I - (void) f:(int) y; @end

the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) matches the declaration of method f with hasParameter matching y.

For blocks, given

b = ^(int y) { printf("%d", y) };

the matcher blockDecl(hasAnyParameter(hasName("y"))) matches the declaration of the block b with hasParameter matching y.

Definition at line 3877 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P() [7/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | parameterCountIs | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, FunctionProtoType) | ,
|  | unsigned | ,
|  | N |
| ) |  |

Matches `FunctionDecls` and `FunctionProtoTypes` that have a specific parameter count.

Given

void f(int i) {}
void g(int i, int j) {}
void h(int i, int j);
void j(int i);
void k(int x, int y, int z, ...);

functionDecl(parameterCountIs(2)) matches `g` and `h` functionProtoType(parameterCountIs(2)) matches `g` and `h` functionProtoType(parameterCountIs(3)) matches `k`

Definition at line 3904 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER_P() [8/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | hasCondition | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(IfStmt, ForStmt, WhileStmt, DoStmt, SwitchStmt, AbstractConditionalOperator) | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches the condition expression of an if statement, for loop, switch statement or conditional operator.

Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))

if (true) {}

Definition at line 4088 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P() [9/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | equalsBoundNode | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(Stmt, Decl, Type, QualType) | ,
|  | std::string | ,
|  | ID |
| ) |  |

Matches if a node equals a previously bound node.

Matches a node if it equals the node previously bound to `ID`.

Given

class X { int a; int b; };

cxxRecordDecl( has(fieldDecl(hasName("a"), hasType(type().bind("t")))), has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) matches the class `X`, as `a` and `b` have the same type.

Note that when multiple matches are involved via `forEach*` matchers, `equalsBoundNodes` acts as a filter. For example: compoundStmt( forEachDescendant(varDecl().bind("d")), forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) will trigger a match for each combination of variable declaration and reference to that variable declaration within a compound statement.

Definition at line 4143 of file ASTMatchers.h.

References clang::ast_type_traits::DynTypedNode::create(), and Node.

## ◆ AST_POLYMORPHIC_MATCHER_P() [10/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | hasBody | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(DoStmt, ForStmt, WhileStmt, CXXForRangeStmt, FunctionDecl) | ,
|  | internal::Matcher< Stmt > | ,
|  | InnerMatcher |
| ) |  |

Matches a 'for', 'while', 'do while' statement or a function definition that has a given body.

Given

for (;;) {}

hasBody(compoundStmt()) matches 'for (;;) {}' with compoundStmt() matching '{}'

Definition at line 4219 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P() [11/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | hasAnySubstatement | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(CompoundStmt, StmtExpr) | ,
|  | internal::Matcher< Stmt > | ,
|  | InnerMatcher |
| ) |  |

Matches compound statements where at least one substatement matches a given matcher.

Also matches StmtExprs that have CompoundStmt as children.

Given

{ {}; 1+2; }

hasAnySubstatement(compoundStmt()) matches '{ {}; 1+2; }' with compoundStmt() matching '{}'

Definition at line 4241 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P() [12/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | hasOperatorName | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, UnaryOperator) | ,
|  | std::string | ,
|  | Name |
| ) |  |

Matches the operator Name of operator expressions (binary or unary).

Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))

!(a || b)

Definition at line 4332 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P() [13/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | hasLHS | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, ArraySubscriptExpr) | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches the left hand side of binary operator expressions.

Example matches a (matcher = binaryOperator(hasLHS()))

a || b

Definition at line 4365 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P() [14/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | hasRHS | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, ArraySubscriptExpr) | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches the right hand side of binary operator expressions.

Example matches b (matcher = binaryOperator(hasRHS()))

a || b

Definition at line 4380 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P() [15/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | hasSourceExpression | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(CastExpr, OpaqueValueExpr) | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches if the cast's source expression or opaque value's source expression matches the given matcher.

Example 1: matches "a string" (matcher = castExpr(hasSourceExpression(cxxConstructExpr())))

class URL { URL(string); };
URL url = "a string";

Example 2: matches 'b' (matcher = opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))

int a = b ?: 1;

Definition at line 4425 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P() [16/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | hasObjectExpression | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, UnresolvedMemberExpr, CXXDependentScopeMemberExpr) | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches a member expression where the object expression is matched by a given matcher.

Given

struct X { int m; };
void f(X x) { x.m; m; }

memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))))) matches "x.m" and "m" with hasObjectExpression(...) matching "x" and the implicit object expression of "m" which has type X*.

Definition at line 4979 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P() [17/17]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P | ( | hasSize | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(ConstantArrayType, StringLiteral) | ,
|  | unsigned | ,
|  | N |
| ) |  |

Matches nodes that have the specified size.

Given

int a[42];
int b[2 * 21];
int c[41], d[43];
char *s = "abcd";
wchar_t *ws = L"abcd";
char *w = "a";

constantArrayType(hasSize(42)) matches "int a[42]" and "int b[2 * 21]" stringLiteral(hasSize(4)) matches "abcd", L"abcd"

Definition at line 5247 of file ASTMatchers.h.

References dependentSizedArrayType, incompleteArrayType, Node, and variableArrayType.

## ◆ AST_POLYMORPHIC_MATCHER_P2() [1/4]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P2 | ( | hasTemplateArgument | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl, TemplateSpecializationType, FunctionDecl) | ,
|  | unsigned | ,
|  | N | ,
|  | internal::Matcher< TemplateArgument > | ,
|  | InnerMatcher |
| ) |  |

Matches classTemplateSpecializations, templateSpecializationType and functionDecl where the n'th TemplateArgument matches the given InnerMatcher.

Given

template<typename T, typename U> class A {};
A<bool, int> b;
A<int, bool> c;
template<typename T> void f() {}
void func() { f<int>(); };

classTemplateSpecializationDecl(hasTemplateArgument( 1, refersToType(asString("int")))) matches the specialization `A<bool, int>`

functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) matches the specialization `f<int>`

Definition at line 896 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P2() [2/4]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P2 | ( | hasArgument | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr, CXXConstructExpr, ObjCMessageExpr) | ,
|  | unsigned | ,
|  | N | ,
|  | internal::Matcher< Expr > | ,
|  | InnerMatcher |
| ) |  |

Matches the n'th argument of a call expression or a constructor call expression.

Example matches y in x(y) (matcher = callExpr(hasArgument(0, declRefExpr())))

void x(int) { int y; x(y); }

Definition at line 3507 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P2() [3/4]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P2 | ( | hasParameter | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, ObjCMethodDecl, BlockDecl) | ,
|  | unsigned | ,
|  | N | ,
|  | internal::Matcher< ParmVarDecl > | ,
|  | InnerMatcher |
| ) |  |

Matches the n'th parameter of a function or an ObjC method declaration or a block.

Given

class X { void f(int x) {} };

cxxMethodDecl(hasParameter(0, hasType(varDecl()))) matches f(int x) {} with hasParameter(...) matching int x

For ObjectiveC, given

@interface I - (void) f:(int) y; @end

the matcher objcMethodDecl(hasParameter(0, hasName("y"))) matches the declaration of method f with hasParameter matching y.

Definition at line 3782 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P2() [4/4]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P2 | ( | forEachArgumentWithParam | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr, CXXConstructExpr) | ,
|  | internal::Matcher< Expr > | ,
|  | ArgMatcher | ,
|  | internal::Matcher< ParmVarDecl > | ,
|  | ParamMatcher |
| ) |  |

Matches all arguments and their respective ParmVarDecl.

Given

void f(int i);
int y;
f(y);

callExpr( forEachArgumentWithParam( declRefExpr(to(varDecl(hasName("y")))), parmVarDecl(hasType(isInteger())) )) matches f(y); with declRefExpr(...) matching int y and parmVarDecl(...) matching int i

Definition at line 3810 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [1/5]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P_OVERLOAD | ( | hasType | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, TypedefNameDecl, ValueDecl) | ,
|  | internal::Matcher< QualType > | ,
|  | InnerMatcher | ,
|  | 0 |
| ) |  |

Matches if the expression's or declaration's type matches a type matcher.

Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) and U (matcher = typedefDecl(hasType(asString("int"))) and friend class X (matcher = friendDecl(hasType("X"))

class X {};
void y(X &x) { x; X z; }
typedef int U;
class Y { friend class X; };

Definition at line 3104 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [2/5]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P_OVERLOAD | ( | hasType | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl) | ,
|  | internal::Matcher< Decl > | ,
|  | InnerMatcher | ,
|  | 1 |
| ) |  |

Overloaded to match the declaration of the expression's or value declaration's type.

In case of a value declaration (for example a variable declaration), this resolves one layer of indirection. For example, in the value declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the declaration of x.

Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) and friend class X (matcher = friendDecl(hasType("X"))

class X {};
void y(X &x) { x; X z; }
class Y { friend class X; };

Usable as: Matcher<Expr>, Matcher<ValueDecl>

Definition at line 3134 of file ASTMatchers.h.

## ◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [3/5]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P_OVERLOAD | ( | equals | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral, CXXBoolLiteralExpr, IntegerLiteral) | ,
|  | bool | ,
|  | Value | ,
|  | 0 |
| ) |  |

Definition at line 4297 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [4/5]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P_OVERLOAD | ( | equals | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral, CXXBoolLiteralExpr, IntegerLiteral) | ,
|  | unsigned | ,
|  | Value | ,
|  | 1 |
| ) |  |

Definition at line 4306 of file ASTMatchers.h.

References Node.

## ◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [5/5]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P_OVERLOAD | ( | equals | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(CharacterLiteral, CXXBoolLiteralExpr, FloatingLiteral, IntegerLiteral) | ,
|  | double | ,
|  | Value | ,
|  | 2 |
| ) |  |

Definition at line 4315 of file ASTMatchers.h.

References Node.

## ◆ AST_TYPE_TRAVERSE_MATCHER() [1/4]

clang::ast_matchers::AST_TYPE_TRAVERSE_MATCHER | ( | hasDeducedType | ,
|  | getDeducedType | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(AutoType) |
| ) |  |

Matches `AutoType` nodes where the deduced type is a specific type.

Note: There is no `TypeLoc` for the deduced type and thus no `getDeducedLoc()` matcher.

Given

auto a = 1;
auto b = 2.0;

autoType(hasDeducedType(isInteger())) matches "auto a"

Usable as: Matcher<AutoType>

## ◆ AST_TYPE_TRAVERSE_MATCHER() [2/4]

clang::ast_matchers::AST_TYPE_TRAVERSE_MATCHER | ( | hasUnderlyingType | ,
|  | getUnderlyingType | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(DecltypeType) |
| ) |  |

Matches `DecltypeType` nodes to find out the underlying type.

Given

decltype(1) a = 1;
decltype(2.0) b = 2.0;

decltypeType(hasUnderlyingType(isInteger())) matches the type of "a"

Usable as: Matcher<DecltypeType>

## ◆ AST_TYPE_TRAVERSE_MATCHER() [3/4]

clang::ast_matchers::AST_TYPE_TRAVERSE_MATCHER | ( | innerType | ,
|  | getInnerType | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(ParenType) |
| ) |  |

Matches `ParenType` nodes where the inner type is a specific type.

Given

int (*ptr_to_array)[4];
int (*ptr_to_func)(int);

`varDecl`(hasType(pointsTo(parenType(innerType(functionType()))))) matches `ptr_to_func` but not `ptr_to_array`.

Usable as: Matcher<ParenType>

## ◆ AST_TYPE_TRAVERSE_MATCHER() [4/4]

clang::ast_matchers::AST_TYPE_TRAVERSE_MATCHER | ( | hasReplacementType | ,
|  | getReplacementType | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(SubstTemplateTypeParmType) |
| ) |  |

Matches template type parameter substitutions that have a replacement type that matches the provided matcher.

Given

template <typename T>
double F(T t);
int i;
double j = F(i);

`substTemplateTypeParmType`(hasReplacementType(type())) matches int

## ◆ AST_TYPELOC_TRAVERSE_MATCHER_DECL() [1/3]

clang::ast_matchers::AST_TYPELOC_TRAVERSE_MATCHER_DECL | ( | hasElementType | ,
|  | getElement | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(ArrayType, ComplexType) |
| ) |  |

Matches arrays and C99 complex types that have a specific element type.

Given

struct A {};
A a[7];
int b[7];

arrayType(hasElementType(builtinType())) matches "int b[7]"

Usable as: Matcher<ArrayType>, Matcher<ComplexType>

Referenced by AST_MATCHER().

## ◆ AST_TYPELOC_TRAVERSE_MATCHER_DECL() [2/3]

clang::ast_matchers::AST_TYPELOC_TRAVERSE_MATCHER_DECL | ( | hasValueType | ,
|  | getValue | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(AtomicType) |
| ) |  |

Matches atomic types with a specific value type.

Given

_Atomic(int) i;
_Atomic(float) f;

atomicType(hasValueType(isInteger())) matches "_Atomic(int) i"

Usable as: Matcher<AtomicType>

## ◆ AST_TYPELOC_TRAVERSE_MATCHER_DECL() [3/3]

clang::ast_matchers::AST_TYPELOC_TRAVERSE_MATCHER_DECL | ( | pointee | ,
|  | getPointee | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType, MemberPointerType, PointerType, ReferenceType) |
| ) |  |

Narrows PointerType (and similar) matchers to those where the `pointee` matches a given matcher.

Given

int *a;
int const *b;
float const *f;

pointerType(pointee(isConstQualified(), isInteger())) matches "int const *b"

Usable as: Matcher<BlockPointerType>, Matcher<MemberPointerType>, Matcher<PointerType>, Matcher<ReferenceType>

## ◆ AST_TYPELOC_TRAVERSE_MATCHER_DEF() [1/3]

clang::ast_matchers::AST_TYPELOC_TRAVERSE_MATCHER_DEF | ( | hasElementType | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(ArrayType, ComplexType) |
| ) |  |

## ◆ AST_TYPELOC_TRAVERSE_MATCHER_DEF() [2/3]

clang::ast_matchers::AST_TYPELOC_TRAVERSE_MATCHER_DEF | ( | hasValueType | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(AtomicType) |
| ) |  |

## ◆ AST_TYPELOC_TRAVERSE_MATCHER_DEF() [3/3]

clang::ast_matchers::AST_TYPELOC_TRAVERSE_MATCHER_DEF | ( | pointee | ,
|  | AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType, MemberPointerType, PointerType, ReferenceType) |
| ) |  |

## ◆ equals()

template<typename ValueT >

internal::PolymorphicMatcherWithParam1<internal::ValueEqualsMatcher, ValueT> clang::ast_matchers::equals | ( | const ValueT & | Value | ) |

Matches literals that are equal to the given value of type ValueT.

Given

f('\0', false, 3.14, 42);

characterLiteral(equals(0)) matches '\0' cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) match false floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) match 3.14 integerLiteral(equals(42)) matches 42

Note that you cannot directly match a negative numeric literal because the minus sign is not part of the literal: It is a unary operator whose operand is the positive numeric literal. Instead, you must use a unaryOperator() matcher to match the minus sign:

unaryOperator(hasOperatorName("-"), hasUnaryOperand(integerLiteral(equals(13))))

Usable as: Matcher<CharacterLiteral>, Matcher<CXXBoolLiteralExpr>, Matcher<FloatingLiteral>, Matcher<IntegerLiteral>

Definition at line 4291 of file ASTMatchers.h.

Referenced by AST_MATCHER_FUNCTION().

## ◆ findAll()

template<typename T >

internal::Matcher<T> clang::ast_matchers::findAll | ( | const internal::Matcher< T > & | Matcher | ) |

Matches if the node or any descendant matches.

Generates results for each match.

For example, in:

class A { class B {}; class C {}; };

The matcher:

cxxRecordDecl(hasName("::A"),
findAll(cxxRecordDecl(isDefinition()).bind("m")))

will generate results for `A`, `B` and `C`.

Usable as: Any Matcher

Definition at line 2780 of file ASTMatchers.h.

## ◆ hasDeclaration()

internal::PolymorphicMatcherWithParam1< internal::HasDeclarationMatcher, internal::Matcher<Decl>, void(internal::HasDeclarationSupportedTypes)> clang::ast_matchers::hasDeclaration | ( | const internal::Matcher< Decl > & | InnerMatcher | ) |
| inline

Matches a node if the declaration associated with that node matches the given matcher.

The associated declaration is:

- for type nodes, the declaration of the underlying type
- for CallExpr, the declaration of the callee
- for MemberExpr, the declaration of the referenced member
- for CXXConstructExpr, the declaration of the constructor
- for CXXNewExpr, the declaration of the operator new
- for ObjCIvarExpr, the declaration of the ivar

For type nodes, hasDeclaration will generally match the declaration of the sugared type. Given

class X {};
typedef X Y;
Y y;

in varDecl(hasType(hasDeclaration(decl()))) the decl will match the typedefDecl. A common use case is to match the underlying, desugared type. This can be achieved by using the hasUnqualifiedDesugaredType matcher:

varDecl(hasType(hasUnqualifiedDesugaredType(
recordType(hasDeclaration(decl())))))

In this matcher, the decl will match the CXXRecordDecl of class X.

Usable as: Matcher<AddrLabelExpr>, Matcher<CallExpr>, Matcher<CXXConstructExpr>, Matcher<CXXNewExpr>, Matcher<DeclRefExpr>, Matcher<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, Matcher<TagType>, Matcher<TemplateSpecializationType>, Matcher<TemplateTypeParmType>, Matcher<TypedefType>, Matcher<UnresolvedUsingType>

Definition at line 2865 of file ASTMatchers.h.

Referenced by clang::ento::getAddrTo(), and wasRegionOfInterestModifiedAt().

## ◆ hasEitherOperand()

internal::Matcher<BinaryOperator> clang::ast_matchers::hasEitherOperand | ( | const internal::Matcher< Expr > & | InnerMatcher | ) |
| inline

Matches if either the left hand side or the right hand side of a binary operator matches.

Definition at line 4391 of file ASTMatchers.h.

Referenced by clang::ento::simpleCondition().

## ◆ hasName()

internal::Matcher<NamedDecl> clang::ast_matchers::hasName | ( | const std::string & | Name | ) |
| inline

Matches NamedDecl nodes that have the specified name.

Supports specifying enclosing namespaces or classes by prefixing the name with '<enclosing>::'. Does not match typedefs of an underlying type with the given name.

Example matches X (Name == "X")

class X;

Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")

namespace a { namespace b { class X; } }

Definition at line 2526 of file ASTMatchers.h.

Referenced by AST_MATCHER_P_OVERLOAD(), and clang::Declarator::setDecompositionBindings().

## ◆ hasOverloadedOperatorName()

internal::PolymorphicMatcherWithParam1< internal::HasOverloadedOperatorNameMatcher, StringRef, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl)> clang::ast_matchers::hasOverloadedOperatorName | ( | StringRef | Name | ) |
| inline

Matches overloaded operator names.

Matches overloaded operator names specified in strings without the "operator" prefix: e.g. "<<".

Given:

class A { int operator*(); };
const A &operator<<(const A &a, const A &b);
A a;
a << a; // <-- This matches

`cxxOperatorCallExpr`(hasOverloadedOperatorName("<<"))) matches the specified line and `cxxRecordDecl`(hasMethod(hasOverloadedOperatorName("*"))) matches the declaration of `A`.

Usable as: Matcher<CXXOperatorCallExpr>, Matcher<FunctionDecl>

Definition at line 2589 of file ASTMatchers.h.

## ◆ id()

template<typename T >

internal::Matcher<T> clang::ast_matchers::id | ( | StringRef | ID,
|  | const internal::BindableMatcher< T > & | InnerMatcher
| ) |  |

If the provided matcher matches a node, binds the node to `ID`.

FIXME: Do we want to support this now that we have bind()?

Definition at line 137 of file ASTMatchers.h.

Referenced by buildByrefHelpers(), clang::ASTContext::getAttributedType(), clang::MicrosoftVTableContext::getVFTableLayout(), HandleAddressSpaceTypeAttribute(), HandleExtVectorTypeAttr(), and clang::threadSafety::til::SExpr::setID().

## ◆ match() [1/3]

template<typename MatcherT , typename NodeT >

SmallVector< BoundNodes, 1 > clang::ast_matchers::match | ( | MatcherT | Matcher,
|  | const NodeT & | Node,
|  | ASTContext & | Context
| ) |  |

Returns the results of matching `Matcher` on `Node`.

Collects the `BoundNodes` of all callback invocations when matching `Matcher` on `Node` and returns the collected results.

Multiple results occur when using matchers like `forEachDescendant`, which generate a result for each sub-match.

If you want to find all matches on the sub-tree rooted at `Node` (rather than only the matches on `Node` itself), surround the `Matcher` with a `findAll()`.

See also
  selectFirst

Definition at line 299 of file ASTMatchFinder.h.

Referenced by clang::Sema::ActOnCXXDelete(), AttributesMatch(), ClassImplementsAllMethodsAndProperties(), clang::Sema::ContextualImplicitConverter::ContextualImplicitConverter(), clang::tooling::IncludeCategoryManager::getIncludePriority(), clang::Sema::ICEConvertDiagnoser::ICEConvertDiagnoser(), isSubclass(), MatchTwoAttributeLists(), clang::ASTContext::ObjCQualifiedClassTypesAreCompatible(), clang::ASTContext::ObjCQualifiedIdTypesAreCompatible(), and clang::Sema::WarnExactTypedMethods().

## ◆ match() [2/3]

template<typename MatcherT >

SmallVector< BoundNodes, 1 > clang::ast_matchers::match | ( | MatcherT | Matcher,
|  | const ast_type_traits::DynTypedNode & | Node,
|  | ASTContext & | Context
| ) |  |

Definition at line 288 of file ASTMatchFinder.h.

## ◆ match() [3/3]

template<typename MatcherT >

SmallVector< BoundNodes, 1 > clang::ast_matchers::match | ( | MatcherT | Matcher,
|  | ASTContext & | Context
| ) |  |

Returns the results of matching `Matcher` on the translation unit of `Context` and collects the `BoundNodes` of all callback invocations.

Definition at line 305 of file ASTMatchFinder.h.

## ◆ selectFirst()

template<typename NodeT >

const NodeT* clang::ast_matchers::selectFirst | ( | StringRef | BoundTo,
|  | const SmallVectorImpl< BoundNodes > & | Results
| ) |  |

Returns the first result of type `NodeT` bound to `BoundTo`.

Returns `NULL` if there is no match, or if the matching node cannot be casted to `NodeT`.

This is useful in combanation with `match()`:

const Decl *D = selectFirst<Decl>("id", match(Matcher.bind("id"),
Node, Context));

Definition at line 268 of file ASTMatchFinder.h.

## ◆ sizeOfExpr()

internal::Matcher<Stmt> clang::ast_matchers::sizeOfExpr | ( | const internal::Matcher< UnaryExprOrTypeTraitExpr > & | InnerMatcher | ) |
| inline

Same as unaryExprOrTypeTraitExpr, but only matching sizeof.

Definition at line 2505 of file ASTMatchers.h.

## Variable Documentation

## ◆ accessSpecDecl

const internal::VariadicDynCastAllOfMatcher< Decl, AccessSpecDecl > clang::ast_matchers::accessSpecDecl

Matches C++ access specifier declarations.

Given

class C {
public:
int a;
};

accessSpecDecl() matches 'public:'

Definition at line 583 of file ASTMatchersInternal.cpp.

## ◆ addrLabelExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, AddrLabelExpr > clang::ast_matchers::addrLabelExpr

Matches address of label statements (GNU extension).

Given

FOO: bar();
void *ptr = &&FOO;
goto *bar;

addrLabelExpr() matches '&&FOO'

Definition at line 705 of file ASTMatchersInternal.cpp.

## ◆ allOf

const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> clang::ast_matchers::allOf = {internal::DynTypedMatcher::VO_AllOf}

Matches if all given matchers match.

Usable as: Any Matcher

Definition at line 776 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::assignedToRef(), AST_MATCHER_P(), and clang::ento::forLoopMatcher().

## ◆ anyOf

const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> clang::ast_matchers::anyOf = {internal::DynTypedMatcher::VO_AnyOf}

Matches if any of the given matchers matches.

Usable as: Any Matcher

Definition at line 773 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::assignedToRef(), AST_MATCHER_FUNCTION(), AST_MATCHER_P(), AST_MATCHER_P_OVERLOAD(), clang::ento::changeIntBoundNode(), clang::ento::forLoopMatcher(), clang::ento::hasSuspiciousStmt(), and clang::ento::simpleCondition().

## ◆ arraySubscriptExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ArraySubscriptExpr > clang::ast_matchers::arraySubscriptExpr

Matches array subscript expressions.

Given

int i = a[1];

arraySubscriptExpr() matches "a[1]"

Definition at line 685 of file ASTMatchersInternal.cpp.

## ◆ arrayType

const AstTypeMatcher< ArrayType > clang::ast_matchers::arrayType

Matches all kinds of arrays.

Given

int a[] = { 2, 3 };
int b[4];
void f() { int c[a[0]]; }

arrayType() matches "int a[]", "int b[4]" and "int c[a[0]]";

Definition at line 808 of file ASTMatchersInternal.cpp.

Referenced by clang::CodeGen::swiftcall::SwiftAggLowering::addTypedData(), clang::CodeGen::CodeGenFunction::emitArrayLength(), clang::CodeGen::CodeGenFunction::EmitCXXConstructExpr(), clang::CodeGen::CodeGenFunction::emitDestroy(), emitPartialArrayDestroy(), clang::CodeGen::CodeGenFunction::getArrayInitIndex(), clang::Type::getBaseElementTypeUnsafe(), clang::ASTContext::getDeclAlign(), and clang::CFGImplicitDtor::getDestructorDecl().

## ◆ asmStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, AsmStmt > clang::ast_matchers::asmStmt

Matches asm statements.

int i = 100;
__asm("mov al, 2");

asmStmt() matches '__asm("mov al, 2")'

Definition at line 715 of file ASTMatchersInternal.cpp.

## ◆ atomicExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, AtomicExpr > clang::ast_matchers::atomicExpr

Matches atomic builtins.

Example matches __atomic_load_n(ptr, 1)

void foo() { int *ptr; __atomic_load_n(ptr, 1); }

Definition at line 732 of file ASTMatchersInternal.cpp.

## ◆ atomicType

const AstTypeMatcher< AtomicType > clang::ast_matchers::atomicType

Matches atomic types.

Given

_Atomic(int) i;

atomicType() matches "_Atomic(int) i"

Definition at line 814 of file ASTMatchersInternal.cpp.

Referenced by findPeephole().

## ◆ autoreleasePoolStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAutoreleasePoolStmt > clang::ast_matchers::autoreleasePoolStmt

Matches an Objective-C autorelease pool statement.

Given

@autoreleasepool {
int x = 0;
}

autoreleasePoolStmt(stmt()) matches the declaration of "x" inside the autorelease pool.

Definition at line 552 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ autoType

const AstTypeMatcher< AutoType > clang::ast_matchers::autoType

Matches types nodes representing C++11 auto types.

Given:

auto n = 4;
int v[] = { 2, 3 }
for (auto i : v) { }

autoType() matches "auto n" and "auto i"

Definition at line 815 of file ASTMatchersInternal.cpp.

## ◆ binaryConditionalOperator

const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryConditionalOperator > clang::ast_matchers::binaryConditionalOperator

Matches binary conditional operator expressions (GNU extension).

Example matches a ?: b

(a ?: b) + 42;

Definition at line 740 of file ASTMatchersInternal.cpp.

## ◆ binaryOperator

const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryOperator > clang::ast_matchers::binaryOperator

Matches binary operator expressions.

Example matches a || b

!(a || b)

Definition at line 735 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::changeIntBoundNode(), clang::ento::forLoopMatcher(), clang::ento::simpleCondition(), and wasRegionOfInterestModifiedAt().

## ◆ blockDecl

const internal::VariadicDynCastAllOfMatcher< Decl, BlockDecl > clang::ast_matchers::blockDecl

Matches block declarations.

Example matches the declaration of the nameless block printing an input integer.

myFunc(^(int p) {
printf("%d", p);
})

Definition at line 641 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER(), clang::CodeGen::CodeGenFunction::GenerateBlockFunction(), clang::CodeGen::CGBlockInfo::getBlockExpr(), getBlockLayoutInfoString(), and GetGCAttrTypeForType().

## ◆ blockExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, BlockExpr > clang::ast_matchers::blockExpr

Matches a reference to a block.

Example: matches "^{}":

void f() { ^{}(); }

Definition at line 693 of file ASTMatchersInternal.cpp.

Referenced by clang::CodeGen::CodeGenFunction::EmitBlockLiteral().

## ◆ blockPointerType

const AstTypeMatcher< BlockPointerType > clang::ast_matchers::blockPointerType

Matches block pointer types, i.e.

types syntactically represented as "void (^)(int)".

The `pointee` is always required to be a `FunctionType`.

Definition at line 820 of file ASTMatchersInternal.cpp.

## ◆ breakStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, BreakStmt > clang::ast_matchers::breakStmt

Matches break statements.

Given

while (true) { break; }

breakStmt() matches 'break'

Definition at line 700 of file ASTMatchersInternal.cpp.

## ◆ builtinType

const AstTypeMatcher< BuiltinType > clang::ast_matchers::builtinType

Matches builtin Types.

Given

struct A {};
A a;
int b;
float c;
bool d;

builtinType() matches "int b", "float c" and "bool d"

Definition at line 807 of file ASTMatchersInternal.cpp.

## ◆ callExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > clang::ast_matchers::callExpr

Matches call expressions.

Example matches x.y() and y()

X x;
x.y();
y();

Definition at line 622 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P(), and clang::ento::callByRef().

## ◆ caseStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, CaseStmt > clang::ast_matchers::caseStmt

Matches case statements inside switch statements.

Given

switch(a) { case 42: break; default: break; }

caseStmt() matches 'case 42:'.

Definition at line 708 of file ASTMatchersInternal.cpp.

## ◆ castExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > clang::ast_matchers::castExpr

Matches any cast nodes of Clang's AST.

Example: castExpr() matches each of the following:

(int) 3;
const_cast<Expr *>(SubExpr);
char c = 0;

but does not match

int i = (0);
int k = 0;

Definition at line 759 of file ASTMatchersInternal.cpp.

Referenced by addFixitForObjCARCConversion(), clang::Sema::CheckObjCBridgeRelatedCast(), clang::Sema::CheckTollFreeBridgeCast(), clang::Sema::diagnoseARCUnbridgedCast(), and tryEmitARCCopyWeakInit().

## ◆ characterLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, CharacterLiteral > clang::ast_matchers::characterLiteral

Matches character literals (also matches wchar_t).

Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), though.

Example matches 'a', L'a'

char ch = 'a';
wchar_t chw = L'a';

Definition at line 720 of file ASTMatchersInternal.cpp.

## ◆ classTemplateDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateDecl > clang::ast_matchers::classTemplateDecl

Matches C++ class template declarations.

Example matches `Z`

template<class T> class Z {};

Definition at line 572 of file ASTMatchersInternal.cpp.

## ◆ classTemplatePartialSpecializationDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplatePartialSpecializationDecl > clang::ast_matchers::classTemplatePartialSpecializationDecl

Matches C++ class template partial specializations.

Given

template<class T1, class T2, int I>
class A {};
template<class T, int I>
class A<T, T*, I> {};
template<>
class A<int, int, 1> {};

classTemplatePartialSpecializationDecl() matches the specialization `A<T,T*,I>` but not `A<int,int,1>`

Definition at line 578 of file ASTMatchersInternal.cpp.

## ◆ classTemplateSpecializationDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateSpecializationDecl > clang::ast_matchers::classTemplateSpecializationDecl

Matches C++ class template specializations.

Given

template<typename T> class A {};
template<> class A<double> {};
A<int> a;

classTemplateSpecializationDecl() matches the specializations `A<int>` and `A<double>`

Definition at line 575 of file ASTMatchersInternal.cpp.

## ◆ complexType

const AstTypeMatcher< ComplexType > clang::ast_matchers::complexType

Matches C99 complex types.

Given

_Complex float f;

complexType() matches "_Complex float f"

Definition at line 809 of file ASTMatchersInternal.cpp.

Referenced by clang::CodeGen::swiftcall::SwiftAggLowering::addTypedData().

## ◆ compoundLiteralExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundLiteralExpr > clang::ast_matchers::compoundLiteralExpr

Matches compound (i.e.

non-scalar) literals

Example match: {1}, (1, 2)

int array[4] = {1};
vector int myvec = (vector int)(1, 2);

Definition at line 728 of file ASTMatchersInternal.cpp.

## ◆ compoundStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundStmt > clang::ast_matchers::compoundStmt

Matches compound statements.

Example matches '{}' and '{{}}' in 'for (;;) {{}}'

for (;;) {{}}

Definition at line 710 of file ASTMatchersInternal.cpp.

## ◆ conditionalOperator

const internal::VariadicDynCastAllOfMatcher< Stmt, ConditionalOperator > clang::ast_matchers::conditionalOperator

Matches conditional operator expressions.

Example matches a ? b : c

(a ? b : c) + 42

Definition at line 738 of file ASTMatchersInternal.cpp.

## ◆ constantArrayType

const AstTypeMatcher< ConstantArrayType > clang::ast_matchers::constantArrayType

Matches C arrays with a specified constant size.

Given

void() {
int a[2];
int b[] = { 2, 3 };
int c[b[0]];
}

constantArrayType() matches "int a[2]"

Definition at line 810 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ constantExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ConstantExpr > clang::ast_matchers::constantExpr

Matches a constant expression wrapper.

Example matches the constant in the case statement: (matcher = constantExpr())

switch (a) {
case 37: break;
}

Definition at line 671 of file ASTMatchersInternal.cpp.

## ◆ continueStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ContinueStmt > clang::ast_matchers::continueStmt

Matches continue statements.

Given

while (true) { continue; }

continueStmt() matches 'continue'

Definition at line 701 of file ASTMatchersInternal.cpp.

## ◆ cStyleCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CStyleCastExpr > clang::ast_matchers::cStyleCastExpr

Matches a C-style cast expression.

Example: Matches (int) 2.2f in

int i = (int) 2.2f;

Definition at line 754 of file ASTMatchersInternal.cpp.

## ◆ cudaKernelCallExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CUDAKernelCallExpr > clang::ast_matchers::cudaKernelCallExpr

Matches CUDA kernel call expression.

Example matches,

kernel<<<i,j>>>();

Definition at line 806 of file ASTMatchersInternal.cpp.

## ◆ cxxBindTemporaryExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBindTemporaryExpr > clang::ast_matchers::cxxBindTemporaryExpr

Matches nodes where temporaries are created.

Example matches FunctionTakesString(GetStringByValue()) (matcher = cxxBindTemporaryExpr())

FunctionTakesString(GetStringByValue());
FunctionTakesStringByPointer(GetStringPointer());

Definition at line 679 of file ASTMatchersInternal.cpp.

## ◆ cxxBoolLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBoolLiteralExpr > clang::ast_matchers::cxxBoolLiteral

Matches bool literals.

Example matches true

true

Definition at line 717 of file ASTMatchersInternal.cpp.

## ◆ cxxCatchStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXCatchStmt > clang::ast_matchers::cxxCatchStmt

Matches catch statements.

try {} catch(int i) {}

cxxCatchStmt() matches 'catch(int i)'

Definition at line 711 of file ASTMatchersInternal.cpp.

## ◆ cxxConstCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstCastExpr > clang::ast_matchers::cxxConstCastExpr

Matches a const_cast expression.

Example: Matches const_cast<int*>(&r) in

int n = 42;
const int &r(n);
int* p = const_cast<int*>(&r);

Definition at line 752 of file ASTMatchersInternal.cpp.

## ◆ cxxConstructExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstructExpr > clang::ast_matchers::cxxConstructExpr

Matches constructor call expressions (including implicit ones).

Example matches string(ptr, n) and ptr within arguments of f (matcher = cxxConstructExpr())

void f(const string &a, const string &b);
char *ptr;
int n;
f(string(ptr, n), ptr);

Definition at line 674 of file ASTMatchersInternal.cpp.

## ◆ cxxConstructorDecl

const internal::VariadicDynCastAllOfMatcher< Decl, CXXConstructorDecl > clang::ast_matchers::cxxConstructorDecl

Matches C++ constructor declarations.

Example matches Foo::Foo() and Foo::Foo(int)

class Foo {
public:
Foo();
Foo(int);
int DoSomething();
};

Definition at line 598 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ cxxConversionDecl

const internal::VariadicDynCastAllOfMatcher< Decl, CXXConversionDecl > clang::ast_matchers::cxxConversionDecl

Matches conversion operator declarations.

Example matches the operator.

class X { operator int() const; };

Definition at line 606 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ cxxCtorInitializer

const internal::VariadicAllOfMatcher< CXXCtorInitializer > clang::ast_matchers::cxxCtorInitializer

Matches constructor initializers.

Examples matches `i(42)`.

class C {
C() : i(42) {}
int i;
};

Definition at line 584 of file ASTMatchersInternal.cpp.

## ◆ cxxDefaultArgExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDefaultArgExpr > clang::ast_matchers::cxxDefaultArgExpr

Matches the value of a default argument at the call site.

Example matches the CXXDefaultArgExpr placeholder inserted for the default value of the second parameter in the call expression f(42) (matcher = cxxDefaultArgExpr())

void f(int x, int y = 0);
f(42);

Definition at line 687 of file ASTMatchersInternal.cpp.

## ◆ cxxDeleteExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDeleteExpr > clang::ast_matchers::cxxDeleteExpr

Matches delete expressions.

Given

delete X;

cxxDeleteExpr() matches 'delete X'.

Definition at line 683 of file ASTMatchersInternal.cpp.

## ◆ cxxDependentScopeMemberExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDependentScopeMemberExpr > clang::ast_matchers::cxxDependentScopeMemberExpr

Matches member expressions where the actual member referenced could not be resolved because the base expression or the member name was dependent.

Given

template <class T> void f() { T t; t.g(); }

cxxDependentScopeMemberExpr() matches t.g

Definition at line 621 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ cxxDestructorDecl

const internal::VariadicDynCastAllOfMatcher< Decl, CXXDestructorDecl > clang::ast_matchers::cxxDestructorDecl

Matches explicit C++ destructor declarations.

Example matches Foo::~Foo()

class Foo {
public:
virtual ~Foo();
};

Definition at line 600 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ cxxDynamicCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDynamicCastExpr > clang::ast_matchers::cxxDynamicCastExpr

Matches a dynamic_cast expression.

Example: cxxDynamicCastExpr() matches dynamic_cast<D*>(&b); in

struct B { virtual ~B() {} }; struct D : B {};
B b;
D* p = dynamic_cast<D*>(&b);

Definition at line 750 of file ASTMatchersInternal.cpp.

## ◆ cxxForRangeStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXForRangeStmt > clang::ast_matchers::cxxForRangeStmt

Matches range-based for statements.

cxxForRangeStmt() matches 'for (auto a : i)'

int i[] = {1, 2, 3}; for (auto a : i);
for(int j = 0; j < 5; ++j);

Definition at line 697 of file ASTMatchersInternal.cpp.

## ◆ cxxFunctionalCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXFunctionalCastExpr > clang::ast_matchers::cxxFunctionalCastExpr

Matches functional cast expressions.

Example: Matches Foo(bar);

Foo f = bar;
Foo g = (Foo) bar;
Foo h = Foo(bar);

Definition at line 761 of file ASTMatchersInternal.cpp.

## ◆ cxxMemberCallExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXMemberCallExpr > clang::ast_matchers::cxxMemberCallExpr

Matches member call expressions.

Example matches x.y()

X x;
x.y();

Definition at line 625 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ cxxMethodDecl

const internal::VariadicDynCastAllOfMatcher< Decl, CXXMethodDecl > clang::ast_matchers::cxxMethodDecl

Matches method declarations.

Example matches y

class X { void y(); };

Definition at line 604 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ cxxNewExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNewExpr > clang::ast_matchers::cxxNewExpr

Matches new expressions.

Given

new X;

cxxNewExpr() matches 'new X'.

Definition at line 682 of file ASTMatchersInternal.cpp.

## ◆ cxxNullPtrLiteralExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNullPtrLiteralExpr > clang::ast_matchers::cxxNullPtrLiteralExpr

Matches nullptr literal.

Definition at line 730 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_FUNCTION().

## ◆ cxxOperatorCallExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXOperatorCallExpr > clang::ast_matchers::cxxOperatorCallExpr

Matches overloaded operator calls.

Note that if an operator isn't overloaded, it won't match. Instead, use binaryOperator matcher. Currently it does not match operators such as new delete. FIXME: figure out why these do not match?

Example matches both operator<<((o << b), c) and operator<<(o, b) (matcher = cxxOperatorCallExpr())

ostream &operator<< (ostream &out, int i) { };
ostream &o; int b = 1, c = 1;
o << b << c;

Definition at line 689 of file ASTMatchersInternal.cpp.

## ◆ cxxRecordDecl

const internal::VariadicDynCastAllOfMatcher< Decl, CXXRecordDecl > clang::ast_matchers::cxxRecordDecl

Matches C++ class declarations.

Example matches `X`, `Z`

class X;
template<class T> class Z {};

Definition at line 570 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_FUNCTION(), and isSubclass().

## ◆ cxxReinterpretCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXReinterpretCastExpr > clang::ast_matchers::cxxReinterpretCastExpr

Matches a reinterpret_cast expression.

Either the source expression or the destination type can be matched using has(), but hasDestinationType() is more specific and can be more readable.

Example matches reinterpret_cast<char*>(&p) in

void* p = reinterpret_cast<char*>(&p);

Definition at line 746 of file ASTMatchersInternal.cpp.

## ◆ cxxStaticCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStaticCastExpr > clang::ast_matchers::cxxStaticCastExpr

Matches a C++ static_cast expression.

See also
  hasDestinationType
  reinterpretCast

Example: cxxStaticCastExpr() matches static_cast<long>(8) in

long eight(static_cast<long>(8));

Definition at line 748 of file ASTMatchersInternal.cpp.

## ◆ cxxStdInitializerListExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStdInitializerListExpr > clang::ast_matchers::cxxStdInitializerListExpr

Matches C++ initializer list expressions.

Given

std::vector<int> a({ 1, 2, 3 });
std::vector<int> b = { 4, 5 };
int c[] = { 6, 7 };
std::pair<int, int> d = { 8, 9 };

cxxStdInitializerListExpr() matches "{ 1, 2, 3 }" and "{ 4, 5 }"

Definition at line 656 of file ASTMatchersInternal.cpp.

## ◆ cxxTemporaryObjectExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTemporaryObjectExpr > clang::ast_matchers::cxxTemporaryObjectExpr

Matches functional cast expressions having N != 1 arguments.

Example: Matches Foo(bar, bar)

Foo h = Foo(bar, bar);

Definition at line 763 of file ASTMatchersInternal.cpp.

## ◆ cxxThisExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThisExpr > clang::ast_matchers::cxxThisExpr

Matches implicit and explicit this expressions.

Example matches the implicit this expression in "return i". (matcher = cxxThisExpr())

struct foo {
int i;
int f() { return i; }
};

Definition at line 677 of file ASTMatchersInternal.cpp.

## ◆ cxxThrowExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThrowExpr > clang::ast_matchers::cxxThrowExpr

Matches throw expressions.

try { throw 5; } catch(int i) {}

cxxThrowExpr() matches 'throw 5'

Definition at line 713 of file ASTMatchersInternal.cpp.

## ◆ cxxTryStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTryStmt > clang::ast_matchers::cxxTryStmt

Matches try statements.

try {} catch(int i) {}

cxxTryStmt() matches 'try {}'

Definition at line 712 of file ASTMatchersInternal.cpp.

## ◆ cxxUnresolvedConstructExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXUnresolvedConstructExpr > clang::ast_matchers::cxxUnresolvedConstructExpr

Matches unresolved constructor call expressions.

Example matches T(t) in return statement of f (matcher = cxxUnresolvedConstructExpr())

template <typename T>
void f(const T& t) { return T(t); }

Definition at line 676 of file ASTMatchersInternal.cpp.

## ◆ decayedType

const AstTypeMatcher< DecayedType > clang::ast_matchers::decayedType

Matches decayed type Example matches i[] in declaration of f.

(matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))) Example matches i[1]. (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())))))

void f(int i[]) {
i[1] = 0;
}

Definition at line 837 of file ASTMatchersInternal.cpp.

## ◆ decl

const internal::VariadicAllOfMatcher< Decl > clang::ast_matchers::decl

Matches declarations.

Examples matches `X`, `C`, and the friend declaration inside `C`;

void X();
class C {
friend X;
};

Definition at line 561 of file ASTMatchersInternal.cpp.

Referenced by clang::Sema::ActOnForEachDeclStmt(), AST_MATCHER_FUNCTION(), clang::ento::StoreManager::getLValueCompoundLiteral(), clang::CodeGen::CodeGenModule::getMemberPointerConstant(), clang::ASTReader::getOwningModuleNameForDiagnostic(), clang::ObjCInterfaceDecl::getTypeParamList(), hasOnlyNonStaticMemberFunctions(), isAccessedBy(), clang::ento::ExprEngine::ProcessInitializer(), clang::Sema::PushParsingDeclaration(), and clang::ASTDeclReader::VisitBlockDecl().

## ◆ declaratorDecl

const internal::VariadicDynCastAllOfMatcher< Decl, DeclaratorDecl > clang::ast_matchers::declaratorDecl

Matches declarator declarations (field, variable, function and non-type template parameter declarations).

Given

class X { int y; };

declaratorDecl() matches `int` y.

Definition at line 580 of file ASTMatchersInternal.cpp.

## ◆ declRefExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, DeclRefExpr > clang::ast_matchers::declRefExpr

Matches expressions that refer to declarations.

Example matches x in if (x)

bool x;
if (x) {}

Definition at line 691 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::assignedToRef(), clang::ento::callByRef(), clang::ento::changeIntBoundNode(), collectSubRegionBindings(), clang::ento::forLoopMatcher(), clang::ento::getAddrTo(), and clang::ento::simpleCondition().

## ◆ declStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, DeclStmt > clang::ast_matchers::declStmt

Matches declaration statements.

Given

int a;

declStmt() matches 'int a'.

Definition at line 616 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::assignedToRef(), AST_MATCHER_P(), and clang::ento::forLoopMatcher().

## ◆ decltypeType

const AstTypeMatcher< DecltypeType > clang::ast_matchers::decltypeType

Matches types nodes representing C++11 decltype(<expr>) types.

Given:

short i = 1;
int j = 42;
decltype(i + j) result = i + j;

decltypeType() matches "decltype(i + j)"

Definition at line 816 of file ASTMatchersInternal.cpp.

## ◆ defaultStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, DefaultStmt > clang::ast_matchers::defaultStmt

Matches default statements inside switch statements.

Given

switch(a) { case 42: break; default: break; }

defaultStmt() matches 'default:'.

Definition at line 709 of file ASTMatchersInternal.cpp.

## ◆ dependentSizedArrayType

const AstTypeMatcher< DependentSizedArrayType > clang::ast_matchers::dependentSizedArrayType

Matches C++ arrays whose size is a value-dependent expression.

Given

template<typename T, int Size>
class array {
T data[Size];
};

dependentSizedArrayType matches "T data[Size]"

Definition at line 811 of file ASTMatchersInternal.cpp.

Referenced by AST_POLYMORPHIC_MATCHER_P().

## ◆ designatedInitExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, DesignatedInitExpr > clang::ast_matchers::designatedInitExpr

Matches C99 designated initializer expressions [C99 6.7.8].

Example: Matches { [2].y = 1.0, [0].x = 1.0 }

point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };

Definition at line 767 of file ASTMatchersInternal.cpp.

## ◆ doStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, DoStmt > clang::ast_matchers::doStmt

Matches do statements.

Given

do {} while (true);

doStmt() matches 'do {} while(true)'

Definition at line 699 of file ASTMatchersInternal.cpp.

## ◆ eachOf

const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> clang::ast_matchers::eachOf = {internal::DynTypedMatcher::VO_EachOf}

Matches if any of the given matchers matches.

Unlike `anyOf`, `eachOf` will generate a match result for each matching submatcher.

For example, in:

class A { int a; int b; };

The matcher:

cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
has(fieldDecl(hasName("b")).bind("v"))))

will generate two results binding "v", the first of which binds the field declaration of `a`, the second the field declaration of `b`.

Usable as: Any Matcher

Definition at line 770 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ elaboratedType

const AstTypeMatcher< ElaboratedType > clang::ast_matchers::elaboratedType

Matches types specified with an elaborated type keyword or with a qualified name.

Given

namespace N {
namespace M {
class D {};
}
}
class C {};
class C c;
N::M::D d;

`elaboratedType()` matches the type of the variable declarations of both `c` and `d`.

Definition at line 833 of file ASTMatchersInternal.cpp.

## ◆ enumConstantDecl

const internal::VariadicDynCastAllOfMatcher< Decl, EnumConstantDecl > clang::ast_matchers::enumConstantDecl

Matches enum constants.

Example matches A, B, C

enum X {
A, B, C
};

Definition at line 603 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ enumDecl

const internal::VariadicDynCastAllOfMatcher< Decl, EnumDecl > clang::ast_matchers::enumDecl

Matches enum declarations.

Example matches X

enum X {
A, B, C
};

Definition at line 601 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ enumType

const AstTypeMatcher< EnumType > clang::ast_matchers::enumType

Matches enum types.

Given

enum C { Green };
enum class S { Red };
C c;
S s;

`enumType()` matches the type of the variable declarations of both `c` and `s`.

Definition at line 828 of file ASTMatchersInternal.cpp.

## ◆ explicitCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ExplicitCastExpr > clang::ast_matchers::explicitCastExpr

Matches explicit cast expressions.

Matches any cast expression written in user code, whether it be a C-style cast, a functional-style cast, or a keyword cast.

Does not match implicit conversions.

Note: the name "explicitCast" is chosen to match Clang's terminology, as Clang uses the term "cast" to apply to implicit conversions as well as to actual cast expressions.

See also
  hasDestinationType.

Example: matches all five of the casts in

int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42)))))

but does not match the implicit conversion in

long ell = 42;

Definition at line 756 of file ASTMatchersInternal.cpp.

## ◆ expr

const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > clang::ast_matchers::expr

Matches expressions.

Example matches x()

void f() { x(); }

Definition at line 690 of file ASTMatchersInternal.cpp.

Referenced by clang::Sema::ActOnFileScopeAsmDecl(), clang::CodeGen::CGCXXABI::adjustCallArgsForDestructorThunk(), AST_MATCHER_FUNCTION(), clang::ento::SValBuilder::conjureSymbol(), emitPointerArithmetic(), clang::CodeGen::CodeGenFunction::getARCCleanupKind(), implies(), clang::Expr::isKnownToHaveBooleanValue(), clang::Sema::isObjCMethodDecl(), clang::OpaqueValueExpr::OpaqueValueExpr(), performTypeAdjustment(), clang::CodeGen::ConstantEmitter::registerCurrentAddrPrivate(), clang::InitListExpr::setInit(), and tryEmitFMulAdd().

## ◆ exprWithCleanups

const internal::VariadicDynCastAllOfMatcher< Stmt, ExprWithCleanups > clang::ast_matchers::exprWithCleanups

Matches expressions that introduce cleanups to be run at the end of the sub-expression's evaluation.

Example matches std::string()

const std::string str = std::string();

Definition at line 653 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ fieldDecl

const internal::VariadicDynCastAllOfMatcher< Decl, FieldDecl > clang::ast_matchers::fieldDecl

Matches field declarations.

Given

class X { int m; };

fieldDecl() matches 'm'.

Definition at line 608 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ floatLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, FloatingLiteral > clang::ast_matchers::floatLiteral

Matches float literals of all sizes / encodings, e.g.

1.0, 1.0f, 1.0L and 1e10.

Does not match implicit conversions such as

float a = 10;

Definition at line 723 of file ASTMatchersInternal.cpp.

## ◆ forEach

const internal::ArgumentAdaptingMatcherFunc< internal::ForEachMatcher > clang::ast_matchers::forEach

Initial value:
=
{}

Matches AST nodes that have child AST nodes that match the provided matcher.

Example matches X, Y, Y::X, Z::Y, Z::Y::X (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))

class X {};
class Y { class X {}; }; // Matches Y, because Y::X is a class of name X
// inside Y.
class Z { class Y { class X {}; }; }; // Does not match Z.

ChildT must be an AST base type.

As opposed to 'has', 'forEach' will cause a match for each result that matches instead of only on the first one.

Usable as: Any Matcher

Definition at line 786 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ forEachDescendant

const internal::ArgumentAdaptingMatcherFunc< internal::ForEachDescendantMatcher > clang::ast_matchers::forEachDescendant = {}

Matches AST nodes that have descendant AST nodes that match the provided matcher.

Example matches X, A, A::X, B, B::C, B::C::X (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))

class X {};
class A { class X {}; }; // Matches A, because A::X is a class of name
// X inside A.
class B { class C { class X {}; }; };

DescendantT must be an AST base type.

As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for each result that matches instead of only on the first one.

Note: Recursively combined ForEachDescendant can cause many matches: cxxRecordDecl(forEachDescendant(cxxRecordDecl( forEachDescendant(cxxRecordDecl()) ))) will match 10 times (plus injected class name matches) on:

class A { class B { class C { class D { class E {}; }; }; }; };

Usable as: Any Matcher

Definition at line 789 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ forStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ForStmt > clang::ast_matchers::forStmt

Matches for statements.

Example matches 'for (;;) {}'

for (;;) {}
int i[] = {1, 2, 3}; for (auto a : i);

Definition at line 695 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::forLoopMatcher().

## ◆ friendDecl

const internal::VariadicDynCastAllOfMatcher< Decl, FriendDecl > clang::ast_matchers::friendDecl

Matches friend declarations.

Given

class X { friend void foo(); };

friendDecl() matches 'friend void foo()'.

Definition at line 614 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ functionDecl

const internal::VariadicDynCastAllOfMatcher< Decl, FunctionDecl > clang::ast_matchers::functionDecl

Matches function declarations.

Example matches f

void f();

Definition at line 611 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_FUNCTION(), AST_MATCHER_P(), and callsNames().

## ◆ functionProtoType

const AstTypeMatcher< FunctionProtoType > clang::ast_matchers::functionProtoType

Matches `FunctionProtoType` nodes.

Given

int (*f)(int);
void g();

functionProtoType() matches "int (*f)(int)" and the type of "g" in C++ mode. In C mode, "g" is not matched because it does not contain a prototype.

Definition at line 818 of file ASTMatchersInternal.cpp.

## ◆ functionTemplateDecl

const internal::VariadicDynCastAllOfMatcher< Decl, FunctionTemplateDecl > clang::ast_matchers::functionTemplateDecl

Matches C++ function template declarations.

Example matches f

template<class T> void f(T t) {}

Definition at line 613 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ functionType

const AstTypeMatcher< FunctionType > clang::ast_matchers::functionType

Matches `FunctionType` nodes.

Given

int (*f)(int);
void g();

functionType() matches "int (*f)(int)" and the type of "g".

Definition at line 817 of file ASTMatchersInternal.cpp.

Referenced by clang::CodeGen::CodeGenFunction::EmitCallee().

## ◆ gnuNullExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, GNUNullExpr > clang::ast_matchers::gnuNullExpr

Matches GNU __null expression.

Definition at line 731 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_FUNCTION().

## ◆ gotoStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, GotoStmt > clang::ast_matchers::gotoStmt

Matches goto statements.

Given

goto FOO;
FOO: bar();

gotoStmt() matches 'goto FOO'

Definition at line 703 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::hasSuspiciousStmt().

## ◆ has

const internal::ArgumentAdaptingMatcherFunc< internal::HasMatcher > clang::ast_matchers::has = {}

Matches AST nodes that have child AST nodes that match the provided matcher.

Example matches X, Y (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X")))

class X {}; // Matches X, because X::X is a class of name X inside X.
class Y { class X {}; };
class Z { class Y { class X {}; }; }; // Does not match Z.

ChildT must be an AST base type.

Usable as: Any Matcher Note that has is direct matcher, so it also matches things like implicit casts and paren casts. If you are matching with expr then you should probably consider using ignoringParenImpCasts like: has(ignoringParenImpCasts(expr())).

Definition at line 783 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::assignedToRef(), AST_MATCHER(), and getLiteralInfo().

## ◆ hasAncestor

const internal::ArgumentAdaptingMatcherFunc< internal::HasAncestorMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc > > clang::ast_matchers::hasAncestor = {}

Matches AST nodes that have an ancestor that matches the provided matcher.

Given

void f() { if (true) { int x = 42; } }
void g() { for (;;) { int x = 43; } }

`expr`(integerLiteral(hasAncestor(ifStmt()))) matches `42`, but not 43.

Usable as: Any Matcher

Definition at line 799 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_FUNCTION().

## ◆ hasAnyName

const internal::VariadicFunction< internal::Matcher< NamedDecl >, StringRef, internal::hasAnyNameFunc > clang::ast_matchers::hasAnyName = {}

Matches NamedDecl nodes that have any of the specified names.

This matcher is only provided as a performance optimization of hasName.

hasAnyName(a, b, c)

is equivalent to, but faster than

anyOf(hasName(a), hasName(b), hasName(c))

Definition at line 779 of file ASTMatchersInternal.cpp.

Referenced by callsNames().

## ◆ hasAnySelector

const internal::VariadicFunction< internal::Matcher< ObjCMessageExpr >, StringRef, internal::hasAnySelectorFunc > clang::ast_matchers::hasAnySelector = {}

Matches when at least one of the supplied string equals to the Selector.getAsString()

matcher = objCMessageExpr(hasSelector("methodA:", "methodB:")); matches both of the expressions below:

[myObj methodA:argA];
[myObj methodB:argB];

Definition at line 782 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ hasDescendant

const internal::ArgumentAdaptingMatcherFunc< internal::HasDescendantMatcher > clang::ast_matchers::hasDescendant = {}

Matches AST nodes that have descendant AST nodes that match the provided matcher.

Example matches X, Y, Z (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X")))))

class X {}; // Matches X, because X::X is a class of name X inside X.
class Y { class X {}; };
class Z { class Y { class X {}; }; };

DescendantT must be an AST base type.

Usable as: Any Matcher

Definition at line 785 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::assignedToRef(), AST_MATCHER(), collectSubRegionBindings(), clang::ento::hasSuspiciousStmt(), and wasRegionOfInterestModifiedAt().

## ◆ hasParent

const internal::ArgumentAdaptingMatcherFunc< internal::HasParentMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc > > clang::ast_matchers::hasParent = {}

Matches AST nodes that have a parent that matches the provided matcher.

Given

void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }

`compoundStmt`(hasParent(ifStmt())) matches "{ int x = 43; }".

Usable as: Any Matcher

Definition at line 794 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_FUNCTION().

## ◆ ifStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, IfStmt > clang::ast_matchers::ifStmt

Matches if statements.

Example matches 'if (x) {}'

if (x) {}

Definition at line 694 of file ASTMatchersInternal.cpp.

## ◆ imaginaryLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, ImaginaryLiteral > clang::ast_matchers::imaginaryLiteral

Matches imaginary literals, which are based on integer and floating point literals e.g.

: 1i, 1.0i

Definition at line 724 of file ASTMatchersInternal.cpp.

## ◆ implicitCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitCastExpr > clang::ast_matchers::implicitCastExpr

Matches the implicit cast nodes of Clang's AST.

This matches many different places, including function call return value eliding, as well as any type conversions.

Definition at line 758 of file ASTMatchersInternal.cpp.

## ◆ implicitValueInitExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitValueInitExpr > clang::ast_matchers::implicitValueInitExpr

Matches implicit initializers of init list expressions.

Given

point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 };

implicitValueInitExpr() matches "[0].y" (implicitly)

Definition at line 658 of file ASTMatchersInternal.cpp.

## ◆ incompleteArrayType

const AstTypeMatcher< IncompleteArrayType > clang::ast_matchers::incompleteArrayType

Matches C arrays with unspecified size.

Given

int a[] = { 2, 3 };
int b[42];
void f(int c[]) { int d[a[0]]; };

incompleteArrayType() matches "int a[]" and "int c[]"

Definition at line 812 of file ASTMatchersInternal.cpp.

Referenced by AST_POLYMORPHIC_MATCHER_P().

## ◆ indirectFieldDecl

const internal::VariadicDynCastAllOfMatcher< Decl, IndirectFieldDecl > clang::ast_matchers::indirectFieldDecl

Matches indirect field declarations.

Given

struct X { struct { int a; }; };

indirectFieldDecl() matches 'a'.

Definition at line 610 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ initListExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, InitListExpr > clang::ast_matchers::initListExpr

Matches init list expressions.

Given

int a[] = { 1, 2 };
struct B { int x, y; };
B b = { 5, 6 };

initListExpr() matches "{ 1, 2 }" and "{ 5, 6 }"

Definition at line 654 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::assignedToRef(), and AST_MATCHER().

## ◆ injectedClassNameType

const AstTypeMatcher< InjectedClassNameType > clang::ast_matchers::injectedClassNameType

Matches injected class name types.

Example matches S s, but not S<T> s. (matcher = parmVarDecl(hasType(injectedClassNameType())))

template <typename T> struct S {
void f(S s);
void g(S<T> s);
};

Definition at line 836 of file ASTMatchersInternal.cpp.

## ◆ integerLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, IntegerLiteral > clang::ast_matchers::integerLiteral

Matches integer literals of all sizes / encodings, e.g.

1, 1L, 0x1 and 1U.

Does not match character-encoded integers such as L'a'.

Definition at line 722 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_FUNCTION(), clang::ento::forLoopMatcher(), and clang::ento::simpleCondition().

## ◆ labelDecl

const internal::VariadicDynCastAllOfMatcher< Decl, LabelDecl > clang::ast_matchers::labelDecl

Matches a declaration of label.

Given

goto FOO;
FOO: bar();

labelDecl() matches 'FOO:'

Definition at line 565 of file ASTMatchersInternal.cpp.

## ◆ labelStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, LabelStmt > clang::ast_matchers::labelStmt

Matches label statements.

Given

goto FOO;
FOO: bar();

labelStmt() matches 'FOO:'

Definition at line 704 of file ASTMatchersInternal.cpp.

## ◆ lambdaExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, LambdaExpr > clang::ast_matchers::lambdaExpr

Matches lambda expressions.

Example matches [&](){return 5;}

[&](){return 5;}

Definition at line 623 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ linkageSpecDecl

const internal::VariadicDynCastAllOfMatcher< Decl, LinkageSpecDecl > clang::ast_matchers::linkageSpecDecl

Matches a declaration of a linkage specification.

Given

extern "C" {}

linkageSpecDecl() matches "extern "C" {}"

Definition at line 563 of file ASTMatchersInternal.cpp.

## ◆ lValueReferenceType

const AstTypeMatcher< LValueReferenceType > clang::ast_matchers::lValueReferenceType

Matches lvalue reference types.

Given:

int *a;
int &b = *a;
int &&c = 1;
auto &d = b;
auto &&e = c;
auto &&f = 2;
int g = 5;

`lValueReferenceType()` matches the types of `b`, `d`, and `e`. `e` is matched since the type is deduced as int& by reference collapsing rules.

Definition at line 825 of file ASTMatchersInternal.cpp.

## ◆ materializeTemporaryExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, MaterializeTemporaryExpr > clang::ast_matchers::materializeTemporaryExpr

Matches nodes where temporaries are materialized.

Example: Given

struct T {void func();};
T f();
void g(T);

materializeTemporaryExpr() matches 'f()' in these statements

T u(f());
g(f());
f().func();

but does not match

f();

Definition at line 681 of file ASTMatchersInternal.cpp.

## ◆ memberExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, MemberExpr > clang::ast_matchers::memberExpr

Matches member expressions.

Given

class Y {
void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
int a; static int b;
};

memberExpr() matches this->x, x, y.x, a, this->b

Definition at line 617 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ memberPointerType

const AstTypeMatcher< MemberPointerType > clang::ast_matchers::memberPointerType

Matches member pointer types.

Given

struct A { int i; }
A::* ptr = A::i;

memberPointerType() matches "A::* ptr"

Definition at line 821 of file ASTMatchersInternal.cpp.

## ◆ namedDecl

const internal::VariadicDynCastAllOfMatcher< Decl, NamedDecl > clang::ast_matchers::namedDecl

Matches a declaration of anything that could have a name.

Example matches `X`, `S`, the anonymous union type, `i`, and `U`;

typedef int X;
struct S {
union {
int i;
} U;
};

Definition at line 564 of file ASTMatchersInternal.cpp.

## ◆ namespaceAliasDecl

const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceAliasDecl > clang::ast_matchers::namespaceAliasDecl

Matches a declaration of a namespace alias.

Given

namespace test {}
namespace alias = ::test;

namespaceAliasDecl() matches "namespace alias" but not "namespace test"

Definition at line 568 of file ASTMatchersInternal.cpp.

## ◆ namespaceDecl

const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceDecl > clang::ast_matchers::namespaceDecl

Matches a declaration of a namespace.

Given

namespace {}
namespace test {}

namespaceDecl() matches "namespace {}" and "namespace test {}"

Definition at line 566 of file ASTMatchersInternal.cpp.

## ◆ nestedNameSpecifier

const internal::VariadicAllOfMatcher< NestedNameSpecifier > clang::ast_matchers::nestedNameSpecifier

Matches nested name specifiers.

Given

namespace ns {
struct A { static void f(); };
void A::f() {}
void g() { A::f(); }
}
ns::A a;

nestedNameSpecifier() matches "ns::" and both "A::"

Definition at line 802 of file ASTMatchersInternal.cpp.

## ◆ nestedNameSpecifierLoc

const internal::VariadicAllOfMatcher< NestedNameSpecifierLoc > clang::ast_matchers::nestedNameSpecifierLoc

Same as `nestedNameSpecifier` but matches `NestedNameSpecifierLoc`.

Definition at line 804 of file ASTMatchersInternal.cpp.

## ◆ nonTypeTemplateParmDecl

const internal::VariadicDynCastAllOfMatcher< Decl, NonTypeTemplateParmDecl > clang::ast_matchers::nonTypeTemplateParmDecl

Matches non-type template parameter declarations.

Given

template <typename T, int N> struct C {};

nonTypeTemplateParmDecl() matches 'N', but not 'T'.

Definition at line 588 of file ASTMatchersInternal.cpp.

## ◆ nullStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, NullStmt > clang::ast_matchers::nullStmt

Matches null statements.

foo();;

nullStmt() matches the second ';'

Definition at line 714 of file ASTMatchersInternal.cpp.

## ◆ objcCatchStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtCatchStmt > clang::ast_matchers::objcCatchStmt

Matches Objective-C statements.

Example matches

@try {}
@catch (...) {}

Definition at line 649 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ objcCategoryDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCCategoryDecl > clang::ast_matchers::objcCategoryDecl

Matches Objective-C category declarations.

Example matches Foo (Additions)

@interface Foo (Additions)
@end

Definition at line 635 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ objcCategoryImplDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCCategoryImplDecl > clang::ast_matchers::objcCategoryImplDecl

Matches Objective-C category definitions.

Example matches Foo (Additions)

@implementation Foo (Additions)
@end

Definition at line 637 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ objcFinallyStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtFinallyStmt > clang::ast_matchers::objcFinallyStmt

Matches Objective-C statements.

Example matches

@try {}
@finally {}

Definition at line 651 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ objcImplementationDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCImplementationDecl > clang::ast_matchers::objcImplementationDecl

Matches Objective-C implementation declarations.

Example matches Foo

@implementation Foo
@end

Definition at line 631 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ objcInterfaceDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCInterfaceDecl > clang::ast_matchers::objcInterfaceDecl

Matches Objective-C interface declarations.

Example matches Foo

@interface Foo
@end

Definition at line 629 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ objcIvarDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCIvarDecl > clang::ast_matchers::objcIvarDecl

Matches Objective-C instance variable declarations.

Example matches _enabled

@implementation Foo {
BOOL _enabled;
}
@end

Definition at line 642 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ objcIvarRefExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCIvarRefExpr > clang::ast_matchers::objcIvarRefExpr

Matches a reference to an ObjCIvar.

Example: matches "a" in "init" method:

@implementation A {
NSString *a;
}
- (void) init {
a = @"hello";
}

Definition at line 692 of file ASTMatchersInternal.cpp.

Referenced by wasRegionOfInterestModifiedAt().

## ◆ objcMessageExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCMessageExpr > clang::ast_matchers::objcMessageExpr

Matches ObjectiveC Message invocation expressions.

The innermost message send invokes the "alloc" class method on the NSString class, while the outermost message send invokes the "initWithString" instance method on the object returned from NSString's "alloc". This matcher should match both message sends.

[[NSString alloc] initWithString:@"Hello"]

Definition at line 627 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ objcMethodDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCMethodDecl > clang::ast_matchers::objcMethodDecl

Matches Objective-C method declarations.

Example matches both declaration and definition of -[Foo method]

@interface Foo
- (void)method;
@end
@implementation Foo
- (void)method {}
@end

Definition at line 639 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ objcObjectPointerType

const AstTypeMatcher< ObjCObjectPointerType > clang::ast_matchers::objcObjectPointerType

Matches an Objective-C object pointer type, which is different from a pointer type, despite being syntactically similar.

Given

int *a;
@interface Foo
@end
Foo *f;

pointerType() matches "Foo *f", but does not match "int *a".

Definition at line 823 of file ASTMatchersInternal.cpp.

## ◆ objcPropertyDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCPropertyDecl > clang::ast_matchers::objcPropertyDecl

Matches Objective-C property declarations.

Example matches enabled

@interface Foo
@property BOOL enabled;
@end

Definition at line 644 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ objcProtocolDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCProtocolDecl > clang::ast_matchers::objcProtocolDecl

Matches Objective-C protocol declarations.

Example matches FooDelegate

@protocol FooDelegate
@end

Definition at line 633 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ objcThrowStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtThrowStmt > clang::ast_matchers::objcThrowStmt

Matches Objective-C @throw statements.

Example matches @throw

@throw obj;

Definition at line 646 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ objcTryStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtTryStmt > clang::ast_matchers::objcTryStmt

Matches Objective-C statements.

Example matches

@try {}
@catch (...) {}

Definition at line 647 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER().

## ◆ opaqueValueExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, OpaqueValueExpr > clang::ast_matchers::opaqueValueExpr

Matches opaque value expressions.

They are used as helpers to reference another expressions and can be met in BinaryConditionalOperators, for example.

Example matches 'a'

(a ?: c) + 42;

Definition at line 742 of file ASTMatchersInternal.cpp.

## ◆ parenExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ParenExpr > clang::ast_matchers::parenExpr

Matches parentheses used in expressions.

Example matches (foo() + 1)

int foo() { return 1; }
int a = (foo() + 1);

Definition at line 672 of file ASTMatchersInternal.cpp.

## ◆ parenListExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ParenListExpr > clang::ast_matchers::parenListExpr

Matches paren list expressions.

ParenListExprs don't have a predefined type and are used for late parsing. In the final AST, they can be met in template declarations.

Given

template<typename T> class X {
void f() {
X x(*this);
int a = 0, b = 1; int i = (a, b);
}
};

parenListExpr() matches "*this" but NOT matches (a, b) because (a, b) has a predefined type and is a ParenExpr, not a ParenListExpr.

Definition at line 659 of file ASTMatchersInternal.cpp.

## ◆ parenType

const AstTypeMatcher< ParenType > clang::ast_matchers::parenType

Matches `ParenType` nodes.

Given

int (*ptr_to_array)[4];
int *array_of_ptrs[4];

`varDecl`(hasType(pointsTo(parenType()))) matches `ptr_to_array` but not `array_of_ptrs`.

Definition at line 819 of file ASTMatchersInternal.cpp.

## ◆ parmVarDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ParmVarDecl > clang::ast_matchers::parmVarDecl

Matches parameter variable declarations.

Given

void f(int x);

parmVarDecl() matches `int` x.

Definition at line 581 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::callByRef().

## ◆ pointerType

const AstTypeMatcher< PointerType > clang::ast_matchers::pointerType

Matches pointer types, but does not match Objective-C object pointer types.

Given

int *a;
int &b = *a;
int c = 5;
@interface Foo
@end
Foo *f;

pointerType() matches "int *a", but does not match "Foo *f".

Definition at line 822 of file ASTMatchersInternal.cpp.

Referenced by clang::Sema::ActOnObjCAtSynchronizedOperand(), AST_MATCHER_FUNCTION(), checkBuiltinArgument(), CheckNonNullArguments(), clang::Sema::CheckObjCForCollectionOperand(), emitPointerArithmetic(), and isValidOrderingForOp().

## ◆ predefinedExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, PredefinedExpr > clang::ast_matchers::predefinedExpr

Matches predefined identifier expressions [C99 6.4.2.2].

Example: Matches func

printf("%s", __func__);

Definition at line 765 of file ASTMatchersInternal.cpp.

## ◆ qualType

const internal::VariadicAllOfMatcher< QualType > clang::ast_matchers::qualType

Matches `QualTypes` in the clang AST.

Definition at line 591 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P(), and clang::ento::callByRef().

## ◆ recordDecl

const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > clang::ast_matchers::recordDecl

Matches class, struct, and union declarations.

Example matches `X`, `Z`, `U`, and `S`

class X;
template<class T> class Z {};
struct S {};
union U {};

Definition at line 569 of file ASTMatchersInternal.cpp.

Referenced by classifyPointerDeclarator().

## ◆ recordType

const AstTypeMatcher< RecordType > clang::ast_matchers::recordType

Matches record types (e.g.

structs, classes).

Given

class C {};
struct S {};
C c;
S s;

`recordType()` matches the type of the variable declarations of both `c` and `s`.

Definition at line 831 of file ASTMatchersInternal.cpp.

Referenced by classifyPointerDeclarator(), classifyType(), clang::CFGImplicitDtor::getDestructorDecl(), getMaxAtomicAccessSize(), and isSafeForCXXConstantCapture().

## ◆ referenceType

const AstTypeMatcher< ReferenceType > clang::ast_matchers::referenceType

Matches both lvalue and rvalue reference types.

Given

int *a;
int &b = *a;
int &&c = 1;
auto &d = b;
auto &&e = c;
auto &&f = 2;
int g = 5;

`referenceType()` matches the types of `b`, `c`, `d`, `e`, and `f`.

Definition at line 824 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::assignedToRef().

## ◆ returnStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ReturnStmt > clang::ast_matchers::returnStmt

Matches return statements.

Given

return 1;

returnStmt() matches 'return 1'

Definition at line 702 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::hasSuspiciousStmt().

## ◆ rValueReferenceType

const AstTypeMatcher< RValueReferenceType > clang::ast_matchers::rValueReferenceType

Matches rvalue reference types.

Given:

int *a;
int &b = *a;
int &&c = 1;
auto &d = b;
auto &&e = c;
auto &&f = 2;
int g = 5;

`rValueReferenceType()` matches the types of `c` and `f`. `e` is not matched as it is deduced to int& by reference collapsing rules.

Definition at line 826 of file ASTMatchersInternal.cpp.

## ◆ staticAssertDecl

const internal::VariadicDynCastAllOfMatcher< Decl, StaticAssertDecl > clang::ast_matchers::staticAssertDecl

Matches a C++ static_assert declaration.

Example: staticAssertExpr() matches static_assert(sizeof(S) == sizeof(int)) in

struct S {
int x;
};
static_assert(sizeof(S) == sizeof(int));

Definition at line 744 of file ASTMatchersInternal.cpp.

## ◆ stmt

const internal::VariadicAllOfMatcher< Stmt > clang::ast_matchers::stmt

Matches statements.

Given

{ ++a; }

stmt() matches both the compound statement '{ ++a; }' and '++a'.

Definition at line 615 of file ASTMatchersInternal.cpp.

Referenced by areExprTypesCompatible(), AST_MATCHER_FUNCTION(), AST_MATCHER_P(), clang::Stmt::children(), collectSubRegionBindings(), clang::LiveVariables::computeLiveness(), clang::ento::SValBuilder::conjureSymbol(), clang::CFGBlock::FilterEdge(), clang::AnalysisDeclContext::getAddInitializers(), clang::ento::hasSuspiciousStmt(), clang::AnalysisDeclContext::registerForcedBlockExpression(), clang::CFG::VisitBlockStmts(), and wasRegionOfInterestModifiedAt().

## ◆ stmtExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, StmtExpr > clang::ast_matchers::stmtExpr

Matches statement expression (GNU extension).

Example match: ({ int X = 4; X; })

int C = ({ int X = 4; X; });

Definition at line 733 of file ASTMatchersInternal.cpp.

## ◆ stringLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, StringLiteral > clang::ast_matchers::stringLiteral

Matches string literals (also matches wide string literals).

Example matches "abcd", L"abcd"

char *s = "abcd";
wchar_t *ws = L"abcd";

Definition at line 718 of file ASTMatchersInternal.cpp.

## ◆ substNonTypeTemplateParmExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, SubstNonTypeTemplateParmExpr > clang::ast_matchers::substNonTypeTemplateParmExpr

Matches substitutions of non-type template parameters.

Given

template <int N>
struct A { static const int n = N; };
struct B : public A<42> {};

substNonTypeTemplateParmExpr() matches "N" in the right-hand side of "static const int n = N;"

Definition at line 661 of file ASTMatchersInternal.cpp.

## ◆ substTemplateTypeParmType

const AstTypeMatcher< SubstTemplateTypeParmType > clang::ast_matchers::substTemplateTypeParmType

Matches types that represent the result of substituting a type for a template type parameter.

Given

template <typename T>
void F(T t) {
int i = 1 + t;
}

`substTemplateTypeParmType()` matches the type of 't' but not '1'

Definition at line 834 of file ASTMatchersInternal.cpp.

## ◆ switchCase

const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchCase > clang::ast_matchers::switchCase

Matches case and default statements inside switch statements.

Given

switch(a) { case 42: break; default: break; }

switchCase() matches 'case 42:' and 'default:'.

Definition at line 707 of file ASTMatchersInternal.cpp.

## ◆ switchStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchStmt > clang::ast_matchers::switchStmt

Matches switch statements.

Given

switch(a) { case 42: break; default: break; }

switchStmt() matches 'switch(a)'.

Definition at line 706 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::hasSuspiciousStmt().

## ◆ tagType

const AstTypeMatcher< TagType > clang::ast_matchers::tagType

Matches tag types (record and enum types).

Given

enum E {};
class C {};
E e;
C c;

`tagType()` matches the type of the variable declarations of both `e` and `c`.

Definition at line 832 of file ASTMatchersInternal.cpp.

## ◆ templateArgument

const internal::VariadicAllOfMatcher< TemplateArgument > clang::ast_matchers::templateArgument

Matches template arguments.

Given

template <typename T> struct C {};
C<int> c;

templateArgument() matches 'int' in C<int>.

Definition at line 585 of file ASTMatchersInternal.cpp.

## ◆ templateName

const internal::VariadicAllOfMatcher< TemplateName > clang::ast_matchers::templateName

Matches template name.

Given

template <typename T> class X { };
X<int> xi;

templateName() matches 'X' in X<int>.

Definition at line 586 of file ASTMatchersInternal.cpp.

## ◆ templateSpecializationType

const AstTypeMatcher< TemplateSpecializationType > clang::ast_matchers::templateSpecializationType

Matches template specialization types.

Given

template <typename T>
class C { };
template class C<int>; // A
C<char> var; // B

`templateSpecializationType()` matches the type of the explicit instantiation in `A` and the type of the variable declaration in `B`.

Definition at line 829 of file ASTMatchersInternal.cpp.

## ◆ templateTypeParmDecl

const internal::VariadicDynCastAllOfMatcher< Decl, TemplateTypeParmDecl > clang::ast_matchers::templateTypeParmDecl

Matches template type parameter declarations.

Given

template <typename T, int N> struct C {};

templateTypeParmDecl() matches 'T', but not 'N'.

Definition at line 590 of file ASTMatchersInternal.cpp.

## ◆ templateTypeParmType

const AstTypeMatcher< TemplateTypeParmType > clang::ast_matchers::templateTypeParmType

Matches template type parameter types.

Example matches T, but not int. (matcher = templateTypeParmType())

template <typename T> void f(int i);

Definition at line 835 of file ASTMatchersInternal.cpp.

## ◆ translationUnitDecl

const internal::VariadicDynCastAllOfMatcher< Decl, TranslationUnitDecl > clang::ast_matchers::translationUnitDecl

Matches the top declaration context.

Given

int X;
namespace NS {
int Y;
} // namespace NS

decl(hasDeclContext(translationUnitDecl())) matches "int X", but not "int Y".

Definition at line 554 of file ASTMatchersInternal.cpp.

Referenced by anything().

## ◆ type

const internal::VariadicAllOfMatcher< Type > clang::ast_matchers::type

Matches `Types` in the clang AST.

Definition at line 592 of file ASTMatchersInternal.cpp.

Referenced by clang::InitializationSequence::AddPassByIndirectCopyRestoreStep(), clang::ASTContext::applyObjCProtocolQualifiers(), AST_MATCHER_P(), breakDownVectorType(), clang::arcmt::trans::canApplyWeak(), checkNullabilityTypeSpecifier(), clang::PseudoObjectExpr::Create(), distributeFunctionTypeAttr(), distributeObjCPointerTypeAttr(), clang::CodeGen::CodeGenFunction::EmitAutoVarInit(), clang::CodeGen::CodeGenFunction::emitAutoVarTypeCleanup(), clang::CodeGen::CodeGenFunction::EmitCallArg(), clang::CodeGen::CodeGenFunction::EmitDelegateCallArg(), clang::CodeGen::CodeGenFunction::EmitExtVectorElementExpr(), clang::CodeGen::CodeGenFunction::EmitStaticVarDecl(), clang::Expr::findBoundMemberType(), clang::Type::getBaseElementTypeUnsafe(), clang::CodeGen::swiftcall::SwiftAggLowering::getCoerceAndExpandTypes(), getComplexType(), clang::CodeGen::CodeGenFunction::getEvaluationKind(), GetGCAttrTypeForType(), getNonMemoryType(), clang::ASTContext::getObjCObjectType(), clang::Type::getPointeeOrArrayElementType(), clang::driver::toolchains::MSVCToolChain::getSubDirectoryPath(), clang::ASTContext::getVariableArrayDecayedType(), handleFunctionTypeAttr(), handleObjCGCTypeAttr(), handleObjCOwnershipTypeAttr(), clang::ASTNodeImporter::ImportArrayChecked(), isPlaceholderToRemoveAsArg(), clang::operator &(), clang::operator<<(), clang::operator|(), clang::operator~(), clang::CodeGen::CodeGenFunction::pushDestroy(), clang::CodeGen::CodeGenFunction::pushLifetimeExtendedDestroy(), clang::QualType::stripObjCKindOfType(), clang::QualType::substObjCTypeArgs(), and tryEmitARCRetainLoadOfScalar().

## ◆ typeAliasDecl

const internal::VariadicDynCastAllOfMatcher< Decl, TypeAliasDecl > clang::ast_matchers::typeAliasDecl

Matches type alias declarations.

Given

typedef int X;
using Y = int;

typeAliasDecl() matches "using Y = int", but not "typedef int X"

Definition at line 558 of file ASTMatchersInternal.cpp.

Referenced by anything().

## ◆ typeAliasTemplateDecl

const internal::VariadicDynCastAllOfMatcher< Decl, TypeAliasTemplateDecl > clang::ast_matchers::typeAliasTemplateDecl

Matches type alias template declarations.

typeAliasTemplateDecl() matches

template <typename T>
using Y = X<T>;

Definition at line 560 of file ASTMatchersInternal.cpp.

Referenced by anything().

## ◆ typedefDecl

const internal::VariadicDynCastAllOfMatcher< Decl, TypedefDecl > clang::ast_matchers::typedefDecl

Matches typedef declarations.

Given

typedef int X;
using Y = int;

typedefDecl() matches "typedef int X", but not "using Y = int"

Definition at line 555 of file ASTMatchersInternal.cpp.

Referenced by anything(), and checkNullabilityTypeSpecifier().

## ◆ typedefNameDecl

const internal::VariadicDynCastAllOfMatcher< Decl, TypedefNameDecl > clang::ast_matchers::typedefNameDecl

Matches typedef name declarations.

Given

typedef int X;
using Y = int;

typedefNameDecl() matches "typedef int X" and "using Y = int"

Definition at line 557 of file ASTMatchersInternal.cpp.

Referenced by anything().

## ◆ typedefType

const AstTypeMatcher< TypedefType > clang::ast_matchers::typedefType

Matches typedef types.

Given

typedef int X;

typedefType() matches "typedef int X"

Definition at line 827 of file ASTMatchersInternal.cpp.

Referenced by checkNullabilityTypeSpecifier(), clang::Type::isObjCIndependentClassType(), and clang::Type::isObjCNSObjectType().

## ◆ typeLoc

const internal::VariadicAllOfMatcher< TypeLoc > clang::ast_matchers::typeLoc

Matches `TypeLocs` in the clang AST.

Definition at line 593 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ unaryExprOrTypeTraitExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryExprOrTypeTraitExpr > clang::ast_matchers::unaryExprOrTypeTraitExpr

Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)

Given

Foo x = bar;
int y = sizeof(x) + alignof(x);

unaryExprOrTypeTraitExpr() matches `sizeof(x)` and `alignof(x)`

Definition at line 595 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ unaryOperator

const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryOperator > clang::ast_matchers::unaryOperator

Matches unary operator expressions.

Example matches !a

!a || b

Definition at line 736 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::changeIntBoundNode(), clang::ento::forLoopMatcher(), and clang::ento::getAddrTo().

## ◆ unaryTransformType

const AstTypeMatcher< UnaryTransformType > clang::ast_matchers::unaryTransformType

Matches types nodes representing unary type transformations.

Given:

typedef __underlying_type(T) type;

unaryTransformType() matches "__underlying_type(T)"

Definition at line 830 of file ASTMatchersInternal.cpp.

## ◆ unless

const internal::VariadicOperatorMatcherFunc< 1, 1 > clang::ast_matchers::unless

Initial value:
= {
internal::DynTypedMatcher::VO_UnaryNot}

Matches if the provided matcher does not match.

Example matches Y (matcher = cxxRecordDecl(unless(hasName("X"))))

class X {};
class Y {};

Usable as: Any Matcher

Definition at line 800 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::callByRef(), and clang::ento::forLoopMatcher().

## ◆ unresolvedLookupExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, UnresolvedLookupExpr > clang::ast_matchers::unresolvedLookupExpr

Matches reference to a name that can be looked up during parsing but could not be resolved to a specific declaration.

Given

template<typename T>
T foo() { T a; return a; }
template<typename T>
void bar() {
foo<T>();
}

unresolvedLookupExpr() matches

foo<T>()

Definition at line 666 of file ASTMatchersInternal.cpp.

## ◆ unresolvedMemberExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, UnresolvedMemberExpr > clang::ast_matchers::unresolvedMemberExpr

Matches unresolved member expressions.

Given

struct X {
template <class T> void f();
void g();
};
template <class T> void h() { X x; x.f<T>(); x.g(); }

unresolvedMemberExpr() matches x.f<T>

Definition at line 619 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ unresolvedUsingTypenameDecl

const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingTypenameDecl > clang::ast_matchers::unresolvedUsingTypenameDecl

Matches unresolved using value declarations that involve the typename.

Given

template <typename T>
struct Base { typedef T Foo; };
template<typename T>
struct S : private Base<T> {
using typename Base<T>::Foo;
};

unresolvedUsingTypenameDecl() matches

using Base<T>::Foo

Definition at line 670 of file ASTMatchersInternal.cpp.

## ◆ unresolvedUsingValueDecl

const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingValueDecl > clang::ast_matchers::unresolvedUsingValueDecl

Matches unresolved using value declarations.

Given

template<typename X>
class C : private X {
using X::x;
};

unresolvedUsingValueDecl() matches

using X::x

Definition at line 668 of file ASTMatchersInternal.cpp.

## ◆ userDefinedLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, UserDefinedLiteral > clang::ast_matchers::userDefinedLiteral

Matches user defined literal operator call.

Example match: "foo"_suffix

Definition at line 726 of file ASTMatchersInternal.cpp.

## ◆ usingDecl

const internal::VariadicDynCastAllOfMatcher< Decl, UsingDecl > clang::ast_matchers::usingDecl

Matches using declarations.

Given

namespace X { int x; }
using X::x;

usingDecl() matches

using X::x

Definition at line 662 of file ASTMatchersInternal.cpp.

## ◆ usingDirectiveDecl

const internal::VariadicDynCastAllOfMatcher< Decl, UsingDirectiveDecl > clang::ast_matchers::usingDirectiveDecl

Matches using namespace declarations.

Given

namespace X { int x; }
using namespace X;

usingDirectiveDecl() matches

using namespace X

Definition at line 664 of file ASTMatchersInternal.cpp.

## ◆ valueDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ValueDecl > clang::ast_matchers::valueDecl

Matches any value declaration.

Example matches A, B, C and F

enum X { A, B, C };
void F();

Definition at line 596 of file ASTMatchersInternal.cpp.

Referenced by AST_MATCHER_P().

## ◆ varDecl

const internal::VariadicDynCastAllOfMatcher< Decl, VarDecl > clang::ast_matchers::varDecl

Matches variable declarations.

Note: this does not match declarations of member variables, which are "field" declarations in Clang parlance.

Example matches a

int a;

Definition at line 607 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::assignedToRef(), AST_MATCHER_P(), clang::ento::callByRef(), clang::ento::changeIntBoundNode(), collectSubRegionBindings(), clang::ento::forLoopMatcher(), clang::ento::ExprEngine::ProcessAutomaticObjDtor(), and clang::ento::simpleCondition().

## ◆ variableArrayType

const AstTypeMatcher< VariableArrayType > clang::ast_matchers::variableArrayType

Matches C arrays with a specified size that is not an integer-constant-expression.

Given

void f() {
int a[] = { 2, 3 }
int b[42];
int c[a[0]];
}

variableArrayType() matches "int c[a[0]]"

Definition at line 813 of file ASTMatchersInternal.cpp.

Referenced by AST_POLYMORPHIC_MATCHER_P().

## ◆ whileStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, WhileStmt > clang::ast_matchers::whileStmt

Matches while statements.

Given

while (true) {}

whileStmt() matches 'while (true) {}'.

Definition at line 698 of file ASTMatchersInternal.cpp.