clang 22.0.0git
clang::ast_matchers Namespace Reference

Namespaces

namespace  dynamic
namespace  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

using DeclarationMatcher = internal::Matcher<Decl>
 Types of matchers for the top-level classes in the AST class hierarchy.
using StatementMatcher = internal::Matcher<Stmt>
using TypeMatcher = internal::Matcher<QualType>
using TypeLocMatcher = internal::Matcher<TypeLoc>
using NestedNameSpecifierMatcher = internal::Matcher<NestedNameSpecifier>
using NestedNameSpecifierLocMatcher = internal::Matcher<NestedNameSpecifierLoc>
using CXXBaseSpecifierMatcher = internal::Matcher<CXXBaseSpecifier>
using CXXCtorInitializerMatcher = internal::Matcher<CXXCtorInitializer>
using TemplateArgumentMatcher = internal::Matcher<TemplateArgument>
using TemplateArgumentLocMatcher = internal::Matcher<TemplateArgumentLoc>
using LambdaCaptureMatcher = internal::Matcher<LambdaCapture>
using AttrMatcher = internal::Matcher<Attr>

Enumerations

enum class  GtestCmp {
  Eq , Ne , Ge , Gt ,
  Le , Lt
}
 Gtest's comparison operations. More...
enum class  MockArgs { None , 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.
 AST_POLYMORPHIC_MATCHER (isExpansionInMainFile, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc))
 Matches AST nodes that were expanded within the main-file.
 AST_POLYMORPHIC_MATCHER (isExpansionInSystemHeader, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc))
 Matches AST nodes that were expanded within system-header-files.
 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.
 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.
 AST_POLYMORPHIC_MATCHER (isPublic, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, CXXBaseSpecifier))
 Matches public C++ declarations and C++ base specifiers that specify public inheritance.
 AST_POLYMORPHIC_MATCHER (isProtected, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, CXXBaseSpecifier))
 Matches protected C++ declarations and C++ base specifiers that specify protected inheritance.
 AST_POLYMORPHIC_MATCHER (isPrivate, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, CXXBaseSpecifier))
 Matches private C++ declarations and C++ base specifiers that specify private inheritance.
 AST_MATCHER (FieldDecl, isBitField)
 Matches non-static data members that are bit-fields.
 AST_MATCHER_P (FieldDecl, hasBitWidth, unsigned, Width)
 Matches non-static data members that are bit-fields of the specified bit width.
 AST_MATCHER_P (FieldDecl, hasInClassInitializer, internal::Matcher< Expr >, InnerMatcher)
 Matches non-static data members that have an in-class initializer.
 AST_MATCHER (FunctionDecl, isMain)
 Determines whether the function is "main", which is the entry point into an executable program.
 AST_MATCHER_P (ClassTemplateSpecializationDecl, hasSpecializedTemplate, internal::Matcher< ClassTemplateDecl >, InnerMatcher)
 Matches the specialized template of a specialization declaration.
 AST_POLYMORPHIC_MATCHER (isImplicit, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Attr, LambdaCapture))
 Matches an entity that has been implicitly added by the compiler (e.g.
 AST_POLYMORPHIC_MATCHER_P (hasAnyTemplateArgument, AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl, VarTemplateSpecializationDecl, FunctionDecl, TemplateSpecializationType), internal::Matcher< TemplateArgument >, InnerMatcher)
 Matches templateSpecializationTypes, class template specializations, variable template specializations, and function template specializations that have at least one TemplateArgument matching the given InnerMatcher.
template<typename T>
internal::Matcher< Ttraverse (TraversalKind TK, const internal::Matcher< T > &InnerMatcher)
 Causes all nested matchers to be matched with the specified traversal kind.
template<typename T>
internal::BindableMatcher< Ttraverse (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... >::Type > traverse (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.
 AST_MATCHER_P (Expr, ignoringImpCasts, internal::Matcher< Expr >, InnerMatcher)
 Matches expressions that match InnerMatcher after any implicit casts are stripped off.
 AST_MATCHER_P (Expr, ignoringParenCasts, internal::Matcher< Expr >, InnerMatcher)
 Matches expressions that match InnerMatcher after parentheses and casts are stripped off.
 AST_MATCHER_P (Expr, ignoringParenImpCasts, internal::Matcher< Expr >, InnerMatcher)
 Matches expressions that match InnerMatcher after implicit casts and parentheses are stripped off.
 AST_MATCHER_P_OVERLOAD (QualType, ignoringParens, internal::Matcher< QualType >, InnerMatcher, 0)
 Matches types that match InnerMatcher after any parens are stripped.
 AST_MATCHER_P_OVERLOAD (Expr, ignoringParens, internal::Matcher< Expr >, InnerMatcher, 1)
 Overload ignoringParens for Expr.
 AST_MATCHER (Expr, isInstantiationDependent)
 Matches expressions that are instantiation-dependent even if it is neither type- nor value-dependent.
 AST_MATCHER (Expr, isTypeDependent)
 Matches expressions that are type-dependent because the template type is not yet instantiated.
 AST_MATCHER (Expr, isValueDependent)
 Matches expression that are value-dependent because they contain a non-type template parameter.
 AST_POLYMORPHIC_MATCHER_P2 (hasTemplateArgument, AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl, VarTemplateSpecializationDecl, FunctionDecl, TemplateSpecializationType), unsigned, N, internal::Matcher< TemplateArgument >, InnerMatcher)
 Matches templateSpecializationType, class template specializations, variable template specializations, and function template specializations where the n'th TemplateArgument matches the given InnerMatcher.
 AST_POLYMORPHIC_MATCHER_P (templateArgumentCountIs, AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl, VarTemplateSpecializationDecl, FunctionDecl, TemplateSpecializationType), unsigned, N)
 Matches if the number of template arguments equals N.
 AST_MATCHER_P (TemplateArgument, refersToType, internal::Matcher< QualType >, InnerMatcher)
 Matches a TemplateArgument that refers to a certain type.
 AST_MATCHER_P (TemplateArgument, refersToTemplate, internal::Matcher< TemplateName >, InnerMatcher)
 Matches a TemplateArgument that refers to a certain template.
 AST_MATCHER_P (TemplateArgument, refersToDeclaration, internal::Matcher< Decl >, InnerMatcher)
 Matches a canonical TemplateArgument that refers to a certain declaration.
 AST_MATCHER_P (TemplateArgument, isExpr, internal::Matcher< Expr >, InnerMatcher)
 Matches a sugar TemplateArgument that refers to a certain expression.
 AST_MATCHER (TemplateArgument, isIntegral)
 Matches a TemplateArgument that is an integral value.
 AST_MATCHER_P (TemplateArgument, refersToIntegralType, internal::Matcher< QualType >, InnerMatcher)
 Matches a TemplateArgument that refers to an integral type.
 AST_MATCHER_P (TemplateArgument, equalsIntegralValue, std::string, Value)
 Matches a TemplateArgument of integral type with a given value.
 AST_MATCHER (CallExpr, usesADL)
 Matches call expressions which were resolved using ADL.
 AST_MATCHER_P (InitListExpr, hasSyntacticForm, internal::Matcher< Expr >, InnerMatcher)
 Matches the syntactic form of init list expressions (if expression have it).
 AST_MATCHER_P (ForStmt, hasIncrement, internal::Matcher< Stmt >, InnerMatcher)
 Matches the increment statement of a for loop.
 AST_MATCHER_P (ForStmt, hasLoopInit, internal::Matcher< Stmt >, InnerMatcher)
 Matches the initialization statement of a for loop.
 AST_MATCHER_P (CXXForRangeStmt, hasLoopVariable, internal::Matcher< VarDecl >, InnerMatcher)
 Matches the initialization statement of a for loop.
 AST_MATCHER_P (CXXForRangeStmt, hasRangeInit, internal::Matcher< Expr >, InnerMatcher)
 Matches the range initialization statement of a for loop.
 AST_MATCHER_P (DesignatedInitExpr, designatorCountIs, unsigned, N)
 Matches designated initializer expressions that contain a specific number of designators.
template<typename T, typename... U>
auto mapAnyOf (internal::VariadicDynCastAllOfMatcher< T, U > const &...)
 Matches any of the NodeMatchers with InnerMatchers nested within.
 AST_MATCHER_P (UnaryExprOrTypeTraitExpr, hasArgumentOfType, internal::Matcher< QualType >, InnerMatcher)
 Matches unary expressions that have a specific type of argument.
 AST_MATCHER_P (UnaryExprOrTypeTraitExpr, ofKind, UnaryExprOrTypeTrait, Kind)
 Matches unary expressions of a certain kind.
internal::BindableMatcher< StmtalignOfExpr (const internal::Matcher< UnaryExprOrTypeTraitExpr > &InnerMatcher)
 Same as unaryExprOrTypeTraitExpr, but only matching alignof.
internal::BindableMatcher< StmtsizeOfExpr (const internal::Matcher< UnaryExprOrTypeTraitExpr > &InnerMatcher)
 Same as unaryExprOrTypeTraitExpr, but only matching sizeof.
internal::Matcher< NamedDeclhasName (StringRef Name)
 Matches NamedDecl nodes that have the specified name.
 AST_MATCHER_REGEX (NamedDecl, matchesName, RegExp)
 Matches NamedDecl nodes whose fully qualified names contain a substring matched by the given RegExp.
internal::PolymorphicMatcher< internal::HasOverloadedOperatorNameMatcher, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl), std::vector< std::string > > hasOverloadedOperatorName (StringRef Name)
 Matches overloaded operator names.
 AST_MATCHER_P (CXXDependentScopeMemberExpr, hasMemberName, std::string, N)
 Matches template-dependent, but known, member names.
 AST_MATCHER_P (CXXDependentScopeMemberExpr, memberHasSameNameAsBoundNode, std::string, BindingID)
 Matches template-dependent, but known, member names against an already-bound node.
 AST_POLYMORPHIC_MATCHER_P (hasDependentName, AST_POLYMORPHIC_SUPPORTED_TYPES(DependentScopeDeclRefExpr, DependentNameType), std::string, N)
 Matches the dependent name of a DependentScopeDeclRefExpr or DependentNameType.
 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.
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD (isDerivedFrom, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl), std::string, BaseName, 1)
 Overloaded method as shortcut for isDerivedFrom(hasName(...)).
 AST_MATCHER_P (CXXRecordDecl, hasAnyBase, internal::Matcher< CXXBaseSpecifier >, BaseSpecMatcher)
 Matches C++ classes that have a direct or indirect base matching BaseSpecMatcher.
 AST_MATCHER_P (CXXRecordDecl, hasDirectBase, internal::Matcher< CXXBaseSpecifier >, BaseSpecMatcher)
 Matches C++ classes that have a direct base matching BaseSpecMatcher.
 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.
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD (isSameOrDerivedFrom, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl), std::string, BaseName, 1)
 Overloaded method as shortcut for isSameOrDerivedFrom(hasName(...)).
 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.
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD (isDirectlyDerivedFrom, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXRecordDecl, ObjCInterfaceDecl), std::string, BaseName, 1)
 Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
 AST_MATCHER_P (CXXRecordDecl, hasMethod, internal::Matcher< CXXMethodDecl >, InnerMatcher)
 Matches the first method of a class or struct that satisfies InnerMatcher.
 AST_MATCHER (CXXRecordDecl, isLambda)
 Matches the generated class of lambda expressions.
template<typename T>
internal::Matcher< TfindAll (const internal::Matcher< T > &Matcher)
 Matches if the node or any descendant matches.
internal::PolymorphicMatcher< internal::HasDeclarationMatcher, void(internal::HasDeclarationSupportedTypes), internal::Matcher< Decl > > hasDeclaration (const internal::Matcher< Decl > &InnerMatcher)
 Matches a node if the declaration associated with that node matches the given matcher.
 AST_MATCHER_P (NamedDecl, hasUnderlyingDecl, internal::Matcher< NamedDecl >, InnerMatcher)
 Matches a NamedDecl whose underlying declaration matches the given matcher.
 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.
 AST_MATCHER_P (ObjCMessageExpr, hasReceiverType, internal::Matcher< QualType >, InnerMatcher)
 Matches on the receiver of an ObjectiveC Message expression.
 AST_MATCHER (ObjCMethodDecl, isClassMethod)
 Returns true when the Objective-C method declaration is a class method.
 AST_MATCHER (ObjCMethodDecl, isInstanceMethod)
 Returns true when the Objective-C method declaration is an instance method.
 AST_MATCHER (ObjCMessageExpr, isClassMessage)
 Returns true when the Objective-C message is sent to a class.
 AST_MATCHER (ObjCMessageExpr, isInstanceMessage)
 Returns true when the Objective-C message is sent to an instance.
 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.
 AST_MATCHER_P (ObjCMessageExpr, hasSelector, std::string, BaseName)
 Matches when BaseName == Selector.getAsString()
 AST_MATCHER_REGEX (ObjCMessageExpr, matchesSelector, RegExp)
 Matches ObjC selectors whose name contains a substring matched by the given RegExp.
 AST_MATCHER (ObjCMessageExpr, hasNullSelector)
 Matches when the selector is the empty selector.
 AST_MATCHER (ObjCMessageExpr, hasUnarySelector)
 Matches when the selector is a Unary Selector.
 AST_MATCHER (ObjCMessageExpr, hasKeywordSelector)
 Matches when the selector is a keyword selector.
 AST_MATCHER_P (ObjCMessageExpr, numSelectorArgs, unsigned, N)
 Matches when the selector has the specified number of arguments.
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD (callee, AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr, CXXFoldExpr), internal::Matcher< Stmt >, InnerMatcher, 0)
 Matches if the call or fold expression's callee expression matches.
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD (callee, AST_POLYMORPHIC_SUPPORTED_TYPES(ObjCMessageExpr, CallExpr), internal::Matcher< Decl >, InnerMatcher, 1)
 Matches 1) if the call expression's callee's declaration matches the given matcher; or 2) if the Obj-C message expression's callee's method declaration matches the given matcher.
 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.
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD (hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl, CXXBaseSpecifier, ObjCInterfaceDecl), internal::Matcher< Decl >, InnerMatcher, 1)
 Overloaded to match the declaration of the expression's or value declaration's type.
 AST_POLYMORPHIC_MATCHER_P (hasTypeLoc, AST_POLYMORPHIC_SUPPORTED_TYPES(BlockDecl, CXXBaseSpecifier, CXXCtorInitializer, CXXFunctionalCastExpr, CXXNewExpr, CXXTemporaryObjectExpr, CXXUnresolvedConstructExpr, CompoundLiteralExpr, DeclaratorDecl, ExplicitCastExpr, ObjCPropertyDecl, TemplateArgumentLoc, TypedefNameDecl), internal::Matcher< TypeLoc >, Inner)
 Matches if the type location of a node matches the inner matcher.
 AST_MATCHER_P (QualType, asString, std::string, Name)
 Matches if the matched type is represented by the given string.
 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.
 AST_MATCHER_P_OVERLOAD (QualType, pointsTo, internal::Matcher< Decl >, InnerMatcher, 1)
 Overloaded to match the pointee type's declaration.
 AST_MATCHER_P (Type, hasUnqualifiedDesugaredType, internal::Matcher< Type >, InnerMatcher)
 Matches if the matched type matches the unqualified desugared type of the matched node.
 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.
 AST_MATCHER_P (QualType, hasCanonicalType, internal::Matcher< QualType >, InnerMatcher)
 Matches QualTypes whose canonical type matches InnerMatcher.
 AST_MATCHER_P_OVERLOAD (QualType, references, internal::Matcher< Decl >, InnerMatcher, 1)
 Overloaded to match the referenced type's declaration.
 AST_MATCHER_P (CXXMemberCallExpr, onImplicitObjectArgument, internal::Matcher< Expr >, InnerMatcher)
 Matches on the implicit object argument of a member call expression.
 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.
 AST_MATCHER_P_OVERLOAD (CXXMemberCallExpr, thisPointerType, internal::Matcher< Decl >, InnerMatcher, 1)
 Overloaded to match the type's declaration.
 AST_MATCHER_P (DeclRefExpr, to, internal::Matcher< Decl >, InnerMatcher)
 Matches a DeclRefExpr that refers to a declaration that matches the specified matcher.
 AST_POLYMORPHIC_MATCHER_P (throughUsingDecl, AST_POLYMORPHIC_SUPPORTED_TYPES(DeclRefExpr, UsingType), internal::Matcher< UsingShadowDecl >, Inner)
 Matches if a node refers to a declaration through a specific using shadow declaration.
 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.
 AST_MATCHER_P (DeclStmt, hasSingleDecl, internal::Matcher< Decl >, InnerMatcher)
 Matches the Decl of a DeclStmt which has a single declaration.
 AST_MATCHER_P (VarDecl, hasInitializer, internal::Matcher< Expr >, InnerMatcher)
 Matches a variable declaration that has an initializer expression that matches the given matcher.
 AST_MATCHER (VarDecl, isInitCapture)
 Matches a variable serving as the implicit variable for a lambda init- capture.
 AST_MATCHER_P (LambdaExpr, forEachLambdaCapture, internal::Matcher< LambdaCapture >, InnerMatcher)
 Matches each lambda capture in a lambda expression.
 AST_MATCHER (VarDecl, isStaticLocal)
 Matches a static variable with local scope.
 AST_MATCHER (VarDecl, hasLocalStorage)
 Matches a variable declaration that has function scope and is a non-static local variable.
 AST_MATCHER (VarDecl, hasGlobalStorage)
 Matches a variable declaration that does not have local storage.
 AST_MATCHER (VarDecl, hasAutomaticStorageDuration)
 Matches a variable declaration that has automatic storage duration.
 AST_MATCHER (VarDecl, hasStaticStorageDuration)
 Matches a variable declaration that has static storage duration.
 AST_MATCHER (VarDecl, hasThreadStorageDuration)
 Matches a variable declaration that has thread storage duration.
 AST_MATCHER (VarDecl, isExceptionVariable)
 Matches a variable declaration that is an exception variable from a C++ catch block, or an Objective-C @catch statement.
 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).
 AST_POLYMORPHIC_MATCHER_P (argumentCountAtLeast, AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr, CXXConstructExpr, CXXUnresolvedConstructExpr, ObjCMessageExpr), unsigned, N)
 Checks that a call expression or a constructor call expression has at least the specified number of arguments (including absent default arguments).
 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.
 AST_MATCHER_P (CXXFoldExpr, hasFoldInit, internal::Matcher< Expr >, InnerMacher)
 Matches the operand that does not contain the parameter pack.
 AST_MATCHER_P (CXXFoldExpr, hasPattern, internal::Matcher< Expr >, InnerMacher)
 Matches the operand that contains the parameter pack.
 AST_MATCHER (CXXFoldExpr, isRightFold)
 Matches right-folding fold expressions.
 AST_MATCHER (CXXFoldExpr, isLeftFold)
 Matches left-folding fold expressions.
 AST_MATCHER (CXXFoldExpr, isUnaryFold)
 Matches unary fold expressions, i.e.
 AST_MATCHER (CXXFoldExpr, isBinaryFold)
 Matches binary fold expressions, i.e.
 AST_MATCHER_P2 (InitListExpr, hasInit, unsigned, N, internal::Matcher< Expr >, InnerMatcher)
 Matches the n'th item of an initializer list expression.
 AST_MATCHER_P (DeclStmt, declCountIs, unsigned, N)
 Matches declaration statements that contain a specific number of declarations.
 AST_MATCHER_P2 (DeclStmt, containsDeclaration, unsigned, N, internal::Matcher< Decl >, InnerMatcher)
 Matches the n'th declaration of a declaration statement.
 AST_MATCHER (CXXCatchStmt, isCatchAll)
 Matches a C++ catch statement that has a catch-all handler.
 AST_MATCHER_P (CXXConstructorDecl, hasAnyConstructorInitializer, internal::Matcher< CXXCtorInitializer >, InnerMatcher)
 Matches a constructor initializer.
 AST_MATCHER_P (CXXCtorInitializer, forField, internal::Matcher< FieldDecl >, InnerMatcher)
 Matches the field declaration of a constructor initializer.
 AST_MATCHER_P (CXXCtorInitializer, withInitializer, internal::Matcher< Expr >, InnerMatcher)
 Matches the initializer expression of a constructor initializer.
 AST_MATCHER (CXXCtorInitializer, isWritten)
 Matches a constructor initializer if it is explicitly written in code (as opposed to implicitly added by the compiler).
 AST_MATCHER (CXXCtorInitializer, isBaseInitializer)
 Matches a constructor initializer if it is initializing a base, as opposed to a member.
 AST_MATCHER (CXXCtorInitializer, isMemberInitializer)
 Matches a constructor initializer if it is initializing a member, as opposed to a base.
 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.
 AST_MATCHER_P (LambdaExpr, hasAnyCapture, internal::Matcher< LambdaCapture >, InnerMatcher)
 Matches any capture in a lambda expression.
 AST_MATCHER_P (LambdaCapture, capturesVar, internal::Matcher< ValueDecl >, InnerMatcher)
 Matches a LambdaCapture that refers to the specified VarDecl.
 AST_MATCHER (LambdaCapture, capturesThis)
 Matches a LambdaCapture that refers to 'this'.
 AST_MATCHER (CXXConstructExpr, isListInitialization)
 Matches a constructor call expression which uses list initialization.
 AST_MATCHER (CXXConstructExpr, requiresZeroInitialization)
 Matches a constructor call expression which requires zero initialization.
 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.
 AST_MATCHER (CXXMethodDecl, isExplicitObjectMemberFunction)
 Matches if the given method declaration declares a member function with an explicit object parameter.
 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.
 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.
 AST_MATCHER_P (OMPExecutableDirective, isAllowedToContainClauseKind, OpenMPClauseKind, CKind)
 / Matches each case or default statement belonging to the given switch / statement.
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.
template<typename NodeT>
const NodeT * selectFirst (StringRef BoundTo, const SmallVectorImpl< BoundNodes > &Results)
 Returns the first result of type NodeT bound to BoundTo.
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.
internal::BindableMatcher< StmtgtestAssertThat (StatementMatcher Actual, StatementMatcher Matcher)
 Matcher for gtest's ASSERT_THAT macro.
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.
internal::BindableMatcher< StmtgtestExpectThat (StatementMatcher Actual, StatementMatcher Matcher)
 Matcher for gtest's EXPECT_THAT macro.
internal::BindableMatcher< StmtgtestExpectCall (StatementMatcher MockObject, llvm::StringRef MockMethodName, MockArgs Args)
 Matcher for gtest's EXPECT_CALL macro.
internal::BindableMatcher< StmtgtestExpectCall (StatementMatcher MockCall, MockArgs Args)
 Matcher for gtest's EXPECT_CALL macro.
internal::BindableMatcher< StmtgtestOnCall (StatementMatcher MockObject, llvm::StringRef MockMethodName, MockArgs Args)
 Like the first gtestExpectCall overload but for ON_CALL.
internal::BindableMatcher< StmtgtestOnCall (StatementMatcher MockCall, MockArgs Args)
 Like the second gtestExpectCall overload but for ON_CALL.
void matchEachArgumentWithParamType (const CallExpr &Node, llvm::function_ref< void(QualType, const Expr *)> OnParamAndArg)
void matchEachArgumentWithParamType (const CXXConstructExpr &Node, llvm::function_ref< void(QualType, const Expr *)> OnParamAndArg)
 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, ObjCObjectPointerType))
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)
static const FunctionDeclgetCallee (const CXXConstructExpr &D)
static const FunctionDeclgetCallee (const CallExpr &D)
template<class ExprNode>
static void matchEachArgumentWithParamTypeImpl (const ExprNode &Node, llvm::function_ref< void(QualType, const Expr *)> OnParamAndArg)
 AST_MATCHER_P (StringLiteral, mentionsBoundType, std::string, BindingID)
template<typename MatcherT, typename NodeT>
SmallVector< BoundNodes, 1 > match (MatcherT Matcher, const NodeT &Node, ASTContext &Context)
 Returns the results of matching Matcher on Node.
template<typename MatcherT>
SmallVector< BoundNodes, 1 > match (MatcherT Matcher, const DynTypedNode &Node, ASTContext &Context)

Variables

const internal::VariadicDynCastAllOfMatcher< Decl, TranslationUnitDecltranslationUnitDecl
 Matches the top declaration context.
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefDecltypedefDecl
 Matches typedef declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, TypedefNameDecltypedefNameDecl
 Matches typedef name declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, TypeAliasDecltypeAliasDecl
 Matches type alias declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, UsingShadowDeclusingShadowDecl
 Matches shadow declarations introduced into a scope by a (resolved) using declaration.
