clang  14.0.0git
Namespaces | Classes | Typedefs | Enumerations | 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 >
 

Enumerations

enum  GtestCmp {
  GtestCmp::Eq, GtestCmp::Ne, GtestCmp::Ge, GtestCmp::Gt,
  GtestCmp::Le, GtestCmp::Lt
}
 Gtest's comparison operations. More...
 
enum  MockArgs { MockArgs::None, MockArgs::Some }
 This enum indicates whether the mock method in the matched ON_CALL or EXPECT_CALL macro has arguments. More...
 

Functions

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_REGEX (isExpansionInFileMatching, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc), RegExp)
 Matches AST nodes that were expanded within files whose name is partially matching a given regex. More...
 
 AST_POLYMORPHIC_MATCHER_P (isExpandedFromMacro, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc), std::string, MacroName)
 Matches statements that are (transitively) expanded from the named macro. More...
 
 AST_POLYMORPHIC_MATCHER (isPublic, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, CXXBaseSpecifier))
 Matches public C++ declarations and C++ base specifers that specify public inheritance. More...
 
 AST_POLYMORPHIC_MATCHER (isProtected, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, CXXBaseSpecifier))
 Matches protected C++ declarations and C++ base specifers that specify protected inheritance. More...
 
 AST_POLYMORPHIC_MATCHER (isPrivate, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, CXXBaseSpecifier))
 Matches private C++ declarations and C++ base specifers that specify private inheritance. 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_POLYMORPHIC_MATCHER (isImplicit, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Attr))
 Matches an entity that has been implicitly added by the compiler (e.g. 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...
 
template<typename T >
internal::Matcher< T > traverse (TraversalKind TK, const internal::Matcher< T > &InnerMatcher)
 Causes all nested matchers to be matched with the specified traversal kind. More...
 
template<typename T >
internal::BindableMatcher< T > traverse (TraversalKind TK, const internal::BindableMatcher< T > &InnerMatcher)
 
template<typename... T>
internal::TraversalWrapper< internal::VariadicOperatorMatcher< T... > > traverse (TraversalKind TK, const internal::VariadicOperatorMatcher< T... > &InnerMatcher)
 
template<template< typename ToArg, typename FromArg > class ArgumentAdapterT, typename T , typename ToTypes >
internal::TraversalWrapper< internal::ArgumentAdaptingMatcherFuncAdaptor< ArgumentAdapterT, T, ToTypes > > traverse (TraversalKind TK, const internal::ArgumentAdaptingMatcherFuncAdaptor< ArgumentAdapterT, T, ToTypes > &InnerMatcher)
 
template<template< typename T, typename... P > class MatcherT, typename... P, typename ReturnTypesF >
internal::TraversalWrapper< internal::PolymorphicMatcher< MatcherT, ReturnTypesF, P... > > traverse (TraversalKind TK, const internal::PolymorphicMatcher< MatcherT, ReturnTypesF, P... > &InnerMatcher)
 
template<typename... T>
internal::Matcher< typename internal::GetClade< T... >::Typetraverse (TraversalKind TK, const internal::MapAnyOfHelper< T... > &InnerMatcher)
 
 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 refers 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...
 
template<typename T , typename... U>
auto mapAnyOf (internal::VariadicDynCastAllOfMatcher< T, U > const &...)
 Matches any of the NodeMatchers with InnerMatchers nested within. 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::BindableMatcher< StmtalignOfExpr (const internal::Matcher< UnaryExprOrTypeTraitExpr > &InnerMatcher)
 Same as unaryExprOrTypeTraitExpr, but only matching alignof. More...
 
internal::BindableMatcher< StmtsizeOfExpr (const internal::Matcher< UnaryExprOrTypeTraitExpr > &InnerMatcher)
 Same as unaryExprOrTypeTraitExpr, but only matching sizeof. More...
 
internal::Matcher< NamedDeclhasName (StringRef Name)
 Matches NamedDecl nodes that have the specified name. More...
 
 AST_MATCHER_REGEX (NamedDecl, matchesName, RegExp)
 Matches NamedDecl nodes whose fully qualified names contain a substring matched by the given RegExp. More...
 
internal::PolymorphicMatcher< internal::HasOverloadedOperatorNameMatcher, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl), std::vector< std::string > > hasOverloadedOperatorName (StringRef Name)
 Matches overloaded operator names. More...
 
 AST_MATCHER_P (CXXDependentScopeMemberExpr, hasMemberName, std::string, N)
 Matches template-dependent, but known, member names. More...
 
 AST_MATCHER_P (CXXDependentScopeMemberExpr, memberHasSameNameAsBoundNode, std::string, BindingID)
 Matches template-dependent, but known, member names against an already-bound node. More...
 
 AST_POLYMORPHIC_MATCHER_P (isDerivedFrom, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl), internal::Matcher< NamedDecl >, Base)
 Matches C++ classes that are directly or indirectly derived from a class matching Base, or Objective-C classes that directly or indirectly subclass a class matching Base. More...
 
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD (isDerivedFrom, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl), std::string, BaseName, 1)
 Overloaded method as shortcut for isDerivedFrom(hasName(...)). More...
 
 AST_MATCHER_P (CXXRecordDecl, hasAnyBase, internal::Matcher< CXXBaseSpecifier >, BaseSpecMatcher)
 Matches C++ classes that have a direct or indirect base matching BaseSpecMatcher. More...
 
 AST_MATCHER_P (CXXRecordDecl, hasDirectBase, internal::Matcher< CXXBaseSpecifier >, BaseSpecMatcher)
 Matches C++ classes that have a direct base matching BaseSpecMatcher. More...
 
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD (isSameOrDerivedFrom, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl), internal::Matcher< NamedDecl >, Base, 0)
 Similar to isDerivedFrom(), but also matches classes that directly match Base. More...
 
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD (isSameOrDerivedFrom, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl), std::string, BaseName, 1)
 Overloaded method as shortcut for isSameOrDerivedFrom(hasName(...)). More...
 
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD (isDirectlyDerivedFrom, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl), internal::Matcher< NamedDecl >, Base, 0)
 Matches C++ or Objective-C classes that are directly derived from a class matching Base. More...
 
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD (isDirectlyDerivedFrom, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl), std::string, BaseName, 1)
 Overloaded method as shortcut for isDirectlyDerivedFrom(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::PolymorphicMatcher< internal::HasDeclarationMatcher, void(internal::HasDeclarationSupportedTypes), internal::Matcher< Decl > > hasDeclaration (const internal::Matcher< Decl > &InnerMatcher)
 Matches a node if the declaration associated with that node matches the given matcher. 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, after stripping off any parentheses or implicit casts. More...
 
 AST_MATCHER_P (ObjCMessageExpr, hasReceiverType, internal::Matcher< QualType >, InnerMatcher)
 Matches on the receiver of an ObjectiveC Message expression. More...
 
 AST_MATCHER (ObjCMethodDecl, isClassMethod)
 Returns true when the Objective-C method declaration is a class method. More...
 
 AST_MATCHER (ObjCMethodDecl, isInstanceMethod)
 Returns true when the Objective-C method declaration is an instance method. More...
 
 AST_MATCHER (ObjCMessageExpr, isClassMessage)
 Returns true when the Objective-C message is sent to a class. 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_REGEX (ObjCMessageExpr, matchesSelector, 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, CXXBaseSpecifier), 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, CXXBaseSpecifier), internal::Matcher< Decl >, InnerMatcher, 1)
 Overloaded to match the declaration of the expression's or value declaration's type. More...
 
 AST_MATCHER_P (QualType, asString, std::string, Name)
 Matches if the type location of a node matches the inner matcher. 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)
 Matches on the implicit object argument of a member call expression. More...
 
 AST_MATCHER_P_OVERLOAD (CXXMemberCallExpr, thisPointerType, internal::Matcher< QualType >, InnerMatcher, 0)
 Matches if the type of the expression's implicit object argument either matches the InnerMatcher, 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, CXXUnresolvedConstructExpr, 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, CXXUnresolvedConstructExpr, 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_P_OVERLOAD (LambdaExpr, hasAnyCapture, internal::Matcher< VarDecl >, InnerMatcher, 0)
 Matches any capture of a lambda expression. More...
 
 AST_MATCHER_P_OVERLOAD (LambdaExpr, hasAnyCapture, internal::Matcher< CXXThisExpr >, InnerMatcher, 1)
 Matches any capture of 'this' in a lambda 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_P2 (forEachArgumentWithParamType, AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr, CXXConstructExpr), internal::Matcher< Expr >, ArgMatcher, internal::Matcher< QualType >, ParamMatcher)
 Matches all arguments and their respective types for a CallExpr or CXXConstructExpr. More...
 
 AST_MATCHER_P (ParmVarDecl, isAtPosition, unsigned, N)
 Matches the ParmVarDecl nodes that are at the N'th position in the parameter list. 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_MATCHER (FunctionDecl, isWeak)
 Matches weak 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 (hasInitStatement, AST_POLYMORPHIC_SUPPORTED_TYPES(IfStmt, SwitchStmt, CXXForRangeStmt), internal::Matcher< Stmt >, InnerMatcher)
 Matches selection statements with initializer. 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_MATCHER_P (FunctionDecl, hasAnyBody, internal::Matcher< Stmt >, InnerMatcher)
 Matches a function declaration that has a given body present in the AST. 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::PolymorphicMatcher< internal::ValueEqualsMatcher, void(internal::AllNodeBaseTypes), 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, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, 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, CXXRewrittenBinaryOperator))
 Matches all kinds of assignment operators. More...
 
 AST_POLYMORPHIC_MATCHER (isComparisonOperator, AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator))
 Matches comparison operators. More...
 
 AST_POLYMORPHIC_MATCHER_P (hasLHS, AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, 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, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, ArraySubscriptExpr), internal::Matcher< Expr >, InnerMatcher)
 Matches the right hand side of binary operator expressions. More...
 
 AST_POLYMORPHIC_MATCHER_P (hasEitherOperand, AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator), internal::Matcher< Expr >, InnerMatcher)
 Matches if either the left hand side or the right hand side of a binary operator matches. More...
 
 AST_POLYMORPHIC_MATCHER_P2 (hasOperands, AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator), internal::Matcher< Expr >, Matcher1, internal::Matcher< Expr >, Matcher2)
 Matches if both matchers match with opposite sides of the binary operator. More...
 
 AST_POLYMORPHIC_MATCHER_P (hasUnaryOperand, AST_POLYMORPHIC_SUPPORTED_TYPES(UnaryOperator, CXXOperatorCallExpr), 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 (TagDecl, isStruct)
 Matches TagDecl object that are spelled with "struct.". More...
 
 AST_MATCHER (TagDecl, isUnion)
 Matches TagDecl object that are spelled with "union.". More...
 
 AST_MATCHER (TagDecl, isClass)
 Matches TagDecl object that are spelled with "class.". More...
 
 AST_MATCHER (TagDecl, isEnum)
 Matches TagDecl object that are spelled with "enum.". 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_POLYMORPHIC_MATCHER (isVirtual, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXMethodDecl, CXXBaseSpecifier))
 Matches declarations of virtual methods and C++ base specifers that specify virtual inheritance. 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 (BaseUsingDecl, 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, whoes 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, CXXDeductionGuideDecl))
 Matches constructor, conversion function, and deduction guide declarations that have an explicit specifier if this explicit specifier is resolved to true. More...
 
 AST_MATCHER_P (FunctionDecl, hasExplicitSpecifier, internal::Matcher< Expr >, InnerMatcher)
 Matches the expression in an explicit specifier if present in the given declaration. 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 (Decl, isInStdNamespace)
 Matches declarations in the namespace std, but not in nested namespaces. 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 (BindingDecl, forDecomposition, internal::Matcher< ValueDecl >, InnerMatcher)
 Matches the DecompositionDecl the binding belongs to. More...
 
 AST_MATCHER_P2 (DecompositionDecl, hasBinding, unsigned, N, internal::Matcher< BindingDecl >, InnerMatcher)
 Matches the Nth binding of a DecompositionDecl. More...
 
 AST_MATCHER_P (DecompositionDecl, hasAnyBinding, internal::Matcher< BindingDecl >, InnerMatcher)
 Matches any binding of a DecompositionDecl. More...
 
 AST_MATCHER_P (Stmt, forFunction, internal::Matcher< FunctionDecl >, InnerMatcher)
 Matches declaration of the function the statement belongs to. More...
 
 AST_MATCHER_P (Stmt, forCallable, internal::Matcher< Decl >, InnerMatcher)
 Matches declaration of the function, method, or block 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_P2 (CXXNewExpr, hasPlacementArg, unsigned, Index, internal::Matcher< Expr >, InnerMatcher)
 Matches placement new expression arguments. More...
 
 AST_MATCHER_P (CXXNewExpr, hasAnyPlacementArg, internal::Matcher< Expr >, InnerMatcher)
 Matches any placement new expression arguments. 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...
 
 AST_MATCHER_P (Expr, ignoringElidableConstructorCall, ast_matchers::internal::Matcher< Expr >, InnerMatcher)
 Matches expressions that match InnerMatcher that are possibly wrapped in an elidable constructor and other corresponding bookkeeping nodes. More...
 
 AST_MATCHER (OMPExecutableDirective, isStandaloneDirective)
 Matches standalone OpenMP directives, i.e., directives that can't have a structured block. More...
 
 AST_MATCHER_P (OMPExecutableDirective, hasStructuredBlock, internal::Matcher< Stmt >, InnerMatcher)
 Matches the structured-block of the OpenMP executable directive. More...
 
 AST_MATCHER_P (OMPExecutableDirective, hasAnyClause, internal::Matcher< OMPClause >, InnerMatcher)
 Matches any clause in an OpenMP directive. More...
 
 AST_MATCHER (OMPDefaultClause, isNoneKind)
 Matches if the OpenMP default clause has none kind specified. More...
 
 AST_MATCHER (OMPDefaultClause, isSharedKind)
 Matches if the OpenMP default clause has shared kind specified. More...
 
 AST_MATCHER (OMPDefaultClause, isFirstPrivateKind)
 Matches if the OpenMP default clause has firstprivate kind specified. More...
 
 AST_MATCHER_P (OMPExecutableDirective, isAllowedToContainClauseKind, OpenMPClauseKind, CKind)
 Matches if the OpenMP directive is allowed to contain the specified OpenMP clause kind. 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...
 
SmallVector< BoundNodes, 1 > matchDynamic (internal::DynTypedMatcher Matcher, const DynTypedNode &Node, ASTContext &Context)
 
template<typename NodeT >
SmallVector< BoundNodes, 1 > matchDynamic (internal::DynTypedMatcher Matcher, const NodeT &Node, ASTContext &Context)
 
SmallVector< BoundNodes, 1 > matchDynamic (internal::DynTypedMatcher Matcher, ASTContext &Context)
 
internal::BindableMatcher< StmtgtestAssert (GtestCmp Cmp, StatementMatcher Left, StatementMatcher Right)
 Matcher for gtest's ASSERT comparison macros including ASSERT_EQ, ASSERT_NE, ASSERT_GE, ASSERT_GT, ASSERT_LE and ASSERT_LT. More...
 
internal::BindableMatcher< StmtgtestAssertThat (StatementMatcher Actual, StatementMatcher Matcher)
 Matcher for gtest's ASSERT_THAT macro. More...
 
internal::BindableMatcher< StmtgtestExpect (GtestCmp Cmp, StatementMatcher Left, StatementMatcher Right)
 Matcher for gtest's EXPECT comparison macros including EXPECT_EQ, EXPECT_NE, EXPECT_GE, EXPECT_GT, EXPECT_LE and EXPECT_LT. More...
 
internal::BindableMatcher< StmtgtestExpectThat (StatementMatcher Actual, StatementMatcher Matcher)
 Matcher for gtest's EXPECT_THAT macro. More...
 
internal::BindableMatcher< StmtgtestExpectCall (StatementMatcher MockObject, llvm::StringRef MockMethodName, MockArgs Args)
 Matcher for gtest's EXPECT_CALL macro. More...
 
internal::BindableMatcher< StmtgtestExpectCall (StatementMatcher MockCall, MockArgs Args)
 Matcher for gtest's EXPECT_CALL macro. More...
 
internal::BindableMatcher< StmtgtestOnCall (StatementMatcher MockObject, llvm::StringRef MockMethodName, MockArgs Args)
 Like the first gtestExpectCall overload but for ON_CALL. More...
 
internal::BindableMatcher< StmtgtestOnCall (StatementMatcher MockCall, MockArgs Args)
 Like the second gtestExpectCall overload but for ON_CALL. 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))
 
static DeclarationMatcher getComparisonDecl (GtestCmp Cmp)
 
static llvm::StringRef getMacroTypeName (MacroType Macro)
 
static llvm::StringRef getComparisonTypeName (GtestCmp Cmp)
 
static std::string getMacroName (MacroType Macro, GtestCmp Cmp)
 
static std::string getMacroName (MacroType Macro, llvm::StringRef Operation)
 
static llvm::StringRef getSpecSetterName (MacroType Macro)
 
static internal::BindableMatcher< StmtgtestComparisonInternal (MacroType Macro, GtestCmp Cmp, StatementMatcher Left, StatementMatcher Right)
 
static internal::BindableMatcher< StmtgtestThatInternal (MacroType Macro, StatementMatcher Actual, StatementMatcher Matcher)
 
static internal::BindableMatcher< StmtgtestCallInternal (MacroType Macro, StatementMatcher MockCall, MockArgs Args)
 
static internal::BindableMatcher< StmtgtestCallInternal (MacroType Macro, StatementMatcher MockObject, llvm::StringRef MockMethodName, MockArgs Args)
 
 AST_MATCHER_P (StringLiteral, mentionsBoundType, std::string, BindingID)
 

Variables

const internal::VariadicDynCastAllOfMatcher< Decl, TranslationUnitDecltranslationUnitDecl
 Matches the top declaration context. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefDecltypedefDecl
 Matches typedef declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefNameDecltypedefNameDecl
 Matches typedef name declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, TypeAliasDecltypeAliasDecl
 Matches type alias declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, TypeAliasTemplateDecltypeAliasTemplateDecl
 Matches type alias template declarations. More...
 
const internal::VariadicAllOfMatcher< Decldecl
 Matches declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, DecompositionDecldecompositionDecl
 Matches decomposition-declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, BindingDeclbindingDecl
 Matches binding declarations Example matches foo and bar (matcher = bindingDecl() More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, LinkageSpecDecllinkageSpecDecl
 Matches a declaration of a linkage specification. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, NamedDeclnamedDecl
 Matches a declaration of anything that could have a name. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, LabelDecllabelDecl
 Matches a declaration of label. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceDeclnamespaceDecl
 Matches a declaration of a namespace. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceAliasDeclnamespaceAliasDecl
 Matches a declaration of a namespace alias. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, RecordDeclrecordDecl
 Matches class, struct, and union declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, CXXRecordDeclcxxRecordDecl
 Matches C++ class declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateDeclclassTemplateDecl
 Matches C++ class template declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateSpecializationDeclclassTemplateSpecializationDecl
 Matches C++ class template specializations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplatePartialSpecializationDeclclassTemplatePartialSpecializationDecl
 Matches C++ class template partial specializations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, DeclaratorDecldeclaratorDecl
 Matches declarator declarations (field, variable, function and non-type template parameter declarations). More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, ParmVarDeclparmVarDecl
 Matches parameter variable declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, AccessSpecDeclaccessSpecDecl
 Matches C++ access specifier declarations. More...
 
const internal::VariadicAllOfMatcher< CXXBaseSpecifiercxxBaseSpecifier
 Matches class bases. More...
 
const internal::VariadicAllOfMatcher< CXXCtorInitializercxxCtorInitializer
 Matches constructor initializers. More...
 
const internal::VariadicAllOfMatcher< TemplateArgumenttemplateArgument
 Matches template arguments. More...
 
const internal::VariadicAllOfMatcher< TemplateArgumentLoctemplateArgumentLoc
 Matches template arguments (with location info). More...
 
const internal::VariadicAllOfMatcher< TemplateNametemplateName
 Matches template name. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, NonTypeTemplateParmDeclnonTypeTemplateParmDecl
 Matches non-type template parameter declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, TemplateTypeParmDecltemplateTypeParmDecl
 Matches template type parameter declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, TemplateTemplateParmDecltemplateTemplateParmDecl
 Matches template template parameter declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAutoreleasePoolStmtautoreleasePoolStmt
 Matches an Objective-C autorelease pool statement. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, ValueDeclvalueDecl
 Matches any value declaration. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, CXXConstructorDeclcxxConstructorDecl
 Matches C++ constructor declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, CXXDestructorDeclcxxDestructorDecl
 Matches explicit C++ destructor declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, EnumDeclenumDecl
 Matches enum declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, EnumConstantDeclenumConstantDecl
 Matches enum constants. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, TagDecltagDecl
 Matches tag declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, CXXMethodDeclcxxMethodDecl
 Matches method declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, CXXConversionDeclcxxConversionDecl
 Matches conversion operator declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, CXXDeductionGuideDeclcxxDeductionGuideDecl
 Matches user-defined and implicitly generated deduction guide. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, VarDeclvarDecl
 Matches variable declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, FieldDeclfieldDecl
 Matches field declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, IndirectFieldDeclindirectFieldDecl
 Matches indirect field declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionDeclfunctionDecl
 Matches function declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionTemplateDeclfunctionTemplateDecl
 Matches C++ function template declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, FriendDeclfriendDecl
 Matches friend declarations. More...
 
const internal::VariadicAllOfMatcher< Stmtstmt
 Matches statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclStmtdeclStmt
 Matches declaration statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, MemberExprmemberExpr
 Matches member expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, UnresolvedMemberExprunresolvedMemberExpr
 Matches unresolved member expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDependentScopeMemberExprcxxDependentScopeMemberExpr
 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, CallExprcallExpr
 Matches call expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, LambdaExprlambdaExpr
 Matches lambda expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXMemberCallExprcxxMemberCallExpr
 Matches member call expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCMessageExprobjcMessageExpr
 Matches ObjectiveC Message invocation expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCInterfaceDeclobjcInterfaceDecl
 Matches Objective-C interface declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCImplementationDeclobjcImplementationDecl
 Matches Objective-C implementation declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCProtocolDeclobjcProtocolDecl
 Matches Objective-C protocol declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCCategoryDeclobjcCategoryDecl
 Matches Objective-C category declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCCategoryImplDeclobjcCategoryImplDecl
 Matches Objective-C category definitions. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCMethodDeclobjcMethodDecl
 Matches Objective-C method declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, BlockDeclblockDecl
 Matches block declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCIvarDeclobjcIvarDecl
 Matches Objective-C instance variable declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCPropertyDeclobjcPropertyDecl
 Matches Objective-C property declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtThrowStmtobjcThrowStmt
 Matches Objective-C @throw statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtTryStmtobjcTryStmt
 Matches Objective-C @try statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtCatchStmtobjcCatchStmt
 Matches Objective-C @catch statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtFinallyStmtobjcFinallyStmt
 Matches Objective-C @finally statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ExprWithCleanupsexprWithCleanups
 Matches expressions that introduce cleanups to be run at the end of the sub-expression's evaluation. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, InitListExprinitListExpr
 Matches init list expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStdInitializerListExprcxxStdInitializerListExpr
 Matches C++ initializer list expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitValueInitExprimplicitValueInitExpr
 Matches implicit initializers of init list expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ParenListExprparenListExpr
 Matches paren list expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, SubstNonTypeTemplateParmExprsubstNonTypeTemplateParmExpr
 Matches substitutions of non-type template parameters. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, UsingDeclusingDecl
 Matches using declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, UsingEnumDeclusingEnumDecl
 Matches using-enum declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, UsingDirectiveDeclusingDirectiveDecl
 Matches using namespace declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, UnresolvedLookupExprunresolvedLookupExpr
 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, UnresolvedUsingValueDeclunresolvedUsingValueDecl
 Matches unresolved using value declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingTypenameDeclunresolvedUsingTypenameDecl
 Matches unresolved using value declarations that involve the typename. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ConstantExprconstantExpr
 Matches a constant expression wrapper. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ParenExprparenExpr
 Matches parentheses used in expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstructExprcxxConstructExpr
 Matches constructor call expressions (including implicit ones). More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXUnresolvedConstructExprcxxUnresolvedConstructExpr
 Matches unresolved constructor call expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThisExprcxxThisExpr
 Matches implicit and explicit this expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBindTemporaryExprcxxBindTemporaryExpr
 Matches nodes where temporaries are created. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, MaterializeTemporaryExprmaterializeTemporaryExpr
 Matches nodes where temporaries are materialized. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNewExprcxxNewExpr
 Matches new expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDeleteExprcxxDeleteExpr
 Matches delete expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNoexceptExprcxxNoexceptExpr
 Matches noexcept expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ArraySubscriptExprarraySubscriptExpr
 Matches array subscript expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDefaultArgExprcxxDefaultArgExpr
 Matches the value of a default argument at the call site. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXOperatorCallExprcxxOperatorCallExpr
 Matches overloaded operator calls. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXRewrittenBinaryOperatorcxxRewrittenBinaryOperator
 Matches rewritten binary operators. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, Exprexpr
 Matches expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclRefExprdeclRefExpr
 Matches expressions that refer to declarations. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCIvarRefExprobjcIvarRefExpr
 Matches a reference to an ObjCIvar. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, BlockExprblockExpr
 Matches a reference to a block. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, IfStmtifStmt
 Matches if statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ForStmtforStmt
 Matches for statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXForRangeStmtcxxForRangeStmt
 Matches range-based for statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, WhileStmtwhileStmt
 Matches while statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, DoStmtdoStmt
 Matches do statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, BreakStmtbreakStmt
 Matches break statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ContinueStmtcontinueStmt
 Matches continue statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CoreturnStmtcoreturnStmt
 Matches co_return statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ReturnStmtreturnStmt
 Matches return statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, GotoStmtgotoStmt
 Matches goto statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, LabelStmtlabelStmt
 Matches label statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, AddrLabelExpraddrLabelExpr
 Matches address of label statements (GNU extension). More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchStmtswitchStmt
 Matches switch statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchCaseswitchCase
 Matches case and default statements inside switch statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CaseStmtcaseStmt
 Matches case statements inside switch statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, DefaultStmtdefaultStmt
 Matches default statements inside switch statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundStmtcompoundStmt
 Matches compound statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXCatchStmtcxxCatchStmt
 Matches catch statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTryStmtcxxTryStmt
 Matches try statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThrowExprcxxThrowExpr
 Matches throw expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, NullStmtnullStmt
 Matches null statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, AsmStmtasmStmt
 Matches asm statements. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBoolLiteralExprcxxBoolLiteral
 Matches bool literals. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, StringLiteralstringLiteral
 Matches string literals (also matches wide string literals). More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CharacterLiteralcharacterLiteral
 Matches character literals (also matches wchar_t). More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, IntegerLiteralintegerLiteral
 Matches integer literals of all sizes / encodings, e.g. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, FloatingLiteralfloatLiteral
 Matches float literals of all sizes / encodings, e.g. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ImaginaryLiteralimaginaryLiteral
 Matches imaginary literals, which are based on integer and floating point literals e.g. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, FixedPointLiteralfixedPointLiteral
 Matches fixed point literals. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, UserDefinedLiteraluserDefinedLiteral
 Matches user defined literal operator call. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundLiteralExprcompoundLiteralExpr
 Matches compound (i.e. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CoawaitExprcoawaitExpr
 Matches co_await expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, DependentCoawaitExprdependentCoawaitExpr
 Matches co_await expressions where the type of the promise is dependent. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CoyieldExprcoyieldExpr
 Matches co_yield expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNullPtrLiteralExprcxxNullPtrLiteralExpr
 Matches nullptr literal. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ChooseExprchooseExpr
 Matches GNU __builtin_choose_expr. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, GNUNullExprgnuNullExpr
 Matches GNU __null expression. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, GenericSelectionExprgenericSelectionExpr
 Matches C11 _Generic expression. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, AtomicExpratomicExpr
 Matches atomic builtins. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, StmtExprstmtExpr
 Matches statement expression (GNU extension). More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryOperatorbinaryOperator
 Matches binary operator expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryOperatorunaryOperator
 Matches unary operator expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ConditionalOperatorconditionalOperator
 Matches conditional operator expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryConditionalOperatorbinaryConditionalOperator
 Matches binary conditional operator expressions (GNU extension). More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, OpaqueValueExpropaqueValueExpr
 Matches opaque value expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Decl, StaticAssertDeclstaticAssertDecl
 Matches a C++ static_assert declaration. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXReinterpretCastExprcxxReinterpretCastExpr
 Matches a reinterpret_cast expression. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStaticCastExprcxxStaticCastExpr
 Matches a C++ static_cast expression. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDynamicCastExprcxxDynamicCastExpr
 Matches a dynamic_cast expression. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstCastExprcxxConstCastExpr
 Matches a const_cast expression. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CStyleCastExprcStyleCastExpr
 Matches a C-style cast expression. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ExplicitCastExprexplicitCastExpr
 Matches explicit cast expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitCastExprimplicitCastExpr
 Matches the implicit cast nodes of Clang's AST. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExprcastExpr
 Matches any cast nodes of Clang's AST. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXFunctionalCastExprcxxFunctionalCastExpr
 Matches functional cast expressions. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTemporaryObjectExprcxxTemporaryObjectExpr
 Matches functional cast expressions having N != 1 arguments. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, PredefinedExprpredefinedExpr
 Matches predefined identifier expressions [C99 6.4.2.2]. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, DesignatedInitExprdesignatedInitExpr
 Matches C99 designated initializer expressions [C99 6.7.8]. More...
 
const internal::VariadicAllOfMatcher< QualTypequalType
 Matches QualTypes in the clang AST. More...
 
const internal::VariadicAllOfMatcher< Typetype
 Matches Types in the clang AST. More...
 
const internal::VariadicAllOfMatcher< TypeLoctypeLoc
 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::VariadicOperatorMatcherFunc< 1, 1 > optionally
 Matches any node regardless of the submatcher. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryExprOrTypeTraitExprunaryExprOrTypeTraitExpr
 Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) More...
 
const internal::MapAnyOfMatcher< BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperatorbinaryOperation
 Matches nodes which can be used with binary operators. More...
 
const internal::MapAnyOfMatcher< CallExpr, CXXConstructExprinvocation
 Matches function calls and constructor calls. More...
 
const internal::VariadicFunction< internal::Matcher< NamedDecl >, StringRef, internal::hasAnyNameFunchasAnyName = {}
 Matches NamedDecl nodes that have any of the specified names. More...
 
const internal::VariadicFunction< internal::PolymorphicMatcher< internal::HasOverloadedOperatorNameMatcher, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl), std::vector< std::string > >, StringRef, internal::hasAnyOverloadedOperatorNameFunchasAnyOverloadedOperatorName = {}
 Matches overloaded operator 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, Attr >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr > > 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, Attr >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr > > 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::hasAnySelectorFunchasAnySelector = {}
 Matches when at least one of the supplied string equals to the Selector.getAsString() More...
 
const internal::VariadicFunction< internal::PolymorphicMatcher< internal::HasAnyOperatorNameMatcher, AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, UnaryOperator), std::vector< std::string > >, StringRef, internal::hasAnyOperatorNameFunchasAnyOperatorName = {}
 Matches operator expressions (binary or unary) that have any of the specified names. More...
 
const AstTypeMatcher< BuiltinTypebuiltinType
 Matches builtin Types. More...
 
const AstTypeMatcher< ArrayTypearrayType
 Matches all kinds of arrays. More...
 
const AstTypeMatcher< ComplexTypecomplexType
 Matches C99 complex types. More...
 
const AstTypeMatcher< ConstantArrayTypeconstantArrayType
 Matches C arrays with a specified constant size. More...
 
const AstTypeMatcher< DependentSizedArrayTypedependentSizedArrayType
 Matches C++ arrays whose size is a value-dependent expression. More...
 
const AstTypeMatcher< IncompleteArrayTypeincompleteArrayType
 Matches C arrays with unspecified size. More...
 
const AstTypeMatcher< VariableArrayTypevariableArrayType
 Matches C arrays with a specified size that is not an integer-constant-expression. More...
 
const AstTypeMatcher< AtomicTypeatomicType
 Matches atomic types. More...
 
const AstTypeMatcher< AutoTypeautoType
 Matches types nodes representing C++11 auto types. More...
 
const AstTypeMatcher< DecltypeTypedecltypeType
 Matches types nodes representing C++11 decltype(<expr>) types. More...
 
const AstTypeMatcher< FunctionTypefunctionType
 Matches FunctionType nodes. More...
 
const AstTypeMatcher< FunctionProtoTypefunctionProtoType
 Matches FunctionProtoType nodes. More...
 
const AstTypeMatcher< ParenTypeparenType
 Matches ParenType nodes. More...
 
const AstTypeMatcher< BlockPointerTypeblockPointerType
 Matches block pointer types, i.e. More...
 
const AstTypeMatcher< MemberPointerTypememberPointerType
 Matches member pointer types. More...
 
const AstTypeMatcher< PointerTypepointerType
 Matches pointer types, but does not match Objective-C object pointer types. More...
 
const AstTypeMatcher< ObjCObjectPointerTypeobjcObjectPointerType
 Matches an Objective-C object pointer type, which is different from a pointer type, despite being syntactically similar. More...
 
const AstTypeMatcher< ReferenceTypereferenceType
 Matches both lvalue and rvalue reference types. More...
 
const AstTypeMatcher< LValueReferenceTypelValueReferenceType
 Matches lvalue reference types. More...
 
const AstTypeMatcher< RValueReferenceTyperValueReferenceType
 Matches rvalue reference types. More...
 
const AstTypeMatcher< TypedefTypetypedefType
 Matches typedef types. More...
 
const AstTypeMatcher< EnumTypeenumType
 Matches enum types. More...
 
const AstTypeMatcher< TemplateSpecializationTypetemplateSpecializationType
 Matches template specialization types. More...
 
const AstTypeMatcher< DeducedTemplateSpecializationTypededucedTemplateSpecializationType
 Matches C++17 deduced template specialization types, e.g. More...
 
const AstTypeMatcher< UnaryTransformTypeunaryTransformType
 Matches types nodes representing unary type transformations. More...
 
const AstTypeMatcher< RecordTyperecordType
 Matches record types (e.g. More...
 
const AstTypeMatcher< TagTypetagType
 Matches tag types (record and enum types). More...
 
const AstTypeMatcher< ElaboratedTypeelaboratedType
 Matches types specified with an elaborated type keyword or with a qualified name. More...
 
const AstTypeMatcher< SubstTemplateTypeParmTypesubstTemplateTypeParmType
 Matches types that represent the result of substituting a type for a template type parameter. More...
 
const AstTypeMatcher< TemplateTypeParmTypetemplateTypeParmType
 Matches template type parameter types. More...
 
const AstTypeMatcher< InjectedClassNameTypeinjectedClassNameType
 Matches injected class name types. More...
 
const AstTypeMatcher< DecayedTypedecayedType
 Matches decayed type Example matches i[] in declaration of f. More...
 
const internal::VariadicAllOfMatcher< NestedNameSpecifiernestedNameSpecifier
 Matches nested name specifiers. More...
 
const internal::VariadicAllOfMatcher< NestedNameSpecifierLocnestedNameSpecifierLoc
 Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. More...
 
const internal::VariadicAllOfMatcher< Attrattr
 Matches attributes. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, CUDAKernelCallExprcudaKernelCallExpr
 Matches CUDA kernel call expression. More...
 
const internal::VariadicDynCastAllOfMatcher< Stmt, OMPExecutableDirectiveompExecutableDirective
 Matches any #pragma omp executable directive. More...
 
const internal::VariadicDynCastAllOfMatcher< OMPClause, OMPDefaultClauseompDefaultClause
 Matches OpenMP default clause. More...
 

Typedef Documentation

◆ AstTypeMatcher

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

Definition at line 6363 of file ASTMatchers.h.

◆ AttrMatcher

using clang::ast_matchers::AttrMatcher = typedef internal::Matcher<Attr>

Definition at line 151 of file ASTMatchers.h.

◆ CXXBaseSpecifierMatcher

Definition at line 147 of file ASTMatchers.h.

◆ CXXCtorInitializerMatcher

Definition at line 148 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 141 of file ASTMatchers.h.

◆ NestedNameSpecifierLocMatcher

Definition at line 146 of file ASTMatchers.h.

◆ NestedNameSpecifierMatcher

Definition at line 145 of file ASTMatchers.h.

◆ StatementMatcher

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

Definition at line 142 of file ASTMatchers.h.

◆ TemplateArgumentLocMatcher

Definition at line 150 of file ASTMatchers.h.

◆ TemplateArgumentMatcher

Definition at line 149 of file ASTMatchers.h.

◆ TypeLocMatcher

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

Definition at line 144 of file ASTMatchers.h.

◆ TypeMatcher

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

Definition at line 143 of file ASTMatchers.h.

Enumeration Type Documentation

◆ GtestCmp

Gtest's comparison operations.

Enumerator
Eq 
Ne 
Ge 
Gt 
Le 
Lt 

Definition at line 25 of file GtestMatchers.h.

◆ MockArgs

This enum indicates whether the mock method in the matched ON_CALL or EXPECT_CALL macro has arguments.

For example, None can be used to match ON_CALL(mock, TwoParamMethod) whereas Some can be used to match ON_CALL(mock, TwoParamMethod(m1, m2)).

Enumerator
None 
Some 

Definition at line 38 of file GtestMatchers.h.

Function Documentation

◆ alignOfExpr()

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

Same as unaryExprOrTypeTraitExpr, but only matching alignof.

Definition at line 2959 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.

◆ AST_MATCHER() [1/71]

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() {
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 1484 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [2/71]

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 4431 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [3/71]

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

Matches a constructor call expression which uses list initialization.

Definition at line 4636 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [4/71]

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 4652 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [5/71]

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 7251 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [6/71]

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 7281 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [7/71]

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 7298 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [8/71]

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 7266 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [9/71]

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 4530 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [10/71]

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 4550 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [11/71]

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 4510 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [12/71]

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 5926 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [13/71]

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 5943 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [14/71]

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 5960 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [15/71]

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 5978 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [16/71]

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 5911 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [17/71]

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 5993 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [18/71]

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 5876 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [19/71]

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 7736 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [20/71]

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 7789 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [21/71]

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 3367 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [22/71]

clang::ast_matchers::AST_MATCHER ( Decl  ,
isInStdNamespace   
)

Matches declarations in the namespace std, but not in nested namespaces.

Given

class vector {};
namespace foo {
class vector {};
namespace std {
class vector {};
}
}
namespace std {
inline namespace __1 {
class vector {}; // #1
namespace experimental {
class vector {};
}
}
}

cxxRecordDecl(hasName("vector"), isInStdNamespace()) will match only #1.

Definition at line 7421 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [23/71]

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 7800 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [24/71]

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 1017 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [25/71]

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 1033 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [26/71]

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 1044 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [27/71]

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 690 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [28/71]

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 7811 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [29/71]

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 5025 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [30/71]

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 5012 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [31/71]

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 735 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [32/71]

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

Matches FunctionDecls that have a noreturn attribute.

Given

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

functionDecl(isNoReturn()) matches all of those except

void nope();

Definition at line 4948 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [33/71]

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 5765 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [34/71]

clang::ast_matchers::AST_MATCHER ( FunctionDecl  ,
isWeak   
)

Matches weak function declarations.

Given:

void foo() __attribute__((__weakref__("__foo")));
void bar();

functionDecl(isWeak()) matches the weak declaration "foo", but not "bar".

Definition at line 5038 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [35/71]

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 7699 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [36/71]

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 7396 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [37/71]

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 3789 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [38/71]

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 3761 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [39/71]

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 3773 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [40/71]

clang::ast_matchers::AST_MATCHER ( ObjCMessageExpr  ,
isClassMessage   
)

Returns true when the Objective-C message is sent to a class.

Example matcher = objcMessageExpr(isClassMessage()) matches

[NSString stringWithFormat:@"format"];

but not

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

Definition at line 3677 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [41/71]

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

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

Example matcher = objcMessageExpr(isInstanceMessage()) matches

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

but not

[NSString stringWithFormat:@"format"];

Definition at line 3694 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [42/71]

clang::ast_matchers::AST_MATCHER ( ObjCMethodDecl  ,
isClassMethod   
)

Returns true when the Objective-C method declaration is a class method.

Example matcher = objcMethodDecl(isClassMethod()) matches

@interface I + (void)foo; @end

but not

@interface I - (void)bar; @end

Definition at line 3644 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [43/71]

clang::ast_matchers::AST_MATCHER ( ObjCMethodDecl  ,
isInstanceMethod   
)

Returns true when the Objective-C method declaration is an instance method.

Example matcher = objcMethodDecl(isInstanceMethod()) matches

@interface I - (void)bar; @end

but not

@interface I + (void)foo; @end

Definition at line 3660 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [44/71]

clang::ast_matchers::AST_MATCHER ( OMPDefaultClause  ,
isFirstPrivateKind   
)

Matches if the OpenMP default clause has firstprivate kind specified.

Given

#pragma omp parallel
#pragma omp parallel default(none)
#pragma omp parallel default(shared)
#pragma omp parallel default(firstprivate)

ompDefaultClause(isFirstPrivateKind()) matches only default(firstprivate).

Definition at line 8002 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [45/71]

clang::ast_matchers::AST_MATCHER ( OMPDefaultClause  ,
isNoneKind   
)

Matches if the OpenMP default clause has none kind specified.

Given

#pragma omp parallel
#pragma omp parallel default(none)
#pragma omp parallel default(shared)
#pragma omp parallel default(firstprivate)

ompDefaultClause(isNoneKind()) matches only default(none).

Definition at line 7968 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [46/71]

clang::ast_matchers::AST_MATCHER ( OMPDefaultClause  ,
isSharedKind   
)

Matches if the OpenMP default clause has shared kind specified.

Given

#pragma omp parallel
#pragma omp parallel default(none)
#pragma omp parallel default(shared)
#pragma omp parallel default(firstprivate)

ompDefaultClause(isSharedKind()) matches only default(shared).

Definition at line 7984 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [47/71]

clang::ast_matchers::AST_MATCHER ( OMPExecutableDirective  ,
isStandaloneDirective   
)

Matches standalone OpenMP directives, i.e., directives that can't have a structured block.

Given

#pragma omp parallel
{}
#pragma omp taskyield

ompExecutableDirective(isStandaloneDirective())) matches omp taskyield.

Definition at line 7895 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [48/71]

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) {}

