Given
switch(a) { case 42: break; default: break; }
caseStmt()
- matches 'case 42: break;'.
+ matches 'case 42:'.
</pre></td></tr>
<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('compoundStmt0')"><a name="compoundStmt0Anchor">compoundStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>>...</td></tr>
<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements.
-Example matches '{}' and '{{}}'in 'for (;;) {{}}'
+Example matches '{}' and '{{}}' in 'for (;;) {{}}'
for (;;) {{}}
</pre></td></tr>
Given
switch(a) { case 42: break; default: break; }
defaultStmt()
- matches 'default: break;'.
+ matches 'default:'.
</pre></td></tr>
materializeTemporaryExpr() matches 'f()' in these statements
T u(f());
g(f());
+ f().func();
but does not match
f();
- f().func();
</pre></td></tr>
Given
switch(a) { case 42: break; default: break; }
switchCase()
- matches 'case 42: break;' and 'default: break;'.
+ matches 'case 42:' and 'default:'.
</pre></td></tr>
void j(int i);
void k(int x, int y, int z, ...);
functionDecl(parameterCountIs(2))
- matches void g(int i, int j) {}
+ matches g and h
functionProtoType(parameterCountIs(2))
- matches void h(int i, int j)
+ matches g and h
functionProtoType(parameterCountIs(3))
- matches void k(int x, int y, int z, ...);
+ matches k
</pre></td></tr>
void j(int i);
void k(int x, int y, int z, ...);
functionDecl(parameterCountIs(2))
- matches void g(int i, int j) {}
+ matches g and h
functionProtoType(parameterCountIs(2))
- matches void h(int i, int j)
+ matches g and h
functionProtoType(parameterCountIs(3))
- matches void k(int x, int y, int z, ...);
+ matches k
</pre></td></tr>
representation of that integral value in base 10.
Given
- template<int T> struct A {};
+ template<int T> struct C {};
C<42> c;
classTemplateSpecializationDecl(
hasAnyTemplateArgument(equalsIntegralValue("42")))
<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value.
Given
- template<int T> struct A {};
+ template<int T> struct C {};
C<42> c;
classTemplateSpecializationDecl(
hasAnyTemplateArgument(isIntegral()))
<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
provided matcher.
-Example matches X, A, B, C
+Example matches X, A, A::X, B, B::C, B::C::X
(matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))
- class X {}; Matches X, because X::X is a class of name X inside X.
- class A { class 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.
<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the
provided matcher.
-Example matches X, Y
+Example matches X, Y, Y::X, Z::Y, Z::Y::X
(matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
- class X {}; Matches X, because X::X is a class of name X inside X.
- class Y { class 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.
Example matches y.x()
(matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))))))
class Y { public: void x(); };
- void z() { Y y; y.x(); }",
+ void z() { Y y; y.x(); }
FIXME: Overload to allow directly matching types?
</pre></td></tr>
A<bool, int> b;
A<int, bool> c;
- template<typename T> f() {};
+ template<typename T> void f() {}
void func() { f<int>(); };
classTemplateSpecializationDecl(hasTemplateArgument(
1, refersToType(asString("int"))))
A<bool, int> b;
A<int, bool> c;
- template<typename T> f() {};
+ template<typename T> void f() {}
void func() { f<int>(); };
classTemplateSpecializationDecl(hasTemplateArgument(
1, refersToType(asString("int"))))
<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression.
Given
- template<typename T> struct A {};
- struct B { B* next; };
+ struct B { int next; };
+ template<int(B::*next_ptr)> struct A {};
A<&B::next> a;
templateSpecializationType(hasAnyTemplateArgument(
isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next"))))))))
declaration.
Given
- template<typename T> struct A {};
- struct B { B* next; };
+ struct B { int next; };
+ template<int(B::*next_ptr)> struct A {};
A<&B::next> a;
classTemplateSpecializationDecl(hasAnyTemplateArgument(
- refersToDeclaration(fieldDecl(hasName("next"))))
+ refersToDeclaration(fieldDecl(hasName("next")))))
matches the specialization A<&B::next> with fieldDecl(...) matching
B::next
</pre></td></tr>
<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type.
Given
- template<int T> struct A {};
+ template<int T> struct C {};
C<42> c;
classTemplateSpecializationDecl(
hasAnyTemplateArgument(refersToIntegralType(asString("int"))))
A<bool, int> b;
A<int, bool> c;
- template<typename T> f() {};
+ template<typename T> void f() {}
void func() { f<int>(); };
classTemplateSpecializationDecl(hasTemplateArgument(
1, refersToType(asString("int"))))
/// A<bool, int> b;
/// A<int, bool> c;
///
-/// template<typename T> f() {};
+/// template<typename T> void f() {}
/// void func() { f<int>(); };
/// \endcode
/// classTemplateSpecializationDecl(hasTemplateArgument(
///
/// Given
/// \code
-/// template<typename T> struct A {};
-/// struct B { B* next; };
+/// struct B { int next; };
+/// template<int(B::*next_ptr)> struct A {};
/// A<&B::next> a;
/// \endcode
/// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"))))
+/// refersToDeclaration(fieldDecl(hasName("next")))))
/// matches the specialization \c A<&B::next> with \c fieldDecl(...) matching
/// \c B::next
AST_MATCHER_P(TemplateArgument, refersToDeclaration,
///
/// Given
/// \code
-/// template<typename T> struct A {};
-/// struct B { B* next; };
+/// struct B { int next; };
+/// template<int(B::*next_ptr)> struct A {};
/// A<&B::next> a;
/// \endcode
/// templateSpecializationType(hasAnyTemplateArgument(
///
/// Given
/// \code
-/// template<int T> struct A {};
+/// template<int T> struct C {};
/// C<42> c;
/// \endcode
/// classTemplateSpecializationDecl(
///
/// Given
/// \code
-/// template<int T> struct A {};
+/// template<int T> struct C {};
/// C<42> c;
/// \endcode
/// classTemplateSpecializationDecl(
///
/// Given
/// \code
-/// template<int T> struct A {};
+/// template<int T> struct C {};
/// C<42> c;
/// \endcode
/// classTemplateSpecializationDecl(
/// \code
/// T u(f());
/// g(f());
+/// f().func();
/// \endcode
/// but does not match
/// \code
/// f();
-/// f().func();
/// \endcode
extern const internal::VariadicDynCastAllOfMatcher<Stmt,
MaterializeTemporaryExpr>
/// switch(a) { case 42: break; default: break; }
/// \endcode
/// switchCase()
-/// matches 'case 42: break;' and 'default: break;'.
+/// matches 'case 42:' and 'default:'.
extern const internal::VariadicDynCastAllOfMatcher<Stmt, SwitchCase> switchCase;
/// \brief Matches case statements inside switch statements.
/// switch(a) { case 42: break; default: break; }
/// \endcode
/// caseStmt()
-/// matches 'case 42: break;'.
+/// matches 'case 42:'.
extern const internal::VariadicDynCastAllOfMatcher<Stmt, CaseStmt> caseStmt;
/// \brief Matches default statements inside switch statements.
/// switch(a) { case 42: break; default: break; }
/// \endcode
/// defaultStmt()
-/// matches 'default: break;'.
+/// matches 'default:'.
extern const internal::VariadicDynCastAllOfMatcher<Stmt, DefaultStmt>
defaultStmt;
/// \brief Matches compound statements.
///
-/// Example matches '{}' and '{{}}'in 'for (;;) {{}}'
+/// Example matches '{}' and '{{}}' in 'for (;;) {{}}'
/// \code
/// for (;;) {{}}
/// \endcode
/// \brief Matches AST nodes that have child AST nodes that match the
/// provided matcher.
///
-/// Example matches X, Y
+/// Example matches X, Y, Y::X, Z::Y, Z::Y::X
/// (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
/// \code
-/// class X {}; // Matches X, because X::X is a class of name X inside X.
-/// class Y { class 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.
/// \endcode
///
/// \brief Matches AST nodes that have descendant AST nodes that match the
/// provided matcher.
///
-/// Example matches X, A, B, C
+/// Example matches X, A, A::X, B, B::C, B::C::X
/// (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))
/// \code
-/// class X {}; // Matches X, because X::X is a class of name X inside X.
-/// class A { class 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 {}; }; };
/// \endcode
///
/// (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))))))
/// \code
/// class Y { public: void x(); };
-/// void z() { Y y; y.x(); }",
+/// void z() { Y y; y.x(); }
/// \endcode
///
/// FIXME: Overload to allow directly matching types?
/// void k(int x, int y, int z, ...);
/// \endcode
/// functionDecl(parameterCountIs(2))
-/// matches void g(int i, int j) {}
+/// matches \c g and \c h
/// functionProtoType(parameterCountIs(2))
-/// matches void h(int i, int j)
+/// matches \c g and \c h
/// functionProtoType(parameterCountIs(3))
-/// matches void k(int x, int y, int z, ...);
+/// matches \c k
AST_POLYMORPHIC_MATCHER_P(parameterCountIs,
AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
FunctionProtoType),