const internal::VariadicDynCastAllOfMatcher< Decl, TypeAliasTemplateDecltypeAliasTemplateDecl
 Matches type alias template declarations.
const internal::VariadicAllOfMatcher< Decldecl
 Matches declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, DecompositionDecldecompositionDecl
 Matches decomposition-declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, BindingDeclbindingDecl
 Matches binding declarations Example matches foo and bar (matcher = bindingDecl()
const internal::VariadicDynCastAllOfMatcher< Decl, LinkageSpecDecllinkageSpecDecl
 Matches a declaration of a linkage specification.
const internal::VariadicDynCastAllOfMatcher< Decl, NamedDeclnamedDecl
 Matches a declaration of anything that could have a name.
const internal::VariadicDynCastAllOfMatcher< Decl, LabelDecllabelDecl
 Matches a declaration of label.
const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceDeclnamespaceDecl
 Matches a declaration of a namespace.
const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceAliasDeclnamespaceAliasDecl
 Matches a declaration of a namespace alias.
const internal::VariadicDynCastAllOfMatcher< Decl, RecordDeclrecordDecl
 Matches class, struct, and union declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXRecordDeclcxxRecordDecl
 Matches C++ class declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateDeclclassTemplateDecl
 Matches C++ class template declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateSpecializationDeclclassTemplateSpecializationDecl
 Matches C++ class template specializations.
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplatePartialSpecializationDeclclassTemplatePartialSpecializationDecl
 Matches C++ class template partial specializations.
const internal::VariadicDynCastAllOfMatcher< Decl, DeclaratorDecldeclaratorDecl
 Matches declarator declarations (field, variable, function and non-type template parameter declarations).
const internal::VariadicDynCastAllOfMatcher< Decl, ParmVarDeclparmVarDecl
 Matches parameter variable declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, AccessSpecDeclaccessSpecDecl
 Matches C++ access specifier declarations.
const internal::VariadicAllOfMatcher< CXXBaseSpecifiercxxBaseSpecifier
 Matches class bases.
const internal::VariadicAllOfMatcher< CXXCtorInitializercxxCtorInitializer
 Matches constructor initializers.
const internal::VariadicAllOfMatcher< TemplateArgumenttemplateArgument
 Matches template arguments.
const internal::VariadicAllOfMatcher< TemplateArgumentLoctemplateArgumentLoc
 Matches template arguments (with location info).
const internal::VariadicAllOfMatcher< TemplateNametemplateName
 Matches template name.
const internal::VariadicDynCastAllOfMatcher< Decl, NonTypeTemplateParmDeclnonTypeTemplateParmDecl
 Matches non-type template parameter declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, TemplateTypeParmDecltemplateTypeParmDecl
 Matches template type parameter declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, TemplateTemplateParmDecltemplateTemplateParmDecl
 Matches template template parameter declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAutoreleasePoolStmtautoreleasePoolStmt
 Matches an Objective-C autorelease pool statement.
const internal::VariadicDynCastAllOfMatcher< Decl, ExportDeclexportDecl
 Matches any export declaration.
const internal::VariadicDynCastAllOfMatcher< Decl, ValueDeclvalueDecl
 Matches any value declaration.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXConstructorDeclcxxConstructorDecl
 Matches C++ constructor declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXDestructorDeclcxxDestructorDecl
 Matches explicit C++ destructor declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, EnumDeclenumDecl
 Matches enum declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, EnumConstantDeclenumConstantDecl
 Matches enum constants.
const internal::VariadicDynCastAllOfMatcher< Decl, TagDecltagDecl
 Matches tag declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXMethodDeclcxxMethodDecl
 Matches method declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXConversionDeclcxxConversionDecl
 Matches conversion operator declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXDeductionGuideDeclcxxDeductionGuideDecl
 Matches user-defined and implicitly generated deduction guide.
const internal::VariadicDynCastAllOfMatcher< Decl, ConceptDeclconceptDecl
 Matches concept declarations.
const internal::VariadicDynCastAllOfMatcher< Expr, RequiresExprrequiresExpr
 Matches concept requirement.
const internal::VariadicDynCastAllOfMatcher< Decl, RequiresExprBodyDeclrequiresExprBodyDecl
 Matches concept requirement body declaration.
const internal::VariadicDynCastAllOfMatcher< Decl, VarDeclvarDecl
 Matches variable declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, FieldDeclfieldDecl
 Matches field declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, IndirectFieldDeclindirectFieldDecl
 Matches indirect field declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionDeclfunctionDecl
 Matches function declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, FunctionTemplateDeclfunctionTemplateDecl
 Matches C++ function template declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, FriendDeclfriendDecl
 Matches friend declarations.
const internal::VariadicAllOfMatcher< Stmtstmt
 Matches statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclStmtdeclStmt
 Matches declaration statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, MemberExprmemberExpr
 Matches member expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, UnresolvedMemberExprunresolvedMemberExpr
 Matches unresolved member expressions.
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.
const internal::VariadicDynCastAllOfMatcher< Stmt, CallExprcallExpr
 Matches call expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, LambdaExprlambdaExpr
 Matches lambda expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXMemberCallExprcxxMemberCallExpr
 Matches member call expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCMessageExprobjcMessageExpr
 Matches ObjectiveC Message invocation expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCStringLiteralobjcStringLiteral
 Matches ObjectiveC String literal expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCInterfaceDeclobjcInterfaceDecl
 Matches Objective-C interface declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCImplementationDeclobjcImplementationDecl
 Matches Objective-C implementation declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCProtocolDeclobjcProtocolDecl
 Matches Objective-C protocol declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCCategoryDeclobjcCategoryDecl
 Matches Objective-C category declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCCategoryImplDeclobjcCategoryImplDecl
 Matches Objective-C category definitions.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCMethodDeclobjcMethodDecl
 Matches Objective-C method declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, BlockDeclblockDecl
 Matches block declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCIvarDeclobjcIvarDecl
 Matches Objective-C instance variable declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, ObjCPropertyDeclobjcPropertyDecl
 Matches Objective-C property declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtThrowStmtobjcThrowStmt
 Matches Objective-C @throw statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtTryStmtobjcTryStmt
 Matches Objective-C @try statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtCatchStmtobjcCatchStmt
 Matches Objective-C @catch statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtFinallyStmtobjcFinallyStmt
 Matches Objective-C @finally statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, ExprWithCleanupsexprWithCleanups
 Matches expressions that introduce cleanups to be run at the end of the sub-expression's evaluation.
const internal::VariadicDynCastAllOfMatcher< Stmt, InitListExprinitListExpr
 Matches init list expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStdInitializerListExprcxxStdInitializerListExpr
 Matches C++ initializer list expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitValueInitExprimplicitValueInitExpr
 Matches implicit initializers of init list expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, ParenListExprparenListExpr
 Matches paren list expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, SubstNonTypeTemplateParmExprsubstNonTypeTemplateParmExpr
 Matches substitutions of non-type template parameters.
const internal::VariadicDynCastAllOfMatcher< Decl, UsingDeclusingDecl
 Matches using declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, UsingEnumDeclusingEnumDecl
 Matches using-enum declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, UsingDirectiveDeclusingDirectiveDecl
 Matches using namespace declarations.
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.
const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingValueDeclunresolvedUsingValueDecl
 Matches unresolved using value declarations.
const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingTypenameDeclunresolvedUsingTypenameDecl
 Matches unresolved using value declarations that involve the typename.
const internal::VariadicDynCastAllOfMatcher< Stmt, ConstantExprconstantExpr
 Matches a constant expression wrapper.
const internal::VariadicDynCastAllOfMatcher< Stmt, ParenExprparenExpr
 Matches parentheses used in expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstructExprcxxConstructExpr
 Matches constructor call expressions (including implicit ones).
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXUnresolvedConstructExprcxxUnresolvedConstructExpr
 Matches unresolved constructor call expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThisExprcxxThisExpr
 Matches implicit and explicit this expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBindTemporaryExprcxxBindTemporaryExpr
 Matches nodes where temporaries are created.
const internal::VariadicDynCastAllOfMatcher< Stmt, MaterializeTemporaryExprmaterializeTemporaryExpr
 Matches nodes where temporaries are materialized.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNewExprcxxNewExpr
 Matches new expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDeleteExprcxxDeleteExpr
 Matches delete expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNoexceptExprcxxNoexceptExpr
 Matches noexcept expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, ArrayInitLoopExprarrayInitLoopExpr
 Matches a loop initializing the elements of an array in a number of contexts:
const internal::VariadicDynCastAllOfMatcher< Stmt, ArrayInitIndexExprarrayInitIndexExpr
 The arrayInitIndexExpr consists of two subexpressions: a common expression (the source array) that is evaluated once up-front, and a per-element initializer that runs once for each array element.
const internal::VariadicDynCastAllOfMatcher< Stmt, ArraySubscriptExprarraySubscriptExpr
 Matches array subscript expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDefaultArgExprcxxDefaultArgExpr
 Matches the value of a default argument at the call site.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXOperatorCallExprcxxOperatorCallExpr
 Matches overloaded operator calls.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXFoldExprcxxFoldExpr
 Matches C++17 fold expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXRewrittenBinaryOperatorcxxRewrittenBinaryOperator
 Matches rewritten binary operators.
const internal::VariadicDynCastAllOfMatcher< Stmt, Exprexpr
 Matches expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclRefExprdeclRefExpr
 Matches expressions that refer to declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, DependentScopeDeclRefExprdependentScopeDeclRefExpr
 Matches expressions that refer to dependent scope declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCIvarRefExprobjcIvarRefExpr
 Matches a reference to an ObjCIvar.
const internal::VariadicDynCastAllOfMatcher< Stmt, BlockExprblockExpr
 Matches a reference to a block.
const internal::VariadicDynCastAllOfMatcher< Stmt, IfStmtifStmt
 Matches if statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, ForStmtforStmt
 Matches for statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXForRangeStmtcxxForRangeStmt
 Matches range-based for statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, WhileStmtwhileStmt
 Matches while statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, DoStmtdoStmt
 Matches do statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, BreakStmtbreakStmt
 Matches break statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, ContinueStmtcontinueStmt
 Matches continue statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CoreturnStmtcoreturnStmt
 Matches co_return statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, ReturnStmtreturnStmt
 Matches return statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, GotoStmtgotoStmt
 Matches goto statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, LabelStmtlabelStmt
 Matches label statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, AddrLabelExpraddrLabelExpr
 Matches address of label statements (GNU extension).
const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchStmtswitchStmt
 Matches switch statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchCaseswitchCase
 Matches case and default statements inside switch statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CaseStmtcaseStmt
 Matches case statements inside switch statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, DefaultStmtdefaultStmt
 Matches default statements inside switch statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundStmtcompoundStmt
 Matches compound statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXCatchStmtcxxCatchStmt
 Matches catch statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTryStmtcxxTryStmt
 Matches try statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThrowExprcxxThrowExpr
 Matches throw expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, NullStmtnullStmt
 Matches null statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, AsmStmtasmStmt
 Matches asm statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBoolLiteralExprcxxBoolLiteral
 Matches bool literals.
const internal::VariadicDynCastAllOfMatcher< Stmt, StringLiteralstringLiteral
 Matches string literals (also matches wide string literals).
const internal::VariadicDynCastAllOfMatcher< Stmt, CharacterLiteralcharacterLiteral
 Matches character literals (also matches wchar_t).
const internal::VariadicDynCastAllOfMatcher< Stmt, IntegerLiteralintegerLiteral
 Matches integer literals of all sizes / encodings, e.g.
const internal::VariadicDynCastAllOfMatcher< Stmt, FloatingLiteralfloatLiteral
 Matches float literals of all sizes / encodings, e.g.
const internal::VariadicDynCastAllOfMatcher< Stmt, ImaginaryLiteralimaginaryLiteral
 Matches imaginary literals, which are based on integer and floating point literals e.g.: 1i, 1.0i.
const internal::VariadicDynCastAllOfMatcher< Stmt, FixedPointLiteralfixedPointLiteral
 Matches fixed-point literals eg.
const internal::VariadicDynCastAllOfMatcher< Stmt, UserDefinedLiteraluserDefinedLiteral
 Matches user defined literal operator call.
const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundLiteralExprcompoundLiteralExpr
 Matches compound (i.e.
const internal::VariadicDynCastAllOfMatcher< Stmt, CoawaitExprcoawaitExpr
 Matches co_await expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, DependentCoawaitExprdependentCoawaitExpr
 Matches co_await expressions where the type of the promise is dependent.
const internal::VariadicDynCastAllOfMatcher< Stmt, CoyieldExprcoyieldExpr
 Matches co_yield expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CoroutineBodyStmtcoroutineBodyStmt
 Matches coroutine body statements.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNullPtrLiteralExprcxxNullPtrLiteralExpr
 Matches nullptr literal.
const internal::VariadicDynCastAllOfMatcher< Stmt, ChooseExprchooseExpr
 Matches GNU __builtin_choose_expr.
const internal::VariadicDynCastAllOfMatcher< Stmt, ConvertVectorExprconvertVectorExpr
 Matches builtin function __builtin_convertvector.
const internal::VariadicDynCastAllOfMatcher< Stmt, GNUNullExprgnuNullExpr
 Matches GNU __null expression.
const internal::VariadicDynCastAllOfMatcher< Stmt, GenericSelectionExprgenericSelectionExpr
 Matches C11 _Generic expression.
const internal::VariadicDynCastAllOfMatcher< Stmt, AtomicExpratomicExpr
 Matches atomic builtins.
const internal::VariadicDynCastAllOfMatcher< Stmt, StmtExprstmtExpr
 Matches statement expression (GNU extension).
const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryOperatorbinaryOperator
 Matches binary operator expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryOperatorunaryOperator
 Matches unary operator expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, ConditionalOperatorconditionalOperator
 Matches conditional operator expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryConditionalOperatorbinaryConditionalOperator
 Matches binary conditional operator expressions (GNU extension).
const internal::VariadicDynCastAllOfMatcher< Stmt, OpaqueValueExpropaqueValueExpr
 Matches opaque value expressions.
const internal::VariadicDynCastAllOfMatcher< Decl, StaticAssertDeclstaticAssertDecl
 Matches a C++ static_assert declaration.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXReinterpretCastExprcxxReinterpretCastExpr
 Matches a reinterpret_cast expression.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStaticCastExprcxxStaticCastExpr
 Matches a C++ static_cast expression.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDynamicCastExprcxxDynamicCastExpr
 Matches a dynamic_cast expression.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstCastExprcxxConstCastExpr
 Matches a const_cast expression.
const internal::VariadicDynCastAllOfMatcher< Stmt, CStyleCastExprcStyleCastExpr
 Matches a C-style cast expression.
const internal::VariadicDynCastAllOfMatcher< Stmt, ExplicitCastExprexplicitCastExpr
 Matches explicit cast expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitCastExprimplicitCastExpr
 Matches the implicit cast nodes of Clang's AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExprcastExpr
 Matches any cast nodes of Clang's AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXFunctionalCastExprcxxFunctionalCastExpr
 Matches functional cast expressions.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTemporaryObjectExprcxxTemporaryObjectExpr
 Matches functional cast expressions having N != 1 arguments.
const internal::VariadicDynCastAllOfMatcher< Stmt, PredefinedExprpredefinedExpr
 Matches predefined identifier expressions [C99 6.4.2.2].
const internal::VariadicDynCastAllOfMatcher< Stmt, DesignatedInitExprdesignatedInitExpr
 Matches C99 designated initializer expressions [C99 6.7.8].
const internal::VariadicAllOfMatcher< QualTypequalType
 Matches QualTypes in the clang AST.
const internal::VariadicAllOfMatcher< Typetype
 Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< TypeLoctypeLoc
 Matches TypeLocs in the clang AST.
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> eachOf = {internal::DynTypedMatcher::VO_EachOf}
 Matches if any of the given matchers matches.
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> anyOf = {internal::DynTypedMatcher::VO_AnyOf}
 Matches if any of the given matchers matches.
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> allOf = {internal::DynTypedMatcher::VO_AllOf}
 Matches if all given matchers match.
const internal::VariadicOperatorMatcherFunc< 1, 1 > optionally
 Matches any node regardless of the submatcher.
const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryExprOrTypeTraitExprunaryExprOrTypeTraitExpr
 Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
const internal::MapAnyOfMatcher< BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperatorbinaryOperation
 Matches nodes which can be used with binary operators.
const internal::MapAnyOfMatcher< CallExpr, CXXConstructExprinvocation
 Matches function calls and constructor calls.
const internal::VariadicFunction< internal::Matcher< NamedDecl >, StringRef, internal::hasAnyNameFunchasAnyName = {}
 Matches NamedDecl nodes that have any of the specified names.
const internal::VariadicFunction< internal::PolymorphicMatcher< internal::HasOverloadedOperatorNameMatcher, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl), std::vector< std::string > >, StringRef, internal::hasAnyOverloadedOperatorNameFunchasAnyOverloadedOperatorName = {}
 Matches overloaded operator names.
const internal::ArgumentAdaptingMatcherFunc< internal::HasMatcher > has = {}
 Matches AST nodes that have child AST nodes that match the provided matcher.
const internal::ArgumentAdaptingMatcherFunc< internal::HasDescendantMatcher > hasDescendant = {}
 Matches AST nodes that have descendant AST nodes that match the provided matcher.
const internal::ArgumentAdaptingMatcherFunc< internal::ForEachMatcher > forEach
 Matches AST nodes that have child AST nodes that match the provided matcher.
const internal::ArgumentAdaptingMatcherFunc< internal::ForEachDescendantMatcher > forEachDescendant = {}
 Matches AST nodes that have descendant AST nodes that match the provided matcher.
const internal::ArgumentAdaptingMatcherFunc< internal::HasParentMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr > > hasParent = {}
 Matches AST nodes that have a parent that matches the provided matcher.
const internal::ArgumentAdaptingMatcherFunc< internal::HasAncestorMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr > > hasAncestor = {}
 Matches AST nodes that have an ancestor that matches the provided matcher.
const internal::VariadicOperatorMatcherFunc< 1, 1 > unless
 Matches if the provided matcher does not match.
const internal::VariadicFunction< internal::Matcher< ObjCMessageExpr >, StringRef, internal::hasAnySelectorFunchasAnySelector = {}
 Matches when at least one of the supplied string equals to the Selector.getAsString()
const internal::VariadicAllOfMatcher< LambdaCapturelambdaCapture
 Matches lambda captures.
const internal::VariadicDynCastAllOfMatcher< TypeLoc, QualifiedTypeLocqualifiedTypeLoc
const internal::VariadicDynCastAllOfMatcher< TypeLoc, PointerTypeLocpointerTypeLoc
const internal::VariadicDynCastAllOfMatcher< TypeLoc, ReferenceTypeLocreferenceTypeLoc
const internal::VariadicDynCastAllOfMatcher< TypeLoc, TemplateSpecializationTypeLoctemplateSpecializationTypeLoc
const internal::VariadicFunction< internal::HasOpNameMatcher, StringRef, internal::hasAnyOperatorNameFunchasAnyOperatorName = {}
const internal::VariadicAllOfMatcher< NestedNameSpecifiernestedNameSpecifier
const internal::VariadicAllOfMatcher< NestedNameSpecifierLocnestedNameSpecifierLoc
const internal::VariadicAllOfMatcher< Attrattr
const internal::VariadicDynCastAllOfMatcher< Stmt, CUDAKernelCallExprcudaKernelCallExpr
const AstTypeMatcher< BuiltinTypebuiltinType
const AstTypeMatcher< ArrayTypearrayType
const AstTypeMatcher< ComplexTypecomplexType
const AstTypeMatcher< ConstantArrayTypeconstantArrayType
const AstTypeMatcher< DeducedTemplateSpecializationType > deducedTemplateSpecializationType
const AstTypeMatcher< DependentSizedArrayTypedependentSizedArrayType
const AstTypeMatcher< DependentSizedExtVectorTypedependentSizedExtVectorType
const AstTypeMatcher< IncompleteArrayTypeincompleteArrayType
const AstTypeMatcher< VariableArrayTypevariableArrayType
const AstTypeMatcher< AtomicTypeatomicType
const AstTypeMatcher< AutoType > autoType
const AstTypeMatcher< DecltypeType > decltypeType
const AstTypeMatcher< FunctionTypefunctionType
const AstTypeMatcher< FunctionProtoTypefunctionProtoType
const AstTypeMatcher< ParenTypeparenType
const AstTypeMatcher< BlockPointerTypeblockPointerType
const AstTypeMatcher< MacroQualifiedTypemacroQualifiedType
const AstTypeMatcher< MemberPointerTypememberPointerType
const AstTypeMatcher< PointerTypepointerType
const AstTypeMatcher< ObjCObjectPointerTypeobjcObjectPointerType
const AstTypeMatcher< ReferenceTypereferenceType
const AstTypeMatcher< LValueReferenceTypelValueReferenceType
const AstTypeMatcher< RValueReferenceTyperValueReferenceType
const AstTypeMatcher< TypedefTypetypedefType
const AstTypeMatcher< EnumType > enumType
const AstTypeMatcher< TemplateSpecializationType > templateSpecializationType
const AstTypeMatcher< UnaryTransformType > unaryTransformType
const AstTypeMatcher< RecordType > recordType
const AstTypeMatcher< TagType > tagType
const AstTypeMatcher< UsingTypeusingType
const AstTypeMatcher< SubstTemplateTypeParmType > substTemplateTypeParmType
const AstTypeMatcher< TemplateTypeParmType > templateTypeParmType
const AstTypeMatcher< InjectedClassNameType > injectedClassNameType
const AstTypeMatcher< DecayedTypedecayedType
const AstTypeMatcher< DependentNameType > dependentNameType
const AstTypeMatcher< DependentTemplateSpecializationType > dependentTemplateSpecializationType
const internal::VariadicDynCastAllOfMatcher< Stmt, OMPExecutableDirectiveompExecutableDirective
const internal::VariadicDynCastAllOfMatcher< OMPClause, OMPDefaultClauseompDefaultClause

Typedef Documentation

◆ AttrMatcher

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

Definition at line 156 of file ASTMatchers.h.

◆ CXXBaseSpecifierMatcher

Definition at line 151 of file ASTMatchers.h.

◆ CXXCtorInitializerMatcher

Definition at line 152 of file ASTMatchers.h.

◆ DeclarationMatcher

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

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

Definition at line 145 of file ASTMatchers.h.

◆ LambdaCaptureMatcher

Definition at line 155 of file ASTMatchers.h.

◆ NestedNameSpecifierLocMatcher

Definition at line 150 of file ASTMatchers.h.

◆ NestedNameSpecifierMatcher

Definition at line 149 of file ASTMatchers.h.

◆ StatementMatcher

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

Definition at line 146 of file ASTMatchers.h.

◆ TemplateArgumentLocMatcher

Definition at line 154 of file ASTMatchers.h.

◆ TemplateArgumentMatcher

Definition at line 153 of file ASTMatchers.h.

◆ TypeLocMatcher

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

Definition at line 148 of file ASTMatchers.h.

◆ TypeMatcher

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

Definition at line 147 of file ASTMatchers.h.

Enumeration Type Documentation

◆ GtestCmp

enum class clang::ast_matchers::GtestCmp
strong

Gtest's comparison operations.

Enumerator
Eq 
Ne 
Ge 
Gt 
Le 
Lt 

Definition at line 25 of file GtestMatchers.h.

◆ MockArgs

enum class clang::ast_matchers::MockArgs
strong

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

References allOf, anyOf, stmt, and unaryExprOrTypeTraitExpr.

◆ 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();
#define and
Definition iso646.h:17

Usable as: Any Matcher

Definition at line 173 of file ASTMatchers.h.

◆ AST_MATCHER() [1/35]

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

Matches call expressions which were resolved using ADL.

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

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

Definition at line 1552 of file ASTMatchers.h.

◆ AST_MATCHER() [2/35]

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

◆ AST_MATCHER() [3/35]

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

Matches a constructor call expression which uses list initialization.

Definition at line 5100 of file ASTMatchers.h.

◆ AST_MATCHER() [4/35]

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

◆ AST_MATCHER() [5/35]

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

◆ AST_MATCHER() [6/35]

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

◆ AST_MATCHER() [7/35]

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

◆ AST_MATCHER() [8/35]

clang::ast_matchers::AST_MATCHER ( CXXFoldExpr ,
isBinaryFold  )

Matches binary fold expressions, i.e.

fold expressions with an initializer.

Example matches (0 + ... + args) (matcher = cxxFoldExpr(isBinaryFold()))

template <typename... Args>
auto sum(Args... args) {
return (0 + ... + args);
}
template <typename... Args>
auto multiply(Args... args) {
return (args * ...);
}

Definition at line 4790 of file ASTMatchers.h.

◆ AST_MATCHER() [9/35]

clang::ast_matchers::AST_MATCHER ( CXXFoldExpr ,
isLeftFold  )

Matches left-folding fold expressions.

Example matches (0 + ... + args) (matcher = cxxFoldExpr(isLeftFold()))

template <typename... Args>
auto sum(Args... args) {
return (0 + ... + args);
}
template <typename... Args>
auto multiply(Args... args) {
return (args * ... * 1);
}

Definition at line 4755 of file ASTMatchers.h.

◆ AST_MATCHER() [10/35]

clang::ast_matchers::AST_MATCHER ( CXXFoldExpr ,
isRightFold  )

Matches right-folding fold expressions.

Example matches (args * ... * 1) (matcher = cxxFoldExpr(isRightFold()))

template <typename... Args>
auto sum(Args... args) {
return (0 + ... + args);
}
template <typename... Args>
auto multiply(Args... args) {
return (args * ... * 1);
}

Definition at line 4738 of file ASTMatchers.h.

◆ AST_MATCHER() [11/35]

clang::ast_matchers::AST_MATCHER ( CXXFoldExpr ,
isUnaryFold  )

Matches unary fold expressions, i.e.

fold expressions without an initializer.

Example matches (args * ...) (matcher = cxxFoldExpr(isUnaryFold()))

template <typename... Args>
auto sum(Args... args) {
return (0 + ... + args);
}
template <typename... Args>
auto multiply(Args... args) {
return (args * ...);
}

Definition at line 4773 of file ASTMatchers.h.

◆ AST_MATCHER() [12/35]

clang::ast_matchers::AST_MATCHER ( CXXMethodDecl ,
isExplicitObjectMemberFunction  )

Matches if the given method declaration declares a member function with an explicit object parameter.

Given

struct A {
int operator-(this A, int);
void fun(this A &&self);
static int operator()(int);
int operator+(int);
};

cxxMethodDecl(isExplicitObjectMemberFunction()) matches the first two methods but not the last two.

Definition at line 5165 of file ASTMatchers.h.

◆ AST_MATCHER() [13/35]

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

◆ AST_MATCHER() [14/35]

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()); }
const FunctionProtoType * T

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

Definition at line 1036 of file ASTMatchers.h.

References clang::Expr::isInstantiationDependent().

◆ AST_MATCHER() [15/35]

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

◆ AST_MATCHER() [16/35]

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

◆ AST_MATCHER() [17/35]

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

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

Given

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

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

Definition at line 708 of file ASTMatchers.h.

◆ AST_MATCHER() [18/35]

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

◆ AST_MATCHER() [19/35]

clang::ast_matchers::AST_MATCHER ( LambdaCapture ,
capturesThis  )

Matches a LambdaCapture that refers to 'this'.

Given

class C {
int cc;
int f() {
auto l = [this]() { return cc; };
return l();
}
};

lambdaExpr(hasAnyCapture(lambdaCapture(capturesThis()))) matches [this]() { return cc; }.

Definition at line 5097 of file ASTMatchers.h.

◆ AST_MATCHER() [20/35]

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

◆ AST_MATCHER() [21/35]

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

◆ AST_MATCHER() [22/35]

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];
#define NULL

Definition at line 3969 of file ASTMatchers.h.

◆ AST_MATCHER() [23/35]

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

◆ AST_MATCHER() [24/35]

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

◆ AST_MATCHER() [25/35]

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

◆ AST_MATCHER() [26/35]

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

References clang::isInstanceMethod().

◆ AST_MATCHER() [27/35]

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

Matches a TemplateArgument that is an integral value.

Given

template<int T> struct C {};
__device__ __2f16 float c

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

Definition at line 1206 of file ASTMatchers.h.

References clang::TemplateArgument::Integral.

◆ AST_MATCHER() [28/35]

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

References clang::SD_Automatic.

◆ AST_MATCHER() [29/35]

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

◆ AST_MATCHER() [30/35]

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

◆ AST_MATCHER() [31/35]

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.
const internal::VariadicDynCastAllOfMatcher< Decl, VarDecl > varDecl
Matches variable declarations.

Definition at line 4572 of file ASTMatchers.h.

References clang::SD_Static.

◆ AST_MATCHER() [32/35]

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

References clang::SD_Thread.

◆ AST_MATCHER() [33/35]

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

◆ AST_MATCHER() [34/35]

clang::ast_matchers::AST_MATCHER ( VarDecl ,
isInitCapture  )

Matches a variable serving as the implicit variable for a lambda init- capture.

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

auto f = [x=3]() { return x; };

Definition at line 4465 of file ASTMatchers.h.

◆ AST_MATCHER() [35/35]

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

◆ AST_MATCHER_P() [1/54]

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

◆ AST_MATCHER_P() [2/54]

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

◆ AST_MATCHER_P() [3/54]

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

◆ AST_MATCHER_P() [4/54]

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

◆ AST_MATCHER_P() [5/54]

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

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();
}
__device__ __2f16 float __ockl_bool s

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

Definition at line 3269 of file ASTMatchers.h.

◆ AST_MATCHER_P() [6/54]

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")
)
const internal::VariadicDynCastAllOfMatcher< Stmt, DeclRefExpr > declRefExpr
Matches expressions that refer to declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDependentScopeMemberExpr > cxxDependentScopeMemberExpr
Matches member expressions where the actual member referenced could not be resolved because the base ...
internal::Matcher< NamedDecl > hasName(StringRef Name)
Matches NamedDecl nodes that have the specified name.
const internal::ArgumentAdaptingMatcherFunc< internal::HasMatcher > has
Matches AST nodes that have child AST nodes that match the provided matcher.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXRecordDecl > cxxRecordDecl
Matches C++ class declarations.
internal::PolymorphicMatcher< internal::HasDeclarationMatcher, void(internal::HasDeclarationSupportedTypes), internal::Matcher< Decl > > hasDeclaration(const internal::Matcher< Decl > &InnerMatcher)
Matches a node if the declaration associated with that node matches the given matcher.
const internal::VariadicDynCastAllOfMatcher< Decl, CXXMethodDecl > cxxMethodDecl
Matches method declarations.
const AstTypeMatcher< TemplateSpecializationType > templateSpecializationType
const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateDecl > classTemplateDecl
Matches C++ class template declarations.

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

References clang::DynTypedNode::get(), and clang::isa().

◆ AST_MATCHER_P() [7/54]

clang::ast_matchers::AST_MATCHER_P ( CXXFoldExpr ,
hasFoldInit ,
internal::Matcher< Expr > ,
InnerMacher  )

Matches the operand that does not contain the parameter pack.

Example matches (0 + ... + args) and (args * ... * 1) (matcher = cxxFoldExpr(hasFoldInit(expr()))) with hasFoldInit(...) matching 0 and 1 respectively

template <typename... Args>
auto sum(Args... args) {
return (0 + ... + args);
}
template <typename... Args>
auto multiply(Args... args) {
return (args * ... * 1);
}

Definition at line 4696 of file ASTMatchers.h.

References clang::Init.

◆ AST_MATCHER_P() [8/54]

clang::ast_matchers::AST_MATCHER_P ( CXXFoldExpr ,
hasPattern ,
internal::Matcher< Expr > ,
InnerMacher  )

Matches the operand that contains the parameter pack.

Example matches (0 + ... + args) (matcher = cxxFoldExpr(hasPattern(expr()))) with hasPattern(...) matching args

template <typename... Args>
auto sum(Args... args) {
return (0 + ... + args);
}
template <typename... Args>
auto multiply(Args... args) {
return (args * ... * 1);
}

Definition at line 4718 of file ASTMatchers.h.

◆ AST_MATCHER_P() [9/54]

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

◆ AST_MATCHER_P() [10/54]

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

References clang::Init.

◆ AST_MATCHER_P() [11/54]

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

References clang::Expr::IgnoreParenImpCasts().

◆ AST_MATCHER_P() [12/54]

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())) only matches (g()).m() (the parens are ignored).

FIXME: Overload to allow directly matching types?

Definition at line 4312 of file ASTMatchers.h.

◆ AST_MATCHER_P() [13/54]

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

References clang::ast_matchers::internal::matchesAnyBase().

◆ AST_MATCHER_P() [14/54]

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

◆ AST_MATCHER_P() [15/54]

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

References clang::Result.

◆ AST_MATCHER_P() [16/54]

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

◆ AST_MATCHER_P() [17/54]

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

Matches declaration statements that contain a specific number of declarations.

Example: Given

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

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

Definition at line 4816 of file ASTMatchers.h.

◆ AST_MATCHER_P() [18/54]

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

◆ AST_MATCHER_P() [19/54]

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

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

Example: Given

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

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

Definition at line 2870 of file ASTMatchers.h.

◆ AST_MATCHER_P() [20/54]

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())))
const internal::VariadicDynCastAllOfMatcher< Stmt, IntegerLiteral > integerLiteral
Matches integer literals of all sizes / encodings, e.g.

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

◆ AST_MATCHER_P() [21/54]

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())))
const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstructExpr > cxxConstructExpr
Matches constructor call expressions (including implicit ones).

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

varDecl(hasInitializer(cxxConstructExpr()))

only match the declarations for b and c.

Definition at line 908 of file ASTMatchers.h.

◆ AST_MATCHER_P() [22/54]

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

◆ AST_MATCHER_P() [23/54]

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

◆ AST_MATCHER_P() [24/54]

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

◆ AST_MATCHER_P() [25/54]

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

References clang::Initializer.

◆ AST_MATCHER_P() [26/54]

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

◆ AST_MATCHER_P() [27/54]

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

References clang::Init.

◆ AST_MATCHER_P() [28/54]

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

◆ AST_MATCHER_P() [29/54]

clang::ast_matchers::AST_MATCHER_P ( LambdaCapture ,
capturesVar ,
internal::Matcher< ValueDecl > ,
InnerMatcher  )

Matches a LambdaCapture that refers to the specified VarDecl.

The VarDecl can be a separate variable that is captured by value or reference, or a synthesized variable if the capture has an initializer.

Given

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

In the matcher lambdaExpr(hasAnyCapture(lambdaCapture(capturesVar(hasName("x")))), capturesVar(hasName("x")) matches x and x = 1.

Definition at line 5075 of file ASTMatchers.h.

◆ AST_MATCHER_P() [30/54]

clang::ast_matchers::AST_MATCHER_P ( LambdaExpr ,
forEachLambdaCapture ,
internal::Matcher< LambdaCapture > ,
InnerMatcher  )

Matches each lambda capture in a lambda expression.

Given

int main() {
int x, y;
float z;
auto f = [=]() { return x + y + z; };
}

lambdaExpr(forEachLambdaCapture( lambdaCapture(capturesVar(varDecl(hasType(isInteger())))))) will trigger two matches, binding for 'x' and 'y' respectively.

Definition at line 4480 of file ASTMatchers.h.

References clang::Result.

◆ AST_MATCHER_P() [31/54]

clang::ast_matchers::AST_MATCHER_P ( LambdaExpr ,
hasAnyCapture ,
internal::Matcher< LambdaCapture > ,
InnerMatcher  )

Matches any capture in a lambda expression.

Given

void foo() {
int t = 5;
auto f = [=](){ return t; };
}

lambdaExpr(hasAnyCapture(lambdaCapture())) and lambdaExpr(hasAnyCapture(lambdaCapture(refersToVarDecl(hasName("t"))))) both match [=](){ return t; }.

Definition at line 5048 of file ASTMatchers.h.

References clang::Result.

◆ AST_MATCHER_P() [32/54]

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

References clang::NamedDecl::getUnderlyingDecl().

◆ AST_MATCHER_P() [33/54]

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

Definition at line 44 of file ASTMatchersInternal.cpp.

◆ AST_MATCHER_P() [34/54]

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

References clang::Expr::IgnoreParenImpCasts().

◆ AST_MATCHER_P() [35/54]

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

◆ AST_MATCHER_P() [36/54]

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

References clang::Selector::getAsString().

◆ AST_MATCHER_P() [37/54]

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

Matches when the selector has the specified number of arguments.

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

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

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

Definition at line 4000 of file ASTMatchers.h.

◆ AST_MATCHER_P() [38/54]

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

/ 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)". AST_MATCHER_P(SwitchStmt, forEachSwitchCase, internal::Matcher<SwitchCase>, InnerMatcher) { BoundNodesTreeBuilder Result; FIXME: getSwitchCaseList() does not necessarily guarantee a stable iteration order. We should use the more general iterating matchers once they are capable of expressing this matcher (for example, it should ignore case statements belonging to nested switch statements). bool Matched = false; for (const SwitchCase *SC = Node.getSwitchCaseList(); SC; SC = SC->getNextSwitchCase()) { BoundNodesTreeBuilder CaseBuilder(*Builder); bool CaseMatched = InnerMatcher.matches(*SC, Finder, &CaseBuilder); if (CaseMatched) { Matched = true; Result.addMatch(CaseBuilder); } } Builder = std::move(Result); return Matched; }

/ 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. AST_MATCHER_P(CXXConstructorDecl, forEachConstructorInitializer, internal::Matcher<CXXCtorInitializer>, InnerMatcher) { BoundNodesTreeBuilder Result; bool Matched = false; for (const auto *I : Node.inits()) { if (Finder->isTraversalIgnoringImplicitNodes() && !I->isWritten()) continue; BoundNodesTreeBuilder InitBuilder(*Builder); if (InnerMatcher.matches(*I, Finder, &InitBuilder)) { Matched = true; Result.addMatch(InitBuilder); } } Builder = std::move(Result); return Matched; }

/ 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. AST_MATCHER(CXXConstructorDecl, isCopyConstructor) { return Node.isCopyConstructor(); }

/ 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. AST_MATCHER(CXXConstructorDecl, isMoveConstructor) { return Node.isMoveConstructor(); }

/ 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. AST_MATCHER(CXXConstructorDecl, isDefaultConstructor) { return Node.isDefaultConstructor(); }

/ 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. AST_MATCHER(CXXConstructorDecl, isDelegatingConstructor) { return Node.isDelegatingConstructor(); }

/ 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. AST_POLYMORPHIC_MATCHER(isExplicit, AST_POLYMORPHIC_SUPPORTED_TYPES( CXXConstructorDecl, CXXConversionDecl, CXXDeductionGuideDecl)) { return Node.isExplicit(); }

/ 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. AST_MATCHER_P(FunctionDecl, hasExplicitSpecifier, internal::Matcher<Expr>, InnerMatcher) { ExplicitSpecifier ES = ExplicitSpecifier::getFromDecl(&Node); if (!ES.getExpr()) return false;

ASTChildrenNotSpelledInSourceScope RAII(Finder, false);

return InnerMatcher.matches(*ES.getExpr(), Finder, Builder); }

/ Matches functions, variables and namespace declarations that are marked with / the inline keyword. / / Given /

/// inline void f();
/// void g();
/// namespace n {
/// inline namespace m {}
/// }
/// inline int Foo = 5;
///

/ functionDecl(isInline()) will match ::f(). / namespaceDecl(isInline()) will match n::m. / varDecl(isInline()) will match Foo; AST_POLYMORPHIC_MATCHER(isInline, AST_POLYMORPHIC_SUPPORTED_TYPES(NamespaceDecl, FunctionDecl, VarDecl)) { This is required because the spelling of the function used to determine whether inline is specified or not differs between the polymorphic types. if (const auto *FD = dyn_cast<FunctionDecl>(&Node)) return FD->isInlineSpecified(); if (const auto *NSD = dyn_cast<NamespaceDecl>(&Node)) return NSD->isInline(); if (const auto *VD = dyn_cast<VarDecl>(&Node)) return VD->isInline(); llvm_unreachable("Not a valid polymorphic type"); }

/ Matches anonymous namespace declarations. / / Given /

/// namespace n {
/// namespace {} // #1
/// }
///

/ namespaceDecl(isAnonymous()) will match #1 but not ::n. AST_MATCHER(NamespaceDecl, isAnonymous) { return Node.isAnonymousNamespace(); }

/ 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. AST_MATCHER(Decl, isInStdNamespace) { return Node.isInStdNamespace(); }

/ Matches declarations in an anonymous namespace. / / Given /

/// class vector {};
/// namespace foo {
/// class vector {};
/// namespace {
/// class vector {}; // #1
/// }
/// }
/// namespace {
/// class vector {}; // #2
/// namespace foo {
/// class vector{}; // #3
/// }
/// }
///

/ cxxRecordDecl(hasName("vector"), isInAnonymousNamespace()) will match / #1, #2 and #3. AST_MATCHER(Decl, isInAnonymousNamespace) { return Node.isInAnonymousNamespace(); }

/ 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:" AST_MATCHER_P(CaseStmt, hasCaseConstant, internal::Matcher<Expr>, InnerMatcher) { if (Node.getRHS()) return false;

return InnerMatcher.matches(*Node.getLHS(), Finder, Builder); }

/ 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"). AST_MATCHER_P(Decl, hasAttr, attr::Kind, AttrKind) { for (const auto *Attr : Node.attrs()) { if (Attr->getKind() == AttrKind) return true; } return false; }

/ Matches the return value expression of a return statement / / Given /

/// return a + b;
///

/ hasReturnValue(binaryOperator()) / matches 'return a + b' / with binaryOperator() / matching 'a + b' AST_MATCHER_P(ReturnStmt, hasReturnValue, internal::Matcher<Expr>, InnerMatcher) { if (const auto *RetValue = Node.getRetValue()) return InnerMatcher.matches(*RetValue, Finder, Builder); return false; }

/ Matches CUDA kernel call expression. / / Example matches, /

/// kernel<<<i,j>>>();
///

extern const internal::VariadicDynCastAllOfMatcher<Stmt, CUDAKernelCallExpr> cudaKernelCallExpr;

/ 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. AST_MATCHER_FUNCTION(internal::Matcher<Expr>, nullPointerConstant) { return anyOf( gnuNullExpr(), cxxNullPtrLiteralExpr(), integerLiteral(equals(0), hasParent(expr(hasType(pointerType()))))); }

/ Matches the DecompositionDecl the binding belongs to. / / For example, in: /

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

/ The matcher: /

/// bindingDecl(hasName("f"),
/// forDecomposition(decompositionDecl())
///

/ matches 'f' in 'auto &[f, s, t]'. AST_MATCHER_P(BindingDecl, forDecomposition, internal::Matcher<ValueDecl>, InnerMatcher) { if (const ValueDecl *VD = Node.getDecomposedDecl()) return InnerMatcher.matches(*VD, Finder, Builder); return false; }

/ 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". AST_MATCHER_P2(DecompositionDecl, hasBinding, unsigned, N, internal::Matcher<BindingDecl>, InnerMatcher) { if (Node.bindings().size() <= N) return false; return InnerMatcher.matches(*Node.bindings()[N], Finder, Builder); }

/ 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". AST_MATCHER_P(DecompositionDecl, hasAnyBinding, internal::Matcher<BindingDecl>, InnerMatcher) { return llvm::any_of(Node.bindings(), [&](const auto *Binding) { return InnerMatcher.matches(*Binding, Finder, Builder); }); }

/ 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' AST_MATCHER_P(Stmt, forFunction, internal::Matcher<FunctionDecl>, InnerMatcher) { const auto &Parents = Finder->getASTContext().getParents(Node);

llvm::SmallVector<DynTypedNode, 8> Stack(Parents.begin(), Parents.end()); while (!Stack.empty()) { const auto &CurNode = Stack.back(); Stack.pop_back(); if (const auto *FuncDeclNode = CurNode.get<FunctionDecl>()) { if (InnerMatcher.matches(*FuncDeclNode, Finder, Builder)) { return true; } } else if (const auto *LambdaExprNode = CurNode.get<LambdaExpr>()) { if (InnerMatcher.matches(*LambdaExprNode->getCallOperator(), Finder, Builder)) { return true; } } else { llvm::append_range(Stack, Finder->getASTContext().getParents(CurNode)); } } return false; }

/ 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'. AST_MATCHER_P(Stmt, forCallable, internal::Matcher<Decl>, InnerMatcher) { const auto &Parents = Finder->getASTContext().getParents(Node);

llvm::SmallVector<DynTypedNode, 8> Stack(Parents.begin(), Parents.end()); while (!Stack.empty()) { const auto &CurNode = Stack.back(); Stack.pop_back(); if (const auto *FuncDeclNode = CurNode.get<FunctionDecl>()) { BoundNodesTreeBuilder B = *Builder; if (InnerMatcher.matches(*FuncDeclNode, Finder, &B)) { Builder = std::move(B); return true; } } else if (const auto *LambdaExprNode = CurNode.get<LambdaExpr>()) { BoundNodesTreeBuilder B = *Builder; if (InnerMatcher.matches(*LambdaExprNode->getCallOperator(), Finder, &B)) { Builder = std::move(B); return true; } } else if (const auto *ObjCMethodDeclNode = CurNode.get<ObjCMethodDecl>()) { BoundNodesTreeBuilder B = *Builder; if (InnerMatcher.matches(*ObjCMethodDeclNode, Finder, &B)) { Builder = std::move(B); return true; } } else if (const auto *BlockDeclNode = CurNode.get<BlockDecl>()) { BoundNodesTreeBuilder B = *Builder; if (InnerMatcher.matches(*BlockDeclNode, Finder, &B)) { Builder = std::move(B); return true; } } else { llvm::append_range(Stack, Finder->getASTContext().getParents(CurNode)); } } return false; }

/ 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 linkage / (matcher = functionDecl(hasExternalFormalLinkage())) / /

/// namespace {
/// void f() {}
/// }
///

AST_MATCHER(NamedDecl, hasExternalFormalLinkage) { return Node.hasExternalFormalLinkage(); }

/ 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()). AST_MATCHER(ParmVarDecl, hasDefaultArgument) { return Node.hasDefaultArg(); }

/ Matches array new expressions. / / Given: /

/// MyClass *p1 = new MyClass[10];
///

/ cxxNewExpr(isArray()) / matches the expression 'new MyClass[10]'. AST_MATCHER(CXXNewExpr, isArray) { return Node.isArray(); }

/ 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()'. AST_MATCHER_P2(CXXNewExpr, hasPlacementArg, unsigned, Index, internal::Matcher<Expr>, InnerMatcher) { return Node.getNumPlacementArgs() > Index && InnerMatcher.matches(*Node.getPlacementArg(Index), Finder, Builder); }

/ Matches any placement new expression arguments. / / Given: /

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

/ cxxNewExpr(hasAnyPlacementArg(anything())) / matches the expression 'new (Storage, 16) MyClass()'. AST_MATCHER_P(CXXNewExpr, hasAnyPlacementArg, internal::Matcher<Expr>, InnerMatcher) { return llvm::any_of(Node.placement_arguments(), [&](const Expr *Arg) { return InnerMatcher.matches(*Arg, Finder, Builder); }); }

/ 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]'. AST_MATCHER_P(CXXNewExpr, hasArraySize, internal::Matcher<Expr>, InnerMatcher) { return Node.isArray() && *Node.getArraySize() && InnerMatcher.matches(**Node.getArraySize(), Finder, Builder); }

/ Matches a class declaration that is defined. / / Example matches x (matcher = cxxRecordDecl(hasDefinition())) /

/// class x {};
/// class y;
///

AST_MATCHER(CXXRecordDecl, hasDefinition) { return Node.hasDefinition(); }

/ Matches C++11 scoped enum declaration. / / Example matches Y (matcher = enumDecl(isScoped())) /

/// enum X {};
/// enum class Y {};
///

AST_MATCHER(EnumDecl, isScoped) { return Node.isScoped(); }

/ Matches a function declared with a trailing return type. / / Example matches Y (matcher = functionDecl(hasTrailingReturn())) /

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

AST_MATCHER(FunctionDecl, hasTrailingReturn) { if (const auto *F = Node.getType()->getAs<FunctionProtoType>()) return F->hasTrailingReturn(); return false; }

/ 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). AST_MATCHER_P(Expr, ignoringElidableConstructorCall, internal::Matcher<Expr>, InnerMatcher) { E tracks the node that we are examining. const Expr *E = &Node; If present, remove an outer ExprWithCleanups corresponding to the underlying CXXConstructExpr. This check won't cover all cases of added ExprWithCleanups corresponding to CXXConstructExpr nodes (because the EWC is placed on the outermost node of the expression, which this may not be), but, it still improves the coverage of this matcher. if (const auto *CleanupsExpr = dyn_cast<ExprWithCleanups>(&Node)) E = CleanupsExpr->getSubExpr(); if (const auto *CtorExpr = dyn_cast<CXXConstructExpr>(E)) { if (CtorExpr->isElidable()) { if (const auto *MaterializeTemp = dyn_cast<MaterializeTemporaryExpr>(CtorExpr->getArg(0))) { return InnerMatcher.matches(*MaterializeTemp->getSubExpr(), Finder, Builder); } } } return InnerMatcher.matches(Node, Finder, Builder); }

-------------------------------------------------------------------------—// OpenMP handling. -------------------------------------------------------------------------—//

/ Matches any #pragma omp executable directive. / / Given / /

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

/ / ompExecutableDirective() matches omp parallel, / omp parallel default(none) and omp taskyield. extern const internal::VariadicDynCastAllOfMatcher<Stmt, OMPExecutableDirective> ompExecutableDirective;

/ 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. AST_MATCHER(OMPExecutableDirective, isStandaloneDirective) { return Node.isStandaloneDirective(); }

/ 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 ; AST_MATCHER_P(OMPExecutableDirective, hasStructuredBlock, internal::Matcher<Stmt>, InnerMatcher) { if (Node.isStandaloneDirective()) return false; // Standalone directives have no structured blocks. return InnerMatcher.matches(*Node.getStructuredBlock(), Finder, Builder); }

/ Matches any clause in an OpenMP directive. / / Given / /

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

/ / ompExecutableDirective(hasAnyClause(anything())) matches / omp parallel default(none). AST_MATCHER_P(OMPExecutableDirective, hasAnyClause, internal::Matcher<OMPClause>, InnerMatcher) { ArrayRef<OMPClause *> Clauses = Node.clauses(); return matchesFirstInPointerRange(InnerMatcher, Clauses.begin(), Clauses.end(), Finder, Builder) != Clauses.end(); }

/ Matches OpenMP default clause. / / Given / /

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

/ / ompDefaultClause() matches default(none), default(shared), / default(private) and default(firstprivate) extern const internal::VariadicDynCastAllOfMatcher<OMPClause, OMPDefaultClause> ompDefaultClause;

/ 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(private)
/// #pragma omp parallel default(firstprivate)
///

/ / ompDefaultClause(isNoneKind()) matches only default(none). AST_MATCHER(OMPDefaultClause, isNoneKind) { return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_none; }

/ 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(private)
/// #pragma omp parallel default(firstprivate)
///

/ / ompDefaultClause(isSharedKind()) matches only default(shared). AST_MATCHER(OMPDefaultClause, isSharedKind) { return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_shared; }

/ Matches if the OpenMP default clause has private kind / specified. / / Given / /

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

/ / ompDefaultClause(isPrivateKind()) matches only / default(private). AST_MATCHER(OMPDefaultClause, isPrivateKind) { return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_private; }

/ 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(private)
/// #pragma omp parallel default(firstprivate)
///

/ / ompDefaultClause(isFirstPrivateKind()) matches only / default(firstprivate). AST_MATCHER(OMPDefaultClause, isFirstPrivateKind) { return Node.getDefaultKind() == llvm::omp::OMP_DEFAULT_firstprivate; }

/ 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 parallel and omp 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 8832 of file ASTMatchers.h.

◆ AST_MATCHER_P() [39/54]

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

◆ AST_MATCHER_P() [40/54]

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

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

Given

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

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

Definition at line 4206 of file ASTMatchers.h.

◆ AST_MATCHER_P() [41/54]

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

◆ AST_MATCHER_P() [42/54]

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

◆ AST_MATCHER_P() [43/54]

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

◆ AST_MATCHER_P() [44/54]

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

Definition at line 39 of file OSObjectCStyleCast.cpp.

References clang::DynTypedNode::get().

◆ AST_MATCHER_P() [45/54]

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 equal to the canonical representation of that integral value in base 10.

Given

template<int T> struct C {};

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

Definition at line 1241 of file ASTMatchers.h.

References clang::TemplateArgument::Integral, and toString().

◆ AST_MATCHER_P() [46/54]

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

References clang::TemplateArgument::Expression.

◆ AST_MATCHER_P() [47/54]

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

References clang::TemplateArgument::Declaration.

◆ AST_MATCHER_P() [48/54]

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

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

Definition at line 1220 of file ASTMatchers.h.

References clang::TemplateArgument::Integral.

◆ AST_MATCHER_P() [49/54]

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

References clang::TemplateArgument::Template.

◆ AST_MATCHER_P() [50/54]

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( recordType(hasDeclaration(recordDecl(hasName("X"))))))) matches the specialization of struct A generated by A<X>.

Definition at line 1132 of file ASTMatchers.h.

References clang::TemplateArgument::Type.

◆ AST_MATCHER_P() [51/54]

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

◆ AST_MATCHER_P() [52/54]

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

◆ AST_MATCHER_P() [53/54]

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

◆ AST_MATCHER_P() [54/54]

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

References clang::Initializer.

◆ AST_MATCHER_P2() [1/2]

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

Matches the n'th declaration of a declaration statement.

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

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

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

matches 'int a, b = 0' as well as 'int d = 2, e;'
but 'int c;' is not matched.
bool is(tok::TokenKind Kind) const
#define not
Definition iso646.h:22

Definition at line 4839 of file ASTMatchers.h.

◆ AST_MATCHER_P2() [2/2]

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

◆ AST_MATCHER_P_OVERLOAD() [1/6]

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

Overloaded to match the type's declaration.

Definition at line 4343 of file ASTMatchers.h.

References anyOf.

◆ AST_MATCHER_P_OVERLOAD() [2/6]

clang::ast_matchers::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.

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

References anyOf.

◆ AST_MATCHER_P_OVERLOAD() [3/6]

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

Overload ignoringParens for Expr.

Given

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

The matcher

implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral())))
const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitCastExpr > implicitCastExpr
Matches the implicit cast nodes of Clang's AST.
const internal::VariadicDynCastAllOfMatcher< Stmt, StringLiteral > stringLiteral
Matches string literals (also matches wide string literals).

would match the implicit cast resulting from the assignment.

Definition at line 1017 of file ASTMatchers.h.

References clang::Expr::IgnoreParens().

◆ AST_MATCHER_P_OVERLOAD() [4/6]

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

Matches types that match InnerMatcher after any parens are stripped.

Given

void (*fp)(void);

The matcher

varDecl(hasType(pointerType(pointee(ignoringParens(functionType())))))
const AstTypeMatcher< FunctionType > functionType
const AstTypeMatcher< PointerType > pointerType

would match the declaration for fp.

Definition at line 1001 of file ASTMatchers.h.

◆ AST_MATCHER_P_OVERLOAD() [5/6]

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

Overloaded to match the pointee type's declaration.

Definition at line 4228 of file ASTMatchers.h.

References hasDeclaration(), and qualType.

◆ AST_MATCHER_P_OVERLOAD() [6/6]

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

Overloaded to match the referenced type's declaration.

Definition at line 4289 of file ASTMatchers.h.

References hasDeclaration(), and qualType.

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

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

◆ AST_POLYMORPHIC_MATCHER() [1/6]

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

References clang::SourceManager::getExpansionLoc(), and clang::SourceManager::isInMainFile().

◆ AST_POLYMORPHIC_MATCHER() [2/6]

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

References clang::SourceManager::getExpansionLoc(), and clang::SourceManager::isInSystemHeader().

◆ AST_POLYMORPHIC_MATCHER() [3/6]

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

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

implicit default/copy constructors).

Definition at line 776 of file ASTMatchers.h.

References clang::Decl::isImplicit().

◆ AST_POLYMORPHIC_MATCHER() [4/6]

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

Matches private C++ declarations and C++ base specifiers 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 691 of file ASTMatchers.h.

References clang::AS_private.

◆ AST_POLYMORPHIC_MATCHER() [5/6]

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

Matches protected C++ declarations and C++ base specifiers 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 668 of file ASTMatchers.h.

References clang::AS_protected.

◆ AST_POLYMORPHIC_MATCHER() [6/6]

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

Matches public C++ declarations and C++ base specifiers 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 646 of file ASTMatchers.h.

References clang::AS_public.

◆ AST_POLYMORPHIC_MATCHER_P() [1/10]

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

Checks that a call expression or a constructor call expression has at least the specified number of arguments (including absent default arguments).

Example matches f(0, 0) and g(0, 0, 0) (matcher = callExpr(argumentCountAtLeast(2)))

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

Definition at line 4642 of file ASTMatchers.h.

References clang::isa().

◆ AST_POLYMORPHIC_MATCHER_P() [2/10]

clang::ast_matchers::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).

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

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

Definition at line 4615 of file ASTMatchers.h.

References clang::isa().

◆ AST_POLYMORPHIC_MATCHER_P() [3/10]

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

References clang::isa(), and clang::Result.

◆ AST_POLYMORPHIC_MATCHER_P() [4/10]

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

Matches templateSpecializationTypes, class template specializations, variable template specializations, and function template specializations 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>(); };
__device__ double

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

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

Definition at line 803 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [5/10]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P ( hasDependentName ,
AST_POLYMORPHIC_SUPPORTED_TYPES( DependentScopeDeclRefExpr, DependentNameType) ,
std::string ,
N  )

Matches the dependent name of a DependentScopeDeclRefExpr or DependentNameType.

Given:

template <class T> class X : T { void f() { T::v; } };

dependentScopeDeclRefExpr(hasDependentName("v")) matches T::v

Given:

template <typename T> struct declToImport {
typedef typename T::type dependent_name;
};

dependentNameType(hasDependentName("type")) matches T::type

Definition at line 3339 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [6/10]

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);

cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int")))) matches int(3)

struct Foo { Foo(int, int); };
auto x = Foo(1, 2);

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<CompoundLiteralExpr>, Matcher<DeclaratorDecl>, Matcher<ExplicitCastExpr>, Matcher<ObjCPropertyDecl>, Matcher<TemplateArgumentLoc>, Matcher<TypedefNameDecl>

Definition at line 4181 of file ASTMatchers.h.

References clang::TypeSourceInfo::getTypeLoc().

◆ AST_POLYMORPHIC_MATCHER_P() [7/10]

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

References clang::cast().

◆ AST_POLYMORPHIC_MATCHER_P() [8/10]

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

References clang::ast_matchers::internal::getExpansionLocOfMacro().

◆ AST_POLYMORPHIC_MATCHER_P() [9/10]

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

Matches if the number of template arguments equals N.

Given

template<typename T> struct C {};
template<typename T> void f() {}
void func() { f<int>(); };

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

functionDecl(templateArgumentCountIs(1)) matches f<int>();

Definition at line 1112 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P() [10/10]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P ( throughUsingDecl ,
AST_POLYMORPHIC_SUPPORTED_TYPES(DeclRefExpr, UsingType) ,
internal::Matcher< UsingShadowDecl > ,
Inner  )

Matches if a node refers to a declaration through a specific using shadow declaration.

Examples:

namespace a { int f(); }
using a::f;
int x = f();

declRefExpr(throughUsingDecl(anything())) matches f

namespace a { class X{}; }
using a::X;
X x;

typeLoc(loc(usingType(throughUsingDecl(anything())))) matches X

Usable as: Matcher<DeclRefExpr>, Matcher<UsingType>

Definition at line 4387 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P2() [1/5]

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

References anyOf, callExpr, cxxConstructExpr, cxxConstructorDecl, cxxMethodDecl, cxxOperatorCallExpr, expr, functionDecl, hasDeclaration(), clang::Result, and unless.

◆ AST_POLYMORPHIC_MATCHER_P2() [2/5]

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

References clang::Call, matchEachArgumentWithParamType(), and clang::Result.

◆ AST_POLYMORPHIC_MATCHER_P2() [3/5]

clang::ast_matchers::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.

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

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

Definition at line 4666 of file ASTMatchers.h.

References clang::Expr::IgnoreParenImpCasts(), and clang::isa().

◆ AST_POLYMORPHIC_MATCHER_P2() [4/5]

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

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

Given

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

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

For ObjectiveC, given

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

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

Definition at line 5140 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P2() [5/5]

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

Matches templateSpecializationType, class template specializations, variable template specializations, and function template specializations 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 1084 of file ASTMatchers.h.

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [1/9]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P_OVERLOAD ( callee ,
AST_POLYMORPHIC_SUPPORTED_TYPES(CallExpr, CXXFoldExpr) ,
internal::Matcher< Stmt > ,
InnerMatcher ,
0  )

Matches if the call or fold 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

Given

template <typename... Args>
auto sum(Args... args) {
return (0 + ... + args);
}
template <typename... Args>
auto multiply(Args... args) {
return (args * ... * 1);
}

cxxFoldExpr(callee(expr())) matches (args * ... * 1) with callee(...) matching *

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

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [2/9]

clang::ast_matchers::AST_POLYMORPHIC_MATCHER_P_OVERLOAD ( callee ,
AST_POLYMORPHIC_SUPPORTED_TYPES(ObjCMessageExpr, CallExpr) ,
internal::Matcher< Decl > ,
InnerMatcher ,
1  )

Matches 1) if the call expression's callee's declaration matches the given matcher; or 2) if the Obj-C message expression's callee's method 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(); }

Example 2. Matches [I foo] with objcMessageExpr(callee(objcMethodDecl(hasName("foo"))))

@interface I: NSObject
+(void)foo;
@end
...
[I foo]

Definition at line 4067 of file ASTMatchers.h.

References callExpr, clang::cast(), hasDeclaration(), and clang::isa().

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [3/9]

clang::ast_matchers::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.

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

References clang::QualType::isNull().

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [4/9]

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

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

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

Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) and friend class X (matcher = friendDecl(hasType("X")) 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 4140 of file ASTMatchers.h.

References hasDeclaration(), clang::QualType::isNull(), and qualType.

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [5/9]

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

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

Definition at line 3391 of file ASTMatchers.h.

References clang::cast(), and hasName().

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [6/9]

clang::ast_matchers::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.

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

References clang::cast().

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [7/9]

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

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

Definition at line 3516 of file ASTMatchers.h.

References clang::cast(), and hasName().

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [8/9]

clang::ast_matchers::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.

Definition at line 3449 of file ASTMatchers.h.

References anyOf, and clang::cast().

◆ AST_POLYMORPHIC_MATCHER_P_OVERLOAD() [9/9]

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

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

Definition at line 3464 of file ASTMatchers.h.

References clang::cast(), and hasName().

◆ AST_POLYMORPHIC_MATCHER_REGEX()

clang::ast_matchers::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.

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

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

ASTMatcher.h:

class Y {};

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

Definition at line 308 of file ASTMatchers.h.

References clang::SourceManager::getExpansionLoc(), clang::SourceManager::getFileEntryRefForID(), and clang::SourceManager::getFileID().

◆ AST_TYPELOC_TRAVERSE_MATCHER_DEF() [1/3]

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

◆ AST_TYPELOC_TRAVERSE_MATCHER_DEF() [2/3]

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

◆ AST_TYPELOC_TRAVERSE_MATCHER_DEF() [3/3]

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

◆ findAll()

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

Matches if the node or any descendant matches.

Generates results for each match.

For example, in:

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

The matcher:

findAll(cxxRecordDecl(isDefinition()).bind("m")))
internal::Matcher< T > findAll(const internal::Matcher< T > &Matcher)
Matches if the node or any descendant matches.

will generate results for A, B and C.

Usable as: Any Matcher

Definition at line 3675 of file ASTMatchers.h.

References eachOf, and forEachDescendant.

Referenced by clang::ASTReader::completeVisibleDeclsMap(), and clang::ento::getWidenedLoopState().

◆ getCallee() [1/2]

const FunctionDecl * clang::ast_matchers::getCallee ( const CallExpr & D)
static

Definition at line 22 of file LowLevelHelpers.cpp.

References clang::CallExpr::getDirectCallee().

◆ getCallee() [2/2]

◆ getComparisonDecl()

DeclarationMatcher clang::ast_matchers::getComparisonDecl ( GtestCmp Cmp)
static

Definition at line 33 of file GtestMatchers.cpp.

References cxxMethodDecl, cxxRecordDecl, Eq, functionDecl, Ge, Gt, hasName(), Le, Lt, and Ne.

Referenced by gtestComparisonInternal().

◆ getComparisonTypeName()

llvm::StringRef clang::ast_matchers::getComparisonTypeName ( GtestCmp Cmp)
static

Definition at line 65 of file GtestMatchers.cpp.

References Eq, Ge, Gt, Le, Lt, and Ne.

Referenced by getMacroName().

◆ getMacroName() [1/2]

std::string clang::ast_matchers::getMacroName ( MacroType Macro,
GtestCmp Cmp )
static

◆ getMacroName() [2/2]

std::string clang::ast_matchers::getMacroName ( MacroType Macro,
llvm::StringRef Operation )
static

Definition at line 87 of file GtestMatchers.cpp.

References getMacroTypeName(), and clang::Macro.

◆ getMacroTypeName()

llvm::StringRef clang::ast_matchers::getMacroTypeName ( MacroType Macro)
static

Definition at line 53 of file GtestMatchers.cpp.

References clang::Macro.

Referenced by getMacroName(), and getMacroName().

◆ getSpecSetterName()

llvm::StringRef clang::ast_matchers::getSpecSetterName ( MacroType Macro)
static

Definition at line 95 of file GtestMatchers.cpp.

References clang::Macro.

Referenced by gtestCallInternal().

◆ gtestAssert()

internal::BindableMatcher< Stmt > clang::ast_matchers::gtestAssert ( 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.

Definition at line 185 of file GtestMatchers.cpp.

References gtestComparisonInternal().

◆ gtestAssertThat()

internal::BindableMatcher< Stmt > clang::ast_matchers::gtestAssertThat ( StatementMatcher Actual,
StatementMatcher Matcher )

Matcher for gtest's ASSERT_THAT macro.

Definition at line 195 of file GtestMatchers.cpp.

References gtestThatInternal().

◆ gtestCallInternal() [1/2]

internal::BindableMatcher< Stmt > clang::ast_matchers::gtestCallInternal ( MacroType Macro,
StatementMatcher MockCall,
MockArgs Args )
static

◆ gtestCallInternal() [2/2]

internal::BindableMatcher< Stmt > clang::ast_matchers::gtestCallInternal ( MacroType Macro,
StatementMatcher MockObject,
llvm::StringRef MockMethodName,
MockArgs Args )
static

◆ gtestComparisonInternal()

internal::BindableMatcher< Stmt > clang::ast_matchers::gtestComparisonInternal ( MacroType Macro,
GtestCmp Cmp,
StatementMatcher Left,
StatementMatcher Right )
static

Definition at line 117 of file GtestMatchers.cpp.

References callExpr, getComparisonDecl(), getMacroName(), and clang::Macro.

Referenced by gtestAssert(), and gtestExpect().

◆ gtestExpect()

internal::BindableMatcher< Stmt > clang::ast_matchers::gtestExpect ( 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.

Definition at line 190 of file GtestMatchers.cpp.

References gtestComparisonInternal().

◆ gtestExpectCall() [1/2]

internal::BindableMatcher< Stmt > clang::ast_matchers::gtestExpectCall ( StatementMatcher MockCall,
MockArgs Args )

Matcher for gtest's EXPECT_CALL macro.

MockCall matches the whole mock member method call. This API is more flexible but requires more knowledge of the AST structure of EXPECT_CALL macros.

Definition at line 222 of file GtestMatchers.cpp.

References gtestCallInternal().

◆ gtestExpectCall() [2/2]

internal::BindableMatcher< Stmt > clang::ast_matchers::gtestExpectCall ( StatementMatcher MockObject,
llvm::StringRef MockMethodName,
MockArgs Args )

Matcher for gtest's EXPECT_CALL macro.

MockObject matches the mock object and MockMethodName is the name of the method invoked on the mock object.

Definition at line 216 of file GtestMatchers.cpp.

References gtestCallInternal().

◆ gtestExpectThat()

internal::BindableMatcher< Stmt > clang::ast_matchers::gtestExpectThat ( StatementMatcher Actual,
StatementMatcher Matcher )

Matcher for gtest's EXPECT_THAT macro.

Definition at line 200 of file GtestMatchers.cpp.

References gtestThatInternal().

◆ gtestOnCall() [1/2]

internal::BindableMatcher< Stmt > clang::ast_matchers::gtestOnCall ( StatementMatcher MockCall,
MockArgs Args )

Like the second gtestExpectCall overload but for ON_CALL.

Definition at line 211 of file GtestMatchers.cpp.

References gtestCallInternal().

◆ gtestOnCall() [2/2]

internal::BindableMatcher< Stmt > clang::ast_matchers::gtestOnCall ( StatementMatcher MockObject,
llvm::StringRef MockMethodName,
MockArgs Args )

Like the first gtestExpectCall overload but for ON_CALL.

Definition at line 205 of file GtestMatchers.cpp.

References gtestCallInternal().

◆ gtestThatInternal()

internal::BindableMatcher< Stmt > clang::ast_matchers::gtestThatInternal ( MacroType Macro,
StatementMatcher Actual,
StatementMatcher Matcher )
static

◆ hasDeclaration()

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

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

The associated declaration is:

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

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

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

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

varDecl(hasType(hasUnqualifiedDesugaredType(
const AstTypeMatcher< RecordType > recordType
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.

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

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

Definition at line 3760 of file ASTMatchers.h.

Referenced by AST_MATCHER_P_OVERLOAD(), AST_MATCHER_P_OVERLOAD(), AST_POLYMORPHIC_MATCHER_P2(), AST_POLYMORPHIC_MATCHER_P_OVERLOAD(), AST_POLYMORPHIC_MATCHER_P_OVERLOAD(), clang::ento::getAddrTo(), hasTypePointingTo(), hasTypePointingTo(), hasUnguardedAccess(), clang::tooling::isKnownPointerLikeType(), and potentiallyWritesIntoIvar().

◆ hasName()

internal::Matcher< NamedDecl > clang::ast_matchers::hasName ( StringRef Name)
inline

Matches NamedDecl nodes that have the specified name.

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

Example matches X (Name == "X")

class X;

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

namespace a { namespace b { class X; } }

Definition at line 3163 of file ASTMatchers.h.

Referenced by AST_POLYMORPHIC_MATCHER_P_OVERLOAD(), AST_POLYMORPHIC_MATCHER_P_OVERLOAD(), AST_POLYMORPHIC_MATCHER_P_OVERLOAD(), getComparisonDecl(), getRunLoopRunM(), gtestCallInternal(), gtestCallInternal(), gtestThatInternal(), and isExactClass().

◆ hasOverloadedOperatorName()

internal::PolymorphicMatcher< internal::HasOverloadedOperatorNameMatcher, AST_POLYMORPHIC_SUPPORTED_TYPES(CXXOperatorCallExpr, FunctionDecl), std::vector< std::string > > clang::ast_matchers::hasOverloadedOperatorName ( StringRef Name)
inline

Matches overloaded operator names.

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

Given:

class A { int operator*(); };
const A &operator<<(const A &a, const A &b);
A a;
a << a; // <-- This matches
clang::CharUnits operator*(clang::CharUnits::QuantityType Scale, const clang::CharUnits &CU)
Definition CharUnits.h:225
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.

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

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

Definition at line 3226 of file ASTMatchers.h.

References AST_POLYMORPHIC_SUPPORTED_TYPES.

Referenced by gtestCallInternal(), and gtestThatInternal().

◆ mapAnyOf()

template<typename T, typename... U>
auto clang::ast_matchers::mapAnyOf ( internal::VariadicDynCastAllOfMatcher< T, U > const & ...)

Matches any of the NodeMatchers with InnerMatchers nested within.

Given

if (true);
for (; true; );

with the matcher

hasCondition(cxxBoolLiteralExpr(equals(true)))
).bind("trueCond")
const internal::VariadicDynCastAllOfMatcher< Stmt, ForStmt > forStmt
Matches for statements.
auto mapAnyOf(internal::VariadicDynCastAllOfMatcher< T, U > const &...)
Matches any of the NodeMatchers with InnerMatchers nested within.
const internal::VariadicDynCastAllOfMatcher< Stmt, IfStmt > ifStmt
Matches if statements.

matches the if and the for. It is equivalent to:

auto trueCond = hasCondition(cxxBoolLiteralExpr(equals(true)));
ifStmt(trueCond).bind("trueCond"),
forStmt(trueCond).bind("trueCond")
);
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> anyOf
Matches if any of the given matchers matches.

The with() chain-call accepts zero or more matchers which are combined as-if with allOf() in each of the node matchers. Usable as: Any Matcher

Definition at line 2985 of file ASTMatchers.h.

◆ match() [1/3]

template<typename MatcherT>
SmallVector< BoundNodes, 1 > clang::ast_matchers::match ( MatcherT Matcher,
ASTContext & Context )

Returns the results of matching Matcher on the translation unit of Context and collects the BoundNodes of all callback invocations.

Definition at line 324 of file ASTMatchFinder.h.

References clang::ast_matchers::MatchFinder::addMatcher(), and clang::ast_matchers::MatchFinder::matchAST().

◆ match() [2/3]

template<typename MatcherT>
SmallVector< BoundNodes, 1 > clang::ast_matchers::match ( MatcherT Matcher,
const DynTypedNode & Node,
ASTContext & Context )

◆ match() [3/3]

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

◆ matchDynamic() [1/3]

SmallVector< BoundNodes, 1 > clang::ast_matchers::matchDynamic ( internal::DynTypedMatcher Matcher,
ASTContext & Context )
inline

◆ matchDynamic() [2/3]

SmallVector< BoundNodes, 1 > clang::ast_matchers::matchDynamic ( internal::DynTypedMatcher Matcher,
const DynTypedNode & Node,
ASTContext & Context )
inline

◆ matchDynamic() [3/3]

template<typename NodeT>
SmallVector< BoundNodes, 1 > clang::ast_matchers::matchDynamic ( internal::DynTypedMatcher Matcher,
const NodeT & Node,
ASTContext & Context )

Definition at line 343 of file ASTMatchFinder.h.

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

◆ matchEachArgumentWithParamType() [1/2]

void clang::ast_matchers::matchEachArgumentWithParamType ( const CallExpr & Node,
llvm::function_ref< void(QualType, const Expr *)> OnParamAndArg )

◆ matchEachArgumentWithParamType() [2/2]

void clang::ast_matchers::matchEachArgumentWithParamType ( const CXXConstructExpr & Node,
llvm::function_ref< void(QualType, const Expr *)> OnParamAndArg )

Definition at line 97 of file LowLevelHelpers.cpp.

References matchEachArgumentWithParamTypeImpl().

◆ matchEachArgumentWithParamTypeImpl()

◆ selectFirst()

template<typename NodeT>
const NodeT * clang::ast_matchers::selectFirst ( StringRef BoundTo,
const SmallVectorImpl< BoundNodes > & Results )

Returns the first result of type NodeT bound to BoundTo.

Returns NULL if there is no match, or if the matching node cannot be casted to NodeT.

This is useful in combination with match():

const Decl *D = selectFirst<Decl>("id", match(Matcher.bind("id"),
Node, Context));
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
const NodeT * selectFirst(StringRef BoundTo, const SmallVectorImpl< BoundNodes > &Results)
Returns the first result of type NodeT bound to BoundTo.

Definition at line 283 of file ASTMatchFinder.h.

◆ sizeOfExpr()

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

Same as unaryExprOrTypeTraitExpr, but only matching sizeof.

Definition at line 3142 of file ASTMatchers.h.

References allOf, stmt, and unaryExprOrTypeTraitExpr.

Referenced by clang::ExprMutationAnalyzer::isUnevaluated().

◆ traverse() [1/6]

template<template< typename ToArg, typename FromArg > class ArgumentAdapterT, typename T, typename ToTypes>
internal::TraversalWrapper< internal::ArgumentAdaptingMatcherFuncAdaptor< ArgumentAdapterT, T, ToTypes > > clang::ast_matchers::traverse ( TraversalKind TK,
const internal::ArgumentAdaptingMatcherFuncAdaptor< ArgumentAdapterT, T, ToTypes > & InnerMatcher )

Definition at line 862 of file ASTMatchers.h.

References clang::T.

◆ traverse() [2/6]

template<typename T>
internal::BindableMatcher< T > clang::ast_matchers::traverse ( TraversalKind TK,
const internal::BindableMatcher< T > & InnerMatcher )

Definition at line 842 of file ASTMatchers.h.

◆ traverse() [3/6]

template<typename... T>
internal::Matcher< typename internal::GetClade< T... >::Type > clang::ast_matchers::traverse ( TraversalKind TK,
const internal::MapAnyOfHelper< T... > & InnerMatcher )

Definition at line 883 of file ASTMatchers.h.

References traverse().

◆ traverse() [4/6]

template<typename T>
internal::Matcher< T > clang::ast_matchers::traverse ( TraversalKind TK,
const internal::Matcher< T > & InnerMatcher )

Causes all nested matchers to be matched with the specified traversal kind.

Given

void foo()
{
int i = 3.0;
}

The matcher

varDecl(hasInitializer(floatLiteral().bind("init")))
)
const internal::VariadicDynCastAllOfMatcher< Stmt, FloatingLiteral > floatLiteral
Matches float literals of all sizes / encodings, e.g.
internal::Matcher< T > traverse(TraversalKind TK, const internal::Matcher< T > &InnerMatcher)
Causes all nested matchers to be matched with the specified traversal kind.
@ TK_IgnoreUnlessSpelledInSource
Ignore AST nodes not written in the source.

matches the variable declaration with "init" bound to the "3.0".

Definition at line 832 of file ASTMatchers.h.

Referenced by clang::ast_matchers::MatchFinder::addMatcher(), clang::ast_matchers::MatchFinder::addMatcher(), clang::syntax::Node::assertInvariantsRecursive(), clang::threadSafety::BeforeSet::checkBeforeAfter(), clang::syntax::Node::dumpTokens(), traverse(), and traverse().

◆ traverse() [5/6]

template<template< typename T, typename... P > class MatcherT, typename... P, typename ReturnTypesF>
internal::TraversalWrapper< internal::PolymorphicMatcher< MatcherT, ReturnTypesF, P... > > clang::ast_matchers::traverse ( TraversalKind TK,
const internal::PolymorphicMatcher< MatcherT, ReturnTypesF, P... > & InnerMatcher )

Definition at line 873 of file ASTMatchers.h.

References traverse().

◆ traverse() [6/6]

template<typename... T>
internal::TraversalWrapper< internal::VariadicOperatorMatcher< T... > > clang::ast_matchers::traverse ( TraversalKind TK,
const internal::VariadicOperatorMatcher< T... > & InnerMatcher )

Definition at line 852 of file ASTMatchers.h.

References clang::T.

Variable Documentation

◆ accessSpecDecl

const internal::VariadicDynCastAllOfMatcher< Decl, AccessSpecDecl > clang::ast_matchers::accessSpecDecl

Matches C++ access specifier declarations.

Given

class C {
public:
int a;
};

accessSpecDecl() matches 'public:'

Definition at line 786 of file ASTMatchersInternal.cpp.

◆ addrLabelExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, AddrLabelExpr > clang::ast_matchers::addrLabelExpr

Matches address of label statements (GNU extension).

Given

FOO: bar();
void *ptr = &&FOO;
goto *bar;

addrLabelExpr() matches '&&FOO'

Definition at line 944 of file ASTMatchersInternal.cpp.

◆ allOf

const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> clang::ast_matchers::allOf = {internal::DynTypedMatcher::VO_AllOf}

Matches if all given matchers match.

Usable as: Any Matcher

Definition at line 1035 of file ASTMatchersInternal.cpp.

Referenced by alignOfExpr(), clang::ento::assignedToRef(), clang::ento::forLoopMatcher(), and sizeOfExpr().

◆ anyOf

◆ arrayInitIndexExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ArrayInitIndexExpr > clang::ast_matchers::arrayInitIndexExpr

The arrayInitIndexExpr consists of two subexpressions: a common expression (the source array) that is evaluated once up-front, and a per-element initializer that runs once for each array element.

Within the per-element initializer, the current index may be obtained via an ArrayInitIndexExpr.

Given

void testStructBinding() {
int a[2] = {1, 2};
auto [x, y] = a;
}

arrayInitIndexExpr() matches the array index that implicitly iterates over the array a to copy each element to the anonymous array that backs the structured binding [x, y] elements of which are referred to by their aliases x and y.

Definition at line 916 of file ASTMatchersInternal.cpp.

◆ arrayInitLoopExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ArrayInitLoopExpr > clang::ast_matchers::arrayInitLoopExpr

Matches a loop initializing the elements of an array in a number of contexts:

  • in the implicit copy/move constructor for a class with an array member
  • when a lambda-expression captures an array by value
  • when a decomposition declaration decomposes an array

Given

void testLambdaCapture() {
int a[10];
auto Lam1 = [a]() {
return;
};
}

arrayInitLoopExpr() matches the implicit loop that initializes each element of the implicit array field inside the lambda object, that represents the array a captured by value.

Definition at line 918 of file ASTMatchersInternal.cpp.

◆ arraySubscriptExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ArraySubscriptExpr > clang::ast_matchers::arraySubscriptExpr

Matches array subscript expressions.

Given

int i = a[1];

arraySubscriptExpr() matches "a[1]"

Definition at line 914 of file ASTMatchersInternal.cpp.

◆ arrayType

◆ asmStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, AsmStmt > clang::ast_matchers::asmStmt

Matches asm statements.

int i = 100;
__asm("mov al, 2");

asmStmt() matches '__asm("mov al, 2")'

Definition at line 956 of file ASTMatchersInternal.cpp.

◆ atomicExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, AtomicExpr > clang::ast_matchers::atomicExpr

Matches atomic builtins.

Example matches __atomic_load_n(ptr, 1)

void foo() { int *ptr; __atomic_load_n(ptr, 1); }

Definition at line 987 of file ASTMatchersInternal.cpp.

◆ atomicType

const AstTypeMatcher<AtomicType> clang::ast_matchers::atomicType

◆ attr

const internal::VariadicAllOfMatcher<Attr> clang::ast_matchers::attr

Definition at line 1073 of file ASTMatchersInternal.cpp.

◆ autoreleasePoolStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAutoreleasePoolStmt > clang::ast_matchers::autoreleasePoolStmt

Matches an Objective-C autorelease pool statement.

Given

@autoreleasepool {
int x = 0;
}

autoreleasePoolStmt(stmt()) matches the declaration of "x" inside the autorelease pool.

Definition at line 751 of file ASTMatchersInternal.cpp.

Referenced by checkTempObjectsInNoPool(), and checkTempObjectsInSamePool().

◆ autoType

const AstTypeMatcher<AutoType> clang::ast_matchers::autoType

Definition at line 1087 of file ASTMatchersInternal.cpp.

◆ binaryConditionalOperator

const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryConditionalOperator > clang::ast_matchers::binaryConditionalOperator

Matches binary conditional operator expressions (GNU extension).

Example matches a ?: b

(a ?: b) + 42;

Definition at line 999 of file ASTMatchersInternal.cpp.

◆ binaryOperation

const internal::MapAnyOfMatcher< BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator > clang::ast_matchers::binaryOperation

Matches nodes which can be used with binary operators.

The code

var1 != var2;

might be represented in the clang AST as a binaryOperator, a cxxOperatorCallExpr or a cxxRewrittenBinaryOperator, depending on

  • whether the types of var1 and var2 are fundamental (binaryOperator) or at least one is a class type (cxxOperatorCallExpr)
  • whether the code appears in a template declaration, if at least one of the vars is a dependent-type (binaryOperator)
  • whether the code relies on a rewritten binary operator, such as a spaceship operator or an inverted equality operator (cxxRewrittenBinaryOperator)

This matcher elides details in places where the matchers for the nodes are compatible.

Given

hasOperatorName("!="),
hasLHS(expr().bind("lhs")),
hasRHS(expr().bind("rhs"))
)
const internal::MapAnyOfMatcher< BinaryOperator, CXXOperatorCallExpr, CXXRewrittenBinaryOperator > binaryOperation
Matches nodes which can be used with binary operators.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.

matches each use of "!=" in:

struct S{
bool operator!=(const S&) const;
};
void foo()
{
1 != 2;
S() != S();
}
template<typename T>
void templ()
{
1 != 2;
T() != S();
}
struct HasOpEq
{
bool operator==(const HasOpEq &) const;
};
void inverse()
{
HasOpEq s1;
HasOpEq s2;
if (s1 != s2)
return;
}
struct HasSpaceship
{
bool operator<=>(const HasOpEq &) const;
};
void use_spaceship()
{
HasSpaceship s1;
HasSpaceship s2;
if (s1 != s2)
return;
}
bool operator==(const CallGraphNode::CallRecord &LHS, const CallGraphNode::CallRecord &RHS)
Definition CallGraph.h:204
bool operator!=(CanQual< T > x, CanQual< U > y)

Definition at line 993 of file ASTMatchersInternal.cpp.

◆ binaryOperator

const internal::VariadicDynCastAllOfMatcher< Stmt, BinaryOperator > clang::ast_matchers::binaryOperator

Matches binary operator expressions.

Example matches a || b

!(a || b)

See also the binaryOperation() matcher for more-general matching.

Definition at line 990 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::changeIntBoundNode(), clang::ento::forLoopMatcher(), potentiallyWritesIntoIvar(), and clang::ento::simpleCondition().

◆ bindingDecl

const internal::VariadicDynCastAllOfMatcher< Decl, BindingDecl > clang::ast_matchers::bindingDecl

Matches binding declarations Example matches foo and bar (matcher = bindingDecl()

auto [foo, bar] = std::make_pair{42, 42};

Definition at line 764 of file ASTMatchersInternal.cpp.

◆ blockDecl

const internal::VariadicDynCastAllOfMatcher< Decl, BlockDecl > clang::ast_matchers::blockDecl

Matches block declarations.

Example matches the declaration of the nameless block printing an input integer.

myFunc(^(int p) {
printf("%d", p);
})
CLINKAGE int printf(__constant const char *st,...) __attribute__((format(printf

Definition at line 867 of file ASTMatchersInternal.cpp.

Referenced by clang::CodeGen::CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(), and clang::CodeGen::CodeGenFunction::GenerateBlockFunction().

◆ blockExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, BlockExpr > clang::ast_matchers::blockExpr

Matches a reference to a block.

Example: matches "^{}":

void f() { ^{}(); }

Definition at line 931 of file ASTMatchersInternal.cpp.

Referenced by clang::CodeGen::CodeGenFunction::EmitBlockLiteral().

◆ blockPointerType

const AstTypeMatcher<BlockPointerType> clang::ast_matchers::blockPointerType

Definition at line 1092 of file ASTMatchersInternal.cpp.

◆ breakStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, BreakStmt > clang::ast_matchers::breakStmt

Matches break statements.

Given

while (true) { break; }

breakStmt() matches 'break'

Definition at line 938 of file ASTMatchersInternal.cpp.

◆ builtinType

const AstTypeMatcher<BuiltinType> clang::ast_matchers::builtinType

Definition at line 1076 of file ASTMatchersInternal.cpp.

◆ callExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CallExpr > clang::ast_matchers::callExpr

◆ caseStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, CaseStmt > clang::ast_matchers::caseStmt

Matches case statements inside switch statements.

Given

switch(a) { case 42: break; default: break; }

caseStmt() matches 'case 42:'.

Definition at line 947 of file ASTMatchersInternal.cpp.

◆ castExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > clang::ast_matchers::castExpr

◆ characterLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, CharacterLiteral > clang::ast_matchers::characterLiteral

Matches character literals (also matches wchar_t).

Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), though.

Example matches 'a', L'a'

char ch = 'a';
wchar_t chw = L'a';

Definition at line 962 of file ASTMatchersInternal.cpp.

◆ chooseExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ChooseExpr > clang::ast_matchers::chooseExpr

Matches GNU __builtin_choose_expr.

Definition at line 975 of file ASTMatchersInternal.cpp.

◆ classTemplateDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateDecl > clang::ast_matchers::classTemplateDecl

Matches C++ class template declarations.

Example matches Z

template<class T> class Z {};

Definition at line 775 of file ASTMatchersInternal.cpp.

◆ classTemplatePartialSpecializationDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplatePartialSpecializationDecl > clang::ast_matchers::classTemplatePartialSpecializationDecl

Matches C++ class template partial specializations.

Given

template<class T1, class T2, int I>
class A {};
template<class T, int I>
class A<T, T*, I> {};
template<>
class A<int, int, 1> {};

classTemplatePartialSpecializationDecl() matches the specialization A<T,T*,I> but not A<int,int,1>

Definition at line 781 of file ASTMatchersInternal.cpp.

◆ classTemplateSpecializationDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ClassTemplateSpecializationDecl > clang::ast_matchers::classTemplateSpecializationDecl

Matches C++ class template specializations.

Given

template<typename T> class A {};
template<> class A<double> {};
A<int> a;

classTemplateSpecializationDecl() matches the specializations A<int> and A<double>

Definition at line 778 of file ASTMatchersInternal.cpp.

Referenced by gtestThatInternal().

◆ coawaitExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CoawaitExpr > clang::ast_matchers::coawaitExpr

Matches co_await expressions.

Given

co_await 1;

coawaitExpr() matches 'co_await 1'

Definition at line 979 of file ASTMatchersInternal.cpp.

◆ complexType

◆ compoundLiteralExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundLiteralExpr > clang::ast_matchers::compoundLiteralExpr

Matches compound (i.e.

non-scalar) literals

Example match: {1}, (1, 2)

int array[4] = {1};
vector int myvec = (vector int)(1, 2);

Definition at line 972 of file ASTMatchersInternal.cpp.

◆ compoundStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, CompoundStmt > clang::ast_matchers::compoundStmt

Matches compound statements.

Example matches '{}' and '{{}}' in 'for (;;) {{}}'

for (;;) {{}}

Definition at line 949 of file ASTMatchersInternal.cpp.

Referenced by clang::CIRGen::CIRGenFunction::emitSwitchBody().

◆ conceptDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ConceptDecl > clang::ast_matchers::conceptDecl

Matches concept declarations.

Example matches integral

template<typename T>
concept integral = std::is_integral_v<T>;

Definition at line 829 of file ASTMatchersInternal.cpp.

◆ conditionalOperator

const internal::VariadicDynCastAllOfMatcher< Stmt, ConditionalOperator > clang::ast_matchers::conditionalOperator

Matches conditional operator expressions.

Example matches a ? b : c

(a ? b : c) + 42

Definition at line 997 of file ASTMatchersInternal.cpp.

Referenced by hasUnguardedAccess().

◆ constantArrayType

const AstTypeMatcher<ConstantArrayType> clang::ast_matchers::constantArrayType

Definition at line 1079 of file ASTMatchersInternal.cpp.

◆ constantExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ConstantExpr > clang::ast_matchers::constantExpr

Matches a constant expression wrapper.

Example matches the constant in the case statement: (matcher = constantExpr())

switch (a) {
case 37: break;
}

Definition at line 898 of file ASTMatchersInternal.cpp.

◆ continueStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ContinueStmt > clang::ast_matchers::continueStmt

Matches continue statements.

Given

while (true) { continue; }

continueStmt() matches 'continue'

Definition at line 939 of file ASTMatchersInternal.cpp.

◆ convertVectorExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ConvertVectorExpr > clang::ast_matchers::convertVectorExpr

Matches builtin function __builtin_convertvector.

Definition at line 977 of file ASTMatchersInternal.cpp.

◆ coreturnStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, CoreturnStmt > clang::ast_matchers::coreturnStmt

Matches co_return statements.

Given

while (true) { co_return; }

coreturnStmt() matches 'co_return'

Definition at line 940 of file ASTMatchersInternal.cpp.

◆ coroutineBodyStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, CoroutineBodyStmt > clang::ast_matchers::coroutineBodyStmt

Matches coroutine body statements.

coroutineBodyStmt() matches the coroutine below

generator<int> gen() {
co_return;
}
-msp430-def

Definition at line 951 of file ASTMatchersInternal.cpp.

◆ coyieldExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CoyieldExpr > clang::ast_matchers::coyieldExpr

Matches co_yield expressions.

Given

co_yield 1;

coyieldExpr() matches 'co_yield 1'

Definition at line 983 of file ASTMatchersInternal.cpp.

◆ cStyleCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CStyleCastExpr > clang::ast_matchers::cStyleCastExpr

Matches a C-style cast expression.

Example: Matches (int) 2.2f in

int i = (int) 2.2f;

Definition at line 1013 of file ASTMatchersInternal.cpp.

◆ cudaKernelCallExpr

const internal::VariadicDynCastAllOfMatcher<Stmt, CUDAKernelCallExpr> clang::ast_matchers::cudaKernelCallExpr

Definition at line 1075 of file ASTMatchersInternal.cpp.

◆ cxxBaseSpecifier

const internal::VariadicAllOfMatcher< CXXBaseSpecifier > clang::ast_matchers::cxxBaseSpecifier

Matches class bases.

Examples matches public virtual B.

class B {};
class C : public virtual B {};

Definition at line 787 of file ASTMatchersInternal.cpp.

◆ cxxBindTemporaryExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBindTemporaryExpr > clang::ast_matchers::cxxBindTemporaryExpr

Matches nodes where temporaries are created.

Example matches FunctionTakesString(GetStringByValue()) (matcher = cxxBindTemporaryExpr())

FunctionTakesString(GetStringByValue());
FunctionTakesStringByPointer(GetStringPointer());

Definition at line 906 of file ASTMatchersInternal.cpp.

◆ cxxBoolLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXBoolLiteralExpr > clang::ast_matchers::cxxBoolLiteral

Matches bool literals.

Example matches true

true

Definition at line 958 of file ASTMatchersInternal.cpp.

◆ cxxCatchStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXCatchStmt > clang::ast_matchers::cxxCatchStmt

Matches catch statements.

try {} catch(int i) {}

cxxCatchStmt() matches 'catch(int i)'

Definition at line 952 of file ASTMatchersInternal.cpp.

◆ cxxConstCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstCastExpr > clang::ast_matchers::cxxConstCastExpr

Matches a const_cast expression.

Example: Matches const_cast<int*>(&r) in

int n = 42;
const int &r(n);
int* p = const_cast<int*>(&r);

Definition at line 1011 of file ASTMatchersInternal.cpp.

◆ cxxConstructExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXConstructExpr > clang::ast_matchers::cxxConstructExpr

Matches constructor call expressions (including implicit ones).

Example matches string(ptr, n) and ptr within arguments of f (matcher = cxxConstructExpr())

void f(const string &a, const string &b);
char *ptr;
int n;
f(string(ptr, n), ptr);

Definition at line 901 of file ASTMatchersInternal.cpp.

Referenced by AST_POLYMORPHIC_MATCHER_P2().

◆ cxxConstructorDecl

const internal::VariadicDynCastAllOfMatcher< Decl, CXXConstructorDecl > clang::ast_matchers::cxxConstructorDecl

Matches C++ constructor declarations.

Example matches Foo::Foo() and Foo::Foo(int)

class Foo {
public:
Foo();
Foo(int);
int DoSomething();
};

Definition at line 819 of file ASTMatchersInternal.cpp.

Referenced by AST_POLYMORPHIC_MATCHER_P2().

◆ cxxConversionDecl

const internal::VariadicDynCastAllOfMatcher< Decl, CXXConversionDecl > clang::ast_matchers::cxxConversionDecl

Matches conversion operator declarations.

Example matches the operator.

class X { operator int() const; };

Definition at line 828 of file ASTMatchersInternal.cpp.

◆ cxxCtorInitializer

const internal::VariadicAllOfMatcher< CXXCtorInitializer > clang::ast_matchers::cxxCtorInitializer

Matches constructor initializers.

Examples matches i(42).

class C {
C() : i(42) {}
int i;
};

Definition at line 788 of file ASTMatchersInternal.cpp.

◆ cxxDeductionGuideDecl

const internal::VariadicDynCastAllOfMatcher< Decl, CXXDeductionGuideDecl > clang::ast_matchers::cxxDeductionGuideDecl

Matches user-defined and implicitly generated deduction guide.

Example matches the deduction guide.

template<typename T>
class X { X(int) };
X(int) -> X<int>;

Definition at line 1130 of file ASTMatchersInternal.cpp.

◆ cxxDefaultArgExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDefaultArgExpr > clang::ast_matchers::cxxDefaultArgExpr

Matches the value of a default argument at the call site.

Example matches the CXXDefaultArgExpr placeholder inserted for the default value of the second parameter in the call expression f(42) (matcher = cxxDefaultArgExpr())

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

Definition at line 920 of file ASTMatchersInternal.cpp.

◆ cxxDeleteExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDeleteExpr > clang::ast_matchers::cxxDeleteExpr

Matches delete expressions.

Given

delete X;

cxxDeleteExpr() matches 'delete X'.

Definition at line 910 of file ASTMatchersInternal.cpp.

◆ cxxDependentScopeMemberExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDependentScopeMemberExpr > clang::ast_matchers::cxxDependentScopeMemberExpr

Matches member expressions where the actual member referenced could not be resolved because the base expression or the member name was dependent.

Given

template <class T> void f() { T t; t.g(); }

cxxDependentScopeMemberExpr() matches t.g

Definition at line 847 of file ASTMatchersInternal.cpp.

◆ cxxDestructorDecl

const internal::VariadicDynCastAllOfMatcher< Decl, CXXDestructorDecl > clang::ast_matchers::cxxDestructorDecl

Matches explicit C++ destructor declarations.

Example matches Foo::~Foo()

class Foo {
public:
virtual ~Foo();
};

Definition at line 821 of file ASTMatchersInternal.cpp.

◆ cxxDynamicCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXDynamicCastExpr > clang::ast_matchers::cxxDynamicCastExpr

Matches a dynamic_cast expression.

Example: cxxDynamicCastExpr() matches dynamic_cast<D*>(&b); in

struct B { virtual ~B() {} }; struct D : B {};
B b;
D* p = dynamic_cast<D*>(&b);

Definition at line 1009 of file ASTMatchersInternal.cpp.

◆ cxxFoldExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXFoldExpr > clang::ast_matchers::cxxFoldExpr

Matches C++17 fold expressions.

Example matches (0 + ... + args):

template <typename... Args>
auto sum(Args... args) {
return (0 + ... + args);
}

Definition at line 925 of file ASTMatchersInternal.cpp.

◆ cxxForRangeStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXForRangeStmt > clang::ast_matchers::cxxForRangeStmt

Matches range-based for statements.

cxxForRangeStmt() matches 'for (auto a : i)'

int i[] = {1, 2, 3}; for (auto a : i);
for(int j = 0; j < 5; ++j);

Definition at line 935 of file ASTMatchersInternal.cpp.

◆ cxxFunctionalCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXFunctionalCastExpr > clang::ast_matchers::cxxFunctionalCastExpr

Matches functional cast expressions.

Example: Matches Foo(bar);

Foo f = bar;
Foo g = (Foo) bar;
Foo h = Foo(bar);

Definition at line 1020 of file ASTMatchersInternal.cpp.

◆ cxxMemberCallExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXMemberCallExpr > clang::ast_matchers::cxxMemberCallExpr

Matches member call expressions.

Example matches x.y()

X x;
x.y();

Definition at line 851 of file ASTMatchersInternal.cpp.

Referenced by gtestCallInternal(), and gtestCallInternal().

◆ cxxMethodDecl

const internal::VariadicDynCastAllOfMatcher< Decl, CXXMethodDecl > clang::ast_matchers::cxxMethodDecl

Matches method declarations.

Example matches y

class X { void y(); };

Definition at line 826 of file ASTMatchersInternal.cpp.

Referenced by AST_POLYMORPHIC_MATCHER_P2(), and getComparisonDecl().

◆ cxxNewExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNewExpr > clang::ast_matchers::cxxNewExpr

Matches new expressions.

Given

new X;

cxxNewExpr() matches 'new X'.

Definition at line 909 of file ASTMatchersInternal.cpp.

◆ cxxNoexceptExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNoexceptExpr > clang::ast_matchers::cxxNoexceptExpr

Matches noexcept expressions.

Given

bool a() noexcept;
bool b() noexcept(true);
bool c() noexcept(false);
bool d() noexcept(noexcept(a()));
bool e = noexcept(b()) || noexcept(c());
#define false
Definition stdbool.h:26
#define true
Definition stdbool.h:25

cxxNoexceptExpr() matches noexcept(a()), noexcept(b()) and noexcept(c()). doesn't match the noexcept specifier in the declarations a, b, c or d.

Definition at line 912 of file ASTMatchersInternal.cpp.

Referenced by clang::ExprMutationAnalyzer::isUnevaluated().

◆ cxxNullPtrLiteralExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXNullPtrLiteralExpr > clang::ast_matchers::cxxNullPtrLiteralExpr

Matches nullptr literal.

Definition at line 974 of file ASTMatchersInternal.cpp.

◆ cxxOperatorCallExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXOperatorCallExpr > clang::ast_matchers::cxxOperatorCallExpr

Matches overloaded operator calls.

Note that if an operator isn't overloaded, it won't match. Instead, use binaryOperator matcher. Currently it does not match operators such as new delete. FIXME: figure out why these do not match?

Example matches both operator<<((o << b), c) and operator<<(o, b) (matcher = cxxOperatorCallExpr())

ostream &operator<< (ostream &out, int i) { };
ostream &o; int b = 1, c = 1;
o << b << c;

See also the binaryOperation() matcher for more-general matching of binary uses of this AST node.

Definition at line 922 of file ASTMatchersInternal.cpp.

Referenced by AST_POLYMORPHIC_MATCHER_P2(), gtestCallInternal(), and gtestThatInternal().

◆ cxxRecordDecl

const internal::VariadicDynCastAllOfMatcher< Decl, CXXRecordDecl > clang::ast_matchers::cxxRecordDecl

◆ cxxReinterpretCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXReinterpretCastExpr > clang::ast_matchers::cxxReinterpretCastExpr

Matches a reinterpret_cast expression.

Either the source expression or the destination type can be matched using has(), but hasDestinationType() is more specific and can be more readable.

Example matches reinterpret_cast<char*>(&p) in

void* p = reinterpret_cast<char*>(&p);

Definition at line 1005 of file ASTMatchersInternal.cpp.

◆ cxxRewrittenBinaryOperator

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXRewrittenBinaryOperator > clang::ast_matchers::cxxRewrittenBinaryOperator

Matches rewritten binary operators.

Example matches use of "<":

#include <compare>
struct HasSpaceshipMem {
int a;
constexpr auto operator<=>(const HasSpaceshipMem&) const = default;
};
void compare() {
HasSpaceshipMem hs1, hs2;
if (hs1 < hs2)
return;
}
static bool compare(const PathDiagnostic &X, const PathDiagnostic &Y)

See also the binaryOperation() matcher for more-general matching of this AST node.

Definition at line 924 of file ASTMatchersInternal.cpp.

◆ cxxStaticCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStaticCastExpr > clang::ast_matchers::cxxStaticCastExpr

Matches a C++ static_cast expression.

See also
hasDestinationType
reinterpretCast

Example: cxxStaticCastExpr() matches static_cast<long>(8) in

long eight(static_cast<long>(8));

Definition at line 1007 of file ASTMatchersInternal.cpp.

◆ cxxStdInitializerListExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXStdInitializerListExpr > clang::ast_matchers::cxxStdInitializerListExpr

Matches C++ initializer list expressions.

Given

std::vector<int> a({ 1, 2, 3 });
std::vector<int> b = { 4, 5 };
int c[] = { 6, 7 };
std::pair<int, int> d = { 8, 9 };

cxxStdInitializerListExpr() matches "{ 1, 2, 3 }" and "{ 4, 5 }"

Definition at line 882 of file ASTMatchersInternal.cpp.

◆ cxxTemporaryObjectExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTemporaryObjectExpr > clang::ast_matchers::cxxTemporaryObjectExpr

Matches functional cast expressions having N != 1 arguments.

Example: Matches Foo(bar, bar)

Foo h = Foo(bar, bar);

Definition at line 1022 of file ASTMatchersInternal.cpp.

◆ cxxThisExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThisExpr > clang::ast_matchers::cxxThisExpr

Matches implicit and explicit this expressions.

Example matches the implicit this expression in "return i". (matcher = cxxThisExpr())

struct foo {
int i;
int f() { return i; }
};

Definition at line 904 of file ASTMatchersInternal.cpp.

◆ cxxThrowExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXThrowExpr > clang::ast_matchers::cxxThrowExpr

Matches throw expressions.

try { throw 5; } catch(int i) {}

cxxThrowExpr() matches 'throw 5'

Definition at line 954 of file ASTMatchersInternal.cpp.

◆ cxxTryStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXTryStmt > clang::ast_matchers::cxxTryStmt

Matches try statements.

try {} catch(int i) {}

cxxTryStmt() matches 'try {}'

Definition at line 953 of file ASTMatchersInternal.cpp.

◆ cxxUnresolvedConstructExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, CXXUnresolvedConstructExpr > clang::ast_matchers::cxxUnresolvedConstructExpr

Matches unresolved constructor call expressions.

Example matches T(t) in return statement of f (matcher = cxxUnresolvedConstructExpr())

template <typename T>
void f(const T& t) { return T(t); }

Definition at line 903 of file ASTMatchersInternal.cpp.

◆ decayedType

const AstTypeMatcher<DecayedType> clang::ast_matchers::decayedType

Definition at line 1110 of file ASTMatchersInternal.cpp.

◆ decl

const internal::VariadicAllOfMatcher< Decl > clang::ast_matchers::decl

◆ declaratorDecl

const internal::VariadicDynCastAllOfMatcher< Decl, DeclaratorDecl > clang::ast_matchers::declaratorDecl

Matches declarator declarations (field, variable, function and non-type template parameter declarations).

Given

class X { int y; };

declaratorDecl() matches int y.

Definition at line 783 of file ASTMatchersInternal.cpp.

◆ declRefExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, DeclRefExpr > clang::ast_matchers::declRefExpr

Matches expressions that refer to declarations.

Example matches x in if (x)

bool x;
if (x) {}

Definition at line 927 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::assignedToRef(), clang::ento::callByRef(), clang::ento::changeIntBoundNode(), clang::ento::forLoopMatcher(), clang::ento::getAddrTo(), and clang::ento::simpleCondition().

◆ declStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, DeclStmt > clang::ast_matchers::declStmt

Matches declaration statements.

Given

int a;

declStmt() matches 'int a'.

Definition at line 842 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::assignedToRef(), and clang::ento::forLoopMatcher().

◆ decltypeType

const AstTypeMatcher<DecltypeType> clang::ast_matchers::decltypeType

Definition at line 1088 of file ASTMatchersInternal.cpp.

◆ decompositionDecl

const internal::VariadicDynCastAllOfMatcher< Decl, DecompositionDecl > clang::ast_matchers::decompositionDecl

Matches decomposition-declarations.

Examples matches the declaration node with foo and bar, but not number. (matcher = declStmt(has(decompositionDecl())))

int number = 42;
auto [foo, bar] = std::make_pair{42, 42};

Definition at line 763 of file ASTMatchersInternal.cpp.

◆ deducedTemplateSpecializationType

const AstTypeMatcher<DeducedTemplateSpecializationType> clang::ast_matchers::deducedTemplateSpecializationType

Definition at line 1081 of file ASTMatchersInternal.cpp.

◆ defaultStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, DefaultStmt > clang::ast_matchers::defaultStmt

Matches default statements inside switch statements.

Given

switch(a) { case 42: break; default: break; }

defaultStmt() matches 'default:'.

Definition at line 948 of file ASTMatchersInternal.cpp.

◆ dependentCoawaitExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, DependentCoawaitExpr > clang::ast_matchers::dependentCoawaitExpr

Matches co_await expressions where the type of the promise is dependent.

Definition at line 981 of file ASTMatchersInternal.cpp.

◆ dependentNameType

const AstTypeMatcher<DependentNameType> clang::ast_matchers::dependentNameType

Definition at line 1111 of file ASTMatchersInternal.cpp.

◆ dependentScopeDeclRefExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, DependentScopeDeclRefExpr > clang::ast_matchers::dependentScopeDeclRefExpr

Matches expressions that refer to dependent scope declarations.

example matches T::v;

template <class T> class X : T { void f() { T::v; } };

Definition at line 929 of file ASTMatchersInternal.cpp.

◆ dependentSizedArrayType

const AstTypeMatcher<DependentSizedArrayType> clang::ast_matchers::dependentSizedArrayType

Definition at line 1082 of file ASTMatchersInternal.cpp.

◆ dependentSizedExtVectorType

const AstTypeMatcher<DependentSizedExtVectorType> clang::ast_matchers::dependentSizedExtVectorType

Definition at line 1083 of file ASTMatchersInternal.cpp.

◆ dependentTemplateSpecializationType

const AstTypeMatcher<DependentTemplateSpecializationType> clang::ast_matchers::dependentTemplateSpecializationType

Definition at line 1113 of file ASTMatchersInternal.cpp.

◆ designatedInitExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, DesignatedInitExpr > clang::ast_matchers::designatedInitExpr

Matches C99 designated initializer expressions [C99 6.7.8].

Example: Matches { [2].y = 1.0, [0].x = 1.0 }

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

Definition at line 1026 of file ASTMatchersInternal.cpp.

◆ doStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, DoStmt > clang::ast_matchers::doStmt

Matches do statements.

Given

do {} while (true);

doStmt() matches 'do {} while(true)'

Definition at line 937 of file ASTMatchersInternal.cpp.

◆ eachOf

const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> clang::ast_matchers::eachOf = {internal::DynTypedMatcher::VO_EachOf}

Matches if any of the given matchers matches.

Unlike anyOf, eachOf will generate a match result for each matching submatcher.

For example, in:

class A { int a; int b; };

The matcher:

has(fieldDecl(hasName("b")).bind("v"))))
const internal::VariadicOperatorMatcherFunc< 2, std::numeric_limits< unsigned >::max()> eachOf
Matches if any of the given matchers matches.
const internal::VariadicDynCastAllOfMatcher< Decl, FieldDecl > fieldDecl
Matches field declarations.

will generate two results binding "v", the first of which binds the field declaration of a, the second the field declaration of b.

Usable as: Any Matcher

Definition at line 1029 of file ASTMatchersInternal.cpp.

Referenced by findAll().

◆ enumConstantDecl

const internal::VariadicDynCastAllOfMatcher< Decl, EnumConstantDecl > clang::ast_matchers::enumConstantDecl

Matches enum constants.

Example matches A, B, C

enum X {
A, B, C
};

Definition at line 824 of file ASTMatchersInternal.cpp.

◆ enumDecl

const internal::VariadicDynCastAllOfMatcher< Decl, EnumDecl > clang::ast_matchers::enumDecl

Matches enum declarations.

Example matches X

enum X {
A, B, C
};

Definition at line 822 of file ASTMatchersInternal.cpp.

◆ enumType

const AstTypeMatcher<EnumType> clang::ast_matchers::enumType

Definition at line 1101 of file ASTMatchersInternal.cpp.

◆ explicitCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ExplicitCastExpr > clang::ast_matchers::explicitCastExpr

Matches explicit cast expressions.

Matches any cast expression written in user code, whether it be a C-style cast, a functional-style cast, or a keyword cast.

Does not match implicit conversions.

Note: the name "explicitCast" is chosen to match Clang's terminology, as Clang uses the term "cast" to apply to implicit conversions as well as to actual cast expressions.

See also
hasDestinationType.

Example: matches all five of the casts in

int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42)))))