Deprecated. Use hasInitializer() instead to be able to match on the contents of the default argument. For example:

void x(int val = 7) {}
void y(int val = 42) {}

parmVarDecl(hasInitializer(integerLiteral(equals(42)))) matches the parameter of y

A matcher such as parmVarDecl(hasInitializer(anything())) is equivalent to parmVarDecl(hasDefaultArgument()).

Definition at line 7724 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [49/71]

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 6154 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [50/71]

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 6079 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [51/71]

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 6099 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [52/71]

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 6118 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [53/71]

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 6037 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [54/71]

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 6065 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [55/71]

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 6051 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [56/71]

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 6137 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [57/71]

clang::ast_matchers::AST_MATCHER ( TagDecl  ,
isClass   
)

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

Example matches C, but not S, U or E.

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

Definition at line 5678 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [58/71]

clang::ast_matchers::AST_MATCHER ( TagDecl  ,
isEnum   
)

Matches TagDecl object that are spelled with "enum.".

Example matches E, but not C, S or U.

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

Definition at line 5691 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [59/71]

clang::ast_matchers::AST_MATCHER ( TagDecl  ,
isStruct   
)

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

Example matches S, but not C, U or E.

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

Definition at line 5652 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [60/71]

clang::ast_matchers::AST_MATCHER ( TagDecl  ,
isUnion   
)

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

Example matches U, but not C, S or E.

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

Definition at line 5665 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [61/71]

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 1179 of file ASTMatchers.h.

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

◆ AST_MATCHER() [62/71]

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

Matches type bool.

Given

struct S { bool func(); };

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

Definition at line 6346 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [63/71]

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 6410 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [64/71]

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

Matches type void.

Given

struct S { void func(); };

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

Definition at line 6358 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [65/71]

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 4261 of file ASTMatchers.h.

References Node, and clang::SD_Automatic.

◆ AST_MATCHER() [66/71]

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 4245 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [67/71]

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 4231 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [68/71]

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 4281 of file ASTMatchers.h.

References Node, and clang::SD_Static.

◆ AST_MATCHER() [69/71]

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 4297 of file ASTMatchers.h.

References Node, and clang::SD_Thread.

◆ AST_MATCHER() [70/71]

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 4312 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER() [71/71]

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 4216 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 6286 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< 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 7498 of file ASTMatchers.h.

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

◆ AST_MATCHER_FUNCTION() [3/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 6306 of file ASTMatchers.h.

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

◆ AST_MATCHER_FUNCTION_P_OVERLOAD() [1/2]

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

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

Definition at line 7041 of file ASTMatchers.h.

◆ AST_MATCHER_FUNCTION_P_OVERLOAD() [2/2]

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

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

Definition at line 6332 of file ASTMatchers.h.

◆ AST_MATCHER_P() [1/93]

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 5721 of file ASTMatchers.h.

◆ AST_MATCHER_P() [2/93]

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 5706 of file ASTMatchers.h.

◆ AST_MATCHER_P() [3/93]

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 5264 of file ASTMatchers.h.

◆ AST_MATCHER_P() [4/93]

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 5247 of file ASTMatchers.h.

◆ AST_MATCHER_P() [5/93]

clang::ast_matchers::AST_MATCHER_P ( BaseUsingDecl  ,
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 6214 of file ASTMatchers.h.

◆ AST_MATCHER_P() [6/93]

clang::ast_matchers::AST_MATCHER_P ( BindingDecl  ,
forDecomposition  ,
internal::Matcher< ValueDecl ,
InnerMatcher   
)

Matches the DecompositionDecl the binding belongs to.

For example, in:

void foo()
{
int arr[3];
auto &[f, s, t] = arr;
f = 42;
}

The matcher:

forDecomposition(decompositionDecl())

matches 'f' in 'auto &[f, s, t]'.

Definition at line 7522 of file ASTMatchers.h.

◆ AST_MATCHER_P() [7/93]

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 3824 of file ASTMatchers.h.

◆ AST_MATCHER_P() [8/93]

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 7432 of file ASTMatchers.h.

◆ AST_MATCHER_P() [9/93]

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;

If the matcher is use from clang-query, CastKind parameter should be passed as a quoted string. e.g., hasCastKind("CK_NullToPointer").

Definition at line 5620 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_P() [10/93]

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 749 of file ASTMatchers.h.

◆ AST_MATCHER_P() [11/93]

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

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 5364 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_P() [12/93]

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 7223 of file ASTMatchers.h.

◆ AST_MATCHER_P() [13/93]

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 4448 of file ASTMatchers.h.

◆ AST_MATCHER_P() [14/93]

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 4470 of file ASTMatchers.h.

◆ AST_MATCHER_P() [15/93]

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 4490 of file ASTMatchers.h.

◆ AST_MATCHER_P() [16/93]

clang::ast_matchers::AST_MATCHER_P ( CXXDependentScopeMemberExpr  ,
hasMemberName  ,
std::string  ,
 
)

Matches template-dependent, but known, member names.

In template declarations, dependent members are not resolved and so can not be matched to particular named declarations.

This matcher allows to match on the known name of members.

Given

template <typename T>
struct S {
void mem();
};
template <typename T>
void x() {
S<T> s;
s.mem();
}

cxxDependentScopeMemberExpr(hasMemberName("mem")) matches s.mem()

Definition at line 3095 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_P() [17/93]

clang::ast_matchers::AST_MATCHER_P ( CXXDependentScopeMemberExpr  ,
memberHasSameNameAsBoundNode  ,
std::string  ,
BindingID   
)

Matches template-dependent, but known, member names against an already-bound node.

In template declarations, dependent members are not resolved and so can not be matched to particular named declarations.

This matcher allows to match on the name of already-bound VarDecl, FieldDecl and CXXMethodDecl nodes.

Given

template <typename T>
struct S {
void mem();
};
template <typename T>
void x() {
S<T> s;
s.mem();
}

The matcher

hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
cxxMethodDecl(hasName("mem")).bind("templMem")
)))))
)))),
memberHasSameNameAsBoundNode("templMem")
)

first matches and binds the mem member of the S template, then compares its name to the usage in s.mem() in the x function template

Definition at line 3133 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_P() [18/93]

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 2128 of file ASTMatchers.h.

◆ AST_MATCHER_P() [19/93]

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 2142 of file ASTMatchers.h.

◆ AST_MATCHER_P() [20/93]

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

Matches on the implicit object argument of a member call expression, after stripping off any parentheses or implicit casts.

Given

class Y { public: void m(); };
Y g();
class X : public Y {};
void z(Y y, X x) { y.m(); (g()).m(); x.m(); }

cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))))) matches y.m() and (g()).m(). cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X"))))) matches x.m(). cxxMemberCallExpr(on(callExpr())) matches (g()).m().

FIXME: Overload to allow directly matching types?

Definition at line 3607 of file ASTMatchers.h.

◆ AST_MATCHER_P() [21/93]

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

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

Unlike on, matches the argument directly without stripping away anything.

Given

class Y { public: void m(); };
Y g();
class X : public Y { void g(); };
void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); }

cxxMemberCallExpr(onImplicitObjectArgument(hasType( cxxRecordDecl(hasName("Y"))))) matches y.m(), x.m() and (g()).m(), but not x.g(). cxxMemberCallExpr(on(callExpr())) does not match (g()).m(), because the parens are not ignored.

FIXME: Overload to allow directly matching types?

Definition at line 4075 of file ASTMatchers.h.

◆ AST_MATCHER_P() [22/93]

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 5820 of file ASTMatchers.h.

◆ AST_MATCHER_P() [23/93]

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 5786 of file ASTMatchers.h.

◆ AST_MATCHER_P() [24/93]

clang::ast_matchers::AST_MATCHER_P ( CXXNewExpr  ,
hasAnyPlacementArg  ,
internal::Matcher< Expr ,
InnerMatcher   
)

Matches any placement new expression arguments.

Given:

MyClass *p1 = new (Storage) MyClass();

cxxNewExpr(hasAnyPlacementArg(anything())) matches the expression 'new (Storage, 16) MyClass()'.

Definition at line 7762 of file ASTMatchers.h.

◆ AST_MATCHER_P() [25/93]

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(integerLiteral(equals(10)))) matches the expression 'new MyClass[10]'.

Definition at line 7777 of file ASTMatchers.h.

◆ AST_MATCHER_P() [26/93]

clang::ast_matchers::AST_MATCHER_P ( CXXRecordDecl  ,
hasAnyBase  ,
internal::Matcher< CXXBaseSpecifier ,
BaseSpecMatcher   
)

Matches C++ classes that have a direct or indirect base matching BaseSpecMatcher.

