[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-22 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC323157: [ASTMatchers] [NFC] Fix code examples (authored by 
MaskRay, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42213?vs=130922=130965#toc

Repository:
  rC Clang

https://reviews.llvm.org/D42213

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h

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 @@
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Stmt.html;>StmtcompoundStmtMatcherhttp://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html;>CompoundStmt...
 Matches compound statements.
 
-Example matches '{}' and '{{}}'in 'for (;;) {{}}'
+Example matches '{}' and '{{}}' in 'for (;;) {{}}'
   for (;;) {{}}
 
 
@@ -1028,7 +1028,7 @@
 Given
   switch(a) { case 42: break; default: break; }
 defaultStmt()
-  matches 'default: break;'.
+  matches 'default:'.
 
 
 
@@ -1197,9 +1197,9 @@
 materializeTemporaryExpr() matches 'f()' in these statements
   T u(f());
   g(f());
+  f().func();
 but does not match
   f();
-  f().func();
 
 
 
@@ -1369,7 +1369,7 @@
 Given
   switch(a) { case 42: break; default: break; }
 switchCase()
-  matches 'case 42: break;' and 'default: break;'.
+  matches 'case 42:' and 'default:'.
 
 
 
@@ -2940,11 +2940,11 @@
   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
 
 
 
@@ -2990,11 +2990,11 @@
   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
 
 
 
@@ -3534,7 +3534,7 @@
 representation of that integral value in base 10.
 
 Given
-  templateint T struct A {};
+  templateint T struct C {};
   C42 c;
 classTemplateSpecializationDecl(
   hasAnyTemplateArgument(equalsIntegralValue("42")))
@@ -3546,7 +3546,7 @@
 Matches a TemplateArgument that is an integral value.
 
 Given
-  templateint T struct A {};
+  templateint T struct C {};
   C42 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 @@
 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?
 
@@ -4795,7 +4797,7 @@
   Abool, int b;
   Aint, bool c;
 
-  templatetypename T f() {};
+  templatetypename T void f() {}
   void func() { fint(); };
 classTemplateSpecializationDecl(hasTemplateArgument(
 1, refersToType(asString("int"
@@ -5312,7 +5314,7 @@
   Abool, int b;
   Aint, bool c;
 
-  templatetypename T f() {};
+  templatetypename T void f() {}
   void func() { fint(); };
 classTemplateSpecializationDecl(hasTemplateArgument(
 1, refersToType(asString("int"
@@ -6000,8 +6002,8 @@
 Matches a sugar TemplateArgument that refers to a certain expression.
 
 Given
-  templatetypename T struct A {};
-  struct B { B* next; };
+  struct B { int next; };
+  templateint(B::*next_ptr) struct A {};
   AB::next a;
 templateSpecializationType(hasAnyTemplateArgument(
   

[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you! Do you need me to commit on your behalf?


Repository:
  rC Clang

https://reviews.llvm.org/D42213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 130922.
MaskRay added a comment.

Regenerate HTML docs

$ cd docs/tools # yes, cd
$ ./dump_ast_matchers.py


Repository:
  rC Clang

https://reviews.llvm.org/D42213

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h

Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -800,7 +800,7 @@
 ///   A b;
 ///   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<::next> a;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"
+/// refersToDeclaration(fieldDecl(hasName("next")
 ///   matches the specialization \c A<::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<::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,12 +1523,12 @@
 /// \code
 ///   T u(f());
 ///   g(f());
-/// \endcode
-/// but does not match
-/// \code
-///   f();
 ///   f().func();
 /// \endcode
+/// but does not match
+/// \code
+///   f();
+/// \endcode
 extern const internal::VariadicDynCastAllOfMatcher
 materializeTemporaryExpr;
@@ -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(); 

[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Great, all that remains is for you to regenerate the documentation file and 
upload that with the next patch.


Repository:
  rC Clang

https://reviews.llvm.org/D42213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 130711.
MaskRay added a comment.

functionProtoType


Repository:
  rC Clang

https://reviews.llvm.org/D42213

Files:
  include/clang/ASTMatchers/ASTMatchers.h

Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -800,7 +800,7 @@
 ///   A b;
 ///   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<::next> a;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"
+/// refersToDeclaration(fieldDecl(hasName("next")
 ///   matches the specialization \c A<::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<::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,12 +1523,12 @@
 /// \code
 ///   T u(f());
 ///   g(f());
-/// \endcode
-/// but does not match
-/// \code
-///   f();
 ///   f().func();
 /// \endcode
+/// but does not match
+/// \code
+///   f();
+/// \endcode
 extern const internal::VariadicDynCastAllOfMatcher
 materializeTemporaryExpr;
@@ -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 

[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D42213#982385, @MaskRay wrote:

> Yes, I was asking about this because the results seemed to be wrong. I should 
> have used `parameterCountIs()` to reduce the confusion :) I'll leave them 
> untouched.


Alternatively, you can try out those declarations and the given matchers in 
clang-query to see if the results match what's listed, and update the comments 
based on what you find. Either way is fine.


Repository:
  rC Clang

https://reviews.llvm.org/D42213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In https://reviews.llvm.org/D42213#982261, @aaron.ballman wrote:

> In https://reviews.llvm.org/D42213#982256, @MaskRay wrote:
>
> > I am also not sure about this function:  line 3548
> >
> >   /// \brief Matches \c FunctionDecls and \c FunctionProtoTypes that have a
> >   /// specific parameter count.
> >   ///
> >   /// Given
> >   /// \code
> >   ///   void f(int i) {}
> >   ///   void g(int i, int j) {}
> >   ///   void h(int i, int j);
> >   ///   void j(int i);
> >   ///   void k(int x, int y, int z, ...);
> >   /// \endcode
> >   /// functionDecl(parameterCountIs(2))
> >   ///   matches void g(int i, int j) {}
> >   /// functionProtoType(parameterCountIs(2))
> >   ///   matches void h(int i, int j)
> >   /// functionProtoType(parameterCountIs(3))
> >   ///   matches void k(int x, int y, int z, ...);
> >   AST_POLYMORPHIC_MATCHER_P(parameterCountIs,
> > AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
> > 
> > FunctionProtoType),
> >   }
> >
> >
> > Both `functionDecl` and `functionProtoType` match these functions as long 
> > as the parameter count is matched.
> >
> >   % echo 'match functionDecl()'|clang-query =(printf 'void f(){}') -- -xc++
> >   % echo 'match functionProtoType()'|clang-query =(printf 'void f(){}') -- 
> > -xc++
> >
>
>
> I'm not certain I'm following along. The quoted matcher is for 
> `parameterCountIs()`, but the test code you've posted doesn't use that 
> matcher. However, the quoted comment seems like it's wrong: 
> `functionDecl(parameterCountIs(2))` should match both g() and h(), not just 
> g(), I believe.


Yes, I was asking about this because the results seemed to be wrong. I should 
have used `parameterCountIs()` to reduce the confusion :) I'll leave them 
untouched.


Repository:
  rC Clang

https://reviews.llvm.org/D42213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D42213#982256, @MaskRay wrote:

> I am also not sure about this function:  line 3548
>
>   /// \brief Matches \c FunctionDecls and \c FunctionProtoTypes that have a
>   /// specific parameter count.
>   ///
>   /// Given
>   /// \code
>   ///   void f(int i) {}
>   ///   void g(int i, int j) {}
>   ///   void h(int i, int j);
>   ///   void j(int i);
>   ///   void k(int x, int y, int z, ...);
>   /// \endcode
>   /// functionDecl(parameterCountIs(2))
>   ///   matches void g(int i, int j) {}
>   /// functionProtoType(parameterCountIs(2))
>   ///   matches void h(int i, int j)
>   /// functionProtoType(parameterCountIs(3))
>   ///   matches void k(int x, int y, int z, ...);
>   AST_POLYMORPHIC_MATCHER_P(parameterCountIs,
> AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
> 
> FunctionProtoType),
>   }
>
>
> Both `functionDecl` and `functionProtoType` match these functions as long as 
> the parameter count is matched.
>
>   % echo 'match functionDecl()'|clang-query =(printf 'void f(){}') -- -xc++
>   % echo 'match functionProtoType()'|clang-query =(printf 'void f(){}') -- 
> -xc++
>


I'm not certain I'm following along. The quoted matcher is for 
`parameterCountIs()`, but the test code you've posted doesn't use that matcher. 
However, the quoted comment seems like it's wrong: 
`functionDecl(parameterCountIs(2))` should match both g() and h(), not just 
g(), I believe.


Repository:
  rC Clang

https://reviews.llvm.org/D42213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I am also not sure about this function:  line 3548

  /// \brief Matches \c FunctionDecls and \c FunctionProtoTypes that have a
  /// specific parameter count.
  ///
  /// Given
  /// \code
  ///   void f(int i) {}
  ///   void g(int i, int j) {}
  ///   void h(int i, int j);
  ///   void j(int i);
  ///   void k(int x, int y, int z, ...);
  /// \endcode
  /// functionDecl(parameterCountIs(2))
  ///   matches void g(int i, int j) {}
  /// functionProtoType(parameterCountIs(2))
  ///   matches void h(int i, int j)
  /// functionProtoType(parameterCountIs(3))
  ///   matches void k(int x, int y, int z, ...);
  AST_POLYMORPHIC_MATCHER_P(parameterCountIs,
AST_POLYMORPHIC_SUPPORTED_TYPES(FunctionDecl,
FunctionProtoType),
  }

Both `functionDecl` and `functionProtoType` match these functions as long as 
the parameter count is matched.

  % echo 'match functionDecl()'|clang-query =(printf 'void f(){}') -- -xc++
  % echo 'match functionProtoType()'|clang-query =(printf 'void f(){}') -- -xc++


Repository:
  rC Clang

https://reviews.llvm.org/D42213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 130672.
MaskRay added a comment.

Address comment


Repository:
  rC Clang

https://reviews.llvm.org/D42213

Files:
  include/clang/ASTMatchers/ASTMatchers.h

Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -800,7 +800,7 @@
 ///   A b;
 ///   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<::next> a;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"
+/// refersToDeclaration(fieldDecl(hasName("next")
 ///   matches the specialization \c A<::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<::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,12 +1523,12 @@
 /// \code
 ///   T u(f());
 ///   g(f());
-/// \endcode
-/// but does not match
-/// \code
-///   f();
 ///   f().func();
 /// \endcode
+/// but does not match
+/// \code
+///   f();
+/// \endcode
 extern const internal::VariadicDynCastAllOfMatcher
 materializeTemporaryExpr;
@@ -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 

[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D42213#982047, @MaskRay wrote:

> In https://reviews.llvm.org/D42213#981700, @aaron.ballman wrote:
>
> > The documentation needs to be regenerated for this patch. One thing that 
> > seems to be inconsistent is with the "what gets matched" messages is that 
> > sometimes it includes extra adornments like curly braces and other times it 
> > does not. It might be good to pick a style and try to be more consistent 
> > with it.
>
>
> Do I need to do anything to re-generate the doc and check it into this 
> revision? If so, can you show me the Doxygen generation instruction?


Yes, the documentation for this is something that has to be generated manually. 
You should just have to execute clang/docs/tools/dump_ast_matchers.py to 
regenerate the documentation.

> Reverted some changes as they may cause confusion which are pointed by you.

Thanks! I found one more minor nit with some example code, but this basically 
looks good aside from the documentation bit.




Comment at: include/clang/ASTMatchers/ASTMatchers.h:803
 ///
-///   template f() {};
+///   template void f() {};
 ///   void func() { f(); };

Spurious semi-colon in the declaration.


Repository:
  rC Clang

https://reviews.llvm.org/D42213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In https://reviews.llvm.org/D42213#981700, @aaron.ballman wrote:

> The documentation needs to be regenerated for this patch. One thing that 
> seems to be inconsistent is with the "what gets matched" messages is that 
> sometimes it includes extra adornments like curly braces and other times it 
> does not. It might be good to pick a style and try to be more consistent with 
> it.


Do I need to do anything to re-generate the doc and check it into this 
revision? If so, can you show me the Doxygen generation instruction?

Reverted some changes as they may cause confusion which are pointed by you.


Repository:
  rC Clang

https://reviews.llvm.org/D42213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 130644.
MaskRay added a comment.

Revert some changes to address comments


Repository:
  rC Clang

https://reviews.llvm.org/D42213

Files:
  include/clang/ASTMatchers/ASTMatchers.h

Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -800,7 +800,7 @@
 ///   A b;
 ///   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<::next> a;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"
+/// refersToDeclaration(fieldDecl(hasName("next")
 ///   matches the specialization \c A<::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<::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,12 +1523,12 @@
 /// \code
 ///   T u(f());
 ///   g(f());
-/// \endcode
-/// but does not match
-/// \code
-///   f();
 ///   f().func();
 /// \endcode
+/// but does not match
+/// \code
+///   f();
+/// \endcode
 extern const internal::VariadicDynCastAllOfMatcher
 materializeTemporaryExpr;
@@ -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: 

[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

The documentation needs to be regenerated for this patch. One thing that seems 
to be inconsistent is with the "what gets matched" messages is that sometimes 
it includes extra adornments like curly braces and other times it does not. It 
might be good to pick a style and try to be more consistent with it.




Comment at: include/clang/ASTMatchers/ASTMatchers.h:1792
 /// switchStmt()
-///   matches 'switch(a)'.
+///   matches 'switch(a) {'.
 extern const internal::VariadicDynCastAllOfMatcher 
switchStmt;

I don't think this adds clarity.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:1841
 /// cxxCatchStmt()
-///   matches 'catch(int i)'
+///   matches 'catch(int i) {}'
 extern const internal::VariadicDynCastAllOfMatcher

I don't think this adds clarity.



Comment at: include/clang/ASTMatchers/ASTMatchers.h:1851
 /// cxxTryStmt()
-///   matches 'try {}'
+///   matches 'try {} catch(int i) {}'
 extern const internal::VariadicDynCastAllOfMatcher 
cxxTryStmt;

I think this adds confusion.


Repository:
  rC Clang

https://reviews.llvm.org/D42213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 130493.
MaskRay added a comment.

More


Repository:
  rC Clang

https://reviews.llvm.org/D42213

Files:
  include/clang/ASTMatchers/ASTMatchers.h

Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -800,7 +800,7 @@
 ///   A b;
 ///   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<::next> a;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"
+/// refersToDeclaration(fieldDecl(hasName("next")
 ///   matches the specialization \c A<::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<::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,12 +1523,12 @@
 /// \code
 ///   T u(f());
 ///   g(f());
-/// \endcode
-/// but does not match
-/// \code
-///   f();
 ///   f().func();
 /// \endcode
+/// but does not match
+/// \code
+///   f();
+/// \endcode
 extern const internal::VariadicDynCastAllOfMatcher
 materializeTemporaryExpr;
@@ -1789,7 +1789,7 @@
 ///   switch(a) { case 42: break; default: break; }
 /// \endcode
 /// switchStmt()
-///   matches 'switch(a)'.
+///   matches 'switch(a) {'.
 extern const internal::VariadicDynCastAllOfMatcher switchStmt;
 
 /// \brief Matches case and default statements inside switch statements.
@@ -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
@@ -1838,7 +1838,7 @@
 ///   try {} catch(int i) {}
 /// \endcode
 /// cxxCatchStmt()
-///   matches 'catch(int i)'
+///   matches 'catch(int i) {}'
 extern const internal::VariadicDynCastAllOfMatcher
 cxxCatchStmt;
 
@@ -1848,7 +1848,7 @@
 ///   try {} catch(int i) {}
 /// \endcode
 /// cxxTryStmt()
-///   matches 'try {}'
+///   matches 'try {} catch(int i) {}'
 extern const internal::VariadicDynCastAllOfMatcher cxxTryStmt;
 
 /// \brief Matches throw expressions.
@@ -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 

[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 130486.
MaskRay added a comment.

More


Repository:
  rC Clang

https://reviews.llvm.org/D42213

Files:
  include/clang/ASTMatchers/ASTMatchers.h

Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -800,7 +800,7 @@
 ///   A b;
 ///   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<::next> a;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"
+/// refersToDeclaration(fieldDecl(hasName("next")
 ///   matches the specialization \c A<::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<::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,12 +1523,12 @@
 /// \code
 ///   T u(f());
 ///   g(f());
-/// \endcode
-/// but does not match
-/// \code
-///   f();
 ///   f().func();
 /// \endcode
+/// but does not match
+/// \code
+///   f();
+/// \endcode
 extern const internal::VariadicDynCastAllOfMatcher
 materializeTemporaryExpr;
@@ -1789,7 +1789,7 @@
 ///   switch(a) { case 42: break; default: break; }
 /// \endcode
 /// switchStmt()
-///   matches 'switch(a)'.
+///   matches 'switch(a) {'.
 extern const internal::VariadicDynCastAllOfMatcher switchStmt;
 
 /// \brief Matches case and default statements inside switch statements.
@@ -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
@@ -1838,7 +1838,7 @@
 ///   try {} catch(int i) {}
 /// \endcode
 /// cxxCatchStmt()
-///   matches 'catch(int i)'
+///   matches 'catch(int i) {}'
 extern const internal::VariadicDynCastAllOfMatcher
 cxxCatchStmt;
 
@@ -1848,7 +1848,7 @@
 ///   try {} catch(int i) {}
 /// \endcode
 /// cxxTryStmt()
-///   matches 'try {}'
+///   matches 'try {} catch(int i) {}'
 extern const internal::VariadicDynCastAllOfMatcher cxxTryStmt;
 
 /// \brief Matches throw expressions.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-18 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Don't forget that you also need to regenerate the HTML docs:

  $ cd docs/tools # yes, cd
  $ ./dump_ast_matchers.py


Repository:
  rC Clang

https://reviews.llvm.org/D42213



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 130458.
MaskRay added a comment.

More


Repository:
  rC Clang

https://reviews.llvm.org/D42213

Files:
  include/clang/ASTMatchers/ASTMatchers.h


Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -800,7 +800,7 @@
 ///   A b;
 ///   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<::next> a;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"
+/// refersToDeclaration(fieldDecl(hasName("next")
 ///   matches the specialization \c A<::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<::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,12 +1523,12 @@
 /// \code
 ///   T u(f());
 ///   g(f());
-/// \endcode
-/// but does not match
-/// \code
-///   f();
 ///   f().func();
 /// \endcode
+/// but does not match
+/// \code
+///   f();
+/// \endcode
 extern const internal::VariadicDynCastAllOfMatcher
 materializeTemporaryExpr;


Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -800,7 +800,7 @@
 ///   A b;
 ///   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<::next> a;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"
+/// refersToDeclaration(fieldDecl(hasName("next")
 ///   matches the specialization \c A<::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<::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,12 +1523,12 @@
 /// \code
 ///   T u(f());
 ///   g(f());
-/// \endcode
-/// but does not match
-/// \code
-///   f();
 ///   f().func();
 /// \endcode
+/// but does not match
+/// \code
+///   f();
+/// \endcode
 extern const internal::VariadicDynCastAllOfMatcher
 materializeTemporaryExpr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D42213: [ASTMatchers] [NFC] Fix code examples

2018-01-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
Herald added subscribers: cfe-commits, klimek.

Repository:
  rC Clang

https://reviews.llvm.org/D42213

Files:
  include/clang/ASTMatchers/ASTMatchers.h


Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -800,7 +800,7 @@
 ///   A b;
 ///   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<::next> a;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"
+/// refersToDeclaration(fieldDecl(hasName("next")
 ///   matches the specialization \c A<::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<::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(


Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -800,7 +800,7 @@
 ///   A b;
 ///   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<::next> a;
 /// \endcode
 /// classTemplateSpecializationDecl(hasAnyTemplateArgument(
-/// refersToDeclaration(fieldDecl(hasName("next"
+/// refersToDeclaration(fieldDecl(hasName("next")
 ///   matches the specialization \c A<::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<::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(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits