diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index 9b30057b5257f..5b2a96d00d592 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -1028,6 +1028,15 @@
Matches concept requirement body declaration.
+
+Example matches '{ *p; }'
+ template<typename T>
+ concept dereferencable = requires(T p) { *p; }
+Matches a C++ static_assert declaration. @@ -1190,6 +1199,17 @@Node Matchers
matches using enum X::x
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 Matches any value declaration. @@ -1210,6 +1230,15 @@Node Matchers
Matches concept requirement.
+
+Example matches 'requires(T p) { *p; }'
+ template<typename T>
+ concept dereferencable = requires(T p) { *p; }
+Matches lambda captures. @@ -1679,6 +1708,19 @@Node Matchers
Matches any named cast expression.
+
+Example: Matches all four of the casts in
+ struct S { virtual void f(); };
+ S* p = nullptr;
+ S* ptr1 = static_cast<S*>(p);
+ S* ptr2 = reinterpret_cast<S*>(p);
+ S* ptr3 = dynamic_cast<S*>(p);
+ S* ptr4 = const_cast<S*>(p);
+Matches new expressions. @@ -2168,7 +2210,7 @@Node Matchers
Matches any ``#pragma omp`` executable directive. Given @@ -2393,17 +2435,6 @@Node Matchers
Matches C or C++ elaborated `TypeLoc`s.
-
-Given
- struct s {};
- struct s ss;
-elaboratedTypeLoc()
- matches the `TypeLoc` of the variable declaration of `ss`.
-Matches pointer `TypeLoc`s. @@ -2474,7 +2505,7 @@Node Matchers
Matches types nodes representing C++11 auto types. Given: @@ -2544,7 +2575,7 @@Node Matchers
Matches types nodes representing C++11 decltype(<expr>) types. Given: @@ -2556,7 +2587,7 @@Node Matchers
Matches C++17 deduced template specialization types, e.g. deduced class template types. @@ -2570,7 +2601,7 @@Node Matchers
Matches a dependent name type Example matches T::type @@ -2607,38 +2638,7 @@Node Matchers
Matches a dependent template specialization type
-
-Example matches A<T>::template B<T>
- template<typename T> struct A;
- template<typename T> struct declToImport {
- typename A<T>::template B<T> a;
- };
-Matches types specified with an elaborated type keyword or with a
-qualified name.
-
-Given
- namespace N {
- namespace M {
- class D {};
- }
- }
- class C {};
-
- class C c;
- N::M::D d;
-
-elaboratedType() matches the type of the variable declarations of both
-c and d.
-Matches enum types. Given @@ -2688,7 +2688,7 @@Node Matchers
Matches injected class name types. Example matches S s, but not S<T> s. @@ -2800,7 +2800,7 @@Node Matchers
Matches record types (e.g. structs, classes). Given @@ -2831,7 +2831,7 @@Node Matchers
Matches types that represent the result of substituting a type for a template type parameter. @@ -2845,7 +2845,7 @@Node Matchers
Matches tag types (record and enum types). Given @@ -2860,7 +2860,7 @@Node Matchers
Matches template specialization types. Given @@ -2875,7 +2875,7 @@Node Matchers
Matches template type parameter types. Example matches T, but not int. @@ -2899,7 +2899,7 @@Node Matchers
Matches types nodes representing unary type transformations. Given: @@ -3077,8 +3077,8 @@Narrowing Matchers
- Matcher<CXXBaseSpecifier> isPrivate Matches private C++ declarations and C++ base specifers that specify private -inheritance. +Matches private C++ declarations and C++ base specifiers that specify +private inheritance. Examples: class C { @@ -3094,7 +3094,7 @@Narrowing Matchers
- Matcher<CXXBaseSpecifier> isProtected Matches protected C++ declarations and C++ base specifers that specify + Matches protected C++ declarations and C++ base specifiers that specify protected inheritance. Examples: @@ -3110,7 +3110,7 @@Narrowing Matchers
- Matcher<CXXBaseSpecifier> isPublic Matches public C++ declarations and C++ base specifers that specify public + Matches public C++ declarations and C++ base specifiers that specify public inheritance. Examples: @@ -3127,7 +3127,7 @@Narrowing Matchers
- Matcher<CXXBaseSpecifier> isVirtual Matches declarations of virtual methods and C++ base specifers that specify + Matches declarations of virtual methods and C++ base specifiers that specify virtual inheritance. Example: @@ -3709,7 +3709,7 @@Narrowing Matchers
- Matcher<CXXMethodDecl> isVirtual Matches declarations of virtual methods and C++ base specifers that specify ++ Matches declarations of virtual methods and C++ base specifiers that specify virtual inheritance. Example: @@ -4161,6 +4161,12 @@Narrowing Matchers
+ Matcher<Decl> declaresSameEntityAsBoundNode std::string ID + + Matches a declaration if it declares the same entity as the node previously +bound to ID. +Matcher<Decl> equalsBoundNode std::string ID Matches if a node equals a previously bound node. @@ -4322,8 +4328,8 @@Narrowing Matchers
- Matcher<Decl> isPrivate Matches private C++ declarations and C++ base specifers that specify private -inheritance. +Matches private C++ declarations and C++ base specifiers that specify +private inheritance. Examples: class C { @@ -4339,7 +4345,7 @@Narrowing Matchers
- Matcher<Decl> isProtected Matches protected C++ declarations and C++ base specifers that specify + Matches protected C++ declarations and C++ base specifiers that specify protected inheritance. Examples: @@ -4355,7 +4361,7 @@Narrowing Matchers
- Matcher<Decl> isPublic Matches public C++ declarations and C++ base specifers that specify public +- Matches public C++ declarations and C++ base specifiers that specify public inheritance. Examples: @@ -4371,7 +4377,7 @@Narrowing Matchers
+ Matcher<DependentNameType> hasDependentName std::string N Matcher<DependentNameType> hasDependentName std::string N - Matches the dependent name of a DependentScopeDeclRefExpr or DependentNameType @@ -5046,7 +5052,7 @@Narrowing Matchers
int z; Example matches f() because it has external formal linkage despite being -unique to the translation unit as though it has internal likage +unique to the translation unit as though it has internal linkage (matcher = functionDecl(hasExternalFormalLinkage())) namespace { @@ -5182,7 +5188,7 @@Narrowing Matchers
+ Matcher<OMPExecutableDirective> isAllowedToContainClauseKind OpenMPClauseKind CKind Matcher<OMPExecutableDirective> isAllowedToContainClauseKind OpenMPClauseKind CKind - Matches if the OpenMP directive is allowed to contain the specified OpenMP clause kind. @@ -5192,7 +5198,7 @@Narrowing Matchers
#pragma omp parallel for #pragma omp for -`ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches +``ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches ``omp parallel`` and ``omp parallel for``. If the matcher is use from clang-query, ``OpenMPClauseKind`` parameter @@ -5201,7 +5207,7 @@Narrowing Matchers
+ Matcher<OMPExecutableDirective> isStandaloneDirective Matcher<OMPExecutableDirective> isStandaloneDirective @@ -5781,7 +5787,7 @@ Matches standalone OpenMP directives, i.e., directives that can't have a structured block. @@ -5545,10 +5551,10 @@Narrowing Matchers
Given void a(int); - void b(long); + void b(unsigned long); void c(double); functionDecl(hasAnyParameter(hasType(isInteger()))) -matches "a(int)", "b(long)", but not "c(double)". +matches "a(int)", "b(unsigned long)", but not "c(double)".Narrowing Matchers
- Matches a TemplateArgument of integral type with a given value. Note that 'Value' is a string as the template argument's value is -an arbitrary precision integer. 'Value' must be euqal to the canonical +an arbitrary precision integer. 'Value' must be equal to the canonical representation of that integral value in base 10. Given @@ -5806,7 +5812,7 @@Narrowing Matchers
+ Matcher<TemplateSpecializationType> templateArgumentCountIs unsigned N Matcher<TemplateSpecializationType> templateArgumentCountIs unsigned N Matches if the number of template arguments equals N. Given @@ -6571,8 +6577,8 @@AST Traversal Matchers
- Matcher<AbstractConditionalOperator> hasCondition Matcher<Expr> InnerMatcher - Matches the condition expression of an if statement, for loop, -switch statement or conditional operator. +- Matches the condition expression of an if statement, for loop, while loop, +do-while loop, switch statement or conditional operator. Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) if (true) {} @@ -6600,8 +6606,8 @@AST Traversal Matchers
- Matcher<AddrLabelExpr> hasDeclaration Matcher<Decl> InnerMatcher - Matches a node if the declaration associated with that node ++ Matcher<AddrLabelExpr> hasDeclaration Matcher<Decl> InnerMatcher @@ -6701,7 +6707,7 @@ Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -6626,11 +6632,11 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>AST Traversal Matchers
+ Matcher<AutoType> hasDeducedType Matcher<Type> Matcher<AutoType> hasDeducedType Matcher<Type> @@ -7026,8 +7032,8 @@ Matches AutoType nodes where the deduced type is a specific type. Note: There is no TypeLoc for the deduced type and thus no @@ -6713,7 +6719,7 @@AST Traversal Matchers
autoType(hasDeducedType(isInteger())) matches "auto a" -Usable as: Matcher<AutoType> +Usable as: Matcher<AutoType>AST Traversal Matchers
- Matcher<CXXConstructExpr> hasDeclaration Matcher<Decl> InnerMatcher - Matches a node if the declaration associated with that node ++ Matcher<CXXConstructExpr> hasDeclaration Matcher<Decl> InnerMatcher @@ -7489,8 +7495,8 @@ Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -7052,11 +7058,11 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>AST Traversal Matchers
- Matcher<CXXNewExpr> hasDeclaration Matcher<Decl> InnerMatcher - Matches a node if the declaration associated with that node ++ Matcher<CXXNewExpr> hasDeclaration Matcher<Decl> InnerMatcher @@ -7952,8 +7958,8 @@ Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -7515,11 +7521,11 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>AST Traversal Matchers
- Matcher<CallExpr> hasDeclaration Matcher<Decl> InnerMatcher Matches a node if the declaration associated with that node ++ Matcher<CallExpr> hasDeclaration Matcher<Decl> InnerMatcher @@ -8204,7 +8210,7 @@ Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -7978,11 +7984,11 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>AST Traversal Matchers
- Matcher<DecayedType> hasDecayedType Matcher<QualType> InnerType - Matches the decayed type, whoes decayed type matches InnerMatcher +@@ -8223,8 +8229,8 @@ Matches the decayed type, whose decayed type matches InnerMatcherAST Traversal Matchers
- Matcher<DeclRefExpr> hasDeclaration Matcher<Decl> InnerMatcher - Matches a node if the declaration associated with that node ++ Matcher<DeclRefExpr> hasDeclaration Matcher<Decl> InnerMatcher @@ -8373,24 +8379,11 @@ Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -8249,11 +8255,11 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>AST Traversal Matchers
} } -cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the +cxxRecordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the declaration of class D.- Matcher<DecltypeType> hasUnderlyingType Matcher<Type> - - Matches DecltypeType or UsingType nodes to find the underlying type. - -Given - decltype(1) a = 1; - decltype(2.0) b = 2.0; -decltypeType(hasUnderlyingType(isInteger())) - matches the type of "a" - -Usable as: Matcher<DecltypeType>, Matcher<UsingType> -Matcher<DecompositionDecl> hasAnyBinding Matcher<BindingDecl> InnerMatcher Matches any binding of a DecompositionDecl. @@ -8451,66 +8444,16 @@AST Traversal Matchers
- Matcher<DoStmt> hasCondition Matcher<Expr> InnerMatcher Matches the condition expression of an if statement, for loop, -switch statement or conditional operator. +- Matches the condition expression of an if statement, for loop, while loop, +do-while loop, switch statement or conditional operator. Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) if (true) {}- Matcher<ElaboratedTypeLoc> hasNamedTypeLoc Matcher<TypeLoc> InnerMatcher - - - Matches elaborated `TypeLoc`s that have a named `TypeLoc` matching -`InnerMatcher`. - -Given - template <typename T> - class C {}; - class C<int> c; - - class D {}; - class D d; -elaboratedTypeLoc(hasNamedTypeLoc(templateSpecializationTypeLoc())); - matches the `TypeLoc` of the variable declaration of `c`, but not `d`. -- Matcher<ElaboratedType> hasQualifier Matcher<NestedNameSpecifier> InnerMatcher - - - Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, -matches InnerMatcher if the qualifier exists. - -Given - namespace N { - namespace M { - class D {}; - } - } - N::M::D d; - -elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) -matches the type of the variable declaration of d. -- Matcher<ElaboratedType> namesType Matcher<QualType> InnerMatcher - - - Matches ElaboratedTypes whose named type matches InnerMatcher. - -Given - namespace N { - namespace M { - class D {}; - } - } - N::M::D d; - -elaboratedType(namesType(recordType( -hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable -declaration of d. -- Matcher<EnumType> hasDeclaration Matcher<Decl> InnerMatcher Matches a node if the declaration associated with that node ++ Matcher<EnumType> hasDeclaration Matcher<Decl> InnerMatcher @@ -8788,14 +8731,26 @@ Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -8535,11 +8478,11 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>AST Traversal Matchers
- Matcher<ForStmt> hasCondition Matcher<Expr> InnerMatcher Matches the condition expression of an if statement, for loop, -switch statement or conditional operator. ++ Matches the condition expression of an if statement, for loop, while loop, +do-while loop, switch statement or conditional operator. Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) if (true) {}+ Matcher<ForStmt> hasConditionVariableStatement Matcher<DeclStmt> InnerMatcher + + Matches the condition variable statement in an if statement, for loop, +while loop or switch statement. + +Given + if (A* a = GetAPointer()) {} + for (; A* a = GetAPointer(); ) {} +hasConditionVariableStatement(...) + matches both 'A* a = GetAPointer()'. +Matcher<ForStmt> hasIncrement Matcher<Stmt> InnerMatcher Matches the increment statement of a for loop. @@ -9099,8 +9054,8 @@AST Traversal Matchers
- Matcher<IfStmt> hasCondition Matcher<Expr> InnerMatcher Matches the condition expression of an if statement, for loop, -switch statement or conditional operator. +Matches the condition expression of an if statement, for loop, while loop, +do-while loop, switch statement or conditional operator. Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) if (true) {} @@ -9108,12 +9063,14 @@AST Traversal Matchers
- Matcher<IfStmt> hasConditionVariableStatement Matcher<DeclStmt> InnerMatcher - Matches the condition variable statement in an if statement. +@@ -9179,8 +9136,8 @@ Matches the condition variable statement in an if statement, for loop, +while loop or switch statement. Given if (A* a = GetAPointer()) {} + for (; A* a = GetAPointer(); ) {} hasConditionVariableStatement(...) - matches 'A* a = GetAPointer()'. + matches both 'A* a = GetAPointer()'.AST Traversal Matchers
- Matcher<InjectedClassNameType> hasDeclaration Matcher<Decl> InnerMatcher Matches a node if the declaration associated with that node ++ Matcher<InjectedClassNameType> hasDeclaration Matcher<Decl> InnerMatcher - Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -9205,16 +9162,16 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>- Matcher<LabelStmt> hasDeclaration Matcher<Decl> InnerMatcher - Matches a node if the declaration associated with that node ++ Matcher<LabelStmt> hasDeclaration Matcher<Decl> InnerMatcher @@ -9293,8 +9250,8 @@ Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -9239,11 +9196,11 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>AST Traversal Matchers
- Matcher<MemberExpr> hasDeclaration Matcher<Decl> InnerMatcher - Matches a node if the declaration associated with that node ++ Matcher<MemberExpr> hasDeclaration Matcher<Decl> InnerMatcher @@ -9456,7 +9413,7 @@ Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -9319,11 +9276,11 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>AST Traversal Matchers
+ Matcher<OMPExecutableDirective> hasAnyClause Matcher<OMPClause> InnerMatcher Matcher<OMPExecutableDirective> hasAnyClause Matcher<OMPClause> InnerMatcher - Matches any clause in an OpenMP directive. Given @@ -9469,7 +9426,7 @@AST Traversal Matchers
+ Matcher<OMPExecutableDirective> hasStructuredBlock Matcher<Stmt> InnerMatcher Matcher<OMPExecutableDirective> hasStructuredBlock Matcher<Stmt> InnerMatcher - Matches the structured-block of the OpenMP executable directive Prerequisite: the executable directive must not be standalone directive. @@ -9826,8 +9783,8 @@AST Traversal Matchers
- Matcher<QualType> hasDeclaration Matcher<Decl> InnerMatcher - Matches a node if the declaration associated with that node ++ Matcher<QualType> hasDeclaration Matcher<Decl> InnerMatcher @@ -9920,8 +9877,8 @@ Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -9852,11 +9809,11 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>AST Traversal Matchers
- Matcher<RecordType> hasDeclaration Matcher<Decl> InnerMatcher - Matches a node if the declaration associated with that node ++ Matcher<RecordType> hasDeclaration Matcher<Decl> InnerMatcher @@ -10066,7 +10023,7 @@ Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -9946,11 +9903,11 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>AST Traversal Matchers
+ Matcher<SubstTemplateTypeParmType> hasReplacementType Matcher<Type> Matcher<SubstTemplateTypeParmType> hasReplacementType Matcher<Type> Matches template type parameter substitutions that have a replacement type that matches the provided matcher. @@ -10094,14 +10051,26 @@AST Traversal Matchers
- Matcher<SwitchStmt> hasCondition Matcher<Expr> InnerMatcher Matches the condition expression of an if statement, for loop, -switch statement or conditional operator. ++ Matches the condition expression of an if statement, for loop, while loop, +do-while loop, switch statement or conditional operator. Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) if (true) {}+ Matcher<SwitchStmt> hasConditionVariableStatement Matcher<DeclStmt> InnerMatcher + + Matches the condition variable statement in an if statement, for loop, +while loop or switch statement. + +Given + if (A* a = GetAPointer()) {} + for (; A* a = GetAPointer(); ) {} +hasConditionVariableStatement(...) + matches both 'A* a = GetAPointer()'. +Matcher<SwitchStmt> hasInitStatement Matcher<Stmt> InnerMatcher - Matches selection statements with initializer. @@ -10125,8 +10094,8 @@AST Traversal Matchers
- Matcher<TagType> hasDeclaration Matcher<Decl> InnerMatcher - Matches a node if the declaration associated with that node ++ Matcher<TagType> hasDeclaration Matcher<Decl> InnerMatcher @@ -10284,7 +10253,7 @@ Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -10151,11 +10120,11 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>AST Traversal Matchers
+ Matcher<TemplateSpecializationType> forEachTemplateArgument Matcher<TemplateArgument> InnerMatcher Matcher<TemplateSpecializationType> forEachTemplateArgument Matcher<TemplateArgument> InnerMatcher - Matches templateSpecializationType, class template specialization, variable template specialization, and function template specialization nodes where the template argument matches the inner matcher. This matcher @@ -10310,7 +10279,7 @@AST Traversal Matchers
+ Matcher<TemplateSpecializationType> hasAnyTemplateArgument Matcher<TemplateArgument> InnerMatcher Matcher<TemplateSpecializationType> hasAnyTemplateArgument 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. @@ -10332,8 +10301,8 @@AST Traversal Matchers
- Matcher<TemplateSpecializationType> hasDeclaration Matcher<Decl> InnerMatcher Matches a node if the declaration associated with that node ++ Matcher<TemplateSpecializationType> hasDeclaration Matcher<Decl> InnerMatcher - Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -10358,15 +10327,15 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>+ Matcher<TemplateSpecializationType> hasTemplateArgument unsigned N, Matcher<TemplateArgument> InnerMatcher Matcher<TemplateSpecializationType> hasTemplateArgument unsigned N, Matcher<TemplateArgument> InnerMatcher - Matches templateSpecializationType, class template specializations, variable template specializations, and function template specializations where the n'th TemplateArgument matches the given InnerMatcher. @@ -10387,8 +10356,8 @@AST Traversal Matchers
- Matcher<TemplateTypeParmType> hasDeclaration Matcher<Decl> InnerMatcher - Matches a node if the declaration associated with that node ++ Matcher<TemplateTypeParmType> hasDeclaration Matcher<Decl> InnerMatcher @@ -10473,8 +10442,8 @@ Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -10413,11 +10382,11 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>AST Traversal Matchers
- Matcher<TypedefType> hasDeclaration Matcher<Decl> InnerMatcher - Matches a node if the declaration associated with that node ++ Matcher<TypedefType> hasDeclaration Matcher<Decl> InnerMatcher + + + Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -10499,11 +10468,41 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType> ++ Matcher<Type> hasQualifier Matcher<NestedNameSpecifier> InnerMatcher + + + Matches Types whose qualifier, a NestedNameSpecifier, +matches InnerMatcher if the qualifier exists. + +Given + namespace N { + namespace M { + class D {}; + } + } + N::M::D d; + +elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) +matches the type of the variable declaration of d. ++ Matcher<Type> hasUnderlyingType Matcher<QualType> Inner @@ -10556,8 +10555,8 @@ Matches QualType nodes to find the underlying type. + +Given + decltype(1) a = 1; + decltype(2.0) b = 2.0; +decltypeType(hasUnderlyingType(isInteger())) + matches the type of "a" + +Usable as: Matcher<QualType>AST Traversal Matchers
- Matcher<UnresolvedUsingType> hasDeclaration Matcher<Decl> InnerMatcher - Matches a node if the declaration associated with that node ++ Matcher<UnresolvedUsingType> hasDeclaration Matcher<Decl> InnerMatcher @@ -10602,16 +10601,37 @@ Matches a node if the declaration associated with that node matches the given matcher. The associated declaration is: @@ -10582,11 +10581,11 @@AST Traversal Matchers
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<EnumType>, Matcher<InjectedClassNameType>, Matcher<LabelStmt>, + Matcher<MemberExpr>, Matcher<QualType>, Matcher<RecordType>, + Matcher<TagType>, Matcher<TemplateSpecializationType>, + Matcher<TemplateTypeParmType>, Matcher<TypedefType>, + Matcher<UnresolvedUsingType>, Matcher<UsingType>AST Traversal Matchers
matches using X::b but not using X::a- Matcher<UsingType> hasUnderlyingType Matcher<Type> Matches DecltypeType or UsingType nodes to find the underlying type. ++ Matcher<UsingType> hasDeclaration Matcher<Decl> InnerMatcher @@ -10832,13 +10852,25 @@ Matches a node if the declaration associated with that node +matches the given matcher. -Given - decltype(1) a = 1; - decltype(2.0) b = 2.0; -decltypeType(hasUnderlyingType(isInteger())) - matches the type of "a" +The associated declaration is: +- for type nodes, the declaration of the underlying type +- for CallExpr, the declaration of the callee +- for MemberExpr, the declaration of the referenced member +- for CXXConstructExpr, the declaration of the constructor +- for CXXNewExpr, the declaration of the operator new +- for ObjCIvarExpr, the declaration of the ivar + +For type nodes, hasDeclaration will generally match the declaration of the +sugared type. Given + class X {}; + typedef X Y; + Y y; +in varDecl(hasType(hasDeclaration(decl()))) the decl will match the +typedefDecl. A common use case is to match the underlying, desugared type. +This can be achieved by using the hasUnqualifiedDesugaredType matcher: + varDecl(hasType(hasUnqualifiedDesugaredType( + recordType(hasDeclaration(decl()))))) +In this matcher, the decl will match the CXXRecordDecl of class X. -Usable as: Matcher<DecltypeType>, Matcher<UsingType> +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>AST Traversal Matchers
- Matcher<WhileStmt> hasCondition Matcher<Expr> InnerMatcher Matches the condition expression of an if statement, for loop, -switch statement or conditional operator. ++ + Matches the condition expression of an if statement, for loop, while loop, +do-while loop, switch statement or conditional operator. Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) if (true) {}+ Matcher<WhileStmt> hasConditionVariableStatement Matcher<DeclStmt> InnerMatcher + Matches the condition variable statement in an if statement, for loop, +while loop or switch statement. + +Given + if (A* a = GetAPointer()) {} + for (; A* a = GetAPointer(); ) {} +hasConditionVariableStatement(...) + matches both 'A* a = GetAPointer()'. +