but does not match the implicit conversion in

long ell = 42;

Definition at line 1015 of file ASTMatchersInternal.cpp.

◆ exportDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ExportDecl > clang::ast_matchers::exportDecl

Matches any export declaration.

Example matches following declarations.

export void foo();
export { void foo(); }
export namespace { void foo(); }
export int v;

Definition at line 816 of file ASTMatchersInternal.cpp.

◆ expr

const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > clang::ast_matchers::expr

Matches expressions.

Example matches x()

void f() { x(); }

Definition at line 926 of file ASTMatchersInternal.cpp.

Referenced by clang::Sema::ActOnFileScopeAsmDecl(), AST_POLYMORPHIC_MATCHER_P2(), clang::CFGTemporaryDtor::CFGTemporaryDtor(), diagnoseScopedEnums(), clang::CIRGen::CIRGenFunction::emitAlignmentAssumption(), emitAtomicOp(), clang::CIRGen::CIRGenFunction::emitCaseDefaultCascade(), clang::CodeGen::CodeGenFunction::EmitConditionalOperatorLValue(), clang::CIRGen::CIRGenFunction::emitCXXPseudoDestructorExpr(), clang::CodeGen::CodeGenFunction::EmitObjCThrowOperand(), clang::CIRGen::CIRGenFunction::emitOpenACCIntExpr(), clang::CIRGen::CIRGenFunction::emitOpenACCWaitConstruct(), emitPointerArithmetic(), emitPointerArithmetic(), clang::CIRGen::CIRGenFunction::emitPointerWithAlignment(), clang::Expr::findBoundMemberType(), clang::CIRGen::CIRGenCallee::forPseudoDestructor(), clang::CodeGen::CGCXXABI::GetArrayCookieSize(), clang::CodeGen::CGCXXABI::GetDeletedVirtualCallName(), getDereferenceExpr(), getIncrementedVar(), clang::ento::SValBuilder::getMetadataSymbolVal(), gtestThatInternal(), clang::CodeGen::CGCXXABI::InitializeArrayCookie(), clang::ExprMutationAnalyzer::isUnevaluated(), clang::ento::SValBuilder::makeLoc(), clang::analyze_os_log::OSLogBufferItem::OSLogBufferItem(), clang::CodeGen::CGCXXABI::ReadArrayCookie(), clang::CodeGen::CGCXXABI::requiresArrayCookie(), clang::CodeGen::CGCXXABI::requiresArrayCookie(), clang::Sema::FullExprArg::Sema, clang::InitListExpr::setInit(), clang::CIRGen::CIRGenFunction::OpaqueValueMapping::shouldBindAsLValue(), clang::CIRGen::CIRGenFunction::OpaqueValueMappingData::shouldBindAsLValue(), clang::CodeGen::CodeGenFunction::OpaqueValueMapping::shouldBindAsLValue(), clang::CodeGen::CodeGenFunction::OpaqueValueMappingData::shouldBindAsLValue(), and clang::InitListExpr::updateInit().

◆ exprWithCleanups

const internal::VariadicDynCastAllOfMatcher< Stmt, ExprWithCleanups > clang::ast_matchers::exprWithCleanups

Matches expressions that introduce cleanups to be run at the end of the sub-expression's evaluation.

Example matches std::string()

const std::string str = std::string();

Definition at line 879 of file ASTMatchersInternal.cpp.

◆ fieldDecl

const internal::VariadicDynCastAllOfMatcher< Decl, FieldDecl > clang::ast_matchers::fieldDecl

Matches field declarations.

Given

class X { int m; };

fieldDecl() matches 'm'.

Definition at line 834 of file ASTMatchersInternal.cpp.

◆ fixedPointLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, FixedPointLiteral > clang::ast_matchers::fixedPointLiteral

Matches fixed-point literals eg.

0.5r, 0.5hr, 0.5lr, 0.5uhr, 0.5ur, 0.5ulr 1.0k, 1.0hk, 1.0lk, 1.0uhk, 1.0uk, 1.0ulk Exponents 1.0e10k Hexadecimal numbers 0x0.2p2r

Does not match implicit conversions such as first two lines:

short _Accum sa = 2;
_Accum a = 12.5;
_Accum b = 1.25hk;
_Fract c = 0.25hr;
_Fract v = 0.35uhr;
_Accum g = 1.45uhk;
_Accum decexp1 = 1.575e1k;

\compile_args{-ffixed-point;-std=c99}

The matcher \matcher{fixedPointLiteral()} matches \match{1.25hk}, \match{0.25hr}, \match{0.35uhr}, \match{1.45uhk}, \match{1.575e1k}, but does not match \nomatch{12.5} and \nomatch{2} from the code block.

Definition at line 968 of file ASTMatchersInternal.cpp.

◆ floatLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, FloatingLiteral > clang::ast_matchers::floatLiteral

Matches float literals of all sizes / encodings, e.g.

1.0, 1.0f, 1.0L and 1e10.

Does not match implicit conversions such as

float a = 10;

Definition at line 965 of file ASTMatchersInternal.cpp.

◆ forEach

const internal::ArgumentAdaptingMatcherFunc< internal::ForEachMatcher > clang::ast_matchers::forEach
Initial value:
=
{}

Matches AST nodes that have child AST nodes that match the provided matcher.

Example matches X, Y, Y::X, Z::Y, Z::Y::X (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))

class X {};
class Y { class X {}; }; // Matches Y, because Y::X is a class of name X
// inside Y.
class Z { class Y { class X {}; }; }; // Does not match Z.

ChildT must be an AST base type.

As opposed to 'has', 'forEach' will cause a match for each result that matches instead of only on the first one.

Usable as: Any Matcher

Definition at line 1054 of file ASTMatchersInternal.cpp.

◆ forEachDescendant

const internal::ArgumentAdaptingMatcherFunc< internal::ForEachDescendantMatcher > clang::ast_matchers::forEachDescendant = {}

Matches AST nodes that have descendant AST nodes that match the provided matcher.

Example matches X, A, A::X, B, B::C, B::C::X (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))

class X {};
class A { class X {}; }; // Matches A, because A::X is a class of name
// X inside A.
class B { class C { class X {}; }; };

DescendantT must be an AST base type.

As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for each result that matches instead of only on the first one.

Note: Recursively combined ForEachDescendant can cause many matches: cxxRecordDecl(forEachDescendant(cxxRecordDecl( forEachDescendant(cxxRecordDecl()) ))) will match 10 times (plus injected class name matches) on:

class A { class B { class C { class D { class E {}; }; }; }; };

Usable as: Any Matcher

Definition at line 1057 of file ASTMatchersInternal.cpp.

Referenced by findAll().

◆ forStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ForStmt > clang::ast_matchers::forStmt

Matches for statements.

Example matches 'for (;;) {}'

for (;;) {}
int i[] = {1, 2, 3}; for (auto a : i);

Definition at line 933 of file ASTMatchersInternal.cpp.

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

◆ friendDecl

const internal::VariadicDynCastAllOfMatcher< Decl, FriendDecl > clang::ast_matchers::friendDecl

Matches friend declarations.

Given

class X { friend void foo(); };

friendDecl() matches 'friend void foo()'.

Definition at line 840 of file ASTMatchersInternal.cpp.

◆ functionDecl

const internal::VariadicDynCastAllOfMatcher< Decl, FunctionDecl > clang::ast_matchers::functionDecl

◆ functionProtoType

const AstTypeMatcher<FunctionProtoType> clang::ast_matchers::functionProtoType

Definition at line 1090 of file ASTMatchersInternal.cpp.

◆ functionTemplateDecl

const internal::VariadicDynCastAllOfMatcher< Decl, FunctionTemplateDecl > clang::ast_matchers::functionTemplateDecl

Matches C++ function template declarations.

Example matches f

template<class T> void f(T t) {}

Definition at line 839 of file ASTMatchersInternal.cpp.

◆ functionType

const AstTypeMatcher<FunctionType> clang::ast_matchers::functionType

◆ genericSelectionExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, GenericSelectionExpr > clang::ast_matchers::genericSelectionExpr

Matches C11 _Generic expression.

Definition at line 986 of file ASTMatchersInternal.cpp.

Referenced by clang::ExprMutationAnalyzer::isUnevaluated().

◆ gnuNullExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, GNUNullExpr > clang::ast_matchers::gnuNullExpr

Matches GNU __null expression.

Definition at line 984 of file ASTMatchersInternal.cpp.

◆ gotoStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, GotoStmt > clang::ast_matchers::gotoStmt

Matches goto statements.

Given

goto FOO;
FOO: bar();

gotoStmt() matches 'goto FOO'

Definition at line 942 of file ASTMatchersInternal.cpp.

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

◆ has

const internal::ArgumentAdaptingMatcherFunc< internal::HasMatcher > clang::ast_matchers::has = {}

Matches AST nodes that have child AST nodes that match the provided matcher.

