summaryrefslogtreecommitdiffstats
path: root/docs/LibASTMatchersReference.html
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2018-01-22 22:34:15 +0000
committerFangrui Song <maskray@google.com>2018-01-22 22:34:15 +0000
commit36e16a4009ab39f0dfd50a02fb602ea8107b225d (patch)
tree90393536bb0d3224515431d204be4bad63b68286 /docs/LibASTMatchersReference.html
parent96479389ab52506b58bffe00f22c26027f576953 (diff)
[ASTMatchers] [NFC] Fix code examples
Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42213 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323157 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'docs/LibASTMatchersReference.html')
-rw-r--r--docs/LibASTMatchersReference.html60
1 files changed, 31 insertions, 29 deletions
diff --git a/docs/LibASTMatchersReference.html b/docs/LibASTMatchersReference.html
index 95d95546ff..abc2834c4c 100644
--- a/docs/LibASTMatchersReference.html
+++ b/docs/LibASTMatchersReference.html
@@ -700,7 +700,7 @@ Example matches x.y() and y()
Given
switch(a) { case 42: break; default: break; }
caseStmt()
- matches 'case 42: break;'.
+ matches 'case 42:'.
</pre></td></tr>
@@ -741,7 +741,7 @@ Example match: {1}, (1, 2)
<tr><td>Matcher&lt;<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('compoundStmt0')"><a name="compoundStmt0Anchor">compoundStmt</a></td><td>Matcher&lt;<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>&gt;...</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>
@@ -1028,7 +1028,7 @@ declStmt()
Given
switch(a) { case 42: break; default: break; }
defaultStmt()
- matches 'default: break;'.
+ matches 'default:'.
</pre></td></tr>
@@ -1197,9 +1197,9 @@ Example: Given
materializeTemporaryExpr() matches 'f()' in these statements
T u(f());
g(f());
+ f().func();
but does not match
f();
- f().func();
</pre></td></tr>
@@ -1369,7 +1369,7 @@ substNonTypeTemplateParmExpr()
Given
switch(a) { case 42: break; default: break; }
switchCase()
- matches 'case 42: break;' and 'default: break;'.
+ matches 'case 42:' and 'default:'.
</pre></td></tr>
@@ -2940,11 +2940,11 @@ Given
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>
@@ -2990,11 +2990,11 @@ Given
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>
@@ -3534,7 +3534,7 @@ an arbitrary precision integer. 'Value' must be euqal to the canonical
representation of that integral value in base 10.
Given
- template&lt;int T&gt; struct A {};
+ template&lt;int T&gt; struct C {};
C&lt;42&gt; c;
classTemplateSpecializationDecl(
hasAnyTemplateArgument(equalsIntegralValue("42")))
@@ -3546,7 +3546,7 @@ classTemplateSpecializationDecl(
<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value.
Given
- template&lt;int T&gt; struct A {};
+ template&lt;int T&gt; struct C {};
C&lt;42&gt; c;
classTemplateSpecializationDecl(
hasAnyTemplateArgument(isIntegral()))
@@ -3973,10 +3973,11 @@ Usable as: Any Matcher
<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.
@@ -3999,10 +4000,11 @@ Usable as: Any Matcher
<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.
@@ -4479,7 +4481,7 @@ matches 'a' in
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>
@@ -4795,7 +4797,7 @@ Given
A&lt;bool, int&gt; b;
A&lt;int, bool&gt; c;
- template&lt;typename T&gt; f() {};
+ template&lt;typename T&gt; void f() {}
void func() { f&lt;int&gt;(); };
classTemplateSpecializationDecl(hasTemplateArgument(
1, refersToType(asString("int"))))
@@ -5312,7 +5314,7 @@ Given
A&lt;bool, int&gt; b;
A&lt;int, bool&gt; c;
- template&lt;typename T&gt; f() {};
+ template&lt;typename T&gt; void f() {}
void func() { f&lt;int&gt;(); };
classTemplateSpecializationDecl(hasTemplateArgument(
1, refersToType(asString("int"))))
@@ -6000,8 +6002,8 @@ Usable as: Matcher&lt;<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrL
<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression.
Given
- template&lt;typename T&gt; struct A {};
- struct B { B* next; };
+ struct B { int next; };
+ template&lt;int(B::*next_ptr)&gt; struct A {};
A&lt;&amp;B::next&gt; a;
templateSpecializationType(hasAnyTemplateArgument(
isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next"))))))))
@@ -6015,11 +6017,11 @@ templateSpecializationType(hasAnyTemplateArgument(
declaration.
Given
- template&lt;typename T&gt; struct A {};
- struct B { B* next; };
+ struct B { int next; };
+ template&lt;int(B::*next_ptr)&gt; struct A {};
A&lt;&amp;B::next&gt; a;
classTemplateSpecializationDecl(hasAnyTemplateArgument(
- refersToDeclaration(fieldDecl(hasName("next"))))
+ refersToDeclaration(fieldDecl(hasName("next")))))
matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
B::next
</pre></td></tr>
@@ -6029,7 +6031,7 @@ classTemplateSpecializationDecl(hasAnyTemplateArgument(
<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type.
Given
- template&lt;int T&gt; struct A {};
+ template&lt;int T&gt; struct C {};
C&lt;42&gt; c;
classTemplateSpecializationDecl(
hasAnyTemplateArgument(refersToIntegralType(asString("int"))))
@@ -6127,7 +6129,7 @@ Given
A&lt;bool, int&gt; b;
A&lt;int, bool&gt; c;
- template&lt;typename T&gt; f() {};
+ template&lt;typename T&gt; void f() {}
void func() { f&lt;int&gt;(); };
classTemplateSpecializationDecl(hasTemplateArgument(
1, refersToType(asString("int"))))