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 specifiers that specify +private inheritance. Examples: class C { @@ -3094,7 +3094,7 @@Narrowing Matchers
- Matcher<CXXBaseSpecifier> isProtected Narrowing Matchers
- Matcher<CXXBaseSpecifier> isPublic Narrowing Matchers
- Matcher<CXXBaseSpecifier> isVirtual Narrowing Matchers
- Matcher<CXXMethodDecl> isVirtual + Narrowing Matchers
+ Matcher<Decl> declaresSameEntityAsBoundNode std::string ID + + Matcher<Decl> equalsBoundNode std::string ID Narrowing Matchers
- Matcher<Decl> isPrivate Matches private C++ declarations and C++ base specifiers that specify +private inheritance. Examples: class C { @@ -4339,7 +4345,7 @@Narrowing Matchers
- Matcher<Decl> isProtected Narrowing Matchers
- Matcher<Decl> isPublic - Narrowing Matchers
+ Matcher<DependentNameType> hasDependentName std::string N Matcher<DependentNameType> hasDependentName std::string N - 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 - 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 @@ 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
- Narrowing Matchers
+ Matcher<TemplateSpecializationType> templateArgumentCountIs unsigned N Matcher<TemplateSpecializationType> templateArgumentCountIs unsigned N AST Traversal Matchers
- Matcher<AbstractConditionalOperator> hasCondition Matcher<Expr> InnerMatcher - - 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 - + Matcher<AddrLabelExpr> hasDeclaration Matcher<Decl> InnerMatcher @@ -6701,7 +6707,7 @@ 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 @@ 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 - + Matcher<CXXConstructExpr> hasDeclaration Matcher<Decl> InnerMatcher @@ -7489,8 +7495,8 @@ 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 - + Matcher<CXXNewExpr> hasDeclaration Matcher<Decl> InnerMatcher @@ -7952,8 +7958,8 @@ 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 + Matcher<CallExpr> hasDeclaration Matcher<Decl> InnerMatcher @@ -8204,7 +8210,7 @@ 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 - @@ -8223,8 +8229,8 @@ AST Traversal Matchers
- Matcher<DeclRefExpr> hasDeclaration Matcher<Decl> InnerMatcher - + Matcher<DeclRefExpr> hasDeclaration Matcher<Decl> InnerMatcher @@ -8373,24 +8379,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> - - Matcher<DecompositionDecl> hasAnyBinding Matcher<BindingDecl> InnerMatcher AST Traversal Matchers
- Matcher<DoStmt> hasCondition Matcher<Expr> InnerMatcher - 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 + Matcher<EnumType> hasDeclaration Matcher<Decl> InnerMatcher @@ -8788,14 +8731,26 @@ 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, 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 AST Traversal Matchers
- Matcher<IfStmt> hasCondition Matcher<Expr> InnerMatcher 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 - @@ -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 + Matcher<InjectedClassNameType> hasDeclaration Matcher<Decl> InnerMatcher - 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 - + Matcher<LabelStmt> hasDeclaration Matcher<Decl> InnerMatcher @@ -9293,8 +9250,8 @@ 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 - + Matcher<MemberExpr> hasDeclaration Matcher<Decl> InnerMatcher @@ -9456,7 +9413,7 @@ 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 - AST Traversal Matchers
+ Matcher<OMPExecutableDirective> hasStructuredBlock Matcher<Stmt> InnerMatcher Matcher<OMPExecutableDirective> hasStructuredBlock Matcher<Stmt> InnerMatcher - AST Traversal Matchers
- Matcher<QualType> hasDeclaration Matcher<Decl> InnerMatcher - + Matcher<QualType> hasDeclaration Matcher<Decl> InnerMatcher @@ -9920,8 +9877,8 @@ 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 - + Matcher<RecordType> hasDeclaration Matcher<Decl> InnerMatcher @@ -10066,7 +10023,7 @@ 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> AST Traversal Matchers
- Matcher<SwitchStmt> hasCondition Matcher<Expr> InnerMatcher + 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 - AST Traversal Matchers
- Matcher<TagType> hasDeclaration Matcher<Decl> InnerMatcher - + Matcher<TagType> hasDeclaration Matcher<Decl> InnerMatcher @@ -10284,7 +10253,7 @@ 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 - AST Traversal Matchers
+ Matcher<TemplateSpecializationType> hasAnyTemplateArgument Matcher<TemplateArgument> InnerMatcher Matcher<TemplateSpecializationType> hasAnyTemplateArgument Matcher<TemplateArgument> InnerMatcher - AST Traversal Matchers
- Matcher<TemplateSpecializationType> hasDeclaration Matcher<Decl> InnerMatcher + Matcher<TemplateSpecializationType> hasDeclaration Matcher<Decl> InnerMatcher - 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 - AST Traversal Matchers
- Matcher<TemplateTypeParmType> hasDeclaration Matcher<Decl> InnerMatcher - + Matcher<TemplateTypeParmType> hasDeclaration Matcher<Decl> InnerMatcher @@ -10473,8 +10442,8 @@ 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 - + Matcher<TypedefType> hasDeclaration Matcher<Decl> InnerMatcher + + + 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 @@ AST Traversal Matchers
- Matcher<UnresolvedUsingType> hasDeclaration Matcher<Decl> InnerMatcher - + Matcher<UnresolvedUsingType> hasDeclaration Matcher<Decl> InnerMatcher @@ -10602,16 +10601,37 @@ 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> + 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, 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()'. +