Example: matcher hasAnyBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))

class Foo;
class Bar : Foo {};
class Baz : Bar {};
class SpecialBase;
class Proxy : SpecialBase {}; // matches Proxy
class IndirectlyDerived : Proxy {}; //matches IndirectlyDerived

Definition at line 3225 of file ASTMatchers.h.

References clang::ast_matchers::internal::matchesAnyBase(), and Node.

◆ AST_MATCHER_P() [27/93]

clang::ast_matchers::AST_MATCHER_P ( CXXRecordDecl  ,
hasDirectBase  ,
internal::Matcher< CXXBaseSpecifier ,
BaseSpecMatcher   
)

Matches C++ classes that have a direct base matching BaseSpecMatcher.

Example: matcher hasDirectBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))

class Foo;
class Bar : Foo {};
class Baz : Bar {};
class SpecialBase;
class Proxy : SpecialBase {}; // matches Proxy
class IndirectlyDerived : Proxy {}; // doesn't match

Definition at line 3242 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_P() [28/93]

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 3344 of file ASTMatchers.h.

◆ AST_MATCHER_P() [29/93]

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

Matches the decayed type, whoes decayed type matches InnerMatcher.

Definition at line 6994 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_P() [30/93]

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 used from clang-query, attr::Kind parameter should be passed as a quoted string. e.g., hasAttr("attr::CUDADevice").

Definition at line 7449 of file ASTMatchers.h.

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

◆ AST_MATCHER_P() [31/93]

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 7013 of file ASTMatchers.h.

◆ AST_MATCHER_P() [32/93]

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 4143 of file ASTMatchers.h.

◆ AST_MATCHER_P() [33/93]

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 4122 of file ASTMatchers.h.

◆ AST_MATCHER_P() [34/93]

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

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 4385 of file ASTMatchers.h.

References distance(), and Node.

◆ AST_MATCHER_P() [35/93]

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 4182 of file ASTMatchers.h.

◆ AST_MATCHER_P() [36/93]

clang::ast_matchers::AST_MATCHER_P ( DecompositionDecl  ,
hasAnyBinding  ,
internal::Matcher< BindingDecl ,
InnerMatcher   
)

Matches any binding of a DecompositionDecl.

For example, in:

void foo()
{
int arr[3];
auto &[f, s, t] = arr;
f = 42;
}

The matcher:

decompositionDecl(hasAnyBinding(bindingDecl(hasName("f").bind("fBinding"))))

matches the decomposition decl with 'f' bound to "fBinding".

Definition at line 7571 of file ASTMatchers.h.

◆ AST_MATCHER_P() [37/93]

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

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 2696 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_P() [38/93]

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 6901 of file ASTMatchers.h.

◆ AST_MATCHER_P() [39/93]

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 6924 of file ASTMatchers.h.

◆ AST_MATCHER_P() [40/93]

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 5628 of file ASTMatchers.h.

◆ AST_MATCHER_P() [41/93]

clang::ast_matchers::AST_MATCHER_P ( Expr  ,
ignoringElidableConstructorCall  ,
ast_matchers::internal::Matcher< Expr ,
InnerMatcher   
)

Matches expressions that match InnerMatcher that are possibly wrapped in an elidable constructor and other corresponding bookkeeping nodes.

In C++17, elidable copy constructors are no longer being generated in the AST as it is not permitted by the standard. They are, however, part of the AST in C++14 and earlier. So, a matcher must abstract over these differences to work in all language modes. This matcher skips elidable constructor-call AST nodes, ExprWithCleanups nodes wrapping elidable constructor-calls and various implicit nodes inside the constructor calls, all of which will not appear in the C++17 AST.

Given

struct H {};
H G();
void f() {
H D = G();
}

varDecl(hasInitializer(ignoringElidableConstructorCall(callExpr()))) matches H D = G() in C++11 through C++17 (and beyond).

Definition at line 7840 of file ASTMatchers.h.

◆ AST_MATCHER_P() [42/93]

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 a.

Definition at line 919 of file ASTMatchers.h.

◆ AST_MATCHER_P() [43/93]

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 889 of file ASTMatchers.h.

◆ AST_MATCHER_P() [44/93]

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 941 of file ASTMatchers.h.

◆ AST_MATCHER_P() [45/93]

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 966 of file ASTMatchers.h.

◆ AST_MATCHER_P() [46/93]

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 707 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_P() [47/93]

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 726 of file ASTMatchers.h.

◆ AST_MATCHER_P() [48/93]

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 2089 of file ASTMatchers.h.

◆ AST_MATCHER_P() [49/93]

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 2104 of file ASTMatchers.h.

◆ AST_MATCHER_P() [50/93]

clang::ast_matchers::AST_MATCHER_P ( FunctionDecl  ,
hasAnyBody  ,
internal::Matcher< Stmt ,
InnerMatcher   
)

Matches a function declaration that has a given body present in the AST.

Note that this matcher matches all the declarations of a function whose body is present in the AST.

Given

void f();
void f() {}
void g();

functionDecl(hasAnyBody(compoundStmt())) matches both 'void f();' and 'void f() {}' with compoundStmt() matching '{}' but does not match 'void g();'

Definition at line 5325 of file ASTMatchers.h.

◆ AST_MATCHER_P() [51/93]

clang::ast_matchers::AST_MATCHER_P ( FunctionDecl  ,
hasExplicitSpecifier  ,
internal::Matcher< Expr ,
InnerMatcher   
)

Matches the expression in an explicit specifier if present in the given declaration.

Given

template<bool b>
struct S {
S(int); // #1
explicit S(double); // #2
operator int(); // #3
explicit operator bool(); // #4
explicit(false) S(bool) // # 7
explicit(true) S(char) // # 8
explicit(b) S(S) // # 9
};
S(int) -> S<true> // #5
explicit S(double) -> S<false> // #6

cxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8 and #9, but not #1 or #2. cxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or #4. cxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not match #5 or #6.

Definition at line 7351 of file ASTMatchers.h.

◆ AST_MATCHER_P() [52/93]

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 4958 of file ASTMatchers.h.

◆ AST_MATCHER_P() [53/93]

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 5230 of file ASTMatchers.h.

◆ AST_MATCHER_P() [54/93]

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 5180 of file ASTMatchers.h.

◆ AST_MATCHER_P() [55/93]

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 5168 of file ASTMatchers.h.

◆ AST_MATCHER_P() [56/93]

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 5638 of file ASTMatchers.h.

◆ AST_MATCHER_P() [57/93]

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 1681 of file ASTMatchers.h.

◆ AST_MATCHER_P() [58/93]

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 6170 of file ASTMatchers.h.

◆ AST_MATCHER_P() [59/93]

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 3581 of file ASTMatchers.h.

◆ AST_MATCHER_P() [60/93]

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 7131 of file ASTMatchers.h.

◆ AST_MATCHER_P() [61/93]

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 {}; }; };

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

Definition at line 7061 of file ASTMatchers.h.

◆ AST_MATCHER_P() [62/93]

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 {}; }; };

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

Definition at line 7079 of file ASTMatchers.h.

◆ AST_MATCHER_P() [63/93]

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

Definition at line 45 of file ASTMatchersInternal.cpp.

◆ AST_MATCHER_P() [64/93]

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 3708 of file ASTMatchers.h.

◆ AST_MATCHER_P() [65/93]

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 3626 of file ASTMatchers.h.

◆ AST_MATCHER_P() [66/93]

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 3724 of file ASTMatchers.h.

References clang::Selector::getAsString(), and Node.

◆ AST_MATCHER_P() [67/93]

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

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 3804 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_P() [68/93]

clang::ast_matchers::AST_MATCHER_P ( OMPExecutableDirective  ,
hasAnyClause  ,
internal::Matcher< OMPClause ,
InnerMatcher   
)

Matches any clause in an OpenMP directive.

Given

#pragma omp parallel
#pragma omp parallel default(none)

ompExecutableDirective(hasAnyClause(anything())) matches omp parallel default(none).

Definition at line 7932 of file ASTMatchers.h.

◆ AST_MATCHER_P() [69/93]

clang::ast_matchers::AST_MATCHER_P ( OMPExecutableDirective  ,
hasStructuredBlock  ,
internal::Matcher< Stmt ,
InnerMatcher   
)

Matches the structured-block of the OpenMP executable directive.

Prerequisite: the executable directive must not be standalone directive. If it is, it will never match.

Given

#pragma omp parallel
;
#pragma omp parallel
{}

ompExecutableDirective(hasStructuredBlock(nullStmt())) will match ;

Definition at line 7914 of file ASTMatchers.h.

◆ AST_MATCHER_P() [70/93]

clang::ast_matchers::AST_MATCHER_P ( OMPExecutableDirective  ,
isAllowedToContainClauseKind  ,
OpenMPClauseKind  ,
CKind   
)

Matches if the OpenMP directive is allowed to contain the specified OpenMP clause kind.

Given

#pragma omp parallel
#pragma omp parallel for
#pragma omp for

