Index: docs/LibASTMatchersReference.html =================================================================== --- docs/LibASTMatchersReference.html +++ docs/LibASTMatchersReference.html @@ -700,7 +700,7 @@ Given switch(a) { case 42: break; default: break; } caseStmt() - matches 'case 42: break;'. + matches 'case 42:'. @@ -741,7 +741,7 @@
Matches compound statements. -Example matches '{}' and '{{}}'in 'for (;;) {{}}' +Example matches '{}' and '{{}}' in 'for (;;) {{}}' for (;;) {{}}
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())) @@ -3973,10 +3973,11 @@ 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. @@ -3999,10 +4000,11 @@@@ -4795,7 +4797,7 @@ 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")))) @@ -5312,7 +5314,7 @@ 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")))) @@ -6000,8 +6002,8 @@ 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. @@ -4479,7 +4481,7 @@ 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?@@ -6029,7 +6031,7 @@ 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")))))))) @@ -6015,11 +6017,11 @@ 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 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")))) @@ -6127,7 +6129,7 @@ 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")))) Index: include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -800,7 +800,7 @@ /// Ab; /// A c; /// -/// template f() {}; +/// template void f() {} /// void func() { f (); }; /// \endcode /// classTemplateSpecializationDecl(hasTemplateArgument( @@ -880,12 +880,12 @@ /// /// Given /// \code -/// template struct A {}; -/// struct B { B* next; }; +/// struct B { int next; }; +/// template 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, @@ -899,8 +899,8 @@ /// /// Given /// \code -/// template struct A {}; -/// struct B { B* next; }; +/// struct B { int next; }; +/// template struct A {}; /// A<&B::next> a; /// \endcode /// templateSpecializationType(hasAnyTemplateArgument( @@ -917,7 +917,7 @@ /// /// Given /// \code -/// template struct A {}; +/// template struct C {}; /// C<42> c; /// \endcode /// classTemplateSpecializationDecl( @@ -932,7 +932,7 @@ /// /// Given /// \code -/// template struct A {}; +/// template struct C {}; /// C<42> c; /// \endcode /// classTemplateSpecializationDecl( @@ -953,7 +953,7 @@ /// /// Given /// \code -/// template struct A {}; +/// template struct C {}; /// C<42> c; /// \endcode /// classTemplateSpecializationDecl( @@ -1523,11 +1523,11 @@ /// \code /// T u(f()); /// g(f()); +/// f().func(); /// \endcode /// but does not match /// \code /// f(); -/// f().func(); /// \endcode extern const internal::VariadicDynCastAllOfMatcher @@ -1799,7 +1799,7 @@ /// 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 switchCase; /// \brief Matches case statements inside switch statements. @@ -1809,7 +1809,7 @@ /// switch(a) { case 42: break; default: break; } /// \endcode /// caseStmt() -/// matches 'case 42: break;'. +/// matches 'case 42:'. extern const internal::VariadicDynCastAllOfMatcher caseStmt; /// \brief Matches default statements inside switch statements. @@ -1819,13 +1819,13 @@ /// switch(a) { case 42: break; default: break; } /// \endcode /// defaultStmt() -/// matches 'default: break;'. +/// matches 'default:'. extern const internal::VariadicDynCastAllOfMatcher defaultStmt; /// \brief Matches compound statements. /// -/// Example matches '{}' and '{{}}'in 'for (;;) {{}}' +/// Example matches '{}' and '{{}}' in 'for (;;) {{}}' /// \code /// for (;;) {{}} /// \endcode @@ -2502,11 +2502,12 @@ /// \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 /// @@ -2522,11 +2523,12 @@ /// \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 /// @@ -2681,7 +2683,7 @@ /// (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? @@ -3555,11 +3557,11 @@ /// 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),