Example matches X, Y (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X")))

class X {}; // Matches X, because X::X is a class of name X inside X.
class Y { class X {}; };
class Z { class Y { class X {}; }; }; // Does not match Z.

ChildT must be an AST base type.

Usable as: Any Matcher Note that has is direct matcher, so it also matches things like implicit casts and paren casts. If you are matching with expr then you should probably consider using ignoringParenImpCasts like: has(ignoringParenImpCasts(expr())).

Definition at line 1051 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::assignedToRef(), getLiteralInfo(), and clang::SanitizerSet::has().

◆ hasAncestor

const internal::ArgumentAdaptingMatcherFunc< internal::HasAncestorMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr > > clang::ast_matchers::hasAncestor = {}

Matches AST nodes that have an ancestor that matches the provided matcher.

Given

void f() { if (true) { int x = 42; } }
void g() { for (;;) { int x = 43; } }

expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.

Usable as: Any Matcher

Definition at line 1067 of file ASTMatchersInternal.cpp.

Referenced by checkTempObjectsInNoPool(), checkTempObjectsInSamePool(), and clang::ExprMutationAnalyzer::isUnevaluated().

◆ hasAnyName

const internal::VariadicFunction< internal::Matcher< NamedDecl >, StringRef, internal::hasAnyNameFunc > clang::ast_matchers::hasAnyName = {}

Matches NamedDecl nodes that have any of the specified names.

This matcher is only provided as a performance optimization of hasName.

const internal::VariadicFunction< internal::Matcher< NamedDecl >, StringRef, internal::hasAnyNameFunc > hasAnyName
Matches NamedDecl nodes that have any of the specified names.

is equivalent to, but faster than

Definition at line 1040 of file ASTMatchersInternal.cpp.

Referenced by callsNames(), hasUnguardedAccess(), and clang::tooling::isKnownPointerLikeType().

◆ hasAnyOperatorName

const internal::VariadicFunction<internal::HasOpNameMatcher, StringRef, internal::hasAnyOperatorNameFunc> clang::ast_matchers::hasAnyOperatorName = {}

Definition at line 1044 of file ASTMatchersInternal.cpp.

◆ hasAnyOverloadedOperatorName

const internal::VariadicFunction< internal::HasOverloadOpNameMatcher, StringRef, internal::hasAnyOverloadedOperatorNameFunc > clang::ast_matchers::hasAnyOverloadedOperatorName = {}

Matches overloaded operator names.

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

hasAnyOverloadedOperatorName("+", "-") Is equivalent to anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))

Definition at line 1047 of file ASTMatchersInternal.cpp.

◆ hasAnySelector

const internal::VariadicFunction< internal::Matcher< ObjCMessageExpr >, StringRef, internal::hasAnySelectorFunc > clang::ast_matchers::hasAnySelector = {}

Matches when at least one of the supplied string equals to the Selector.getAsString()

matcher = objCMessageExpr(hasSelector("methodA:", "methodB:")); matches both of the expressions below:

[myObj methodA:argA];
[myObj methodB:argB];

Definition at line 1050 of file ASTMatchersInternal.cpp.

◆ hasDescendant

const internal::ArgumentAdaptingMatcherFunc< internal::HasDescendantMatcher > clang::ast_matchers::hasDescendant = {}

Matches AST nodes that have descendant AST nodes that match the provided matcher.

Example matches X, Y, Z (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X")))))

class X {}; // Matches X, because X::X is a class of name X inside X.
class Y { class X {}; };
class Z { class Y { class X {}; }; };

DescendantT must be an AST base type.

Usable as: Any Matcher

Definition at line 1053 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::assignedToRef(), checkTempObjectsInNoPool(), checkTempObjectsInSamePool(), clang::ento::getWidenedLoopState(), clang::ento::hasSuspiciousStmt(), hasUnguardedAccess(), clang::ExprMutationAnalyzer::isUnevaluated(), and potentiallyWritesIntoIvar().

◆ hasParent

const internal::ArgumentAdaptingMatcherFunc< internal::HasParentMatcher, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr >, internal::TypeList< Decl, NestedNameSpecifierLoc, Stmt, TypeLoc, Attr > > clang::ast_matchers::hasParent = {}

Matches AST nodes that have a parent that matches the provided matcher.

Given

void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }

compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".

Usable as: Any Matcher

Definition at line 1062 of file ASTMatchersInternal.cpp.

◆ ifStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, IfStmt > clang::ast_matchers::ifStmt

Matches if statements.

Example matches 'if (x) {}'

if (x) {}

Definition at line 932 of file ASTMatchersInternal.cpp.

Referenced by hasUnguardedAccess().

◆ imaginaryLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, ImaginaryLiteral > clang::ast_matchers::imaginaryLiteral

Matches imaginary literals, which are based on integer and floating point literals e.g.: 1i, 1.0i.

Definition at line 966 of file ASTMatchersInternal.cpp.

◆ implicitCastExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitCastExpr > clang::ast_matchers::implicitCastExpr

Matches the implicit cast nodes of Clang's AST.

This matches many different places, including function call return value eliding, as well as any type conversions.

Definition at line 1017 of file ASTMatchersInternal.cpp.

◆ implicitValueInitExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ImplicitValueInitExpr > clang::ast_matchers::implicitValueInitExpr

Matches implicit initializers of init list expressions.

Given

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

implicitValueInitExpr() matches "[0].y" (implicitly)

Definition at line 884 of file ASTMatchersInternal.cpp.

◆ incompleteArrayType

const AstTypeMatcher<IncompleteArrayType> clang::ast_matchers::incompleteArrayType

Definition at line 1084 of file ASTMatchersInternal.cpp.

◆ indirectFieldDecl

const internal::VariadicDynCastAllOfMatcher< Decl, IndirectFieldDecl > clang::ast_matchers::indirectFieldDecl

Matches indirect field declarations.

Given

struct X { struct { int a; }; };

indirectFieldDecl() matches 'a'.

Definition at line 836 of file ASTMatchersInternal.cpp.

◆ initListExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, InitListExpr > clang::ast_matchers::initListExpr

Matches init list expressions.

Given

int a[] = { 1, 2 };
struct B { int x, y; };
B b = { 5, 6 };

initListExpr() matches "{ 1, 2 }" and "{ 5, 6 }"

Definition at line 880 of file ASTMatchersInternal.cpp.

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

◆ injectedClassNameType

const AstTypeMatcher<InjectedClassNameType> clang::ast_matchers::injectedClassNameType

Definition at line 1109 of file ASTMatchersInternal.cpp.

◆ integerLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, IntegerLiteral > clang::ast_matchers::integerLiteral

Matches integer literals of all sizes / encodings, e.g.

1, 1L, 0x1 and 1U.

Does not match character-encoded integers such as L'a'.

Definition at line 964 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::forLoopMatcher(), and clang::ento::simpleCondition().

◆ invocation

const internal::MapAnyOfMatcher< CallExpr, CXXConstructExpr > clang::ast_matchers::invocation

Matches function calls and constructor calls.

Because CallExpr and CXXConstructExpr do not share a common base class with API accessing arguments etc, AST Matchers for code which should match both are typically duplicated. This matcher removes the need for duplication.

Given code

struct ConstructorTakesInt
{
ConstructorTakesInt(int i) {}
};
void callTakesInt(int i)
{
}
void doCall()
{
callTakesInt(42);
}
void doConstruct()
{
ConstructorTakesInt cti(42);
}

The matcher

invocation(hasArgument(0, integerLiteral(equals(42))))
const internal::MapAnyOfMatcher< CallExpr, CXXConstructExpr > invocation
Matches function calls and constructor calls.

matches the expression in both doCall and doConstruct

Definition at line 994 of file ASTMatchersInternal.cpp.

◆ labelDecl

const internal::VariadicDynCastAllOfMatcher< Decl, LabelDecl > clang::ast_matchers::labelDecl

Matches a declaration of label.

Given

goto FOO;
FOO: bar();

labelDecl() matches 'FOO:'

Definition at line 768 of file ASTMatchersInternal.cpp.

◆ labelStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, LabelStmt > clang::ast_matchers::labelStmt

Matches label statements.

Given

goto FOO;
FOO: bar();

labelStmt() matches 'FOO:'

Definition at line 943 of file ASTMatchersInternal.cpp.

◆ lambdaCapture

const internal::VariadicAllOfMatcher< LambdaCapture > clang::ast_matchers::lambdaCapture

Matches lambda captures.

Given

int main() {
int x;
auto f = [x](){};
auto g = [x = 1](){};
}

In the matcher lambdaExpr(hasAnyCapture(lambdaCapture())), lambdaCapture() matches x and x=1.

Definition at line 799 of file ASTMatchersInternal.cpp.

◆ lambdaExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, LambdaExpr > clang::ast_matchers::lambdaExpr

Matches lambda expressions.

Example matches [&](){return 5;}

[&](){return 5;}

Definition at line 849 of file ASTMatchersInternal.cpp.

◆ linkageSpecDecl

const internal::VariadicDynCastAllOfMatcher< Decl, LinkageSpecDecl > clang::ast_matchers::linkageSpecDecl

Matches a declaration of a linkage specification.

Given

extern "C" {}

linkageSpecDecl() matches "extern "C" {}"

Definition at line 766 of file ASTMatchersInternal.cpp.

◆ lValueReferenceType

const AstTypeMatcher<LValueReferenceType> clang::ast_matchers::lValueReferenceType

Definition at line 1098 of file ASTMatchersInternal.cpp.

◆ macroQualifiedType

const AstTypeMatcher<MacroQualifiedType> clang::ast_matchers::macroQualifiedType

Definition at line 1093 of file ASTMatchersInternal.cpp.

◆ materializeTemporaryExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, MaterializeTemporaryExpr > clang::ast_matchers::materializeTemporaryExpr

Matches nodes where temporaries are materialized.

Example: Given

struct T {void func();};
T f();
void g(T);

materializeTemporaryExpr() matches 'f()' in these statements

T u(f());
g(f());
f().func();

but does not match

f();

Definition at line 908 of file ASTMatchersInternal.cpp.

◆ memberExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, MemberExpr > clang::ast_matchers::memberExpr

Matches member expressions.

Given

class Y {
void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
int a; static int b;
};

memberExpr() matches this->x, x, y.x, a, this->b

Definition at line 843 of file ASTMatchersInternal.cpp.

Referenced by hasUnguardedAccess().

◆ memberPointerType

const AstTypeMatcher<MemberPointerType> clang::ast_matchers::memberPointerType

Definition at line 1094 of file ASTMatchersInternal.cpp.

◆ namedDecl

const internal::VariadicDynCastAllOfMatcher< Decl, NamedDecl > clang::ast_matchers::namedDecl

Matches a declaration of anything that could have a name.

Example matches X, S, the anonymous union type, i, and U;

typedef int X;
struct S {
union {
int i;
} U;
};

Definition at line 767 of file ASTMatchersInternal.cpp.

◆ namespaceAliasDecl

const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceAliasDecl > clang::ast_matchers::namespaceAliasDecl

Matches a declaration of a namespace alias.

Given

namespace test {}
namespace alias = ::test;

namespaceAliasDecl() matches "namespace alias" but not "namespace test"

Definition at line 771 of file ASTMatchersInternal.cpp.

◆ namespaceDecl

const internal::VariadicDynCastAllOfMatcher< Decl, NamespaceDecl > clang::ast_matchers::namespaceDecl

Matches a declaration of a namespace.

Given

namespace {}
namespace test {}

namespaceDecl() matches "namespace {}" and "namespace test {}"

Definition at line 769 of file ASTMatchersInternal.cpp.

◆ nestedNameSpecifier

const internal::VariadicAllOfMatcher<NestedNameSpecifier> clang::ast_matchers::nestedNameSpecifier

Definition at line 1070 of file ASTMatchersInternal.cpp.

◆ nestedNameSpecifierLoc

const internal::VariadicAllOfMatcher<NestedNameSpecifierLoc> clang::ast_matchers::nestedNameSpecifierLoc

Definition at line 1072 of file ASTMatchersInternal.cpp.

◆ nonTypeTemplateParmDecl

const internal::VariadicDynCastAllOfMatcher< Decl, NonTypeTemplateParmDecl > clang::ast_matchers::nonTypeTemplateParmDecl

Matches non-type template parameter declarations.

Given

template <typename T, int N> struct C {};

nonTypeTemplateParmDecl() matches 'N', but not 'T'.

Definition at line 793 of file ASTMatchersInternal.cpp.

◆ nullStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, NullStmt > clang::ast_matchers::nullStmt

Matches null statements.

foo();;

nullStmt() matches the second ';'

Definition at line 955 of file ASTMatchersInternal.cpp.

◆ objcCatchStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtCatchStmt > clang::ast_matchers::objcCatchStmt

Matches Objective-C @catch statements.

Example matches @catch

@try {}
@catch (...) {}

Definition at line 875 of file ASTMatchersInternal.cpp.

◆ objcCategoryDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCCategoryDecl > clang::ast_matchers::objcCategoryDecl

Matches Objective-C category declarations.

Example matches Foo (Additions)

@interface Foo (Additions)
@end

Definition at line 861 of file ASTMatchersInternal.cpp.

◆ objcCategoryImplDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCCategoryImplDecl > clang::ast_matchers::objcCategoryImplDecl

Matches Objective-C category definitions.

Example matches Foo (Additions)

@implementation Foo (Additions)
@end

Definition at line 863 of file ASTMatchersInternal.cpp.

◆ objcFinallyStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtFinallyStmt > clang::ast_matchers::objcFinallyStmt

Matches Objective-C @finally statements.

Example matches @finally

@try {}
@finally {}

Definition at line 877 of file ASTMatchersInternal.cpp.

◆ objcImplementationDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCImplementationDecl > clang::ast_matchers::objcImplementationDecl

Matches Objective-C implementation declarations.

Example matches Foo

@implementation Foo
@end

Definition at line 857 of file ASTMatchersInternal.cpp.

◆ objcInterfaceDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCInterfaceDecl > clang::ast_matchers::objcInterfaceDecl

Matches Objective-C interface declarations.

Example matches Foo

@interface Foo
@end

Definition at line 855 of file ASTMatchersInternal.cpp.

◆ objcIvarDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCIvarDecl > clang::ast_matchers::objcIvarDecl

Matches Objective-C instance variable declarations.

Example matches _enabled

@implementation Foo {
BOOL _enabled;
}
@end

Definition at line 868 of file ASTMatchersInternal.cpp.

◆ objcIvarRefExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCIvarRefExpr > clang::ast_matchers::objcIvarRefExpr

Matches a reference to an ObjCIvar.

Example: matches "a" in "init" method:

@implementation A {
}
- (void) init {
a = @"hello";
}

Definition at line 930 of file ASTMatchersInternal.cpp.

Referenced by potentiallyWritesIntoIvar().

◆ objcMessageExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCMessageExpr > clang::ast_matchers::objcMessageExpr

Matches ObjectiveC Message invocation expressions.

The innermost message send invokes the "alloc" class method on the NSString class, while the outermost message send invokes the "initWithString" instance method on the object returned from NSString's "alloc". This matcher should match both message sends.

[[NSString alloc] initWithString:@"Hello"]

Definition at line 853 of file ASTMatchersInternal.cpp.

Referenced by getOtherMessageSentM(), and getRunLoopRunM().

◆ objcMethodDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCMethodDecl > clang::ast_matchers::objcMethodDecl

Matches Objective-C method declarations.

Example matches both declaration and definition of -[Foo method]

@interface Foo
- (void)method;
@end
@implementation Foo
- (void)method {}
@end

Definition at line 865 of file ASTMatchersInternal.cpp.

◆ objcObjectPointerType

const AstTypeMatcher<ObjCObjectPointerType> clang::ast_matchers::objcObjectPointerType

Definition at line 1096 of file ASTMatchersInternal.cpp.

◆ objcPropertyDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCPropertyDecl > clang::ast_matchers::objcPropertyDecl

Matches Objective-C property declarations.

Example matches enabled

@interface Foo
@property BOOL enabled;
@end

Definition at line 870 of file ASTMatchersInternal.cpp.

◆ objcProtocolDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ObjCProtocolDecl > clang::ast_matchers::objcProtocolDecl

Matches Objective-C protocol declarations.

Example matches FooDelegate

@protocol FooDelegate
@end

Definition at line 859 of file ASTMatchersInternal.cpp.

◆ objcStringLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCStringLiteral > clang::ast_matchers::objcStringLiteral

Matches ObjectiveC String literal expressions.

Example matches "abcd" @code NSString *s = @"abcd";

Definition at line 960 of file ASTMatchersInternal.cpp.

◆ objcThrowStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtThrowStmt > clang::ast_matchers::objcThrowStmt

Matches Objective-C @throw statements.

Example matches @throw

@throw obj;

Definition at line 872 of file ASTMatchersInternal.cpp.

◆ objcTryStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ObjCAtTryStmt > clang::ast_matchers::objcTryStmt

Matches Objective-C @try statements.

Example matches @try

@try {}
@catch (...) {}

Definition at line 873 of file ASTMatchersInternal.cpp.

◆ ompDefaultClause

const internal::VariadicDynCastAllOfMatcher<OMPClause, OMPDefaultClause> clang::ast_matchers::ompDefaultClause

Definition at line 1128 of file ASTMatchersInternal.cpp.

◆ ompExecutableDirective

const internal::VariadicDynCastAllOfMatcher<Stmt, OMPExecutableDirective> clang::ast_matchers::ompExecutableDirective

Definition at line 1126 of file ASTMatchersInternal.cpp.

◆ opaqueValueExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, OpaqueValueExpr > clang::ast_matchers::opaqueValueExpr

Matches opaque value expressions.

They are used as helpers to reference another expressions and can be met in BinaryConditionalOperators, for example.

Example matches 'a'

(a ?: c) + 42;

Definition at line 1001 of file ASTMatchersInternal.cpp.

◆ optionally

const internal::VariadicOperatorMatcherFunc< 1, 1 > clang::ast_matchers::optionally
Initial value:
= {
internal::DynTypedMatcher::VO_Optionally}

Matches any node regardless of the submatcher.

However, optionally will retain any bindings generated by the submatcher. Useful when additional information which may or may not present about a main matching node is desired.

For example, in:

class Foo {
int bar;
}

The matcher:

fieldDecl(hasName("bar")).bind("var")
))).bind("record")
const internal::VariadicOperatorMatcherFunc< 1, 1 > optionally
Matches any node regardless of the submatcher.

will produce a result binding for both "record" and "var". The matcher will produce a "record" binding for even if there is no data member named "bar" in that class.

Usable as: Any Matcher

Definition at line 1036 of file ASTMatchersInternal.cpp.

◆ parenExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ParenExpr > clang::ast_matchers::parenExpr

Matches parentheses used in expressions.

Example matches (foo() + 1)

int foo() { return 1; }
int a = (foo() + 1);

Definition at line 899 of file ASTMatchersInternal.cpp.

◆ parenListExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, ParenListExpr > clang::ast_matchers::parenListExpr

Matches paren list expressions.

ParenListExprs don't have a predefined type and are used for late parsing. In the final AST, they can be met in template declarations.

Given

template<typename T> class X {
void f() {
X x(*this);
int a = 0, b = 1; int i = (a, b);
}
};

parenListExpr() matches "*this" but NOT matches (a, b) because (a, b) has a predefined type and is a ParenExpr, not a ParenListExpr.

Definition at line 885 of file ASTMatchersInternal.cpp.

◆ parenType

const AstTypeMatcher<ParenType> clang::ast_matchers::parenType

Definition at line 1091 of file ASTMatchersInternal.cpp.

◆ parmVarDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ParmVarDecl > clang::ast_matchers::parmVarDecl

Matches parameter variable declarations.

Given

void f(int x);

parmVarDecl() matches int x.

Definition at line 784 of file ASTMatchersInternal.cpp.

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

◆ pointerType

◆ pointerTypeLoc

const internal::VariadicDynCastAllOfMatcher<TypeLoc, PointerTypeLoc> clang::ast_matchers::pointerTypeLoc

Definition at line 807 of file ASTMatchersInternal.cpp.

◆ predefinedExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, PredefinedExpr > clang::ast_matchers::predefinedExpr

Matches predefined identifier expressions [C99 6.4.2.2].

Example: Matches func

printf("%s", __func__);

Definition at line 1024 of file ASTMatchersInternal.cpp.

◆ qualifiedTypeLoc

const internal::VariadicDynCastAllOfMatcher<TypeLoc, QualifiedTypeLoc> clang::ast_matchers::qualifiedTypeLoc

Definition at line 805 of file ASTMatchersInternal.cpp.

◆ qualType

const internal::VariadicAllOfMatcher< QualType > clang::ast_matchers::qualType

◆ recordDecl

const internal::VariadicDynCastAllOfMatcher< Decl, RecordDecl > clang::ast_matchers::recordDecl

Matches class, struct, and union declarations.

Example matches X, Z, U, and S

class X;
template<class T> class Z {};
struct S {};
union U {};

Definition at line 772 of file ASTMatchersInternal.cpp.

Referenced by classifyPointerDeclarator(), clang::CIRGen::CIRGenTypes::getRecordTypeName(), clang::serialization::DataStreamBasicReader< Impl >::readLValuePathSerializationHelper(), and clang::serialization::DataStreamBasicWriter< Impl >::writeLValuePathSerializationHelper().

◆ recordType

const AstTypeMatcher<RecordType> clang::ast_matchers::recordType

◆ referenceType

const AstTypeMatcher<ReferenceType> clang::ast_matchers::referenceType

◆ referenceTypeLoc

const internal::VariadicDynCastAllOfMatcher<TypeLoc, ReferenceTypeLoc> clang::ast_matchers::referenceTypeLoc

Definition at line 809 of file ASTMatchersInternal.cpp.

◆ requiresExpr

const internal::VariadicDynCastAllOfMatcher< Expr, RequiresExpr > clang::ast_matchers::requiresExpr

Matches concept requirement.

Example matches 'requires(T p) { *p; }'

template<typename T>
concept dereferencable = requires(T p) { *p; }

Definition at line 830 of file ASTMatchersInternal.cpp.

◆ requiresExprBodyDecl

const internal::VariadicDynCastAllOfMatcher< Decl, RequiresExprBodyDecl > clang::ast_matchers::requiresExprBodyDecl

Matches concept requirement body declaration.

Example matches '{ *p; }'

template<typename T>
concept dereferencable = requires(T p) { *p; }

Definition at line 832 of file ASTMatchersInternal.cpp.

◆ returnStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, ReturnStmt > clang::ast_matchers::returnStmt

Matches return statements.

Given

return 1;

returnStmt() matches 'return 1'

Definition at line 941 of file ASTMatchersInternal.cpp.

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

◆ rValueReferenceType

const AstTypeMatcher<RValueReferenceType> clang::ast_matchers::rValueReferenceType

Definition at line 1099 of file ASTMatchersInternal.cpp.

◆ staticAssertDecl

const internal::VariadicDynCastAllOfMatcher< Decl, StaticAssertDecl > clang::ast_matchers::staticAssertDecl

Matches a C++ static_assert declaration.

Example: staticAssertDecl() matches static_assert(sizeof(S) == sizeof(int)) in

struct S {
int x;
};
static_assert(sizeof(S) == sizeof(int));

Definition at line 1003 of file ASTMatchersInternal.cpp.

◆ stmt

◆ stmtExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, StmtExpr > clang::ast_matchers::stmtExpr

Matches statement expression (GNU extension).

Example match: ({ int X = 4; X; })

int C = ({ int X = 4; X; });

Definition at line 988 of file ASTMatchersInternal.cpp.

◆ stringLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, StringLiteral > clang::ast_matchers::stringLiteral

Matches string literals (also matches wide string literals).

Example matches "abcd", L"abcd"

char *s = "abcd";
wchar_t *ws = L"abcd";

Definition at line 959 of file ASTMatchersInternal.cpp.

◆ substNonTypeTemplateParmExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, SubstNonTypeTemplateParmExpr > clang::ast_matchers::substNonTypeTemplateParmExpr

Matches substitutions of non-type template parameters.

Given

template <int N>
struct A { static const int n = N; };
struct B : public A<42> {};

substNonTypeTemplateParmExpr() matches "N" in the right-hand side of "static const int n = N;"

Definition at line 887 of file ASTMatchersInternal.cpp.

◆ substTemplateTypeParmType

const AstTypeMatcher<SubstTemplateTypeParmType> clang::ast_matchers::substTemplateTypeParmType

Definition at line 1107 of file ASTMatchersInternal.cpp.

◆ switchCase

const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchCase > clang::ast_matchers::switchCase

Matches case and default statements inside switch statements.

Given

switch(a) { case 42: break; default: break; }

switchCase() matches 'case 42:' and 'default:'.

Definition at line 946 of file ASTMatchersInternal.cpp.