ompExecutableDirective(isAllowedToContainClause(OMPC_default))matches omp parallelandomp parallel for`.

If the matcher is use from clang-query, OpenMPClauseKind parameter should be passed as a quoted string. e.g., isAllowedToContainClauseKind("OMPC_default").

Definition at line 8023 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_P() [71/93]

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 4166 of file ASTMatchers.h.

◆ AST_MATCHER_P() [72/93]

clang::ast_matchers::AST_MATCHER_P ( ParmVarDecl  ,
isAtPosition  ,
unsigned  ,
 
)

Matches the ParmVarDecl nodes that are at the N'th position in the parameter list.

The parameter list could be that of either a block, function, or objc-method.

Given

void f(int a, int b, int c) {
}

parmVarDecl(isAtPosition(0)) matches int a.

parmVarDecl(isAtPosition(1)) matches int b.

Definition at line 4855 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_P() [73/93]

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

Matches if the type location of a node matches the inner matcher.

Examples:

int x;

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

auto x = int(3);
\code
cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
matches int(3)
\code
struct Foo { Foo(int, int); };
auto x = Foo(1, 2);
\code
cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
matches Foo(1, 2)
Usable as: Matcher<BlockDecl>, Matcher<CXXBaseSpecifier>,
Matcher<CXXCtorInitializer>, Matcher<CXXFunctionalCastExpr>,
Matcher<CXXNewExpr>, Matcher<CXXTemporaryObjectExpr>,
Matcher<CXXUnresolvedConstructExpr>,
Matcher<ClassTemplateSpecializationDecl>, Matcher<CompoundLiteralExpr>,
Matcher<DeclaratorDecl>, Matcher<ExplicitCastExpr>,
Matcher<ObjCPropertyDecl>, Matcher<TemplateArgumentLoc>,
Matcher<TypedefNameDecl>
hasTypeLoc,
BlockDecl, CXXBaseSpecifier, CXXCtorInitializer, CXXFunctionalCastExpr,
CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr,
ClassTemplateSpecializationDecl, CompoundLiteralExpr, DeclaratorDecl,
ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc,
TypedefNameDecl),
internal::Matcher<TypeLoc>, Inner) {
TypeSourceInfo *source = internal::GetTypeSourceInfo(Node);
if (source == nullptr) {
// This happens for example for implicit destructors.
return false;
}
return Inner.matches(source->getTypeLoc(), Finder, Builder);
}
Matches if the matched type is represented by the given string.
Given
\code
class Y { public: void x(); };
void z() { Y* y; y->x(); }

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

Definition at line 3969 of file ASTMatchers.h.

◆ AST_MATCHER_P() [74/93]

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 4044 of file ASTMatchers.h.

◆ AST_MATCHER_P() [75/93]

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 3983 of file ASTMatchers.h.

◆ AST_MATCHER_P() [76/93]

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 4026 of file ASTMatchers.h.

◆ AST_MATCHER_P() [77/93]

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 7467 of file ASTMatchers.h.

◆ AST_MATCHER_P() [78/93]

clang::ast_matchers::AST_MATCHER_P ( Stmt  ,
forCallable  ,
internal::Matcher< Decl ,
InnerMatcher   
)

Matches declaration of the function, method, or block 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(forCallable(functionDecl(hasName("operator=")))) matches 'return *this' but does not match 'return v > 0'

Given:

-(void) foo {
int x = 1;
dispatch_sync(queue, ^{ int y = 2; });
}

declStmt(forCallable(objcMethodDecl())) matches 'int x = 1' but does not match 'int y = 2'. whereas declStmt(forCallable(blockDecl())) matches 'int y = 2' but does not match 'int x = 1'.

Definition at line 7647 of file ASTMatchers.h.

◆ AST_MATCHER_P() [79/93]

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

Matches declaration of the function the statement belongs to.

Deprecated. Use forCallable() to correctly handle the situation when the declaration is not a function (but a block or an Objective-C method). forFunction() not only fails to take non-functions into account but also may match the wrong declaration in their presence.

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 not match 'return v > 0'

Definition at line 7595 of file ASTMatchers.h.

◆ AST_MATCHER_P() [80/93]

clang::ast_matchers::AST_MATCHER_P ( StringLiteral  ,
mentionsBoundType  ,
std::string  ,
BindingID   
)

Definition at line 39 of file OSObjectCStyleCast.cpp.

◆ AST_MATCHER_P() [81/93]

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 7192 of file ASTMatchers.h.

◆ AST_MATCHER_P() [82/93]

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 1214 of file ASTMatchers.h.

References clang::TemplateArgument::Integral, Node, and clang::threadSafety::sx::toString().

◆ AST_MATCHER_P() [83/93]

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 1162 of file ASTMatchers.h.

◆ AST_MATCHER_P() [84/93]

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 1143 of file ASTMatchers.h.

◆ AST_MATCHER_P() [85/93]

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

Matches a TemplateArgument that refers 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 1193 of file ASTMatchers.h.

◆ AST_MATCHER_P() [86/93]

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 1123 of file ASTMatchers.h.

◆ AST_MATCHER_P() [87/93]

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 1105 of file ASTMatchers.h.

◆ AST_MATCHER_P() [88/93]

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 4007 of file ASTMatchers.h.

◆ AST_MATCHER_P() [89/93]

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 2935 of file ASTMatchers.h.

◆ AST_MATCHER_P() [90/93]

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)

If the matcher is use from clang-query, UnaryExprOrTypeTrait parameter should be passed as a quoted string. e.g., ofKind("UETT_SizeOf").

Definition at line 2953 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_P() [91/93]

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 6233 of file ASTMatchers.h.

◆ AST_MATCHER_P() [92/93]

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 4198 of file ASTMatchers.h.

◆ AST_MATCHER_P() [93/93]

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 6519 of file ASTMatchers.h.

◆ AST_MATCHER_P2() [1/4]

clang::ast_matchers::AST_MATCHER_P2 ( CXXNewExpr  ,
hasPlacementArg  ,
unsigned  ,
Index  ,
internal::Matcher< Expr ,
InnerMatcher   
)

Matches placement new expression arguments.

Given:

MyClass *p1 = new (Storage, 16) MyClass();

cxxNewExpr(hasPlacementArg(1, integerLiteral(equals(16)))) matches the expression 'new (Storage, 16) MyClass()'.

Definition at line 7748 of file ASTMatchers.h.

◆ AST_MATCHER_P2() [2/4]

clang::ast_matchers::AST_MATCHER_P2 ( DeclStmt  ,
containsDeclaration  ,
unsigned  ,
,
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 4408 of file ASTMatchers.h.

◆ AST_MATCHER_P2() [3/4]

clang::ast_matchers::AST_MATCHER_P2 ( DecompositionDecl  ,
hasBinding  ,
unsigned  ,
,
internal::Matcher< BindingDecl ,
InnerMatcher   
)

Matches the Nth binding of a DecompositionDecl.

For example, in:

void foo()
{
int arr[3];
auto &[f, s, t] = arr;
f = 42;
}

The matcher:

decompositionDecl(hasBinding(0,
bindingDecl(hasName("f").bind("fBinding"))))

matches the decomposition decl with 'f' bound to "fBinding".

Definition at line 7547 of file ASTMatchers.h.

◆ AST_MATCHER_P2() [4/4]

clang::ast_matchers::AST_MATCHER_P2 ( InitListExpr  ,
hasInit  ,
unsigned  ,
,
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 4368 of file ASTMatchers.h.

◆ AST_MATCHER_P_OVERLOAD() [1/14]

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

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 3840 of file ASTMatchers.h.

◆ AST_MATCHER_P_OVERLOAD() [2/14]

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

Overloaded to match the type's declaration.

Definition at line 4106 of file ASTMatchers.h.

◆ AST_MATCHER_P_OVERLOAD() [3/14]

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

Matches if the type of the expression's implicit object argument either matches the InnerMatcher, or is a pointer to a type that matches the InnerMatcher.

Given

class Y { public: void m(); };
class X : public Y { void g(); };
void z() { Y y; y.m(); Y *p; p->m(); X x; x.m(); x.g(); }

cxxMemberCallExpr(thisPointerType(hasDeclaration( cxxRecordDecl(hasName("Y"))))) matches y.m(), p->m() and x.m(). cxxMemberCallExpr(thisPointerType(hasDeclaration( cxxRecordDecl(hasName("X"))))) matches x.g().

Definition at line 4098 of file ASTMatchers.h.

◆ AST_MATCHER_P_OVERLOAD() [4/14]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD ( Decl  ,
equalsNode  ,
const Decl ,
Other  ,
 
)

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 7163 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_P_OVERLOAD() [5/14]

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

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 998 of file ASTMatchers.h.

◆ AST_MATCHER_P_OVERLOAD() [6/14]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD ( LambdaExpr  ,
hasAnyCapture  ,
internal::Matcher< CXXThisExpr ,
InnerMatcher  ,
 
)

Matches any capture of 'this' in a lambda expression.

Given

struct foo {
void bar() {
auto f = [this](){};
}
}

lambdaExpr(hasAnyCapture(cxxThisExpr())) matches [this](){};

Definition at line 4628 of file ASTMatchers.h.

◆ AST_MATCHER_P_OVERLOAD() [7/14]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD ( LambdaExpr  ,
hasAnyCapture  ,
internal::Matcher< VarDecl ,
InnerMatcher  ,
 
)

Matches any capture of a lambda expression.

Given

void foo() {
int x;
auto f = [x](){};
}

lambdaExpr(hasAnyCapture(anything())) matches [x](){};

Definition at line 4602 of file ASTMatchers.h.

◆ AST_MATCHER_P_OVERLOAD() [8/14]

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

Matches on the prefix of a NestedNameSpecifier.

Given

struct A { struct B { struct C {}; }; };

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

Definition at line 7094 of file ASTMatchers.h.

◆ AST_MATCHER_P_OVERLOAD() [9/14]

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

Matches on the prefix of a NestedNameSpecifierLoc.

Given

struct A { struct B { struct C {}; }; };

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

Definition at line 7112 of file ASTMatchers.h.

◆ AST_MATCHER_P_OVERLOAD() [10/14]

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

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 982 of file ASTMatchers.h.

◆ AST_MATCHER_P_OVERLOAD() [11/14]

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

Overloaded to match the pointee type's declaration.

Definition at line 3991 of file ASTMatchers.h.

◆ AST_MATCHER_P_OVERLOAD() [12/14]

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

Overloaded to match the referenced type's declaration.

Definition at line 4052 of file ASTMatchers.h.

◆ AST_MATCHER_P_OVERLOAD() [13/14]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD ( Stmt  ,
equalsNode  ,
const Stmt ,
Other  ,
 
)

Matches if a node equals another node.

Stmt has pointer identity in the AST.

Definition at line 7169 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_P_OVERLOAD() [14/14]

clang::ast_matchers::AST_MATCHER_P_OVERLOAD ( Type  ,
equalsNode  ,
const Type ,
Other  ,
 
)

Matches if a node equals another node.

Type has pointer identity in the AST.

Definition at line 7175 of file ASTMatchers.h.

References Node.

◆ AST_MATCHER_REGEX() [1/2]

clang::ast_matchers::AST_MATCHER_REGEX ( NamedDecl  ,
matchesName  ,
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 3024 of file ASTMatchers.h.

References Node, and string().

◆ AST_MATCHER_REGEX() [2/2]

clang::ast_matchers::AST_MATCHER_REGEX ( ObjCMessageExpr  ,
matchesSelector  ,
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 3752 of file ASTMatchers.h.

References Node, and string().

◆ AST_POLYMORPHIC_MATCHER() [1/21]

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 5055 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER() [2/21]

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 6021 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER() [3/21]

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

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 5476 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER() [4/21]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER ( isComparisonOperator  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator  
)

Matches comparison operators.

Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))

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

Example 2: matches s1 < s2 (matcher = cxxOperatorCallExpr(isComparisonOperator()))

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

Definition at line 5497 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER() [5/21]

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 5108 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER() [6/21]

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 5748 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER() [7/21]

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() [8/21]

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() [9/21]

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

Matches constructor, conversion function, and deduction guide declarations that have an explicit specifier if this explicit specifier is resolved to true.

Given

template<bool b>
struct S {
S(int); // #1
explicit S(double); // #2
operator int(); // #3
explicit operator bool(); // #4
explicit(false) S(bool) // # 7
explicit(true) S(char) // # 8
explicit(b) S(S) // # 9
};
S(int) -> S<true> // #5
explicit S(double) -> S<false> // #6

cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9. cxxConversionDecl(isExplicit()) will match #4, but not #3. cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.

Definition at line 7324 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER() [10/21]

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 6324 of file ASTMatchers.h.

References Node, and clang::TSK_ExplicitSpecialization.

◆ AST_POLYMORPHIC_MATCHER() [11/21]

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 4978 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER() [12/21]

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 5895 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER() [13/21]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER ( isImplicit  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Attr  
)

Matches an entity that has been implicitly added by the compiler (e.g.

implicit default/copy constructors).

Definition at line 758 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER() [14/21]

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 7375 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER() [15/21]

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 5075 of file ASTMatchers.h.

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

◆ AST_POLYMORPHIC_MATCHER() [16/21]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER ( isPrivate  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, CXXBaseSpecifier  
)

Matches private C++ declarations and C++ base specifers that specify private inheritance.

Examples:

class C {
public: int a;
protected: int b;
private: int c; // fieldDecl(isPrivate()) matches 'c'
};
struct Base {};
struct Derived1 : private Base {}; // matches 'Base'
class Derived2 : Base {}; // matches 'Base'

Definition at line 673 of file ASTMatchers.h.

References clang::AS_private, and Node.

◆ AST_POLYMORPHIC_MATCHER() [17/21]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER ( isProtected  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, CXXBaseSpecifier  
)

Matches protected C++ declarations and C++ base specifers that specify protected inheritance.

Examples:

class C {
public: int a;
protected: int b; // fieldDecl(isProtected()) matches 'b'
private: int c;
};
class Base {};
class Derived : protected Base {}; // matches 'Base'

Definition at line 650 of file ASTMatchers.h.

References clang::AS_protected, and Node.

◆ AST_POLYMORPHIC_MATCHER() [18/21]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER ( isPublic  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, CXXBaseSpecifier  
)

Matches public C++ declarations and C++ base specifers that specify public inheritance.

Examples:

class C {
public: int a; // fieldDecl(isPublic()) matches 'a'
protected: int b;
private: int c;
};
class Base {};
class Derived1 : public Base {}; // matches 'Base'
struct Derived2 : Base {}; // matches 'Base'

Definition at line 628 of file ASTMatchers.h.

References clang::AS_public, and Node.

◆ AST_POLYMORPHIC_MATCHER() [19/21]

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 4997 of file ASTMatchers.h.

References Node, and clang::SC_Static.

◆ AST_POLYMORPHIC_MATCHER() [20/21]

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 6265 of file ASTMatchers.h.

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

◆ AST_POLYMORPHIC_MATCHER() [21/21]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER ( isVirtual  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(CXXMethodDecl, CXXBaseSpecifier  
)

Matches declarations of virtual methods and C++ base specifers that specify virtual inheritance.

Example:

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

Example:

class Base {};
class DirectlyDerived : virtual Base {}; // matches Base
class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base

Usable as: Matcher<CXXMethodDecl>, Matcher<CXXBaseSpecifier>

Definition at line 5856 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER_P() [1/21]

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

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 4324 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER_P() [2/21]

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 5206 of file ASTMatchers.h.

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

◆ AST_POLYMORPHIC_MATCHER_P() [3/21]

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 4573 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [4/21]

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 4899 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [5/21]

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 5344 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [6/21]

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 784 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [7/21]

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.

Note that in case of functions this matcher only matches the definition itself and not the other declarations of the same function.

Given

for (;;) {}

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

Given

void f();
void f() {}

hasBody(functionDecl()) matches 'void f() {}' with compoundStmt() matching '{}' but does not match 'void f();'

Definition at line 5296 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [8/21]

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 5151 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [9/21]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P ( hasEitherOperand  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator ,
internal::Matcher< Expr ,
InnerMatcher   
)

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

Definition at line 5538 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [10/21]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P ( hasInitStatement  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(IfStmt, SwitchStmt, CXXForRangeStmt ,
internal::Matcher< Stmt ,
InnerMatcher   
)

Matches selection statements with initializer.

Given:

void foo() {
if (int i = foobar(); i > 0) {}
switch (int i = foobar(); i) {}
for (auto& a = get_range(); auto& x : a) {}
}
void bar() {
if (foobar() > 0) {}
switch (foobar()) {}
for (auto& x : get_range()) {}
}

ifStmt(hasInitStatement(anything())) matches the if statement in foo but not in bar. switchStmt(hasInitStatement(anything())) matches the switch statement in foo but not in bar. cxxForRangeStmt(hasInitStatement(anything())) matches the range for statement in foo but not in bar.

Definition at line 5136 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [11/21]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P ( hasLHS  ,
AST_POLYMORPHIC_SUPPORTED_TYPES( BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, 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 5510 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [12/21]

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.

Implicit object expressions are included; that is, it matches use of implicit this.

Given

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

memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))) matches x.m, but not m; however, memberExpr(hasObjectExpression(hasType(pointsTo( matches m (aka. this->m), but not x.m.

Definition at line 6191 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [13/21]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P ( hasOperatorName  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, 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 5437 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [14/21]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P ( hasRHS  ,
AST_POLYMORPHIC_SUPPORTED_TYPES( BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator, 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 5526 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [15/21]

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

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 6460 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER_P() [16/21]

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 5600 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [17/21]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P ( hasUnaryOperand  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(UnaryOperator, CXXOperatorCallExpr ,
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 5576 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [18/21]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P ( isDerivedFrom  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl ,
internal::Matcher< NamedDecl ,
Base   
)

Matches C++ classes that are directly or indirectly derived from a class matching Base, or Objective-C classes that directly or indirectly subclass 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

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

@interface NSObject @end
@interface Bar : NSObject @end

Usable as: Matcher<CXXRecordDecl>, Matcher<ObjCInterfaceDecl>

Definition at line 3179 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER_P() [19/21]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P ( isExpandedFromMacro  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc ,
std::string  ,
MacroName   
)

Matches statements that are (transitively) expanded from the named macro.

Does not match if only part of the statement is expanded from that macro or if different parts of the statement are expanded from different appearances of the macro.

Definition at line 313 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [20/21]

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

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 4927 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER_P() [21/21]

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

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 1086 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER_P2() [1/6]

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 4704 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P2() [2/6]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P2 ( forEachArgumentWithParamType  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr, CXXConstructExpr ,
internal::Matcher< Expr ,
ArgMatcher  ,
internal::Matcher< QualType ,
ParamMatcher   
)

Matches all arguments and their respective types for a CallExpr or CXXConstructExpr.

It is very similar to forEachArgumentWithParam but it works on calls through function pointers as well.

The difference is, that function pointers do not provide access to a ParmVarDecl, but only the QualType for each argument.

Given

void f(int i);
int y;
f(y);
void (*f_ptr)(int) = f;
f_ptr(y);

callExpr( forEachArgumentWithParamType( declRefExpr(to(varDecl(hasName("y")))), qualType(isInteger()).bind("type) )) matches f(y) and f_ptr(y) with declRefExpr(...) matching int y and qualType(...) matching int

Definition at line 4765 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P2() [3/6]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P2 ( hasArgument  ,
AST_POLYMORPHIC_SUPPORTED_TYPES( CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr ,
unsigned  ,
,
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 4348 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P2() [4/6]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P2 ( hasOperands  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator ,
internal::Matcher< Expr ,
Matcher1  ,
internal::Matcher< Expr ,
Matcher2   
)

Matches if both matchers match with opposite sides of the binary operator.

Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1), integerLiteral(equals(2)))

1 + 2 // Match
2 + 1 // Match
1 + 1 // No match
2 + 2 // No match

Definition at line 5558 of file ASTMatchers.h.

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

◆ AST_POLYMORPHIC_MATCHER_P2() [5/6]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P2 ( hasParameter  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl, ObjCMethodDecl, BlockDecl ,
unsigned  ,
,
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 4676 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P2() [6/6]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P2 ( hasTemplateArgument  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl, TemplateSpecializationType, FunctionDecl ,
unsigned  ,
,
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 1064 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [1/10]

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

Definition at line 5420 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [2/10]

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

Definition at line 5402 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [3/10]

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

Definition at line 5411 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [4/10]

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

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")) and public virtual X (matcher = cxxBaseSpecifier(hasType( asString("class X")))

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

Definition at line 3861 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [5/10]

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

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")) and public virtual X (matcher = cxxBaseSpecifier(hasType( cxxRecordDecl(hasName("X"))))

class X {};
void y(X &x) { x; X z; }
class Y { friend class X; };
class Z : public virtual X {};

Example matches class Derived (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))

class Base {};
class Derived : Base {};

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

Definition at line 3902 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [6/10]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P_OVERLOAD ( isDerivedFrom  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl ,
std::string  ,
BaseName  ,
 
)

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

Definition at line 3194 of file ASTMatchers.h.

References hasName(), and Node.

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [7/10]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P_OVERLOAD ( isDirectlyDerivedFrom  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl ,
internal::Matcher< NamedDecl ,
Base  ,
 
)

Matches C++ or Objective-C classes that are directly derived from a class matching Base.

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

Example matches Y, 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 3304 of file ASTMatchers.h.

References Node.

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [8/10]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P_OVERLOAD ( isDirectlyDerivedFrom  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl ,
std::string  ,
BaseName  ,
 
)

Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).

Definition at line 3319 of file ASTMatchers.h.

References hasName(), and Node.

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [9/10]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P_OVERLOAD ( isSameOrDerivedFrom  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl ,
internal::Matcher< NamedDecl ,
Base  ,
 
)

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

Definition at line 3252 of file ASTMatchers.h.

References anyOf, and Node.

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [10/10]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P_OVERLOAD ( isSameOrDerivedFrom  ,
AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl ,
std::string  ,
BaseName  ,
 
)

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

Definition at line 3267 o