Referenced by clang::CIRGen::CIRGenFunction::emitSwitchBody().

◆ switchStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, SwitchStmt > clang::ast_matchers::switchStmt

Matches switch statements.

Given

switch(a) { case 42: break; default: break; }

switchStmt() matches 'switch(a)'.

Definition at line 945 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::hasSuspiciousStmt(), and hasUnguardedAccess().

◆ tagDecl

const internal::VariadicDynCastAllOfMatcher< Decl, TagDecl > clang::ast_matchers::tagDecl

Matches tag declarations.

Example matches X, Z, U, S, E

class X;
template<class T> class Z {};
struct S {};
union U {};
enum E {
A, B, C
};

Definition at line 825 of file ASTMatchersInternal.cpp.

◆ tagType

const AstTypeMatcher<TagType> clang::ast_matchers::tagType

◆ templateArgument

const internal::VariadicAllOfMatcher< TemplateArgument > clang::ast_matchers::templateArgument

Matches template arguments.

Given

template <typename T> struct C {};

templateArgument() matches 'int' in C<int>.

Definition at line 789 of file ASTMatchersInternal.cpp.

◆ templateArgumentLoc

const internal::VariadicAllOfMatcher< TemplateArgumentLoc > clang::ast_matchers::templateArgumentLoc

Matches template arguments (with location info).

Given

template <typename T> struct C {};

templateArgumentLoc() matches 'int' in C<int>.

Definition at line 790 of file ASTMatchersInternal.cpp.

◆ templateName

const internal::VariadicAllOfMatcher< TemplateName > clang::ast_matchers::templateName

Matches template name.

Given

template <typename T> class X { };
X<int> xi;

templateName() matches 'X' in X<int>.

Definition at line 791 of file ASTMatchersInternal.cpp.

◆ templateSpecializationType

const AstTypeMatcher<TemplateSpecializationType> clang::ast_matchers::templateSpecializationType

Definition at line 1102 of file ASTMatchersInternal.cpp.

◆ templateSpecializationTypeLoc

const internal::VariadicDynCastAllOfMatcher<TypeLoc, TemplateSpecializationTypeLoc> clang::ast_matchers::templateSpecializationTypeLoc

Definition at line 812 of file ASTMatchersInternal.cpp.

◆ templateTemplateParmDecl

const internal::VariadicDynCastAllOfMatcher< Decl, TemplateTemplateParmDecl > clang::ast_matchers::templateTemplateParmDecl

Matches template template parameter declarations.

Given

template <template <typename> class Z, int N> struct C {};

templateTypeParmDecl() matches 'Z', but not 'N'.

Definition at line 797 of file ASTMatchersInternal.cpp.

◆ templateTypeParmDecl

const internal::VariadicDynCastAllOfMatcher< Decl, TemplateTypeParmDecl > clang::ast_matchers::templateTypeParmDecl

Matches template type parameter declarations.

Given

template <typename T, int N> struct C {};

templateTypeParmDecl() matches 'T', but not 'N'.

Definition at line 795 of file ASTMatchersInternal.cpp.

◆ templateTypeParmType

const AstTypeMatcher<TemplateTypeParmType> clang::ast_matchers::templateTypeParmType

Definition at line 1108 of file ASTMatchersInternal.cpp.

◆ translationUnitDecl

const internal::VariadicDynCastAllOfMatcher< Decl, TranslationUnitDecl > clang::ast_matchers::translationUnitDecl

Matches the top declaration context.

Given

int X;
namespace NS {
int Y;
} // namespace NS

decl(hasDeclContext(translationUnitDecl())) matches "int X", but not "int Y".

Definition at line 753 of file ASTMatchersInternal.cpp.

◆ type

const internal::VariadicAllOfMatcher< Type > clang::ast_matchers::type

Matches Types in the clang AST.

Definition at line 801 of file ASTMatchersInternal.cpp.

Referenced by clang::Sema::ActOnForEachDeclStmt(), clang::Sema::ActOnIdExpression(), clang::SemaObjC::ActOnObjCAtSynchronizedOperand(), clang::SemaObjC::actOnObjCTypeArgsOrProtocolQualifiers(), clang::CIRGen::CallArgList::add(), clang::CodeGen::CallArgList::add(), addBlockLayout(), clang::CIRGen::CIRGenCXXABI::addImplicitConstructorArgs(), clang::Qualifiers::addObjCGCAttr(), clang::Qualifiers::addObjCLifetime(), clang::SemaSwift::AddParameterABIAttr(), clang::InitializationSequence::AddPassByIndirectCopyRestoreStep(), clang::CodeGen::ConstantAggregateBuilderBase::addPlaceholderWithSize(), clang::Sema::AddPushedVisibilityAttribute(), clang::CodeGen::ConstantAggregateBuilderBase::addRelativeOffset(), clang::CodeGen::ConstantAggregateBuilderBase::addRelativeOffsetToPosition(), clang::CodeGen::ConstantAggregateBuilderBase::addTaggedRelativeOffset(), clang::CodeGen::swiftcall::SwiftAggLowering::addTypedData(), clang::CodeGen::swiftcall::SwiftAggLowering::addTypedData(), clang::CodeGen::swiftcall::SwiftAggLowering::addTypedData(), clang::CIRGen::CallArgList::addUncopiedAggregate(), clang::CodeGen::CallArgList::addUncopiedAggregate(), clang::ASTContext::applyObjCProtocolQualifiers(), clang::applyObjCTypeArgs(), breakDownVectorType(), clang::Sema::BuildDeclarationNameExpr(), clang::Sema::BuildMemberReferenceExpr(), clang::SemaObjC::BuildObjCBoxedExpr(), clang::CIRGen::CIRGenCXXABI::buildStructorSignature(), clang::SemaPPC::BuiltinPPCMMACall(), clang::Type::canHaveNullability(), clang::CharacterLiteral::CharacterLiteral(), clang::Sema::CheckCompleteVariableDeclaration(), CheckNonNullArguments(), checkObjCKindOfType(), checkVarTypeForConstantEmission(), clang::CodeGen::swiftcall::classifyArgumentType(), classifyPointerDeclarator(), clang::CodeGen::swiftcall::classifyReturnType(), classifyType(), classifyTypeForARCConversion(), clang::SemaCodeCompletion::CodeCompleteCase(), clang::ento::SValBuilder::conjureSymbol(), clang::ento::SValBuilder::conjureSymbolVal(), clang::ento::SValBuilder::conjureSymbolVal(), clang::ento::SValBuilder::conjureSymbolVal(), clang::CIRGen::CIRGenFunction::convertTempToRValue(), clang::CodeGen::CodeGenFunction::convertTempToRValue(), clang::CIRGen::CIRGenModule::convertType(), clang::CIRGen::CIRGenTypes::convertType(), clang::IntegerLiteral::Create(), clang::OffsetOfExpr::Create(), clang::PseudoObjectExpr::Create(), clang::UnaryOperator::Create(), clang::FixedPointLiteral::CreateFromRawInt(), clang::CIRGen::CIRGenBuilderTy::createVersionedGlobal(), destroyARCStrongWithStore(), diagnoseBadTypeAttribute(), diagnoseScopedEnums(), distributeFunctionTypeAttr(), distributeNullabilityTypeAttr(), distributeObjCPointerTypeAttr(), clang::CodeGen::CodeGenFunction::EmitARCRetain(), clang::CodeGen::CodeGenFunction::EmitARCRetainAutorelease(), emitARCRetainLoadOfScalar(), clang::CodeGen::CodeGenFunction::EmitARCStoreStrong(), emitAutoreleasedReturnValueMarker(), clang::CodeGen::CodeGenFunction::EmitAutoVarInit(), clang::CIRGen::CIRGenFunction::emitAutoVarInit(), clang::CIRGen::CIRGenFunction::emitAutoVarTypeCleanup(), clang::CodeGen::CodeGenFunction::emitAutoVarTypeCleanup(), clang::CIRGen::CIRGenFunction::emitBuiltinExpr(), clang::CodeGen::CodeGenFunction::emitByrefStructureInit(), clang::CodeGen::CodeGenFunction::EmitCallArg(), clang::CIRGen::CIRGenFunction::emitCaseDefaultCascade(), clang::CIRGen::CIRGenFunction::emitCompoundStmt(), clang::CodeGen::CodeGenFunction::EmitCXXAggrConstructorCall(), clang::CIRGen::CIRGenFunction::emitCXXAggrConstructorCall(), clang::CIRGen::CIRGenFunction::emitCXXConstructExpr(), clang::CIRGen::CIRGenFunction::emitCXXConstructorCall(), clang::CIRGen::CIRGenFunction::emitCXXConstructorCall(), emitCXXDestructMethod(), clang::CIRGen::CIRGenFunction::emitCXXDestructorCall(), EmitCXXNewAllocSize(), emitCXXNewAllocSize(), clang::CodeGen::CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(), EmitDeclInit(), clang::CodeGen::CodeGenFunction::EmitDelegateCallArg(), clang::CIRGen::CIRGenFunction::emitDelegateCallArg(), clang::CIRGen::CIRGenFunction::emitDestroy(), clang::CodeGen::CodeGenFunction::emitDestroy(), clang::CIRGen::CIRGenCXXABI::emitDestructorCall(), clang::CodeGen::CodeGenFunction::EmitExprAsInit(), clang::CIRGen::CIRGenFunction::emitExprAsInit(), clang::CodeGen::CodeGenFunction::EmitExtVectorElementExpr(), clang::CodeGen::CodeGenFunction::EmitObjCConsumeObject(), clang::CodeGen::CodeGenFunction::EmitObjCExtendObjectLifetime(), emitPartialArrayDestroy(), clang::CIRGen::CIRGenFunction::emitVAArg(), clang::CodeGen::CodeGenFunction::EmitVariablyModifiedType(), clang::CIRGen::CIRGenFunction::emitVariablyModifiedType(), clang::CodeGen::CodeGenFunction::EnterDtorCleanups(), clang::ento::SValBuilder::evalBinOp(), clang::ento::SValBuilder::evalUnaryOp(), clang::CodeGen::ConstantAggregateBuilderBase::fillPlaceholderWithInt(), clang::Expr::findBoundMemberType(), clang::CodeGen::ConstantAggregateBuilderBase::finishArray(), clang::FixedPointLiteral::FixedPointLiteral(), clang::Sema::FixOverloadedFunctionReference(), clang::CodeGen::CodeGenFunction::generateDestroyHelper(), clang::CodeGen::ConstantAggregateBuilderBase::getAddrOfCurrentPosition(), clang::CodeGen::ConstantAggregateBuilderBase::getAddrOfPosition(), getArrayDepth(), clang::ASTContext::getAttributedType(), clang::ASTContext::getBaseElementType(), clang::Type::getBaseElementTypeUnsafe(), getBaseMessageSendResultType(), clang::CIRGen::CIRGenModule::getBuiltinLibFunction(), clang::CodeGen::swiftcall::SwiftAggLowering::getCoerceAndExpandTypes(), clang::CIRGen::CIRGenBuilderTy::getCompleteNamedRecordType(), getComplexType(), getComplexType(), clang::ento::SValBuilder::getConjuredHeapSymbolVal(), clang::CIRGen::CIRGenBuilderTy::getConstRecordOrZeroAttr(), clang::CIRGen::CIRGenFunction::getEvaluationKind(), clang::CodeGen::CodeGenFunction::getEvaluationKind(), clang::CIRGen::CIRGenCXXABI::getImplicitConstructorArgs(), getImpliedARCOwnership(), clang::ASTContext::getLifetimeQualifiedType(), clang::CodeGen::CodeGenModule::getMemberPointerConstant(), clang::ento::SValBuilder::getMetadataSymbolVal(), clang::CodeGen::swiftcall::getNaturalAlignment(), getNonMemoryType(), getNullForVariable(), clang::ASTContext::getObjCEncodingTypeSize(), clang::ASTContext::getObjCObjectType(), clang::Type::getPointeeOrArrayElementType(), getStorage(), getTypeAllocSize(), getTypeStoreSize(), clang::ASTContext::getUnqualifiedArrayType(), clang::ASTContext::getUnqualifiedObjCPointerType(), clang::ASTContext::getVariableArrayDecayedType(), clang::CodeGen::CodeGenFunction::getVLAElements1D(), clang::CodeGen::CodeGenFunction::getVLASize(), clang::CodeGen::CodeGenFunction::getVLASize(), clang::SemaObjC::handleBlocksAttr(), handleFunctionTypeAttr(), handleObjCGCTypeAttr(), handleObjCOwnershipTypeAttr(), handleObjCPointerTypeAttr(), handleVisibilityAttr(), clang::CIRGen::CIRGenFunction::hasAggregateEvaluationKind(), clang::CIRGen::CIRGenFunction::hasScalarEvaluationKind(), hasWeakMember(), inferARCLifetimeForPointee(), clang::SemaObjC::inferObjCARCLifetime(), clang::IntegerLiteral::IntegerLiteral(), isConstantEmittableObjectType(), isFullSizeType(), clang::CIRGen::CIRGenTypes::isFuncParamTypeConvertible(), isInAllocaArgument(), clang::tooling::isKnownPointerLikeType(), isMergeableEntryType(), isNonNullType(), clang::Type::isObjCLifetimeType(), clang::CodeGen::CodeGenModule::isPaddedAtomicType(), clang::CodeGen::CodeGenModule::isPaddedAtomicType(), isPlaceholderToRemoveAsArg(), clang::isPtrOfType(), isSafeForCXXConstantCapture(), isTriviallyCopyableTypeImpl(), clang::SemaObjC::LookupMethodInObjectType(), clang::CodeGen::LValue::MakeAddr(), clang::CodeGen::LValue::MakeBitfield(), clang::ento::SValBuilder::makeCompoundVal(), clang::CodeGen::LValue::MakeExtVectorElt(), clang::sema::DelayedDiagnostic::makeForbiddenType(), clang::CodeGen::LValue::MakeGlobalReg(), clang::ento::SValBuilder::makeIntVal(), clang::CodeGen::LValue::MakeMatrixElt(), clang::ento::SValBuilder::makeNonLoc(), clang::ento::SValBuilder::makeNonLoc(), clang::ento::SValBuilder::makeNonLoc(), clang::ento::SValBuilder::makeNonLoc(), clang::ento::SValBuilder::makeNullWithType(), clang::ento::SValBuilder::makeTruthVal(), clang::CodeGen::LValue::MakeVectorElt(), clang::ento::SValBuilder::makeZeroVal(), mergeTypeNullabilityForRedecl(), clang::ObjCIndirectCopyRestoreExpr::ObjCIndirectCopyRestoreExpr(), clang::CodeGen::SwiftABIInfo::occupiesMoreThan(), clang::SemaObjC::PrepareCastToObjCObjectPointer(), processTypeAttrs(), clang::CIRGen::CIRGenFunction::pushDestroy(), clang::CodeGen::CodeGenFunction::pushDestroy(), clang::CodeGen::CodeGenFunction::pushDestroy(), clang::CodeGen::CodeGenFunction::pushDestroyAndDeferDeactivation(), clang::CodeGen::CodeGenFunction::pushDestroyAndDeferDeactivation(), clang::CodeGen::CodeGenFunction::pushEHDestroy(), clang::CodeGen::CodeGenFunction::pushLifetimeExtendedDestroy(), clang::CodeGen::CodeGenFunction::pushLifetimeExtendedDestroy(), PushPragmaVisibility(), clang::Qualifiers::setObjCGCAttr(), clang::Qualifiers::setObjCLifetime(), clang::api_notes::VariableInfo::setType(), clang::ento::SValBuilder::simplifySVal(), clang::QualifierCollector::strip(), tryCaptureAsConstant(), tryEmitARCRetainLoadOfScalar(), tryEmitARCRetainLoadOfScalar(), and clang::UnaryOperator::UnaryOperator().

◆ typeAliasDecl

const internal::VariadicDynCastAllOfMatcher< Decl, TypeAliasDecl > clang::ast_matchers::typeAliasDecl

Matches type alias declarations.

Given

typedef int X;
using Y = int;

typeAliasDecl() matches "using Y = int", but not "typedef int X"

Definition at line 757 of file ASTMatchersInternal.cpp.

◆ typeAliasTemplateDecl

const internal::VariadicDynCastAllOfMatcher< Decl, TypeAliasTemplateDecl > clang::ast_matchers::typeAliasTemplateDecl

Matches type alias template declarations.

typeAliasTemplateDecl() matches

template <typename T>
using Y = X<T>;

Definition at line 761 of file ASTMatchersInternal.cpp.

◆ typedefDecl

const internal::VariadicDynCastAllOfMatcher< Decl, TypedefDecl > clang::ast_matchers::typedefDecl

Matches typedef declarations.

Given

typedef int X;
using Y = int;

typedefDecl() matches "typedef int X", but not "using Y = int"

Definition at line 754 of file ASTMatchersInternal.cpp.

Referenced by CheckNullabilityTypeSpecifier().

◆ typedefNameDecl

const internal::VariadicDynCastAllOfMatcher< Decl, TypedefNameDecl > clang::ast_matchers::typedefNameDecl

Matches typedef name declarations.

Given

typedef int X;
using Y = int;

typedefNameDecl() matches "typedef int X" and "using Y = int"

Definition at line 756 of file ASTMatchersInternal.cpp.

Referenced by clang::CIRGen::CIRGenTypes::getRecordTypeName().

◆ typedefType

const AstTypeMatcher<TypedefType> clang::ast_matchers::typedefType

◆ typeLoc

const internal::VariadicAllOfMatcher< TypeLoc > clang::ast_matchers::typeLoc

Matches TypeLocs in the clang AST.

Definition at line 802 of file ASTMatchersInternal.cpp.

Referenced by clang::ExprMutationAnalyzer::isUnevaluated().

◆ unaryExprOrTypeTraitExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryExprOrTypeTraitExpr > clang::ast_matchers::unaryExprOrTypeTraitExpr

Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)

Given

Foo x = bar;
int y = sizeof(x) + alignof(x);

unaryExprOrTypeTraitExpr() matches sizeof(x) and alignof(x)

Definition at line 815 of file ASTMatchersInternal.cpp.

Referenced by alignOfExpr(), clang::ExprMutationAnalyzer::isUnevaluated(), and sizeOfExpr().

◆ unaryOperator

const internal::VariadicDynCastAllOfMatcher< Stmt, UnaryOperator > clang::ast_matchers::unaryOperator

Matches unary operator expressions.

Example matches !a

!a || b

Definition at line 995 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::changeIntBoundNode(), clang::ento::forLoopMatcher(), and clang::ento::getAddrTo().

◆ unaryTransformType

const AstTypeMatcher<UnaryTransformType> clang::ast_matchers::unaryTransformType

Definition at line 1103 of file ASTMatchersInternal.cpp.

◆ unless

const internal::VariadicOperatorMatcherFunc< 1, 1 > clang::ast_matchers::unless
Initial value:
= {
internal::DynTypedMatcher::VO_UnaryNot}

Matches if the provided matcher does not match.

Example matches Y (matcher = cxxRecordDecl(unless(hasName("X"))))

class X {};
class Y {};

Usable as: Any Matcher

Definition at line 1068 of file ASTMatchersInternal.cpp.

Referenced by AST_POLYMORPHIC_MATCHER_P2(), clang::ento::callByRef(), checkTempObjectsInNoPool(), clang::ento::forLoopMatcher(), getOtherMessageSentM(), and clang::ExprMutationAnalyzer::isUnevaluated().

◆ unresolvedLookupExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, UnresolvedLookupExpr > clang::ast_matchers::unresolvedLookupExpr

Matches reference to a name that can be looked up during parsing but could not be resolved to a specific declaration.

Given

template<typename T>
T foo() { T a; return a; }
template<typename T>
void bar() {
foo<T>();
}

unresolvedLookupExpr() matches

foo<T>()

Definition at line 893 of file ASTMatchersInternal.cpp.

◆ unresolvedMemberExpr

const internal::VariadicDynCastAllOfMatcher< Stmt, UnresolvedMemberExpr > clang::ast_matchers::unresolvedMemberExpr

Matches unresolved member expressions.

Given

struct X {
template <class T> void f();
void g();
};
template <class T> void h() { X x; x.f<T>(); x.g(); }

unresolvedMemberExpr() matches x.f<T>

Definition at line 845 of file ASTMatchersInternal.cpp.

◆ unresolvedUsingTypenameDecl

const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingTypenameDecl > clang::ast_matchers::unresolvedUsingTypenameDecl

Matches unresolved using value declarations that involve the typename.

Given

template <typename T>
struct Base { typedef T Foo; };
template<typename T>
struct S : private Base<T> {
using typename Base<T>::Foo;
};

unresolvedUsingTypenameDecl() matches

using Base<T>::Foo

Definition at line 897 of file ASTMatchersInternal.cpp.

◆ unresolvedUsingValueDecl

const internal::VariadicDynCastAllOfMatcher< Decl, UnresolvedUsingValueDecl > clang::ast_matchers::unresolvedUsingValueDecl

Matches unresolved using value declarations.

Given

template<typename X>
class C : private X {
using X::x;
};

unresolvedUsingValueDecl() matches

using X::x

Definition at line 895 of file ASTMatchersInternal.cpp.

◆ userDefinedLiteral

const internal::VariadicDynCastAllOfMatcher< Stmt, UserDefinedLiteral > clang::ast_matchers::userDefinedLiteral

Matches user defined literal operator call.

Example match: "foo"_suffix

Definition at line 970 of file ASTMatchersInternal.cpp.

◆ usingDecl

const internal::VariadicDynCastAllOfMatcher< Decl, UsingDecl > clang::ast_matchers::usingDecl

Matches using declarations.

Given

namespace X { int x; }
using X::x;

usingDecl() matches

using X::x

Definition at line 888 of file ASTMatchersInternal.cpp.

◆ usingDirectiveDecl

const internal::VariadicDynCastAllOfMatcher< Decl, UsingDirectiveDecl > clang::ast_matchers::usingDirectiveDecl

Matches using namespace declarations.

Given

namespace X { int x; }
using namespace X;

usingDirectiveDecl() matches

using namespace X

Definition at line 891 of file ASTMatchersInternal.cpp.

◆ usingEnumDecl

const internal::VariadicDynCastAllOfMatcher< Decl, UsingEnumDecl > clang::ast_matchers::usingEnumDecl

Matches using-enum declarations.

Given

namespace X { enum x {...}; }
using enum X::x;

usingEnumDecl() matches

using enum X::x

Definition at line 889 of file ASTMatchersInternal.cpp.

◆ usingShadowDecl

const internal::VariadicDynCastAllOfMatcher< Decl, UsingShadowDecl > clang::ast_matchers::usingShadowDecl

Matches shadow declarations introduced into a scope by a (resolved) using declaration.

Given

namespace n { int f; }
namespace declToImport { using n::f; }

usingShadowDecl() matches

f

Definition at line 759 of file ASTMatchersInternal.cpp.

◆ usingType

const AstTypeMatcher<UsingType> clang::ast_matchers::usingType

Definition at line 1106 of file ASTMatchersInternal.cpp.

◆ valueDecl

const internal::VariadicDynCastAllOfMatcher< Decl, ValueDecl > clang::ast_matchers::valueDecl

Matches any value declaration.

Example matches A, B, C and F

enum X { A, B, C };
void F();

Definition at line 817 of file ASTMatchersInternal.cpp.

Referenced by clang::serialization::DataStreamBasicWriter< Impl >::writeLValuePathSerializationHelper().

◆ varDecl

const internal::VariadicDynCastAllOfMatcher< Decl, VarDecl > clang::ast_matchers::varDecl

Matches variable declarations.

Note: this does not match declarations of member variables, which are "field" declarations in Clang parlance.

Example matches a

int a;

Definition at line 833 of file ASTMatchersInternal.cpp.

Referenced by clang::ento::assignedToRef(), clang::ento::callByRef(), clang::ento::changeIntBoundNode(), clang::ento::forLoopMatcher(), clang::ento::getWidenedLoopState(), clang::ento::ExprEngine::ProcessAutomaticObjDtor(), and clang::ento::simpleCondition().

◆ variableArrayType

const AstTypeMatcher<VariableArrayType> clang::ast_matchers::variableArrayType

◆ whileStmt

const internal::VariadicDynCastAllOfMatcher< Stmt, WhileStmt > clang::ast_matchers::whileStmt

Matches while statements.

Given

while (true) {}

whileStmt() matches 'while (true) {}'.

Definition at line 936 of file ASTMatchersInternal.cpp.