blob: e95e09558a53c182fb9060d1211b8d414b99908b [file] [log] [blame]
Manuel Klimek1da79332012-08-20 20:54:03 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3<html>
4<head>
5<title>AST Matcher Reference</title>
6<link type="text/css" rel="stylesheet" href="../menu.css" />
7<link type="text/css" rel="stylesheet" href="../content.css" />
8<style type="text/css">
9td {
10 padding: .33em;
11}
12td.doc {
13 display: none;
14 border-bottom: 1px solid black;
15}
16td.name:hover {
17 color: blue;
18 cursor: pointer;
19}
20</style>
21<script type="text/javascript">
22function toggle(id) {
Manuel Klimek67619ff2012-09-07 13:10:32 +000023 if (!id) return;
Manuel Klimek1da79332012-08-20 20:54:03 +000024 row = document.getElementById(id);
25 if (row.style.display != 'table-cell')
26 row.style.display = 'table-cell';
27 else
28 row.style.display = 'none';
29}
30</script>
31</head>
Manuel Klimek67619ff2012-09-07 13:10:32 +000032<body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))">
Manuel Klimek1da79332012-08-20 20:54:03 +000033
34<!--#include virtual="../menu.html.incl"-->
35
36<div id="content">
37
38<h1>AST Matcher Reference</h1>
39
40<p>This document shows all currently implemented matchers. The matchers are grouped
41by category and node type they match. You can click on matcher names to show the
42matcher's source documentation.</p>
43
44<p>There are three different basic categories of matchers:
45<ul>
46<li><a href="#decl-matchers">Node Matchers:</a> Matchers that match a specific type of AST node.</li>
47<li><a href="#narrowing-matchers">Narrowing Matchers:</a> Matchers that match attributes on AST nodes.</li>
48<li><a href="#traversal-matchers">Traversal Matchers:</a> Matchers that allow traversal between AST nodes.</li>
49</ul>
50</p>
51
52<p>Within each category the matchers are ordered by node type they match on.
53Note that if a matcher can match multiple node types, it will it will appear
54multiple times. This means that by searching for Matcher&lt;Stmt&gt; you can
55find all matchers that can be used to match on Stmt nodes.</p>
56
57<p>The exception to that rule are matchers that can match on any node. Those
58are marked with a * and are listed in the beginning of each category.</p>
59
Manuel Klimek8c5f9482013-06-21 09:59:59 +000060<p>Note that the categorization of matchers is a great help when you combine
61them into matcher expressions. You will usually want to form matcher expressions
62that read like english sentences by alternating between node matchers and
63narrowing or traversal matchers, like this:
64<pre>
65recordDecl(hasDescendant(
66 ifStmt(hasTrueExpression(
67 expr(hasDescendant(
68 ifStmt()))))))
69</pre>
70</p>
71
Manuel Klimek1da79332012-08-20 20:54:03 +000072<!-- ======================================================================= -->
73<h2 id="decl-matchers">Node Matchers</h2>
74<!-- ======================================================================= -->
75
76<p>Node matchers are at the core of matcher expressions - they specify the type
77of node that is expected. Every match expression starts with a node matcher,
78which can then be further refined with a narrowing or traversal matcher. All
79traversal matchers take node matchers as their arguments.</p>
80
81<p>For convenience, all node matchers take an arbitrary number of arguments
82and implicitly act as allOf matchers.</p>
83
84<p>Node matchers are the only matchers that support the bind("id") call to
85bind the matched node to the given string, to be later retrieved from the
86match callback.</p>
87
Manuel Klimek8c5f9482013-06-21 09:59:59 +000088<p>It is important to remember that the arguments to node matchers are
89predicates on the same node, just with additional information about the type.
90This is often useful to make matcher expression more readable by inlining bind
91calls into redundant node matchers inside another node matcher:
92<pre>
93// This binds the CXXRecordDecl to "id", as the decl() matcher will stay on
94// the same node.
95recordDecl(decl().bind("id"), hasName("::MyClass"))
96</pre>
97</p>
98
Manuel Klimek1da79332012-08-20 20:54:03 +000099<table>
100<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
101<!-- START_DECL_MATCHERS -->
102
Manuel Klimek532870f2013-07-24 05:46:07 +0000103<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;</td><td class="name" onclick="toggle('ctorInitializer0')"><a name="ctorInitializer0Anchor">ctorInitializer</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;...</td></tr>
104<tr><td colspan="4" class="doc" id="ctorInitializer0"><pre>Matches constructor initializers.
105
106Examples matches i(42).
107 class C {
108 C() : i(42) {}
109 int i;
110 };
111</pre></td></tr>
112
113
Daniel Jasperc7093d92013-02-25 12:39:41 +0000114<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('accessSpecDecl0')"><a name="accessSpecDecl0Anchor">accessSpecDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AccessSpecDecl.html">AccessSpecDecl</a>&gt;...</td></tr>
115<tr><td colspan="4" class="doc" id="accessSpecDecl0"><pre>Matches C++ access specifier declarations.
116
117Given
118 class C {
119 public:
120 int a;
121 };
122accessSpecDecl()
123 matches 'public:'
124</pre></td></tr>
125
126
Manuel Klimek67619ff2012-09-07 13:10:32 +0000127<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('classTemplateDecl0')"><a name="classTemplateDecl0Anchor">classTemplateDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html">ClassTemplateDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000128<tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000129
130Example matches Z
131 template&lt;class T&gt; class Z {};
132</pre></td></tr>
133
134
Manuel Klimek67619ff2012-09-07 13:10:32 +0000135<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('classTemplateSpecializationDecl0')"><a name="classTemplateSpecializationDecl0Anchor">classTemplateSpecializationDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000136<tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000137
138Given
139 template&lt;typename T&gt; class A {};
140 template&lt;&gt; class A&lt;double&gt; {};
141 A&lt;int&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +0000142classTemplateSpecializationDecl()
Manuel Klimek1da79332012-08-20 20:54:03 +0000143 matches the specializations A&lt;int&gt; and A&lt;double&gt;
144</pre></td></tr>
145
146
Manuel Klimek67619ff2012-09-07 13:10:32 +0000147<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('constructorDecl0')"><a name="constructorDecl0Anchor">constructorDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000148<tr><td colspan="4" class="doc" id="constructorDecl0"><pre>Matches C++ constructor declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000149
150Example matches Foo::Foo() and Foo::Foo(int)
151 class Foo {
152 public:
153 Foo();
154 Foo(int);
155 int DoSomething();
156 };
157</pre></td></tr>
158
159
Manuel Klimek67619ff2012-09-07 13:10:32 +0000160<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('decl0')"><a name="decl0Anchor">decl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000161<tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations.
162
163Examples matches X, C, and the friend declaration inside C;
164 void X();
165 class C {
166 friend X;
167 };
168</pre></td></tr>
169
170
Manuel Klimek1a68afd2013-06-20 13:08:29 +0000171<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('declaratorDecl0')"><a name="declaratorDecl0Anchor">declaratorDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;...</td></tr>
172<tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function
173and non-type template parameter declarations).
174
175Given
176 class X { int y; };
177declaratorDecl()
178 matches int y.
179</pre></td></tr>
180
181
Manuel Klimek67619ff2012-09-07 13:10:32 +0000182<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('destructorDecl0')"><a name="destructorDecl0Anchor">destructorDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000183<tr><td colspan="4" class="doc" id="destructorDecl0"><pre>Matches explicit C++ destructor declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000184
185Example matches Foo::~Foo()
186 class Foo {
187 public:
188 virtual ~Foo();
189 };
190</pre></td></tr>
191
192
Manuel Klimek67619ff2012-09-07 13:10:32 +0000193<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('enumConstantDecl0')"><a name="enumConstantDecl0Anchor">enumConstantDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumConstantDecl.html">EnumConstantDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000194<tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants.
Manuel Klimek1da79332012-08-20 20:54:03 +0000195
196Example matches A, B, C
197 enum X {
198 A, B, C
199 };
200</pre></td></tr>
201
202
Manuel Klimek67619ff2012-09-07 13:10:32 +0000203<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('enumDecl0')"><a name="enumDecl0Anchor">enumDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000204<tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations.
205
206Example matches X
207 enum X {
208 A, B, C
209 };
210</pre></td></tr>
211
212
Manuel Klimek67619ff2012-09-07 13:10:32 +0000213<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('fieldDecl0')"><a name="fieldDecl0Anchor">fieldDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000214<tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000215
216Given
217 class X { int m; };
Manuel Klimeke44a0062012-08-26 23:55:24 +0000218fieldDecl()
Manuel Klimek1da79332012-08-20 20:54:03 +0000219 matches 'm'.
220</pre></td></tr>
221
222
Manuel Klimek532870f2013-07-24 05:46:07 +0000223<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('friendDecl0')"><a name="friendDecl0Anchor">friendDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>&gt;...</td></tr>
224<tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations.
225
226Given
227 class X { friend void foo(); };
228friendDecl()
229 matches 'friend void foo()'.
230</pre></td></tr>
231
232
Manuel Klimek67619ff2012-09-07 13:10:32 +0000233<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('functionDecl0')"><a name="functionDecl0Anchor">functionDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000234<tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000235
236Example matches f
237 void f();
238</pre></td></tr>
239
240
Manuel Klimek67619ff2012-09-07 13:10:32 +0000241<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('functionTemplateDecl0')"><a name="functionTemplateDecl0Anchor">functionTemplateDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionTemplateDecl.html">FunctionTemplateDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000242<tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000243
244Example matches f
245 template&lt;class T&gt; void f(T t) {}
246</pre></td></tr>
247
248
Manuel Klimek67619ff2012-09-07 13:10:32 +0000249<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('methodDecl0')"><a name="methodDecl0Anchor">methodDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000250<tr><td colspan="4" class="doc" id="methodDecl0"><pre>Matches method declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000251
252Example matches y
253 class X { void y() };
254</pre></td></tr>
255
256
Manuel Klimek67619ff2012-09-07 13:10:32 +0000257<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('namedDecl0')"><a name="namedDecl0Anchor">namedDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000258<tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name.
Manuel Klimek1da79332012-08-20 20:54:03 +0000259
260Example matches X, S, the anonymous union type, i, and U;
261 typedef int X;
262 struct S {
263 union {
264 int i;
265 } U;
266 };
267</pre></td></tr>
268
269
Edwin Vane0332e0a2013-05-09 16:42:37 +0000270<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('namespaceDecl0')"><a name="namespaceDecl0Anchor">namespaceDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>&gt;...</td></tr>
271<tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace.
272
273Given
274 namespace {}
275 namespace test {}
276namespaceDecl()
277 matches "namespace {}" and "namespace test {}"
278</pre></td></tr>
279
280
Manuel Klimek1a68afd2013-06-20 13:08:29 +0000281<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('parmVarDecl0')"><a name="parmVarDecl0Anchor">parmVarDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt;...</td></tr>
282<tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations.
283
284Given
285 void f(int x);
286parmVarDecl()
287 matches int x.
288</pre></td></tr>
289
290
Manuel Klimek67619ff2012-09-07 13:10:32 +0000291<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('recordDecl0')"><a name="recordDecl0Anchor">recordDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000292<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches C++ class declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000293
294Example matches X, Z
295 class X;
296 template&lt;class T&gt; class Z {};
297</pre></td></tr>
298
299
Manuel Klimek532870f2013-07-24 05:46:07 +0000300<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('unresolvedUsingValueDecl0')"><a name="unresolvedUsingValueDecl0Anchor">unresolvedUsingValueDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingValueDecl.html">UnresolvedUsingValueDecl</a>&gt;...</td></tr>
301<tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations.
302
303Given
304 template&lt;typename X&gt;
305 class C : private X {
306 using X::x;
307 };
308unresolvedUsingValueDecl()
309 matches using X::x </pre></td></tr>
310
311
Manuel Klimek67619ff2012-09-07 13:10:32 +0000312<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('usingDecl0')"><a name="usingDecl0Anchor">usingDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html">UsingDecl</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000313<tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations.
314
315Given
316 namespace X { int x; }
317 using X::x;
318usingDecl()
319 matches using X::x </pre></td></tr>
320
321
Manuel Klimek67619ff2012-09-07 13:10:32 +0000322<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('varDecl0')"><a name="varDecl0Anchor">varDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000323<tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000324
325Note: this does not match declarations of member variables, which are
326"field" declarations in Clang parlance.
327
328Example matches a
329 int a;
330</pre></td></tr>
331
332
Manuel Klimek41df16e2013-01-09 09:38:21 +0000333<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>&gt;</td><td class="name" onclick="toggle('nestedNameSpecifierLoc0')"><a name="nestedNameSpecifierLoc0Anchor">nestedNameSpecifierLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>&gt;...</td></tr>
334<tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
335</pre></td></tr>
336
337
338<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt;</td><td class="name" onclick="toggle('nestedNameSpecifier0')"><a name="nestedNameSpecifier0Anchor">nestedNameSpecifier</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt;...</td></tr>
339<tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers.
340
341Given
342 namespace ns {
343 struct A { static void f(); };
344 void A::f() {}
345 void g() { A::f(); }
346 }
347 ns::A a;
348nestedNameSpecifier()
349 matches "ns::" and both "A::"
350</pre></td></tr>
351
352
353<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('qualType0')"><a name="qualType0Anchor">qualType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;...</td></tr>
354<tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST.
355</pre></td></tr>
356
357
Manuel Klimek67619ff2012-09-07 13:10:32 +0000358<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('arraySubscriptExpr0')"><a name="arraySubscriptExpr0Anchor">arraySubscriptExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000359<tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions.
360
361Given
362 int i = a[1];
363arraySubscriptExpr()
364 matches "a[1]"
365</pre></td></tr>
366
367
Daniel Jaspere0b89972012-12-04 12:08:08 +0000368<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('asmStmt0')"><a name="asmStmt0Anchor">asmStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AsmStmt.html">AsmStmt</a>&gt;...</td></tr>
369<tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements.
370
371 int i = 100;
372 __asm("mov al, 2");
373asmStmt()
374 matches '__asm("mov al, 2")'
375</pre></td></tr>
376
377
Manuel Klimek67619ff2012-09-07 13:10:32 +0000378<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('binaryOperator0')"><a name="binaryOperator0Anchor">binaryOperator</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000379<tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions.
380
381Example matches a || b
382 !(a || b)
383</pre></td></tr>
384
385
Manuel Klimek67619ff2012-09-07 13:10:32 +0000386<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('bindTemporaryExpr0')"><a name="bindTemporaryExpr0Anchor">bindTemporaryExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000387<tr><td colspan="4" class="doc" id="bindTemporaryExpr0"><pre>Matches nodes where temporaries are created.
Manuel Klimek1da79332012-08-20 20:54:03 +0000388
389Example matches FunctionTakesString(GetStringByValue())
Manuel Klimeke44a0062012-08-26 23:55:24 +0000390 (matcher = bindTemporaryExpr())
Manuel Klimek1da79332012-08-20 20:54:03 +0000391 FunctionTakesString(GetStringByValue());
392 FunctionTakesStringByPointer(GetStringPointer());
393</pre></td></tr>
394
395
Daniel Jaspere0b89972012-12-04 12:08:08 +0000396<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('boolLiteral0')"><a name="boolLiteral0Anchor">boolLiteral</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>&gt;...</td></tr>
397<tr><td colspan="4" class="doc" id="boolLiteral0"><pre>Matches bool literals.
398
399Example matches true
400 true
401</pre></td></tr>
402
403
404<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('breakStmt0')"><a name="breakStmt0Anchor">breakStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BreakStmt.html">BreakStmt</a>&gt;...</td></tr>
405<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements.
406
407Given
408 while (true) { break; }
409breakStmt()
410 matches 'break'
411</pre></td></tr>
412
413
414<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cStyleCastExpr0')"><a name="cStyleCastExpr0Anchor">cStyleCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CStyleCastExpr.html">CStyleCastExpr</a>&gt;...</td></tr>
415<tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression.
416
417Example: Matches (int*) 2.2f in
418 int i = (int) 2.2f;
419</pre></td></tr>
420
421
Manuel Klimek67619ff2012-09-07 13:10:32 +0000422<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('callExpr0')"><a name="callExpr0Anchor">callExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000423<tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000424
425Example matches x.y() and y()
426 X x;
427 x.y();
428 y();
429</pre></td></tr>
430
431
Manuel Klimek03a83232013-06-10 08:52:15 +0000432<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('caseStmt0')"><a name="caseStmt0Anchor">caseStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt</a>&gt;...</td></tr>
433<tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements.
434
435Given
436 switch(a) { case 42: break; default: break; }
437caseStmt()
438 matches 'case 42: break;'.
439</pre></td></tr>
440
441
Daniel Jaspere0b89972012-12-04 12:08:08 +0000442<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('castExpr0')"><a name="castExpr0Anchor">castExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>&gt;...</td></tr>
443<tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST.
444
445Example: castExpr() matches each of the following:
446 (int) 3;
447 const_cast&lt;Expr *&gt;(SubExpr);
448 char c = 0;
449but does not match
450 int i = (0);
451 int k = 0;
452</pre></td></tr>
453
454
455<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('catchStmt0')"><a name="catchStmt0Anchor">catchStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>&gt;...</td></tr>
456<tr><td colspan="4" class="doc" id="catchStmt0"><pre>Matches catch statements.
457
458 try {} catch(int i) {}
459catchStmt()
460 matches 'catch(int i)'
461</pre></td></tr>
462
463
464<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('characterLiteral0')"><a name="characterLiteral0Anchor">characterLiteral</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;...</td></tr>
465<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t).
466
467Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
468though.
469
470Example matches 'a', L'a'
471 char ch = 'a'; wchar_t chw = L'a';
472</pre></td></tr>
473
474
Manuel Klimek415514d2013-02-06 20:36:22 +0000475<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('compoundLiteralExpr0')"><a name="compoundLiteralExpr0Anchor">compoundLiteralExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;...</td></tr>
476<tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals
477
478Example match: {1}, (1, 2)
479 int array[4] = {1}; vector int myvec = (vector int)(1, 2);
480</pre></td></tr>
481
482
Manuel Klimek67619ff2012-09-07 13:10:32 +0000483<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>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000484<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements.
Manuel Klimek1da79332012-08-20 20:54:03 +0000485
486Example matches '{}' and '{{}}'in 'for (;;) {{}}'
487 for (;;) {{}}
488</pre></td></tr>
489
490
Manuel Klimek67619ff2012-09-07 13:10:32 +0000491<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('conditionalOperator0')"><a name="conditionalOperator0Anchor">conditionalOperator</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000492<tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions.
493
494Example matches a ? b : c
495 (a ? b : c) + 42
496</pre></td></tr>
497
498
Daniel Jaspere0b89972012-12-04 12:08:08 +0000499<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('constCastExpr0')"><a name="constCastExpr0Anchor">constCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>&gt;...</td></tr>
500<tr><td colspan="4" class="doc" id="constCastExpr0"><pre>Matches a const_cast expression.
501
502Example: Matches const_cast&lt;int*&gt;(&amp;r) in
503 int n = 42;
504 const int &amp;r(n);
505 int* p = const_cast&lt;int*&gt;(&amp;r);
506</pre></td></tr>
507
508
Manuel Klimek67619ff2012-09-07 13:10:32 +0000509<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('constructExpr0')"><a name="constructExpr0Anchor">constructExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000510<tr><td colspan="4" class="doc" id="constructExpr0"><pre>Matches constructor call expressions (including implicit ones).
Manuel Klimek1da79332012-08-20 20:54:03 +0000511
512Example matches string(ptr, n) and ptr within arguments of f
Manuel Klimeke44a0062012-08-26 23:55:24 +0000513 (matcher = constructExpr())
Manuel Klimek1da79332012-08-20 20:54:03 +0000514 void f(const string &amp;a, const string &amp;b);
515 char *ptr;
516 int n;
517 f(string(ptr, n), ptr);
518</pre></td></tr>
519
520
Daniel Jaspere0b89972012-12-04 12:08:08 +0000521<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('continueStmt0')"><a name="continueStmt0Anchor">continueStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ContinueStmt.html">ContinueStmt</a>&gt;...</td></tr>
522<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements.
523
524Given
525 while (true) { continue; }
526continueStmt()
527 matches 'continue'
528</pre></td></tr>
529
530
Manuel Klimek67619ff2012-09-07 13:10:32 +0000531<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('declRefExpr0')"><a name="declRefExpr0Anchor">declRefExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000532<tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000533
534Example matches x in if (x)
535 bool x;
536 if (x) {}
537</pre></td></tr>
538
539
Manuel Klimek67619ff2012-09-07 13:10:32 +0000540<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('declStmt0')"><a name="declStmt0Anchor">declStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000541<tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements.
Manuel Klimek1da79332012-08-20 20:54:03 +0000542
543Given
544 int a;
Manuel Klimeke44a0062012-08-26 23:55:24 +0000545declStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +0000546 matches 'int a'.
547</pre></td></tr>
548
549
Manuel Klimek67619ff2012-09-07 13:10:32 +0000550<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('defaultArgExpr0')"><a name="defaultArgExpr0Anchor">defaultArgExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000551<tr><td colspan="4" class="doc" id="defaultArgExpr0"><pre>Matches the value of a default argument at the call site.
Manuel Klimek1da79332012-08-20 20:54:03 +0000552
553Example matches the CXXDefaultArgExpr placeholder inserted for the
554 default value of the second parameter in the call expression f(42)
Manuel Klimeke44a0062012-08-26 23:55:24 +0000555 (matcher = defaultArgExpr())
Manuel Klimek1da79332012-08-20 20:54:03 +0000556 void f(int x, int y = 0);
557 f(42);
558</pre></td></tr>
559
560
Manuel Klimek03a83232013-06-10 08:52:15 +0000561<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('defaultStmt0')"><a name="defaultStmt0Anchor">defaultStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DefaultStmt.html">DefaultStmt</a>&gt;...</td></tr>
562<tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements.
563
564Given
565 switch(a) { case 42: break; default: break; }
566defaultStmt()
567 matches 'default: break;'.
568</pre></td></tr>
569
570
Manuel Klimek67619ff2012-09-07 13:10:32 +0000571<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('deleteExpr0')"><a name="deleteExpr0Anchor">deleteExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000572<tr><td colspan="4" class="doc" id="deleteExpr0"><pre>Matches delete expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000573
574Given
575 delete X;
Manuel Klimeke44a0062012-08-26 23:55:24 +0000576deleteExpr()
Manuel Klimek1da79332012-08-20 20:54:03 +0000577 matches 'delete X'.
578</pre></td></tr>
579
580
Manuel Klimek67619ff2012-09-07 13:10:32 +0000581<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('doStmt0')"><a name="doStmt0Anchor">doStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000582<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements.
583
584Given
585 do {} while (true);
586doStmt()
587 matches 'do {} while(true)'
588</pre></td></tr>
589
590
Daniel Jaspere0b89972012-12-04 12:08:08 +0000591<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('dynamicCastExpr0')"><a name="dynamicCastExpr0Anchor">dynamicCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>&gt;...</td></tr>
592<tr><td colspan="4" class="doc" id="dynamicCastExpr0"><pre>Matches a dynamic_cast expression.
593
594Example:
595 dynamicCastExpr()
596matches
597 dynamic_cast&lt;D*&gt;(&amp;b);
598in
599 struct B { virtual ~B() {} }; struct D : B {};
600 B b;
601 D* p = dynamic_cast&lt;D*&gt;(&amp;b);
602</pre></td></tr>
603
604
605<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('explicitCastExpr0')"><a name="explicitCastExpr0Anchor">explicitCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;...</td></tr>
606<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions.
607
608Matches any cast expression written in user code, whether it be a
609C-style cast, a functional-style cast, or a keyword cast.
610
611Does not match implicit conversions.
612
613Note: the name "explicitCast" is chosen to match Clang's terminology, as
614Clang uses the term "cast" to apply to implicit conversions as well as to
615actual cast expressions.
616
617hasDestinationType.
618
619Example: matches all five of the casts in
620 int((int)(reinterpret_cast&lt;int&gt;(static_cast&lt;int&gt;(const_cast&lt;int&gt;(42)))))
621but does not match the implicit conversion in
622 long ell = 42;
623</pre></td></tr>
624
625
Manuel Klimek67619ff2012-09-07 13:10:32 +0000626<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('expr0')"><a name="expr0Anchor">expr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000627<tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000628
629Example matches x()
630 void f() { x(); }
631</pre></td></tr>
632
633
Samuel Benzaquenee0da952013-08-16 16:19:42 +0000634<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('floatLiteral0')"><a name="floatLiteral0Anchor">floatLiteral</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>&gt;...</td></tr>
635<tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes encodings, e.g.
6361.0, 1.0f, 1.0L and 1e10.
637
638Does not match implicit conversions such as
639 float a = 10;
640</pre></td></tr>
641
642
Daniel Jaspere0b89972012-12-04 12:08:08 +0000643<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('forRangeStmt0')"><a name="forRangeStmt0Anchor">forRangeStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>&gt;...</td></tr>
644<tr><td colspan="4" class="doc" id="forRangeStmt0"><pre>Matches range-based for statements.
645
646forRangeStmt() matches 'for (auto a : i)'
647 int i[] = {1, 2, 3}; for (auto a : i);
648 for(int j = 0; j &lt; 5; ++j);
649</pre></td></tr>
650
651
Manuel Klimek67619ff2012-09-07 13:10:32 +0000652<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('forStmt0')"><a name="forStmt0Anchor">forStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000653<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements.
654
655Example matches 'for (;;) {}'
656 for (;;) {}
Daniel Jaspere0b89972012-12-04 12:08:08 +0000657 int i[] = {1, 2, 3}; for (auto a : i);
658</pre></td></tr>
659
660
661<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('functionalCastExpr0')"><a name="functionalCastExpr0Anchor">functionalCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;...</td></tr>
662<tr><td colspan="4" class="doc" id="functionalCastExpr0"><pre>Matches functional cast expressions
663
664Example: Matches Foo(bar);
665 Foo f = bar;
666 Foo g = (Foo) bar;
667 Foo h = Foo(bar);
668</pre></td></tr>
669
670
671<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('gotoStmt0')"><a name="gotoStmt0Anchor">gotoStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1GotoStmt.html">GotoStmt</a>&gt;...</td></tr>
672<tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements.
673
674Given
675 goto FOO;
676 FOO: bar();
677gotoStmt()
678 matches 'goto FOO'
Manuel Klimek1da79332012-08-20 20:54:03 +0000679</pre></td></tr>
680
681
Manuel Klimek67619ff2012-09-07 13:10:32 +0000682<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('ifStmt0')"><a name="ifStmt0Anchor">ifStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000683<tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements.
684
685Example matches 'if (x) {}'
686 if (x) {}
687</pre></td></tr>
688
689
Daniel Jaspere0b89972012-12-04 12:08:08 +0000690<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('implicitCastExpr0')"><a name="implicitCastExpr0Anchor">implicitCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ImplicitCastExpr.html">ImplicitCastExpr</a>&gt;...</td></tr>
691<tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST.
692
693This matches many different places, including function call return value
694eliding, as well as any type conversions.
695</pre></td></tr>
696
697
Manuel Klimek67619ff2012-09-07 13:10:32 +0000698<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('initListExpr0')"><a name="initListExpr0Anchor">initListExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000699<tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions.
700
701Given
702 int a[] = { 1, 2 };
703 struct B { int x, y; };
704 B b = { 5, 6 };
705initList()
706 matches "{ 1, 2 }" and "{ 5, 6 }"
707</pre></td></tr>
708
709
Daniel Jaspere0b89972012-12-04 12:08:08 +0000710<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('integerLiteral0')"><a name="integerLiteral0Anchor">integerLiteral</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;...</td></tr>
Samuel Benzaquenee0da952013-08-16 16:19:42 +0000711<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings, e.g.
7121, 1L, 0x1 and 1U.
Daniel Jaspere0b89972012-12-04 12:08:08 +0000713
Samuel Benzaquenee0da952013-08-16 16:19:42 +0000714Does not match character-encoded integers such as L'a'.
Daniel Jaspere0b89972012-12-04 12:08:08 +0000715</pre></td></tr>
716
717
718<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('labelStmt0')"><a name="labelStmt0Anchor">labelStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;...</td></tr>
719<tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements.
720
721Given
722 goto FOO;
723 FOO: bar();
724labelStmt()
725 matches 'FOO:'
726</pre></td></tr>
727
728
729<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('lambdaExpr0')"><a name="lambdaExpr0Anchor">lambdaExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>&gt;...</td></tr>
730<tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions.
731
732Example matches [&amp;](){return 5;}
733 [&amp;](){return 5;}
734</pre></td></tr>
735
736
Manuel Klimek67619ff2012-09-07 13:10:32 +0000737<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('materializeTemporaryExpr0')"><a name="materializeTemporaryExpr0Anchor">materializeTemporaryExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MaterializeTemporaryExpr.html">MaterializeTemporaryExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000738<tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized.
739
740Example: Given
741 struct T {void func()};
742 T f();
743 void g(T);
744materializeTemporaryExpr() matches 'f()' in these statements
745 T u(f());
746 g(f());
747but does not match
748 f();
749 f().func();
750</pre></td></tr>
751
752
Manuel Klimek67619ff2012-09-07 13:10:32 +0000753<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('memberCallExpr0')"><a name="memberCallExpr0Anchor">memberCallExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000754<tr><td colspan="4" class="doc" id="memberCallExpr0"><pre>Matches member call expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000755
756Example matches x.y()
757 X x;
758 x.y();
759</pre></td></tr>
760
761
Manuel Klimek67619ff2012-09-07 13:10:32 +0000762<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('memberExpr0')"><a name="memberExpr0Anchor">memberExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000763<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000764
765Given
766 class Y {
767 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
768 int a; static int b;
769 };
Manuel Klimeke44a0062012-08-26 23:55:24 +0000770memberExpr()
Manuel Klimek1da79332012-08-20 20:54:03 +0000771 matches this-&gt;x, x, y.x, a, this-&gt;b
772</pre></td></tr>
773
774
Manuel Klimek67619ff2012-09-07 13:10:32 +0000775<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('newExpr0')"><a name="newExpr0Anchor">newExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000776<tr><td colspan="4" class="doc" id="newExpr0"><pre>Matches new expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000777
778Given
779 new X;
Manuel Klimeke44a0062012-08-26 23:55:24 +0000780newExpr()
Manuel Klimek1da79332012-08-20 20:54:03 +0000781 matches 'new X'.
782</pre></td></tr>
783
784
Daniel Jaspere0b89972012-12-04 12:08:08 +0000785<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('nullPtrLiteralExpr0')"><a name="nullPtrLiteralExpr0Anchor">nullPtrLiteralExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>&gt;...</td></tr>
786<tr><td colspan="4" class="doc" id="nullPtrLiteralExpr0"><pre>Matches nullptr literal.
787</pre></td></tr>
788
789
790<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('nullStmt0')"><a name="nullStmt0Anchor">nullStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NullStmt.html">NullStmt</a>&gt;...</td></tr>
791<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements.
792
793 foo();;
794nullStmt()
795 matches the second ';'
796</pre></td></tr>
797
798
Manuel Klimek67619ff2012-09-07 13:10:32 +0000799<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('operatorCallExpr0')"><a name="operatorCallExpr0Anchor">operatorCallExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000800<tr><td colspan="4" class="doc" id="operatorCallExpr0"><pre>Matches overloaded operator calls.
Manuel Klimek1da79332012-08-20 20:54:03 +0000801
802Note that if an operator isn't overloaded, it won't match. Instead, use
803binaryOperator matcher.
804Currently it does not match operators such as new delete.
805FIXME: figure out why these do not match?
806
807Example matches both operator&lt;&lt;((o &lt;&lt; b), c) and operator&lt;&lt;(o, b)
Manuel Klimeke44a0062012-08-26 23:55:24 +0000808 (matcher = operatorCallExpr())
Manuel Klimek1da79332012-08-20 20:54:03 +0000809 ostream &amp;operator&lt;&lt; (ostream &amp;out, int i) { };
810 ostream &amp;o; int b = 1, c = 1;
811 o &lt;&lt; b &lt;&lt; c;
812</pre></td></tr>
813
814
Daniel Jaspere0b89972012-12-04 12:08:08 +0000815<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('reinterpretCastExpr0')"><a name="reinterpretCastExpr0Anchor">reinterpretCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>&gt;...</td></tr>
816<tr><td colspan="4" class="doc" id="reinterpretCastExpr0"><pre>Matches a reinterpret_cast expression.
817
818Either the source expression or the destination type can be matched
819using has(), but hasDestinationType() is more specific and can be
820more readable.
821
822Example matches reinterpret_cast&lt;char*&gt;(&amp;p) in
823 void* p = reinterpret_cast&lt;char*&gt;(&amp;p);
824</pre></td></tr>
825
826
827<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('returnStmt0')"><a name="returnStmt0Anchor">returnStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">ReturnStmt</a>&gt;...</td></tr>
828<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements.
829
830Given
831 return 1;
832returnStmt()
833 matches 'return 1'
834</pre></td></tr>
835
836
837<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('staticCastExpr0')"><a name="staticCastExpr0Anchor">staticCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>&gt;...</td></tr>
838<tr><td colspan="4" class="doc" id="staticCastExpr0"><pre>Matches a C++ static_cast expression.
839
840hasDestinationType
841reinterpretCast
842
843Example:
844 staticCastExpr()
845matches
846 static_cast&lt;long&gt;(8)
847in
848 long eight(static_cast&lt;long&gt;(8));
849</pre></td></tr>
850
851
Manuel Klimek67619ff2012-09-07 13:10:32 +0000852<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('stmt0')"><a name="stmt0Anchor">stmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000853<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements.
Manuel Klimek1da79332012-08-20 20:54:03 +0000854
855Given
856 { ++a; }
Manuel Klimeke44a0062012-08-26 23:55:24 +0000857stmt()
Manuel Klimek1da79332012-08-20 20:54:03 +0000858 matches both the compound statement '{ ++a; }' and '++a'.
859</pre></td></tr>
860
861
Daniel Jaspere0b89972012-12-04 12:08:08 +0000862<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('stringLiteral0')"><a name="stringLiteral0Anchor">stringLiteral</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>&gt;...</td></tr>
863<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals).
864
865Example matches "abcd", L"abcd"
866 char *s = "abcd"; wchar_t *ws = L"abcd"
867</pre></td></tr>
868
869
Manuel Klimek67619ff2012-09-07 13:10:32 +0000870<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('switchCase0')"><a name="switchCase0Anchor">switchCase</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000871<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements.
872
873Given
874 switch(a) { case 42: break; default: break; }
875switchCase()
876 matches 'case 42: break;' and 'default: break;'.
877</pre></td></tr>
878
879
Daniel Jaspere0b89972012-12-04 12:08:08 +0000880<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('switchStmt0')"><a name="switchStmt0Anchor">switchStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>&gt;...</td></tr>
881<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements.
882
883Given
884 switch(a) { case 42: break; default: break; }
885switchStmt()
886 matches 'switch(a)'.
887</pre></td></tr>
888
889
890<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('thisExpr0')"><a name="thisExpr0Anchor">thisExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>&gt;...</td></tr>
891<tr><td colspan="4" class="doc" id="thisExpr0"><pre>Matches implicit and explicit this expressions.
892
893Example matches the implicit this expression in "return i".
894 (matcher = thisExpr())
895struct foo {
896 int i;
897 int f() { return i; }
898};
899</pre></td></tr>
900
901
902<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('throwExpr0')"><a name="throwExpr0Anchor">throwExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>&gt;...</td></tr>
903<tr><td colspan="4" class="doc" id="throwExpr0"><pre>Matches throw expressions.
904
905 try { throw 5; } catch(int i) {}
906throwExpr()
907 matches 'throw 5'
908</pre></td></tr>
909
910
911<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('tryStmt0')"><a name="tryStmt0Anchor">tryStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>&gt;...</td></tr>
912<tr><td colspan="4" class="doc" id="tryStmt0"><pre>Matches try statements.
913
914 try {} catch(int i) {}
915tryStmt()
916 matches 'try {}'
917</pre></td></tr>
918
919
Manuel Klimek67619ff2012-09-07 13:10:32 +0000920<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('unaryExprOrTypeTraitExpr0')"><a name="unaryExprOrTypeTraitExpr0Anchor">unaryExprOrTypeTraitExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000921<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
922
923Given
924 Foo x = bar;
925 int y = sizeof(x) + alignof(x);
926unaryExprOrTypeTraitExpr()
927 matches sizeof(x) and alignof(x)
928</pre></td></tr>
929
930
Manuel Klimek67619ff2012-09-07 13:10:32 +0000931<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('unaryOperator0')"><a name="unaryOperator0Anchor">unaryOperator</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000932<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions.
933
934Example matches !a
935 !a || b
936</pre></td></tr>
937
938
Manuel Klimek532870f2013-07-24 05:46:07 +0000939<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('unresolvedConstructExpr0')"><a name="unresolvedConstructExpr0Anchor">unresolvedConstructExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;...</td></tr>
940<tr><td colspan="4" class="doc" id="unresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions.
941
942Example matches T(t) in return statement of f
943 (matcher = unresolvedConstructExpr())
944 template &lt;typename T&gt;
945 void f(const T&amp; t) { return T(t); }
946</pre></td></tr>
947
948
Daniel Jaspere0b89972012-12-04 12:08:08 +0000949<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('userDefinedLiteral0')"><a name="userDefinedLiteral0Anchor">userDefinedLiteral</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UserDefinedLiteral.html">UserDefinedLiteral</a>&gt;...</td></tr>
950<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call.
951
952Example match: "foo"_suffix
953</pre></td></tr>
954
955
Manuel Klimek67619ff2012-09-07 13:10:32 +0000956<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('whileStmt0')"><a name="whileStmt0Anchor">whileStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000957<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements.
958
959Given
960 while (true) {}
961whileStmt()
962 matches 'while (true) {}'.
963</pre></td></tr>
964
Daniel Jaspere0b89972012-12-04 12:08:08 +0000965
966<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('typeLoc0')"><a name="typeLoc0Anchor">typeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;...</td></tr>
967<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST.
968</pre></td></tr>
969
970
Manuel Klimek41df16e2013-01-09 09:38:21 +0000971<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('arrayType0')"><a name="arrayType0Anchor">arrayType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>&gt;...</td></tr>
972<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays.
973
974Given
975 int a[] = { 2, 3 };
976 int b[4];
977 void f() { int c[a[0]]; }
978arrayType()
979 matches "int a[]", "int b[4]" and "int c[a[0]]";
980</pre></td></tr>
981
982
983<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('atomicType0')"><a name="atomicType0Anchor">atomicType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;...</td></tr>
984<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types.
985
986Given
987 _Atomic(int) i;
988atomicType()
989 matches "_Atomic(int) i"
990</pre></td></tr>
991
992
993<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('autoType0')"><a name="autoType0Anchor">autoType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>&gt;...</td></tr>
994<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types.
995
996Given:
997 auto n = 4;
998 int v[] = { 2, 3 }
999 for (auto i : v) { }
1000autoType()
1001 matches "auto n" and "auto i"
1002</pre></td></tr>
1003
1004
1005<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('blockPointerType0')"><a name="blockPointerType0Anchor">blockPointerType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;...</td></tr>
1006<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as
1007"void (^)(int)".
1008
1009The pointee is always required to be a FunctionType.
1010</pre></td></tr>
1011
1012
1013<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('builtinType0')"><a name="builtinType0Anchor">builtinType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BuiltinType.html">BuiltinType</a>&gt;...</td></tr>
1014<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types.
1015
1016Given
1017 struct A {};
1018 A a;
1019 int b;
1020 float c;
1021 bool d;
1022builtinType()
1023 matches "int b", "float c" and "bool d"
1024</pre></td></tr>
1025
1026
1027<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('complexType0')"><a name="complexType0Anchor">complexType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>&gt;...</td></tr>
1028<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types.
1029
1030Given
1031 _Complex float f;
1032complexType()
1033 matches "_Complex float f"
1034</pre></td></tr>
1035
1036
1037<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('constantArrayType0')"><a name="constantArrayType0Anchor">constantArrayType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>&gt;...</td></tr>
1038<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size.
1039
1040Given
1041 void() {
1042 int a[2];
1043 int b[] = { 2, 3 };
1044 int c[b[0]];
1045 }
1046constantArrayType()
1047 matches "int a[2]"
1048</pre></td></tr>
1049
1050
1051<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('dependentSizedArrayType0')"><a name="dependentSizedArrayType0Anchor">dependentSizedArrayType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayType.html">DependentSizedArrayType</a>&gt;...</td></tr>
1052<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression.
1053
1054Given
1055 template&lt;typename T, int Size&gt;
1056 class array {
1057 T data[Size];
1058 };
1059dependentSizedArrayType
1060 matches "T data[Size]"
1061</pre></td></tr>
1062
1063
Edwin Vane742d9e72013-02-25 20:43:32 +00001064<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('elaboratedType0')"><a name="elaboratedType0Anchor">elaboratedType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>&gt;...</td></tr>
1065<tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a
1066qualified name.
1067
1068Given
1069 namespace N {
1070 namespace M {
1071 class D {};
1072 }
1073 }
1074 class C {};
1075
1076 class C c;
1077 N::M::D d;
1078
1079elaboratedType() matches the type of the variable declarations of both
1080c and d.
1081</pre></td></tr>
1082
1083
Manuel Klimek41df16e2013-01-09 09:38:21 +00001084<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('functionType0')"><a name="functionType0Anchor">functionType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionType.html">FunctionType</a>&gt;...</td></tr>
1085<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes.
1086
1087Given
1088 int (*f)(int);
1089 void g();
1090functionType()
1091 matches "int (*f)(int)" and the type of "g".
1092</pre></td></tr>
1093
1094
1095<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('incompleteArrayType0')"><a name="incompleteArrayType0Anchor">incompleteArrayType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IncompleteArrayType.html">IncompleteArrayType</a>&gt;...</td></tr>
1096<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size.
1097
1098Given
1099 int a[] = { 2, 3 };
1100 int b[42];
1101 void f(int c[]) { int d[a[0]]; };
1102incompleteArrayType()
1103 matches "int a[]" and "int c[]"
1104</pre></td></tr>
1105
1106
Edwin Vane8203d9f2013-03-28 13:50:22 +00001107<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('lValueReferenceType0')"><a name="lValueReferenceType0Anchor">lValueReferenceType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LValueReferenceType.html">LValueReferenceType</a>&gt;...</td></tr>
1108<tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types.
Edwin Vanef4b48042013-03-07 15:44:40 +00001109
1110Given:
1111 int *a;
1112 int &amp;b = *a;
1113 int &amp;&amp;c = 1;
1114 auto &amp;d = b;
1115 auto &amp;&amp;e = c;
1116 auto &amp;&amp;f = 2;
1117 int g = 5;
1118
Edwin Vane8203d9f2013-03-28 13:50:22 +00001119lValueReferenceType() matches the types of b, d, and e. e is
Edwin Vanef4b48042013-03-07 15:44:40 +00001120matched since the type is deduced as int&amp; by reference collapsing rules.
1121</pre></td></tr>
1122
1123
Manuel Klimek41df16e2013-01-09 09:38:21 +00001124<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('memberPointerType0')"><a name="memberPointerType0Anchor">memberPointerType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;...</td></tr>
1125<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types.
1126Given
1127 struct A { int i; }
1128 A::* ptr = A::i;
1129memberPointerType()
1130 matches "A::* ptr"
1131</pre></td></tr>
1132
1133
Edwin Vane88be2fd2013-04-01 18:33:34 +00001134<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('parenType0')"><a name="parenType0Anchor">parenType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>&gt;...</td></tr>
1135<tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes.
1136
1137Given
1138 int (*ptr_to_array)[4];
1139 int *array_of_ptrs[4];
1140
1141varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not
1142array_of_ptrs.
1143</pre></td></tr>
1144
1145
Manuel Klimek41df16e2013-01-09 09:38:21 +00001146<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('pointerType0')"><a name="pointerType0Anchor">pointerType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;...</td></tr>
1147<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types.
1148
1149Given
1150 int *a;
1151 int &amp;b = *a;
1152 int c = 5;
1153pointerType()
1154 matches "int *a"
1155</pre></td></tr>
1156
1157
Edwin Vane8203d9f2013-03-28 13:50:22 +00001158<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('rValueReferenceType0')"><a name="rValueReferenceType0Anchor">rValueReferenceType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RValueReferenceType.html">RValueReferenceType</a>&gt;...</td></tr>
1159<tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types.
1160
1161Given:
1162 int *a;
1163 int &amp;b = *a;
1164 int &amp;&amp;c = 1;
1165 auto &amp;d = b;
1166 auto &amp;&amp;e = c;
1167 auto &amp;&amp;f = 2;
1168 int g = 5;
1169
1170rValueReferenceType() matches the types of c and f. e is not
1171matched as it is deduced to int&amp; by reference collapsing rules.
1172</pre></td></tr>
1173
1174
Edwin Vane742d9e72013-02-25 20:43:32 +00001175<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('recordType0')"><a name="recordType0Anchor">recordType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;...</td></tr>
1176<tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes).
1177
1178Given
1179 class C {};
1180 struct S {};
1181
1182 C c;
1183 S s;
1184
1185recordType() matches the type of the variable declarations of both c
1186and s.
1187</pre></td></tr>
1188
1189
Manuel Klimek41df16e2013-01-09 09:38:21 +00001190<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('referenceType0')"><a name="referenceType0Anchor">referenceType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;...</td></tr>
Edwin Vanef4b48042013-03-07 15:44:40 +00001191<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types.
Manuel Klimek41df16e2013-01-09 09:38:21 +00001192
1193Given
1194 int *a;
1195 int &amp;b = *a;
Edwin Vanef4b48042013-03-07 15:44:40 +00001196 int &amp;&amp;c = 1;
1197 auto &amp;d = b;
1198 auto &amp;&amp;e = c;
1199 auto &amp;&amp;f = 2;
1200 int g = 5;
1201
1202referenceType() matches the types of b, c, d, e, and f.
1203</pre></td></tr>
1204
1205
Edwin Vane3abf7782013-02-25 14:49:29 +00001206<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('templateSpecializationType0')"><a name="templateSpecializationType0Anchor">templateSpecializationType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;...</td></tr>
1207<tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types.
1208
1209Given
1210 template &lt;typename T&gt;
1211 class C { };
1212
1213 template class C&lt;int&gt;; A
1214 C&lt;char&gt; var; B
1215
1216templateSpecializationType() matches the type of the explicit
1217instantiation in A and the type of the variable declaration in B.
1218</pre></td></tr>
1219
1220
Daniel Jaspere0b89972012-12-04 12:08:08 +00001221<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('type0')"><a name="type0Anchor">type</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;...</td></tr>
1222<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST.
1223</pre></td></tr>
1224
Manuel Klimek41df16e2013-01-09 09:38:21 +00001225
1226<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('typedefType0')"><a name="typedefType0Anchor">typedefType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;...</td></tr>
1227<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types.
1228
1229Given
1230 typedef int X;
1231typedefType()
1232 matches "typedef int X"
1233</pre></td></tr>
1234
1235
Manuel Klimek532870f2013-07-24 05:46:07 +00001236<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('unaryTransformType0')"><a name="unaryTransformType0Anchor">unaryTransformType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryTransformType.html">UnaryTransformType</a>&gt;...</td></tr>
1237<tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations.
1238
1239Given:
1240 typedef __underlying_type(T) type;
1241unaryTransformType()
1242 matches "__underlying_type(T)"
1243</pre></td></tr>
1244
1245
Manuel Klimek41df16e2013-01-09 09:38:21 +00001246<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('variableArrayType0')"><a name="variableArrayType0Anchor">variableArrayType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VariableArrayType.html">VariableArrayType</a>&gt;...</td></tr>
1247<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an
1248integer-constant-expression.
1249
1250Given
1251 void f() {
1252 int a[] = { 2, 3 }
1253 int b[42];
1254 int c[a[0]];
1255variableArrayType()
1256 matches "int c[a[0]]"
1257</pre></td></tr>
1258
Manuel Klimek1da79332012-08-20 20:54:03 +00001259<!--END_DECL_MATCHERS -->
1260</table>
1261
1262<!-- ======================================================================= -->
1263<h2 id="narrowing-matchers">Narrowing Matchers</h2>
1264<!-- ======================================================================= -->
1265
1266<p>Narrowing matchers match certain attributes on the current node, thus
1267narrowing down the set of nodes of the current type to match on.</p>
1268
1269<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless)
1270which allow users to create more powerful match expressions.</p>
1271
1272<table>
1273<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
1274<!-- START_NARROWING_MATCHERS -->
1275
Samuel Benzaquend36e4632013-08-27 15:11:16 +00001276<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher&lt;*&gt;, ..., Matcher&lt;*&gt;</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001277<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match.
1278
1279Usable as: Any Matcher
1280</pre></td></tr>
1281
1282
Samuel Benzaquend36e4632013-08-27 15:11:16 +00001283<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher&lt;*&gt;, ..., Matcher&lt;*&gt;</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001284<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches.
1285
1286Usable as: Any Matcher
1287</pre></td></tr>
1288
1289
Manuel Klimek67619ff2012-09-07 13:10:32 +00001290<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001291<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node.
1292
1293Useful when another matcher requires a child matcher, but there's no
1294additional constraint. This will often be used with an explicit conversion
1295to an internal::Matcher&lt;&gt; type such as TypeMatcher.
1296
1297Example: DeclarationMatcher(anything()) matches all declarations, e.g.,
1298"int* p" and "void f()" in
1299 int* p;
1300 void f();
1301
1302Usable as: Any Matcher
1303</pre></td></tr>
1304
1305
Manuel Klimek67619ff2012-09-07 13:10:32 +00001306<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher&lt;*&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001307<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match.
1308
Manuel Klimeke44a0062012-08-26 23:55:24 +00001309Example matches Y (matcher = recordDecl(unless(hasName("X"))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001310 class X {};
1311 class Y {};
1312
1313Usable as: Any Matcher
1314</pre></td></tr>
1315
1316
Manuel Klimek67619ff2012-09-07 13:10:32 +00001317<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasOperatorName0')"><a name="hasOperatorName0Anchor">hasOperatorName</a></td><td>std::string Name</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001318<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or
1319unary).
1320
1321Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
1322 !(a || b)
1323</pre></td></tr>
1324
1325
Manuel Klimek67619ff2012-09-07 13:10:32 +00001326<tr><td>Matcher&lt;CXXBoolLiteral&gt;</td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>ValueT Value</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001327<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value.
1328
1329Example matches true (matcher = boolLiteral(equals(true)))
1330 true
1331
1332Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1333 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;
1334</pre></td></tr>
1335
1336
Samuel Benzaquenef7eb022013-06-21 15:51:31 +00001337<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('argumentCountIs1')"><a name="argumentCountIs1Anchor">argumentCountIs</a></td><td>unsigned N</td></tr>
1338<tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has
1339a specific number of arguments (including absent default arguments).
1340
1341Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
1342 void f(int x, int y);
1343 f(0, 0);
1344</pre></td></tr>
1345
1346
Manuel Klimek67619ff2012-09-07 13:10:32 +00001347<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001348<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a constructor declaration that has been implicitly added
1349by the compiler (eg. implicit defaultcopy constructors).
1350</pre></td></tr>
1351
1352
Manuel Klimek67619ff2012-09-07 13:10:32 +00001353<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;</td><td class="name" onclick="toggle('isWritten0')"><a name="isWritten0Anchor">isWritten</a></td><td></td></tr>
Benjamin Kramere5753592013-09-09 14:48:42 +00001354<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in
Manuel Klimek1da79332012-08-20 20:54:03 +00001355code (as opposed to implicitly added by the compiler).
1356
1357Given
1358 struct Foo {
1359 Foo() { }
1360 Foo(int) : foo_("A") { }
1361 string foo_;
1362 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00001363constructorDecl(hasAnyConstructorInitializer(isWritten()))
Manuel Klimek1da79332012-08-20 20:54:03 +00001364 will match Foo(int), but not Foo()
1365</pre></td></tr>
1366
1367
Edwin Vane6a19a972013-03-06 17:02:57 +00001368<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001369<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names.
1370
1371Matches overloaded operator names specified in strings without the
Edwin Vane6a19a972013-03-06 17:02:57 +00001372"operator" prefix: e.g. "&lt;&lt;".
Manuel Klimek1da79332012-08-20 20:54:03 +00001373
Edwin Vane6a19a972013-03-06 17:02:57 +00001374Given:
1375 class A { int operator*(); };
1376 const A &amp;operator&lt;&lt;(const A &amp;a, const A &amp;b);
1377 A a;
1378 a &lt;&lt; a; &lt;-- This matches
1379
1380operatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the specified
1381line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches
1382the declaration of A.
1383
1384Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;
1385</pre></td></tr>
1386
1387
Edwin Vane32a6ebc2013-05-09 17:00:17 +00001388<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isConst0')"><a name="isConst0Anchor">isConst</a></td><td></td></tr>
1389<tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const.
1390
1391Given
1392struct A {
1393 void foo() const;
1394 void bar();
1395};
1396
1397methodDecl(isConst()) matches A::foo() but not A::bar()
1398</pre></td></tr>
1399
1400
Edwin Vane5771a2f2013-04-09 20:46:36 +00001401<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isOverride0')"><a name="isOverride0Anchor">isOverride</a></td><td></td></tr>
1402<tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method.
1403
1404Given
1405 class A {
1406 public:
1407 virtual void x();
1408 };
1409 class B : public A {
1410 public:
1411 virtual void x();
1412 };
1413 matches B::x
1414</pre></td></tr>
1415
1416
1417<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isVirtual0')"><a name="isVirtual0Anchor">isVirtual</a></td><td></td></tr>
1418<tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual.
1419
1420Given
1421 class A {
1422 public:
1423 virtual void x();
1424 };
1425 matches A::x
1426</pre></td></tr>
1427
1428
Edwin Vane6a19a972013-03-06 17:02:57 +00001429<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;</td><td class="name" onclick="toggle('hasOverloadedOperatorName1')"><a name="hasOverloadedOperatorName1Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr>
1430<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names.
1431
1432Matches overloaded operator names specified in strings without the
1433"operator" prefix: e.g. "&lt;&lt;".
1434
1435Given:
1436 class A { int operator*(); };
1437 const A &amp;operator&lt;&lt;(const A &amp;a, const A &amp;b);
1438 A a;
1439 a &lt;&lt; a; &lt;-- This matches
1440
1441operatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the specified
1442line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches
1443the declaration of A.
1444
1445Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;
Manuel Klimek1da79332012-08-20 20:54:03 +00001446</pre></td></tr>
1447
1448
Manuel Klimek67619ff2012-09-07 13:10:32 +00001449<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isDerivedFrom1')"><a name="isDerivedFrom1Anchor">isDerivedFrom</a></td><td>StringRef BaseName</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001450<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
1451</pre></td></tr>
1452
1453
Manuel Klimek415514d2013-02-06 20:36:22 +00001454<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isExplicitTemplateSpecialization2')"><a name="isExplicitTemplateSpecialization2Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr>
1455<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or
Manuel Klimek1da79332012-08-20 20:54:03 +00001456static member variable template instantiations.
1457
1458Given
1459 template&lt;typename T&gt; void A(T t) { }
1460 template&lt;&gt; void A(int N) { }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001461functionDecl(isExplicitTemplateSpecialization())
Manuel Klimek1da79332012-08-20 20:54:03 +00001462 matches the specialization A&lt;int&gt;().
1463
1464Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
1465</pre></td></tr>
1466
1467
Daniel Jaspere0b89972012-12-04 12:08:08 +00001468<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isSameOrDerivedFrom1')"><a name="isSameOrDerivedFrom1Anchor">isSameOrDerivedFrom</a></td><td>StringRef BaseName</td></tr>
1469<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for
1470isSameOrDerivedFrom(hasName(...)).
1471</pre></td></tr>
1472
1473
Manuel Klimek415514d2013-02-06 20:36:22 +00001474<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isTemplateInstantiation2')"><a name="isTemplateInstantiation2Anchor">isTemplateInstantiation</a></td><td></td></tr>
1475<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static
Manuel Klimek1da79332012-08-20 20:54:03 +00001476member variable template instantiations.
1477
1478Given
1479 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
1480or
1481 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001482recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001483 matches the template instantiation of X&lt;A&gt;.
1484
1485But given
1486 template &lt;typename T&gt; class X {}; class A {};
1487 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001488recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001489 does not match, as X&lt;A&gt; is an explicit template specialization.
1490
1491Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
1492</pre></td></tr>
1493
1494
Manuel Klimek67619ff2012-09-07 13:10:32 +00001495<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('argumentCountIs0')"><a name="argumentCountIs0Anchor">argumentCountIs</a></td><td>unsigned N</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001496<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has
1497a specific number of arguments (including absent default arguments).
1498
Manuel Klimeke44a0062012-08-26 23:55:24 +00001499Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
Manuel Klimek1da79332012-08-20 20:54:03 +00001500 void f(int x, int y);
1501 f(0, 0);
1502</pre></td></tr>
1503
1504
Manuel Klimek67619ff2012-09-07 13:10:32 +00001505<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;</td><td class="name" onclick="toggle('equals3')"><a name="equals3Anchor">equals</a></td><td>ValueT Value</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001506<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value.
1507
1508Example matches true (matcher = boolLiteral(equals(true)))
1509 true
1510
1511Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1512 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;
1513</pre></td></tr>
1514
1515
Manuel Klimek67619ff2012-09-07 13:10:32 +00001516<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>&gt;</td><td class="name" onclick="toggle('statementCountIs0')"><a name="statementCountIs0Anchor">statementCountIs</a></td><td>unsigned N</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001517<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of
1518child statements.
1519
1520Example: Given
1521 { for (;;) {} }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001522compoundStmt(statementCountIs(0)))
Manuel Klimek1da79332012-08-20 20:54:03 +00001523 matches '{}'
1524 but does not match the outer compound statement.
1525</pre></td></tr>
1526
1527
Daniel Jaspere0b89972012-12-04 12:08:08 +00001528<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>&gt;</td><td class="name" onclick="toggle('hasSize0')"><a name="hasSize0Anchor">hasSize</a></td><td>unsigned N</td></tr>
1529<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size.
1530
1531Given
1532 int a[42];
1533 int b[2 * 21];
1534 int c[41], d[43];
1535constantArrayType(hasSize(42))
1536 matches "int a[42]" and "int b[2 * 21]"
1537</pre></td></tr>
1538
1539
Manuel Klimek67619ff2012-09-07 13:10:32 +00001540<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>&gt;</td><td class="name" onclick="toggle('declCountIs0')"><a name="declCountIs0Anchor">declCountIs</a></td><td>unsigned N</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001541<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of
1542declarations.
1543
1544Example: Given
1545 int a, b;
1546 int c;
1547 int d = 2, e;
1548declCountIs(2)
1549 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.
1550</pre></td></tr>
1551
1552
Manuel Klimekcf52ca62013-06-20 14:06:32 +00001553<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('equalsBoundNode1')"><a name="equalsBoundNode1Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr>
1554<tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node.
1555
1556Matches a node if it equals the node previously bound to ID.
1557
1558Given
1559 class X { int a; int b; };
1560recordDecl(
1561 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
1562 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
1563 matches the class X, as a and b have the same type.
1564
1565Note that when multiple matches are involved via forEach* matchers,
1566equalsBoundNodes acts as a filter.
1567For example:
1568compoundStmt(
1569 forEachDescendant(varDecl().bind("d")),
1570 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
1571will trigger a match for each combination of variable declaration
1572and reference to that variable declaration within a compound statement.
1573</pre></td></tr>
1574
1575
Manuel Klimekfa37c5c2013-02-07 12:42:10 +00001576<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('equalsNode0')"><a name="equalsNode0Anchor">equalsNode</a></td><td>Decl* Other</td></tr>
1577<tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node.
1578
1579Decl has pointer identity in the AST.
1580</pre></td></tr>
1581
1582
Daniel Jasperc7093d92013-02-25 12:39:41 +00001583<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isPrivate0')"><a name="isPrivate0Anchor">isPrivate</a></td><td></td></tr>
1584<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations.
1585
1586Given
1587 class C {
1588 public: int a;
1589 protected: int b;
1590 private: int c;
1591 };
1592fieldDecl(isPrivate())
1593 matches 'int c;'
1594</pre></td></tr>
1595
1596
1597<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isProtected0')"><a name="isProtected0Anchor">isProtected</a></td><td></td></tr>
1598<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations.
1599
1600Given
1601 class C {
1602 public: int a;
1603 protected: int b;
1604 private: int c;
1605 };
1606fieldDecl(isProtected())
1607 matches 'int b;'
1608</pre></td></tr>
1609
1610
1611<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isPublic0')"><a name="isPublic0Anchor">isPublic</a></td><td></td></tr>
1612<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations.
1613
1614Given
1615 class C {
1616 public: int a;
1617 protected: int b;
1618 private: int c;
1619 };
1620fieldDecl(isPublic())
1621 matches 'int a;'
1622</pre></td></tr>
1623
1624
Manuel Klimek67619ff2012-09-07 13:10:32 +00001625<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>&gt;</td><td class="name" onclick="toggle('equals1')"><a name="equals1Anchor">equals</a></td><td>ValueT Value</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001626<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value.
1627
1628Example matches true (matcher = boolLiteral(equals(true)))
1629 true
1630
1631Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1632 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;
1633</pre></td></tr>
1634
1635
Manuel Klimek415514d2013-02-06 20:36:22 +00001636<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isDefinition2')"><a name="isDefinition2Anchor">isDefinition</a></td><td></td></tr>
1637<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached.
Manuel Klimek1da79332012-08-20 20:54:03 +00001638
1639Example matches A, va, fa
1640 class A {};
1641 class B; Doesn't match, as it has no body.
1642 int va;
1643 extern int vb; Doesn't match, as it doesn't define the variable.
1644 void fa() {}
1645 void fb(); Doesn't match, as it has no body.
1646
1647Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;
1648</pre></td></tr>
1649
1650
Manuel Klimek415514d2013-02-06 20:36:22 +00001651<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isExplicitTemplateSpecialization0')"><a name="isExplicitTemplateSpecialization0Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr>
1652<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or
Manuel Klimek1da79332012-08-20 20:54:03 +00001653static member variable template instantiations.
1654
1655Given
1656 template&lt;typename T&gt; void A(T t) { }
1657 template&lt;&gt; void A(int N) { }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001658functionDecl(isExplicitTemplateSpecialization())
Manuel Klimek1da79332012-08-20 20:54:03 +00001659 matches the specialization A&lt;int&gt;().
1660
1661Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
1662</pre></td></tr>
1663
1664
Manuel Klimek67619ff2012-09-07 13:10:32 +00001665<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isExternC0')"><a name="isExternC0Anchor">isExternC</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001666<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations.
1667
1668Given:
1669 extern "C" void f() {}
1670 extern "C" { void g() {} }
1671 void h() {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00001672functionDecl(isExternC())
Manuel Klimek1da79332012-08-20 20:54:03 +00001673 matches the declaration of f and g, but not the declaration h
1674</pre></td></tr>
1675
1676
Manuel Klimek415514d2013-02-06 20:36:22 +00001677<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isTemplateInstantiation0')"><a name="isTemplateInstantiation0Anchor">isTemplateInstantiation</a></td><td></td></tr>
1678<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static
Manuel Klimek1da79332012-08-20 20:54:03 +00001679member variable template instantiations.
1680
1681Given
1682 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
1683or
1684 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001685recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001686 matches the template instantiation of X&lt;A&gt;.
1687
1688But given
1689 template &lt;typename T&gt; class X {}; class A {};
1690 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001691recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001692 does not match, as X&lt;A&gt; is an explicit template specialization.
1693
1694Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
1695</pre></td></tr>
1696
1697
Daniel Jaspere0b89972012-12-04 12:08:08 +00001698<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('parameterCountIs0')"><a name="parameterCountIs0Anchor">parameterCountIs</a></td><td>unsigned N</td></tr>
1699<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count.
1700
1701Given
1702 void f(int i) {}
1703 void g(int i, int j) {}
1704functionDecl(parameterCountIs(2))
1705 matches g(int i, int j) {}
1706</pre></td></tr>
1707
1708
Manuel Klimek67619ff2012-09-07 13:10:32 +00001709<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;</td><td class="name" onclick="toggle('equals0')"><a name="equals0Anchor">equals</a></td><td>ValueT Value</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001710<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value.
1711
1712Example matches true (matcher = boolLiteral(equals(true)))
1713 true
1714
1715Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1716 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;
1717</pre></td></tr>
1718
1719
Manuel Klimek67619ff2012-09-07 13:10:32 +00001720<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;</td><td class="name" onclick="toggle('isArrow0')"><a name="isArrow0Anchor">isArrow</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001721<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '-&gt;' as opposed
1722to '.'.
1723
1724Member calls on the implicit this pointer match as called with '-&gt;'.
1725
1726Given
1727 class Y {
1728 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
1729 int a;
1730 static int b;
1731 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00001732memberExpr(isArrow())
Manuel Klimek1da79332012-08-20 20:54:03 +00001733 matches this-&gt;x, x, y.x, a, this-&gt;b
1734</pre></td></tr>
1735
1736
Manuel Klimek67619ff2012-09-07 13:10:32 +00001737<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt;</td><td class="name" onclick="toggle('hasName0')"><a name="hasName0Anchor">hasName</a></td><td>std::string Name</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001738<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name.
1739
1740Supports specifying enclosing namespaces or classes by prefixing the name
1741with '&lt;enclosing&gt;::'.
1742Does not match typedefs of an underlying type with the given name.
1743
1744Example matches X (Name == "X")
1745 class X;
1746
1747Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
1748 namespace a { namespace b { class X; } }
1749</pre></td></tr>
1750
1751
Manuel Klimek67619ff2012-09-07 13:10:32 +00001752<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt;</td><td class="name" onclick="toggle('matchesName0')"><a name="matchesName0Anchor">matchesName</a></td><td>std::string RegExp</td></tr>
Manuel Klimek41df16e2013-01-09 09:38:21 +00001753<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain
1754a substring matched by the given RegExp.
Manuel Klimek1da79332012-08-20 20:54:03 +00001755
1756Supports specifying enclosing namespaces or classes by
1757prefixing the name with '&lt;enclosing&gt;::'. Does not match typedefs
1758of an underlying type with the given name.
1759
1760Example matches X (regexp == "::X")
1761 class X;
1762
1763Example matches X (regexp is one of "::X", "^foo::.*X", among others)
1764 namespace foo { namespace bar { class X; } }
1765</pre></td></tr>
1766
1767
Manuel Klimek67619ff2012-09-07 13:10:32 +00001768<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('asString0')"><a name="asString0Anchor">asString</a></td><td>std::string Name</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001769<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string.
1770
1771Given
1772 class Y { public: void x(); };
1773 void z() { Y* y; y-&gt;x(); }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001774callExpr(on(hasType(asString("class Y *"))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001775 matches y-&gt;x()
1776</pre></td></tr>
1777
1778
Manuel Klimekcf52ca62013-06-20 14:06:32 +00001779<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('equalsBoundNode3')"><a name="equalsBoundNode3Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr>
1780<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node.
1781
1782Matches a node if it equals the node previously bound to ID.
1783
1784Given
1785 class X { int a; int b; };
1786recordDecl(
1787 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
1788 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
1789 matches the class X, as a and b have the same type.
1790
1791Note that when multiple matches are involved via forEach* matchers,
1792equalsBoundNodes acts as a filter.
1793For example:
1794compoundStmt(
1795 forEachDescendant(varDecl().bind("d")),
1796 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
1797will trigger a match for each combination of variable declaration
1798and reference to that variable declaration within a compound statement.
1799</pre></td></tr>
1800
1801
Edwin Vane7b69cd02013-04-02 18:15:55 +00001802<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('hasLocalQualifiers0')"><a name="hasLocalQualifiers0Anchor">hasLocalQualifiers</a></td><td></td></tr>
1803<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to
1804the node, not hidden within a typedef.
1805
1806Given
1807 typedef const int const_int;
1808 const_int i;
1809 int *const j;
1810 int *volatile k;
1811 int m;
1812varDecl(hasType(hasLocalQualifiers())) matches only j and k.
1813i is const-qualified but the qualifier is not local.
1814</pre></td></tr>
1815
1816
Manuel Klimek67619ff2012-09-07 13:10:32 +00001817<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('isConstQualified0')"><a name="isConstQualified0Anchor">isConstQualified</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001818<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that
1819include "top-level" const.
1820
1821Given
1822 void a(int);
1823 void b(int const);
1824 void c(const int);
1825 void d(const int*);
1826 void e(int const) {};
Manuel Klimeke44a0062012-08-26 23:55:24 +00001827functionDecl(hasAnyParameter(hasType(isConstQualified())))
Manuel Klimek1da79332012-08-20 20:54:03 +00001828 matches "void b(int const)", "void c(const int)" and
1829 "void e(int const) {}". It does not match d as there
1830 is no top-level const on the parameter type "const int *".
1831</pre></td></tr>
1832
1833
Manuel Klimek67619ff2012-09-07 13:10:32 +00001834<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('isInteger0')"><a name="isInteger0Anchor">isInteger</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001835<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type.
1836
1837Given
1838 void a(int);
1839 void b(long);
1840 void c(double);
Manuel Klimeke44a0062012-08-26 23:55:24 +00001841functionDecl(hasAnyParameter(hasType(isInteger())))
Manuel Klimek1da79332012-08-20 20:54:03 +00001842matches "a(int)", "b(long)", but not "c(double)".
1843</pre></td></tr>
1844
1845
Manuel Klimekcf52ca62013-06-20 14:06:32 +00001846<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('equalsBoundNode0')"><a name="equalsBoundNode0Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr>
1847<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node.
1848
1849Matches a node if it equals the node previously bound to ID.
1850
1851Given
1852 class X { int a; int b; };
1853recordDecl(
1854 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
1855 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
1856 matches the class X, as a and b have the same type.
1857
1858Note that when multiple matches are involved via forEach* matchers,
1859equalsBoundNodes acts as a filter.
1860For example:
1861compoundStmt(
1862 forEachDescendant(varDecl().bind("d")),
1863 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
1864will trigger a match for each combination of variable declaration
1865and reference to that variable declaration within a compound statement.
1866</pre></td></tr>
1867
1868
Manuel Klimekfa37c5c2013-02-07 12:42:10 +00001869<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('equalsNode1')"><a name="equalsNode1Anchor">equalsNode</a></td><td>Stmt* Other</td></tr>
1870<tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node.
1871
1872Stmt has pointer identity in the AST.
1873
1874</pre></td></tr>
1875
1876
Manuel Klimek415514d2013-02-06 20:36:22 +00001877<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;</td><td class="name" onclick="toggle('isDefinition0')"><a name="isDefinition0Anchor">isDefinition</a></td><td></td></tr>
1878<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached.
Manuel Klimek1da79332012-08-20 20:54:03 +00001879
1880Example matches A, va, fa
1881 class A {};
1882 class B; Doesn't match, as it has no body.
1883 int va;
1884 extern int vb; Doesn't match, as it doesn't define the variable.
1885 void fa() {}
1886 void fb(); Doesn't match, as it has no body.
1887
1888Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;
1889</pre></td></tr>
1890
1891
Manuel Klimekcf52ca62013-06-20 14:06:32 +00001892<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('equalsBoundNode2')"><a name="equalsBoundNode2Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr>
1893<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node.
1894
1895Matches a node if it equals the node previously bound to ID.
1896
1897Given
1898 class X { int a; int b; };
1899recordDecl(
1900 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
1901 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
1902 matches the class X, as a and b have the same type.
1903
1904Note that when multiple matches are involved via forEach* matchers,
1905equalsBoundNodes acts as a filter.
1906For example:
1907compoundStmt(
1908 forEachDescendant(varDecl().bind("d")),
1909 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
1910will trigger a match for each combination of variable declaration
1911and reference to that variable declaration within a compound statement.
1912</pre></td></tr>
1913
1914
Manuel Klimek67619ff2012-09-07 13:10:32 +00001915<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt;</td><td class="name" onclick="toggle('ofKind0')"><a name="ofKind0Anchor">ofKind</a></td><td>UnaryExprOrTypeTrait Kind</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001916<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind.
1917
1918Given
1919 int x;
1920 int s = sizeof(x) + alignof(x)
1921unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
1922 matches sizeof(x)
1923</pre></td></tr>
1924
1925
Manuel Klimek67619ff2012-09-07 13:10:32 +00001926<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasOperatorName1')"><a name="hasOperatorName1Anchor">hasOperatorName</a></td><td>std::string Name</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001927<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or
1928unary).
1929
1930Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
1931 !(a || b)
1932</pre></td></tr>
1933
1934
Manuel Klimek67619ff2012-09-07 13:10:32 +00001935<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isDefinition1')"><a name="isDefinition1Anchor">isDefinition</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001936<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached.
1937
1938Example matches A, va, fa
1939 class A {};
1940 class B; Doesn't match, as it has no body.
1941 int va;
1942 extern int vb; Doesn't match, as it doesn't define the variable.
1943 void fa() {}
1944 void fb(); Doesn't match, as it has no body.
1945
1946Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;
1947</pre></td></tr>
1948
1949
Manuel Klimek67619ff2012-09-07 13:10:32 +00001950<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isExplicitTemplateSpecialization1')"><a name="isExplicitTemplateSpecialization1Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001951<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or
1952static member variable template instantiations.
1953
1954Given
1955 template&lt;typename T&gt; void A(T t) { }
1956 template&lt;&gt; void A(int N) { }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001957functionDecl(isExplicitTemplateSpecialization())
Manuel Klimek1da79332012-08-20 20:54:03 +00001958 matches the specialization A&lt;int&gt;().
1959
1960Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
1961</pre></td></tr>
1962
1963
Manuel Klimek67619ff2012-09-07 13:10:32 +00001964<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isTemplateInstantiation1')"><a name="isTemplateInstantiation1Anchor">isTemplateInstantiation</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001965<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static
1966member variable template instantiations.
1967
1968Given
1969 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
1970or
1971 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001972recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001973 matches the template instantiation of X&lt;A&gt;.
1974
1975But given
1976 template &lt;typename T&gt; class X {}; class A {};
1977 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001978recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001979 does not match, as X&lt;A&gt; is an explicit template specialization.
1980
1981Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
1982</pre></td></tr>
1983
1984<!--END_NARROWING_MATCHERS -->
1985</table>
1986
1987<!-- ======================================================================= -->
1988<h2 id="traversal-matchers">AST Traversal Matchers</h2>
1989<!-- ======================================================================= -->
1990
1991<p>Traversal matchers specify the relationship to other nodes that are
1992reachable from the current node.</p>
1993
1994<p>Note that there are special traversal matchers (has, hasDescendant, forEach and
1995forEachDescendant) which work on all nodes and allow users to write more generic
1996match expressions.</p>
1997
1998<table>
1999<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
2000<!-- START_TRAVERSAL_MATCHERS -->
2001
Samuel Benzaquend36e4632013-08-27 15:11:16 +00002002<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher&lt;*&gt;, ..., Matcher&lt;*&gt;</td></tr>
Manuel Klimek152ea0e2013-02-04 10:59:20 +00002003<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches.
2004
2005Unlike anyOf, eachOf will generate a match result for each
2006matching submatcher.
2007
2008For example, in:
2009 class A { int a; int b; };
2010The matcher:
2011 recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
2012 has(fieldDecl(hasName("b")).bind("v"))))
2013will generate two results binding "v", the first of which binds
2014the field declaration of a, the second the field declaration of
2015b.
2016
2017Usable as: Any Matcher
2018</pre></td></tr>
2019
2020
Samuel Benzaquenee0da952013-08-16 16:19:42 +00002021<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher&lt;*&gt;</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002022<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the
2023provided matcher.
2024
Manuel Klimeke44a0062012-08-26 23:55:24 +00002025Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X")))
Manuel Klimek1da79332012-08-20 20:54:03 +00002026 class X {}; Matches X, because X::X is a class of name X inside X.
2027 class Y { class X {}; };
2028 class Z { class Y { class X {}; }; }; Does not match Z.
2029
2030ChildT must be an AST base type.
2031
2032As opposed to 'has', 'forEach' will cause a match for each result that
2033matches instead of only on the first one.
2034
2035Usable as: Any Matcher
2036</pre></td></tr>
2037
2038
Samuel Benzaquenee0da952013-08-16 16:19:42 +00002039<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher&lt;*&gt;</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002040<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
2041provided matcher.
2042
2043Example matches X, A, B, C
Manuel Klimeke44a0062012-08-26 23:55:24 +00002044 (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002045 class X {}; Matches X, because X::X is a class of name X inside X.
2046 class A { class X {}; };
2047 class B { class C { class X {}; }; };
2048
2049DescendantT must be an AST base type.
2050
2051As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
2052each result that matches instead of only on the first one.
2053
2054Note: Recursively combined ForEachDescendant can cause many matches:
Manuel Klimeke44a0062012-08-26 23:55:24 +00002055 recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl()))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002056will match 10 times (plus injected class name matches) on:
2057 class A { class B { class C { class D { class E {}; }; }; }; };
2058
2059Usable as: Any Matcher
2060</pre></td></tr>
2061
2062
Samuel Benzaquenee0da952013-08-16 16:19:42 +00002063<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher&lt;*&gt;</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002064<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the
2065provided matcher.
2066
Manuel Klimeke44a0062012-08-26 23:55:24 +00002067Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X")))
Manuel Klimek1da79332012-08-20 20:54:03 +00002068 class X {}; Matches X, because X::X is a class of name X inside X.
2069 class Y { class X {}; };
2070 class Z { class Y { class X {}; }; }; Does not match Z.
2071
2072ChildT must be an AST base type.
2073
2074Usable as: Any Matcher
2075</pre></td></tr>
2076
2077
Samuel Benzaquenee0da952013-08-16 16:19:42 +00002078<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher&lt;*&gt;</td></tr>
Manuel Klimek67619ff2012-09-07 13:10:32 +00002079<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided
2080matcher.
2081
2082Given
2083void f() { if (true) { int x = 42; } }
2084void g() { for (;;) { int x = 43; } }
Daniel Jaspere0b89972012-12-04 12:08:08 +00002085expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.
Manuel Klimek67619ff2012-09-07 13:10:32 +00002086
2087Usable as: Any Matcher
2088</pre></td></tr>
2089
2090
Samuel Benzaquenee0da952013-08-16 16:19:42 +00002091<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher&lt;*&gt;</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002092<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
2093provided matcher.
2094
2095Example matches X, Y, Z
Manuel Klimeke44a0062012-08-26 23:55:24 +00002096 (matcher = recordDecl(hasDescendant(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002097 class X {}; Matches X, because X::X is a class of name X inside X.
2098 class Y { class X {}; };
2099 class Z { class Y { class X {}; }; };
2100
2101DescendantT must be an AST base type.
2102
2103Usable as: Any Matcher
2104</pre></td></tr>
2105
2106
Samuel Benzaquenee0da952013-08-16 16:19:42 +00002107<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher&lt;*&gt;</td></tr>
Daniel Jaspere0b89972012-12-04 12:08:08 +00002108<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided
2109matcher.
2110
2111Given
2112void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
2113compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".
2114
2115Usable as: Any Matcher
2116</pre></td></tr>
2117
2118
Manuel Klimek67619ff2012-09-07 13:10:32 +00002119<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>&gt;</td><td class="name" onclick="toggle('hasBase0')"><a name="hasBase0Anchor">hasBase</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002120<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression.
2121
2122Given
2123 int i[5];
2124 void f() { i[1] = 42; }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002125arraySubscriptExpression(hasBase(implicitCastExpr(
2126 hasSourceExpression(declRefExpr()))))
2127 matches i[1] with the declRefExpr() matching i
Manuel Klimek1da79332012-08-20 20:54:03 +00002128</pre></td></tr>
2129
2130
Manuel Klimek67619ff2012-09-07 13:10:32 +00002131<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>&gt;</td><td class="name" onclick="toggle('hasIndex0')"><a name="hasIndex0Anchor">hasIndex</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002132<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression.
2133
2134Given
2135 int i[5];
2136 void f() { i[1] = 42; }
2137arraySubscriptExpression(hasIndex(integerLiteral()))
2138 matches i[1] with the integerLiteral() matching 1
2139</pre></td></tr>
2140
2141
Samuel Benzaquen3f84bb32013-07-15 19:25:06 +00002142<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayTypeLoc.html">ArrayTypeLoc</a>&gt;</td><td class="name" onclick="toggle('hasElementTypeLoc0')"><a name="hasElementTypeLoc0Anchor">hasElementTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td></tr>
2143<tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element
Manuel Klimek41df16e2013-01-09 09:38:21 +00002144type.
2145
2146Given
2147 struct A {};
2148 A a[7];
2149 int b[7];
2150arrayType(hasElementType(builtinType()))
2151 matches "int b[7]"
2152
2153Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>&gt;
2154</pre></td></tr>
2155
2156
Samuel Benzaquen3f84bb32013-07-15 19:25:06 +00002157<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>&gt;</td><td class="name" onclick="toggle('hasElementType0')"><a name="hasElementType0Anchor">hasElementType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
2158<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element
Manuel Klimek41df16e2013-01-09 09:38:21 +00002159type.
2160
2161Given
2162 struct A {};
2163 A a[7];
2164 int b[7];
2165arrayType(hasElementType(builtinType()))
2166 matches "int b[7]"
2167
2168Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>&gt;
2169</pre></td></tr>
2170
2171
2172<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicTypeLoc.html">AtomicTypeLoc</a>&gt;</td><td class="name" onclick="toggle('hasValueTypeLoc0')"><a name="hasValueTypeLoc0Anchor">hasValueTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td></tr>
2173<tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type.
2174
2175Given
2176 _Atomic(int) i;
2177 _Atomic(float) f;
2178atomicType(hasValueType(isInteger()))
2179 matches "_Atomic(int) i"
2180
2181Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
2182</pre></td></tr>
2183
2184
2185<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;</td><td class="name" onclick="toggle('hasValueType0')"><a name="hasValueType0Anchor">hasValueType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
2186<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type.
2187
2188Given
2189 _Atomic(int) i;
2190 _Atomic(float) f;
2191atomicType(hasValueType(isInteger()))
2192 matches "_Atomic(int) i"
2193
2194Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
2195</pre></td></tr>
2196
2197
2198<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>&gt;</td><td class="name" onclick="toggle('hasDeducedType0')"><a name="hasDeducedType0Anchor">hasDeducedType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
2199<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type.
2200
2201Note: There is no TypeLoc for the deduced type and thus no
2202getDeducedLoc() matcher.
2203
2204Given
2205 auto a = 1;
2206 auto b = 2.0;
2207autoType(hasDeducedType(isInteger()))
2208 matches "auto a"
2209
2210Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>&gt;
2211</pre></td></tr>
2212
2213
Manuel Klimek67619ff2012-09-07 13:10:32 +00002214<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasEitherOperand0')"><a name="hasEitherOperand0Anchor">hasEitherOperand</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002215<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a
2216binary operator matches.
2217</pre></td></tr>
2218
2219
Manuel Klimek67619ff2012-09-07 13:10:32 +00002220<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasLHS0')"><a name="hasLHS0Anchor">hasLHS</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002221<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions.
2222
2223Example matches a (matcher = binaryOperator(hasLHS()))
2224 a || b
2225</pre></td></tr>
2226
2227
Manuel Klimek67619ff2012-09-07 13:10:32 +00002228<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasRHS0')"><a name="hasRHS0Anchor">hasRHS</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002229<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions.
2230
2231Example matches b (matcher = binaryOperator(hasRHS()))
2232 a || b
2233</pre></td></tr>
2234
2235
Samuel Benzaquen3f84bb32013-07-15 19:25:06 +00002236<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerTypeLoc.html">BlockPointerTypeLoc</a>&gt;</td><td class="name" onclick="toggle('pointeeLoc0')"><a name="pointeeLoc0Anchor">pointeeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td></tr>
2237<tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the
Manuel Klimek41df16e2013-01-09 09:38:21 +00002238pointee matches a given matcher.
2239
2240Given
2241 int *a;
2242 int const *b;
2243 float const *f;
2244pointerType(pointee(isConstQualified(), isInteger()))
2245 matches "int const *b"
2246
2247Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;,
2248 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;
2249</pre></td></tr>
2250
2251
Samuel Benzaquen3f84bb32013-07-15 19:25:06 +00002252<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;</td><td class="name" onclick="toggle('pointee0')"><a name="pointee0Anchor">pointee</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
2253<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the
Manuel Klimek41df16e2013-01-09 09:38:21 +00002254pointee matches a given matcher.
2255
2256Given
2257 int *a;
2258 int const *b;
2259 float const *f;
2260pointerType(pointee(isConstQualified(), isInteger()))
2261 matches "int const *b"
2262
2263Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;,
2264 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;
2265</pre></td></tr>
2266
2267
Samuel Benzaquenef7eb022013-06-21 15:51:31 +00002268<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnyArgument1')"><a name="hasAnyArgument1Anchor">hasAnyArgument</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
2269<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call
2270expression.
2271
2272Given
2273 void x(int, int, int) { int y; x(1, y, 42); }
2274callExpr(hasAnyArgument(declRefExpr()))
2275 matches x(1, y, 42)
2276with hasAnyArgument(...)
2277 matching y
2278
2279FIXME: Currently this will ignore parentheses and implicit casts on
2280the argument before applying the inner matcher. We'll want to remove
2281this to allow for greater control by the user once ignoreImplicit()
2282has been implemented.
2283</pre></td></tr>
2284
2285
2286<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('hasArgument1')"><a name="hasArgument1Anchor">hasArgument</a></td><td>unsigned N, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
2287<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor
2288call expression.
2289
2290Example matches y in x(y)
2291 (matcher = callExpr(hasArgument(0, declRefExpr())))
2292 void x(int) { int y; x(y); }
2293</pre></td></tr>
2294
2295
Edwin Vane3abf7782013-02-25 14:49:29 +00002296<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration3')"><a name="hasDeclaration3Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek03a83232013-06-10 08:52:15 +00002297<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node
2298matches the given matcher.
Manuel Klimek1da79332012-08-20 20:54:03 +00002299
Manuel Klimek03a83232013-06-10 08:52:15 +00002300The associated declaration is:
2301- for type nodes, the declaration of the underlying type
2302- for CallExpr, the declaration of the callee
2303- for MemberExpr, the declaration of the referenced member
2304- for CXXConstructExpr, the declaration of the constructor
2305
2306Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
2307function. e.g. various subtypes of clang::Type and various expressions.
2308FIXME: Add all node types for which this is matcher is usable due to
2309getDecl().
Edwin Vane52380602013-02-19 17:14:34 +00002310
Daniel Jaspere0b89972012-12-04 12:08:08 +00002311Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
Edwin Vane3abf7782013-02-25 14:49:29 +00002312 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
2313 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;
Manuel Klimek1da79332012-08-20 20:54:03 +00002314</pre></td></tr>
2315
2316
Manuel Klimek532870f2013-07-24 05:46:07 +00002317<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('forEachConstructorInitializer0')"><a name="forEachConstructorInitializer0Anchor">forEachConstructorInitializer</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt; InnerMatcher</td></tr>
2318<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition.
2319
2320Given
2321 class A { A() : i(42), j(42) {} int i; int j; };
2322constructorDecl(forEachConstructorInitializer(forField(decl().bind("x"))))
2323 will trigger two matches, binding for 'i' and 'j' respectively.
2324</pre></td></tr>
2325
2326
Manuel Klimek67619ff2012-09-07 13:10:32 +00002327<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyConstructorInitializer0')"><a name="hasAnyConstructorInitializer0Anchor">hasAnyConstructorInitializer</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002328<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer.
2329
2330Given
2331 struct Foo {
2332 Foo() : foo_(1) { }
2333 int foo_;
2334 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002335recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything()))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002336 record matches Foo, hasAnyConstructorInitializer matches foo_(1)
2337</pre></td></tr>
2338
2339
Manuel Klimek67619ff2012-09-07 13:10:32 +00002340<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;</td><td class="name" onclick="toggle('forField0')"><a name="forField0Anchor">forField</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002341<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer.
2342
2343Given
2344 struct Foo {
2345 Foo() : foo_(1) { }
2346 int foo_;
2347 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002348recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
Manuel Klimek1da79332012-08-20 20:54:03 +00002349 forField(hasName("foo_"))))))
2350 matches Foo
2351with forField matching foo_
2352</pre></td></tr>
2353
2354
Manuel Klimek67619ff2012-09-07 13:10:32 +00002355<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;</td><td class="name" onclick="toggle('withInitializer0')"><a name="withInitializer0Anchor">withInitializer</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002356<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer.
2357
2358Given
2359 struct Foo {
2360 Foo() : foo_(1) { }
2361 int foo_;
2362 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002363recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
Manuel Klimek1da79332012-08-20 20:54:03 +00002364 withInitializer(integerLiteral(equals(1)))))))
2365 matches Foo
2366with withInitializer matching (1)
2367</pre></td></tr>
2368
2369
Manuel Klimek67619ff2012-09-07 13:10:32 +00002370<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>&gt;</td><td class="name" onclick="toggle('on0')"><a name="on0Anchor">on</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002371<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression.
2372
Manuel Klimeke44a0062012-08-26 23:55:24 +00002373Example matches y.x() (matcher = callExpr(on(hasType(recordDecl(hasName("Y"))))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002374 class Y { public: void x(); };
2375 void z() { Y y; y.x(); }",
2376
2377FIXME: Overload to allow directly matching types?
2378</pre></td></tr>
2379
2380
Manuel Klimek67619ff2012-09-07 13:10:32 +00002381<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>&gt;</td><td class="name" onclick="toggle('onImplicitObjectArgument0')"><a name="onImplicitObjectArgument0Anchor">onImplicitObjectArgument</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002382<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr>
2383
2384
Manuel Klimek532870f2013-07-24 05:46:07 +00002385<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>&gt;</td><td class="name" onclick="toggle('thisPointerType1')"><a name="thisPointerType1Anchor">thisPointerType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002386<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration.
2387</pre></td></tr>
2388
2389
Manuel Klimek67619ff2012-09-07 13:10:32 +00002390<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('ofClass0')"><a name="ofClass0Anchor">ofClass</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002391<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration
2392belongs to.
2393
2394FIXME: Generalize this for other kinds of declarations.
2395FIXME: What other kind of declarations would we need to generalize
2396this to?
2397
2398Example matches A() in the last line
Manuel Klimeke44a0062012-08-26 23:55:24 +00002399 (matcher = constructExpr(hasDeclaration(methodDecl(
Manuel Klimek1da79332012-08-20 20:54:03 +00002400 ofClass(hasName("A"))))))
2401 class A {
2402 public:
2403 A();
2404 };
2405 A a = A();
2406</pre></td></tr>
2407
2408
Edwin Vane6a19a972013-03-06 17:02:57 +00002409<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('hasMethod0')"><a name="hasMethod0Anchor">hasMethod</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt; InnerMatcher</td></tr>
2410<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher.
2411
2412Given:
2413 class A { void func(); };
2414 class B { void member(); };
2415
2416recordDecl(hasMethod(hasName("func"))) matches the declaration of A
2417but not B.
2418</pre></td></tr>
2419
2420
Manuel Klimek67619ff2012-09-07 13:10:32 +00002421<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isDerivedFrom0')"><a name="isDerivedFrom0Anchor">isDerivedFrom</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt; Base</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002422<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from
2423a class matching Base.
2424
Manuel Klimek67619ff2012-09-07 13:10:32 +00002425Note that a class is not considered to be derived from itself.
Manuel Klimek1da79332012-08-20 20:54:03 +00002426
Manuel Klimek67619ff2012-09-07 13:10:32 +00002427Example matches Y, Z, C (Base == hasName("X"))
2428 class X;
Manuel Klimek1da79332012-08-20 20:54:03 +00002429 class Y : public X {}; directly derived
2430 class Z : public Y {}; indirectly derived
2431 typedef X A;
2432 typedef A B;
2433 class C : public B {}; derived from a typedef of X
2434
2435In the following example, Bar matches isDerivedFrom(hasName("X")):
2436 class Foo;
2437 typedef Foo X;
2438 class Bar : public Foo {}; derived from a type that X is a typedef of
2439</pre></td></tr>
2440
2441
Daniel Jaspere0b89972012-12-04 12:08:08 +00002442<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isSameOrDerivedFrom0')"><a name="isSameOrDerivedFrom0Anchor">isSameOrDerivedFrom</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt; Base</td></tr>
2443<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly
2444match Base.
2445</pre></td></tr>
2446
2447
Manuel Klimek532870f2013-07-24 05:46:07 +00002448<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('callee1')"><a name="callee1Anchor">callee</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002449<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the
2450given matcher.
2451
Manuel Klimeke44a0062012-08-26 23:55:24 +00002452Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002453 class Y { public: void x(); };
2454 void z() { Y y; y.x();
2455</pre></td></tr>
2456
2457
Manuel Klimek67619ff2012-09-07 13:10:32 +00002458<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnyArgument0')"><a name="hasAnyArgument0Anchor">hasAnyArgument</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002459<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call
2460expression.
2461
2462Given
2463 void x(int, int, int) { int y; x(1, y, 42); }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002464callExpr(hasAnyArgument(declRefExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002465 matches x(1, y, 42)
2466with hasAnyArgument(...)
2467 matching y
Manuel Klimek1a68afd2013-06-20 13:08:29 +00002468
2469FIXME: Currently this will ignore parentheses and implicit casts on
2470the argument before applying the inner matcher. We'll want to remove
2471this to allow for greater control by the user once ignoreImplicit()
2472has been implemented.
Manuel Klimek1da79332012-08-20 20:54:03 +00002473</pre></td></tr>
2474
2475
Manuel Klimek67619ff2012-09-07 13:10:32 +00002476<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('hasArgument0')"><a name="hasArgument0Anchor">hasArgument</a></td><td>unsigned N, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002477<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor
2478call expression.
2479
2480Example matches y in x(y)
Manuel Klimeke44a0062012-08-26 23:55:24 +00002481 (matcher = callExpr(hasArgument(0, declRefExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002482 void x(int) { int y; x(y); }
2483</pre></td></tr>
2484
2485
Edwin Vane3abf7782013-02-25 14:49:29 +00002486<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration4')"><a name="hasDeclaration4Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek03a83232013-06-10 08:52:15 +00002487<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node
2488matches the given matcher.
Manuel Klimek1da79332012-08-20 20:54:03 +00002489
Manuel Klimek03a83232013-06-10 08:52:15 +00002490The associated declaration is:
2491- for type nodes, the declaration of the underlying type
2492- for CallExpr, the declaration of the callee
2493- for MemberExpr, the declaration of the referenced member
2494- for CXXConstructExpr, the declaration of the constructor
2495
2496Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
2497function. e.g. various subtypes of clang::Type and various expressions.
2498FIXME: Add all node types for which this is matcher is usable due to
2499getDecl().
Edwin Vane52380602013-02-19 17:14:34 +00002500
Daniel Jaspere0b89972012-12-04 12:08:08 +00002501Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
Edwin Vane3abf7782013-02-25 14:49:29 +00002502 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
2503 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;
Manuel Klimek1da79332012-08-20 20:54:03 +00002504</pre></td></tr>
2505
2506
Manuel Klimek03a83232013-06-10 08:52:15 +00002507<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt</a>&gt;</td><td class="name" onclick="toggle('hasCaseConstant0')"><a name="hasCaseConstant0Anchor">hasCaseConstant</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
2508<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range
2509extension, matches the constant given in the statement.
2510
2511Given
2512 switch (1) { case 1: case 1+1: case 3 ... 4: ; }
2513caseStmt(hasCaseConstant(integerLiteral()))
2514 matches "case 1:"
2515</pre></td></tr>
2516
2517
Manuel Klimek67619ff2012-09-07 13:10:32 +00002518<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>&gt;</td><td class="name" onclick="toggle('hasSourceExpression0')"><a name="hasSourceExpression0Anchor">hasSourceExpression</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002519<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher.
2520
2521Example: matches "a string" (matcher =
Manuel Klimeke44a0062012-08-26 23:55:24 +00002522 hasSourceExpression(constructExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002523class URL { URL(string); };
2524URL url = "a string";
2525</pre></td></tr>
2526
2527
Manuel Klimek67619ff2012-09-07 13:10:32 +00002528<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyTemplateArgument0')"><a name="hasAnyTemplateArgument0Anchor">hasAnyTemplateArgument</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002529<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one
2530TemplateArgument matching the given InnerMatcher.
2531
2532Given
2533 template&lt;typename T&gt; class A {};
2534 template&lt;&gt; class A&lt;double&gt; {};
2535 A&lt;int&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002536classTemplateSpecializationDecl(hasAnyTemplateArgument(
Manuel Klimek1da79332012-08-20 20:54:03 +00002537 refersToType(asString("int"))))
2538 matches the specialization A&lt;int&gt;
2539</pre></td></tr>
2540
2541
Manuel Klimek67619ff2012-09-07 13:10:32 +00002542<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;</td><td class="name" onclick="toggle('hasTemplateArgument0')"><a name="hasTemplateArgument0Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002543<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument
2544matches the given InnerMatcher.
2545
2546Given
2547 template&lt;typename T, typename U&gt; class A {};
2548 A&lt;bool, int&gt; b;
2549 A&lt;int, bool&gt; c;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002550classTemplateSpecializationDecl(hasTemplateArgument(
Manuel Klimek1da79332012-08-20 20:54:03 +00002551 1, refersToType(asString("int"))))
2552 matches the specialization A&lt;bool, int&gt;
2553</pre></td></tr>
2554
2555
Samuel Benzaquen3f84bb32013-07-15 19:25:06 +00002556<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexTypeLoc.html">ComplexTypeLoc</a>&gt;</td><td class="name" onclick="toggle('hasElementTypeLoc1')"><a name="hasElementTypeLoc1Anchor">hasElementTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td></tr>
2557<tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element
Manuel Klimek41df16e2013-01-09 09:38:21 +00002558type.
2559
2560Given
2561 struct A {};
2562 A a[7];
2563 int b[7];
2564arrayType(hasElementType(builtinType()))
2565 matches "int b[7]"
2566
2567Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>&gt;
2568</pre></td></tr>
2569
2570
Samuel Benzaquen3f84bb32013-07-15 19:25:06 +00002571<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>&gt;</td><td class="name" onclick="toggle('hasElementType1')"><a name="hasElementType1Anchor">hasElementType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
2572<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element
Manuel Klimek41df16e2013-01-09 09:38:21 +00002573type.
2574
2575Given
2576 struct A {};
2577 A a[7];
2578 int b[7];
2579arrayType(hasElementType(builtinType()))
2580 matches "int b[7]"
2581
2582Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>&gt;
2583</pre></td></tr>
2584
2585
Manuel Klimek67619ff2012-09-07 13:10:32 +00002586<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>&gt;</td><td class="name" onclick="toggle('hasAnySubstatement0')"><a name="hasAnySubstatement0Anchor">hasAnySubstatement</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002587<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches
2588a given matcher.
2589
2590Given
2591 { {}; 1+2; }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002592hasAnySubstatement(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00002593 matches '{ {}; 1+2; }'
Manuel Klimeke44a0062012-08-26 23:55:24 +00002594with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00002595 matching '{}'
2596</pre></td></tr>
2597
2598
Manuel Klimek67619ff2012-09-07 13:10:32 +00002599<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>&gt;</td><td class="name" onclick="toggle('hasCondition4')"><a name="hasCondition4Anchor">hasCondition</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002600<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop,
2601or conditional operator.
2602
2603Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2604 if (true) {}
2605</pre></td></tr>
2606
2607
Manuel Klimek67619ff2012-09-07 13:10:32 +00002608<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>&gt;</td><td class="name" onclick="toggle('hasFalseExpression0')"><a name="hasFalseExpression0Anchor">hasFalseExpression</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002609<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator.
2610
2611Example matches b
2612 condition ? a : b
2613</pre></td></tr>
2614
2615
Manuel Klimek67619ff2012-09-07 13:10:32 +00002616<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>&gt;</td><td class="name" onclick="toggle('hasTrueExpression0')"><a name="hasTrueExpression0Anchor">hasTrueExpression</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002617<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator.
2618
2619Example matches a
2620 condition ? a : b
2621</pre></td></tr>
2622
2623
Manuel Klimek67619ff2012-09-07 13:10:32 +00002624<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;</td><td class="name" onclick="toggle('throughUsingDecl0')"><a name="throughUsingDecl0Anchor">throughUsingDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002625<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a
2626specific using shadow declaration.
2627
2628FIXME: This currently only works for functions. Fix.
2629
2630Given
2631 namespace a { void f() {} }
2632 using a::f;
2633 void g() {
2634 f(); Matches this ..
2635 a::f(); .. but not this.
2636 }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002637declRefExpr(throughUsingDeclaration(anything()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002638 matches f()
2639</pre></td></tr>
2640
2641
Manuel Klimek67619ff2012-09-07 13:10:32 +00002642<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;</td><td class="name" onclick="toggle('to0')"><a name="to0Anchor">to</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002643<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the
2644specified matcher.
2645
2646Example matches x in if(x)
Manuel Klimeke44a0062012-08-26 23:55:24 +00002647 (matcher = declRefExpr(to(varDecl(hasName("x")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002648 bool x;
2649 if (x) {}
2650</pre></td></tr>
2651
2652
Manuel Klimek67619ff2012-09-07 13:10:32 +00002653<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>&gt;</td><td class="name" onclick="toggle('containsDeclaration0')"><a name="containsDeclaration0Anchor">containsDeclaration</a></td><td>unsigned N, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002654<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement.
2655
2656Note that this does not work for global declarations because the AST
2657breaks up multiple-declaration DeclStmt's into multiple single-declaration
2658DeclStmt's.
2659Example: Given non-global declarations
2660 int a, b = 0;
2661 int c;
2662 int d = 2, e;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002663declStmt(containsDeclaration(
2664 0, varDecl(hasInitializer(anything()))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002665 matches only 'int d = 2, e;', and
Manuel Klimeke44a0062012-08-26 23:55:24 +00002666declStmt(containsDeclaration(1, varDecl()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002667 matches 'int a, b = 0' as well as 'int d = 2, e;'
2668 but 'int c;' is not matched.
2669</pre></td></tr>
2670
2671
Manuel Klimek67619ff2012-09-07 13:10:32 +00002672<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>&gt;</td><td class="name" onclick="toggle('hasSingleDecl0')"><a name="hasSingleDecl0Anchor">hasSingleDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002673<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration.
2674
2675Given
2676 int a, b;
2677 int c;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002678declStmt(hasSingleDecl(anything()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002679 matches 'int c;' but not 'int a, b;'.
2680</pre></td></tr>
2681
2682
Manuel Klimek1a68afd2013-06-20 13:08:29 +00002683<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc0')"><a name="hasTypeLoc0Anchor">hasTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
2684<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches
2685the inner matcher.
2686
2687Given
2688 int x;
2689declaratorDecl(hasTypeLoc(loc(asString("int"))))
2690 matches int x
2691</pre></td></tr>
2692
2693
Edwin Vane742d9e72013-02-25 20:43:32 +00002694<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('hasDeclContext0')"><a name="hasDeclContext0Anchor">hasDeclContext</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
2695<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a
2696Decl, matches InnerMatcher.
2697
2698Given
2699 namespace N {
2700 namespace M {
2701 class D {};
2702 }
2703 }
2704
2705recordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
2706declaration of class D.
2707</pre></td></tr>
2708
2709
Manuel Klimek67619ff2012-09-07 13:10:32 +00002710<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>&gt;</td><td class="name" onclick="toggle('hasBody0')"><a name="hasBody0Anchor">hasBody</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002711<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has
2712a given body.
2713
2714Given
2715 for (;;) {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00002716hasBody(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00002717 matches 'for (;;) {}'
Manuel Klimeke44a0062012-08-26 23:55:24 +00002718with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00002719 matching '{}'
2720</pre></td></tr>
2721
2722
Manuel Klimek67619ff2012-09-07 13:10:32 +00002723<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>&gt;</td><td class="name" onclick="toggle('hasCondition3')"><a name="hasCondition3Anchor">hasCondition</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002724<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop,
2725or conditional operator.
2726
2727Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2728 if (true) {}
2729</pre></td></tr>
2730
2731
Edwin Vane742d9e72013-02-25 20:43:32 +00002732<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>&gt;</td><td class="name" onclick="toggle('hasQualifier0')"><a name="hasQualifier0Anchor">hasQualifier</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt; InnerMatcher</td></tr>
2733<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
Edwin Vaneaec89ac2013-03-04 17:51:00 +00002734matches InnerMatcher if the qualifier exists.
Edwin Vane742d9e72013-02-25 20:43:32 +00002735
2736Given
2737 namespace N {
2738 namespace M {
2739 class D {};
2740 }
2741 }
2742 N::M::D d;
2743
2744elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N"))))
2745matches the type of the variable declaration of d.
2746</pre></td></tr>
2747
2748
2749<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>&gt;</td><td class="name" onclick="toggle('namesType0')"><a name="namesType0Anchor">namesType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
2750<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher.
2751
2752Given
2753 namespace N {
2754 namespace M {
2755 class D {};
2756 }
2757 }
2758 N::M::D d;
2759
2760elaboratedType(namesType(recordType(
2761hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable
2762declaration of d.
2763</pre></td></tr>
2764
2765
Manuel Klimek67619ff2012-09-07 13:10:32 +00002766<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;</td><td class="name" onclick="toggle('hasDestinationType0')"><a name="hasDestinationType0Anchor">hasDestinationType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002767<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher.
2768
2769(Note: Clang's AST refers to other conversions as "casts" too, and calls
2770actual casts "explicit" casts.)
2771</pre></td></tr>
2772
2773
Manuel Klimek532870f2013-07-24 05:46:07 +00002774<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('hasType2')"><a name="hasType2Anchor">hasType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
2775<tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value
Manuel Klimek1da79332012-08-20 20:54:03 +00002776declaration's type.
2777
2778In case of a value declaration (for example a variable declaration),
2779this resolves one layer of indirection. For example, in the value
Manuel Klimeke44a0062012-08-26 23:55:24 +00002780declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
2781while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
Manuel Klimek1da79332012-08-20 20:54:03 +00002782of x."
2783
Manuel Klimeke44a0062012-08-26 23:55:24 +00002784Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
2785 and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002786 class X {};
2787 void y(X &amp;x) { x; X z; }
2788
2789Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;
2790</pre></td></tr>
2791
2792
Manuel Klimek67619ff2012-09-07 13:10:32 +00002793<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('ignoringImpCasts0')"><a name="ignoringImpCasts0Anchor">ignoringImpCasts</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002794<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts
2795are stripped off.
2796
2797Parentheses and explicit casts are not discarded.
2798Given
2799 int arr[5];
2800 int a = 0;
2801 char b = 0;
2802 const int c = a;
2803 int *d = arr;
2804 long e = (long) 0l;
2805The matchers
Manuel Klimeke44a0062012-08-26 23:55:24 +00002806 varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
2807 varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002808would match the declarations for a, b, c, and d, but not e.
2809While
Manuel Klimeke44a0062012-08-26 23:55:24 +00002810 varDecl(hasInitializer(integerLiteral()))
2811 varDecl(hasInitializer(declRefExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002812only match the declarations for b, c, and d.
2813</pre></td></tr>
2814
2815
Manuel Klimek67619ff2012-09-07 13:10:32 +00002816<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('ignoringParenCasts0')"><a name="ignoringParenCasts0Anchor">ignoringParenCasts</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002817<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and
2818casts are stripped off.
2819
2820Implicit and non-C Style casts are also discarded.
2821Given
2822 int a = 0;
2823 char b = (0);
2824 void* c = reinterpret_cast&lt;char*&gt;(0);
2825 char d = char(0);
2826The matcher
Manuel Klimeke44a0062012-08-26 23:55:24 +00002827 varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002828would match the declarations for a, b, c, and d.
2829while
Manuel Klimeke44a0062012-08-26 23:55:24 +00002830 varDecl(hasInitializer(integerLiteral()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002831only match the declaration for a.
2832</pre></td></tr>
2833
2834
Manuel Klimek67619ff2012-09-07 13:10:32 +00002835<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('ignoringParenImpCasts0')"><a name="ignoringParenImpCasts0Anchor">ignoringParenImpCasts</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002836<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and
2837parentheses are stripped off.
2838
2839Explicit casts are not discarded.
2840Given
2841 int arr[5];
2842 int a = 0;
2843 char b = (0);
2844 const int c = a;
2845 int *d = (arr);
2846 long e = ((long) 0l);
2847The matchers
Manuel Klimeke44a0062012-08-26 23:55:24 +00002848 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
2849 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002850would match the declarations for a, b, c, and d, but not e.
2851while
Manuel Klimeke44a0062012-08-26 23:55:24 +00002852 varDecl(hasInitializer(integerLiteral()))
2853 varDecl(hasInitializer(declRefExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002854would only match the declaration for a.
2855</pre></td></tr>
2856
2857
Manuel Klimek67619ff2012-09-07 13:10:32 +00002858<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>&gt;</td><td class="name" onclick="toggle('hasBody1')"><a name="hasBody1Anchor">hasBody</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002859<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has
2860a given body.
2861
2862Given
2863 for (;;) {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00002864hasBody(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00002865 matches 'for (;;) {}'
Manuel Klimeke44a0062012-08-26 23:55:24 +00002866with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00002867 matching '{}'
2868</pre></td></tr>
2869
2870
Manuel Klimek67619ff2012-09-07 13:10:32 +00002871<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>&gt;</td><td class="name" onclick="toggle('hasCondition1')"><a name="hasCondition1Anchor">hasCondition</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002872<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop,
2873or conditional operator.
2874
2875Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2876 if (true) {}
2877</pre></td></tr>
2878
2879
Manuel Klimek67619ff2012-09-07 13:10:32 +00002880<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>&gt;</td><td class="name" onclick="toggle('hasIncrement0')"><a name="hasIncrement0Anchor">hasIncrement</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002881<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop.
2882
2883Example:
2884 forStmt(hasIncrement(unaryOperator(hasOperatorName("++"))))
2885matches '++x' in
2886 for (x; x &lt; N; ++x) { }
2887</pre></td></tr>
2888
2889
Manuel Klimek67619ff2012-09-07 13:10:32 +00002890<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>&gt;</td><td class="name" onclick="toggle('hasLoopInit0')"><a name="hasLoopInit0Anchor">hasLoopInit</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002891<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop.
2892
2893Example:
Manuel Klimeke44a0062012-08-26 23:55:24 +00002894 forStmt(hasLoopInit(declStmt()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002895matches 'int x = 0' in
2896 for (int x = 0; x &lt; N; ++x) { }
2897</pre></td></tr>
2898
2899
Manuel Klimek67619ff2012-09-07 13:10:32 +00002900<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyParameter0')"><a name="hasAnyParameter0Anchor">hasAnyParameter</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002901<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration.
2902
2903Does not match the 'this' parameter of a method.
2904
2905Given
2906 class X { void f(int x, int y, int z) {} };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002907methodDecl(hasAnyParameter(hasName("y")))
Manuel Klimek1da79332012-08-20 20:54:03 +00002908 matches f(int x, int y, int z) {}
2909with hasAnyParameter(...)
2910 matching int y
2911</pre></td></tr>
2912
2913
Manuel Klimek67619ff2012-09-07 13:10:32 +00002914<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasParameter0')"><a name="hasParameter0Anchor">hasParameter</a></td><td>unsigned N, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002915<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration.
2916
2917Given
2918 class X { void f(int x) {} };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002919methodDecl(hasParameter(0, hasType(varDecl())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002920 matches f(int x) {}
2921with hasParameter(...)
2922 matching int x
2923</pre></td></tr>
2924
2925
Manuel Klimek67619ff2012-09-07 13:10:32 +00002926<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('returns0')"><a name="returns0Anchor">returns</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002927<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration.
2928
2929Given:
2930 class X { int f() { return 1; } };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002931methodDecl(returns(asString("int")))
Manuel Klimek1da79332012-08-20 20:54:03 +00002932 matches int f() { return 1; }
2933</pre></td></tr>
2934
2935
Manuel Klimek67619ff2012-09-07 13:10:32 +00002936<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>&gt;</td><td class="name" onclick="toggle('hasCondition0')"><a name="hasCondition0Anchor">hasCondition</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002937<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop,
2938or conditional operator.
2939
2940Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2941 if (true) {}
2942</pre></td></tr>
2943
2944
Manuel Klimek67619ff2012-09-07 13:10:32 +00002945<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>&gt;</td><td class="name" onclick="toggle('hasConditionVariableStatement0')"><a name="hasConditionVariableStatement0Anchor">hasConditionVariableStatement</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002946<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement.
2947
2948Given
2949 if (A* a = GetAPointer()) {}
2950hasConditionVariableStatment(...)
2951 matches 'A* a = GetAPointer()'.
2952</pre></td></tr>
2953
2954
Manuel Klimek67619ff2012-09-07 13:10:32 +00002955<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ImplicitCastExpr.html">ImplicitCastExpr</a>&gt;</td><td class="name" onclick="toggle('hasImplicitDestinationType0')"><a name="hasImplicitDestinationType0Anchor">hasImplicitDestinationType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002956<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given
2957matcher.
2958
2959FIXME: Unit test this matcher
2960</pre></td></tr>
2961
2962
Edwin Vane3abf7782013-02-25 14:49:29 +00002963<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration2')"><a name="hasDeclaration2Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek03a83232013-06-10 08:52:15 +00002964<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node
2965matches the given matcher.
Daniel Jaspere0b89972012-12-04 12:08:08 +00002966
Manuel Klimek03a83232013-06-10 08:52:15 +00002967The associated declaration is:
2968- for type nodes, the declaration of the underlying type
2969- for CallExpr, the declaration of the callee
2970- for MemberExpr, the declaration of the referenced member
2971- for CXXConstructExpr, the declaration of the constructor
2972
2973Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
2974function. e.g. various subtypes of clang::Type and various expressions.
2975FIXME: Add all node types for which this is matcher is usable due to
2976getDecl().
Edwin Vane52380602013-02-19 17:14:34 +00002977
Daniel Jaspere0b89972012-12-04 12:08:08 +00002978Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
Edwin Vane3abf7782013-02-25 14:49:29 +00002979 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
2980 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;
Daniel Jaspere0b89972012-12-04 12:08:08 +00002981</pre></td></tr>
2982
2983
Manuel Klimek67619ff2012-09-07 13:10:32 +00002984<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;</td><td class="name" onclick="toggle('hasObjectExpression0')"><a name="hasObjectExpression0Anchor">hasObjectExpression</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002985<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is
2986matched by a given matcher.
2987
2988Given
2989 struct X { int m; };
2990 void f(X x) { x.m; m; }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002991memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002992 matches "x.m" and "m"
2993with hasObjectExpression(...)
2994 matching "x" and the implicit object expression of "m" which has type X*.
2995</pre></td></tr>
2996
2997
Manuel Klimek67619ff2012-09-07 13:10:32 +00002998<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;</td><td class="name" onclick="toggle('member0')"><a name="member0Anchor">member</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002999<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a
3000given matcher.
3001
3002Given
3003 struct { int first, second; } first, second;
3004 int i(second.first);
3005 int j(first.second);
Manuel Klimeke44a0062012-08-26 23:55:24 +00003006memberExpr(member(hasName("first")))
Manuel Klimek1da79332012-08-20 20:54:03 +00003007 matches second.first
3008 but not first.second (because the member name there is "second").
3009</pre></td></tr>
3010
3011
Samuel Benzaquen3f84bb32013-07-15 19:25:06 +00003012<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerTypeLoc.html">MemberPointerTypeLoc</a>&gt;</td><td class="name" onclick="toggle('pointeeLoc1')"><a name="pointeeLoc1Anchor">pointeeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td></tr>
3013<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the
Manuel Klimek41df16e2013-01-09 09:38:21 +00003014pointee matches a given matcher.
3015
3016Given
3017 int *a;
3018 int const *b;
3019 float const *f;
3020pointerType(pointee(isConstQualified(), isInteger()))
3021 matches "int const *b"
3022
3023Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;,
3024 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;
3025</pre></td></tr>
3026
3027
Samuel Benzaquen3f84bb32013-07-15 19:25:06 +00003028<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;</td><td class="name" onclick="toggle('pointee1')"><a name="pointee1Anchor">pointee</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
3029<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the
Manuel Klimek41df16e2013-01-09 09:38:21 +00003030pointee matches a given matcher.
3031
3032Given
3033 int *a;
3034 int const *b;
3035 float const *f;
3036pointerType(pointee(isConstQualified(), isInteger()))
3037 matches "int const *b"
3038
3039Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;,
3040 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;
3041</pre></td></tr>
3042
3043
Manuel Klimek415514d2013-02-06 20:36:22 +00003044<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>&gt;</td><td class="name" onclick="toggle('hasPrefix1')"><a name="hasPrefix1Anchor">hasPrefix</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>&gt; InnerMatcher</td></tr>
Daniel Jaspere0b89972012-12-04 12:08:08 +00003045<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc.
3046
3047Given
3048 struct A { struct B { struct C {}; }; };
3049 A::B::C c;
3050nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A")))))
3051 matches "A::"
3052</pre></td></tr>
3053
3054
Manuel Klimek41df16e2013-01-09 09:38:21 +00003055<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>&gt;</td><td class="name" onclick="toggle('loc1')"><a name="loc1Anchor">loc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt; InnerMatcher</td></tr>
3056<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner
3057NestedNameSpecifier-matcher matches.
3058</pre></td></tr>
3059
3060
Daniel Jaspere0b89972012-12-04 12:08:08 +00003061<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>&gt;</td><td class="name" onclick="toggle('specifiesTypeLoc0')"><a name="specifiesTypeLoc0Anchor">specifiesTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; InnerMatcher</td></tr>
3062<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the
3063given TypeLoc.
3064
3065Given
3066 struct A { struct B { struct C {}; }; };
3067 A::B::C c;
3068nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
3069 hasDeclaration(recordDecl(hasName("A")))))))
3070 matches "A::"
3071</pre></td></tr>
3072
3073
Manuel Klimek415514d2013-02-06 20:36:22 +00003074<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt;</td><td class="name" onclick="toggle('hasPrefix0')"><a name="hasPrefix0Anchor">hasPrefix</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt; InnerMatcher</td></tr>
Daniel Jaspere0b89972012-12-04 12:08:08 +00003075<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier.
3076
3077Given
3078 struct A { struct B { struct C {}; }; };
3079 A::B::C c;
3080nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and
3081 matches "A::"
3082</pre></td></tr>
3083
3084
3085<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt;</td><td class="name" onclick="toggle('specifiesNamespace0')"><a name="specifiesNamespace0Anchor">specifiesNamespace</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>&gt; InnerMatcher</td></tr>
3086<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the
3087given namespace matcher.
3088
3089Given
3090 namespace ns { struct A {}; }
3091 ns::A a;
3092nestedNameSpecifier(specifiesNamespace(hasName("ns")))
3093 matches "ns::"
3094</pre></td></tr>
3095
3096
3097<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt;</td><td class="name" onclick="toggle('specifiesType0')"><a name="specifiesType0Anchor">specifiesType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
3098<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the
3099given QualType matcher without qualifiers.
3100
3101Given
3102 struct A { struct B { struct C {}; }; };
3103 A::B::C c;
3104nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A")))))
3105 matches "A::"
3106</pre></td></tr>
3107
3108
Edwin Vane88be2fd2013-04-01 18:33:34 +00003109<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>&gt;</td><td class="name" onclick="toggle('innerType0')"><a name="innerType0Anchor">innerType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
3110<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type.
3111
3112Given
3113 int (*ptr_to_array)[4];
3114 int (*ptr_to_func)(int);
3115
3116varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
3117ptr_to_func but not ptr_to_array.
3118
3119Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>&gt;
3120</pre></td></tr>
3121
3122
Samuel Benzaquen3f84bb32013-07-15 19:25:06 +00003123<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>&gt;</td><td class="name" onclick="toggle('pointeeLoc2')"><a name="pointeeLoc2Anchor">pointeeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td></tr>
3124<tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the
Manuel Klimek41df16e2013-01-09 09:38:21 +00003125pointee matches a given matcher.
3126
3127Given
3128 int *a;
3129 int const *b;
3130 float const *f;
3131pointerType(pointee(isConstQualified(), isInteger()))
3132 matches "int const *b"
3133
3134Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;,
3135 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;
3136</pre></td></tr>
3137
3138
Samuel Benzaquen3f84bb32013-07-15 19:25:06 +00003139<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;</td><td class="name" onclick="toggle('pointee2')"><a name="pointee2Anchor">pointee</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
3140<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the
Manuel Klimek41df16e2013-01-09 09:38:21 +00003141pointee matches a given matcher.
3142
3143Given
3144 int *a;
3145 int const *b;
3146 float const *f;
3147pointerType(pointee(isConstQualified(), isInteger()))
3148 matches "int const *b"
3149
3150Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;,
3151 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;
3152</pre></td></tr>
3153
3154
Edwin Vane6a19a972013-03-06 17:02:57 +00003155<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('hasCanonicalType0')"><a name="hasCanonicalType0Anchor">hasCanonicalType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
3156<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher.
3157
3158Given:
3159 typedef int &amp;int_ref;
3160 int a;
3161 int_ref b = a;
3162
3163varDecl(hasType(qualType(referenceType()))))) will not match the
3164declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does.
3165</pre></td></tr>
3166
3167
Edwin Vane3abf7782013-02-25 14:49:29 +00003168<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration5')"><a name="hasDeclaration5Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek03a83232013-06-10 08:52:15 +00003169<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node
3170matches the given matcher.
Manuel Klimek1da79332012-08-20 20:54:03 +00003171
Manuel Klimek03a83232013-06-10 08:52:15 +00003172The associated declaration is:
3173- for type nodes, the declaration of the underlying type
3174- for CallExpr, the declaration of the callee
3175- for MemberExpr, the declaration of the referenced member
3176- for CXXConstructExpr, the declaration of the constructor
3177
3178Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
3179function. e.g. various subtypes of clang::Type and various expressions.
3180FIXME: Add all node types for which this is matcher is usable due to
3181getDecl().
Edwin Vane52380602013-02-19 17:14:34 +00003182
Daniel Jaspere0b89972012-12-04 12:08:08 +00003183Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
Edwin Vane3abf7782013-02-25 14:49:29 +00003184 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
3185 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;
Manuel Klimek1da79332012-08-20 20:54:03 +00003186</pre></td></tr>
3187
3188
Manuel Klimek532870f2013-07-24 05:46:07 +00003189<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('pointsTo1')"><a name="pointsTo1Anchor">pointsTo</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00003190<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration.
3191</pre></td></tr>
3192
3193
Manuel Klimek532870f2013-07-24 05:46:07 +00003194<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('references1')"><a name="references1Anchor">references</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00003195<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration.
3196</pre></td></tr>
3197
3198
Samuel Benzaquen3f84bb32013-07-15 19:25:06 +00003199<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>&gt;</td><td class="name" onclick="toggle('pointeeLoc3')"><a name="pointeeLoc3Anchor">pointeeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td></tr>
3200<tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the
Manuel Klimek41df16e2013-01-09 09:38:21 +00003201pointee matches a given matcher.
3202
3203Given
3204 int *a;
3205 int const *b;
3206 float const *f;
3207pointerType(pointee(isConstQualified(), isInteger()))
3208 matches "int const *b"
3209
3210Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;,
3211 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;
3212</pre></td></tr>
3213
3214
Samuel Benzaquen3f84bb32013-07-15 19:25:06 +00003215<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;</td><td class="name" onclick="toggle('pointee3')"><a name="pointee3Anchor">pointee</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
3216<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the
Manuel Klimek41df16e2013-01-09 09:38:21 +00003217pointee matches a given matcher.
3218
3219Given
3220 int *a;
3221 int const *b;
3222 float const *f;
3223pointerType(pointee(isConstQualified(), isInteger()))
3224 matches "int const *b"
3225
3226Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;,
3227 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;
3228</pre></td></tr>
3229
3230
Manuel Klimek67619ff2012-09-07 13:10:32 +00003231<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('alignOfExpr0')"><a name="alignOfExpr0Anchor">alignOfExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00003232<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
3233alignof.
3234</pre></td></tr>
3235
3236
Manuel Klimek67619ff2012-09-07 13:10:32 +00003237<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('sizeOfExpr0')"><a name="sizeOfExpr0Anchor">sizeOfExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00003238<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
3239sizeof.
3240</pre></td></tr>
3241
3242
Manuel Klimek03a83232013-06-10 08:52:15 +00003243<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>&gt;</td><td class="name" onclick="toggle('forEachSwitchCase0')"><a name="forEachSwitchCase0Anchor">forEachSwitchCase</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>&gt; InnerMatcher</td></tr>
3244<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch
3245statement. This matcher may produce multiple matches.
3246
3247Given
3248 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }
3249switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s")
3250 matches four times, with "c" binding each of "case 1:", "case 2:",
3251"case 3:" and "case 4:", and "s" respectively binding "switch (1)",
3252"switch (1)", "switch (2)" and "switch (2)".
3253</pre></td></tr>
3254
3255
Manuel Klimek67619ff2012-09-07 13:10:32 +00003256<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('refersToDeclaration0')"><a name="refersToDeclaration0Anchor">refersToDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00003257<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a TemplateArgument that refers to a certain declaration.
3258
3259Given
3260 template&lt;typename T&gt; struct A {};
3261 struct B { B* next; };
3262 A&lt;&amp;B::next&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +00003263classTemplateSpecializationDecl(hasAnyTemplateArgument(
3264 refersToDeclaration(fieldDecl(hasName("next"))))
3265 matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
Manuel Klimek1da79332012-08-20 20:54:03 +00003266 B::next
3267</pre></td></tr>
3268
3269
Manuel Klimek67619ff2012-09-07 13:10:32 +00003270<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('refersToType0')"><a name="refersToType0Anchor">refersToType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00003271<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type.
3272
3273Given
3274 struct X {};
3275 template&lt;typename T&gt; struct A {};
3276 A&lt;X&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +00003277classTemplateSpecializationDecl(hasAnyTemplateArgument(
Manuel Klimek1da79332012-08-20 20:54:03 +00003278 refersToType(class(hasName("X")))))
3279 matches the specialization A&lt;X&gt;
3280</pre></td></tr>
3281
3282
Edwin Vane3abf7782013-02-25 14:49:29 +00003283<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration0')"><a name="hasDeclaration0Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek03a83232013-06-10 08:52:15 +00003284<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node
3285matches the given matcher.
Edwin Vane52380602013-02-19 17:14:34 +00003286
Manuel Klimek03a83232013-06-10 08:52:15 +00003287The associated declaration is:
3288- for type nodes, the declaration of the underlying type
3289- for CallExpr, the declaration of the callee
3290- for MemberExpr, the declaration of the referenced member
3291- for CXXConstructExpr, the declaration of the constructor
3292
3293Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
3294function. e.g. various subtypes of clang::Type and various expressions.
3295FIXME: Add all node types for which this is matcher is usable due to
3296getDecl().
Edwin Vane52380602013-02-19 17:14:34 +00003297
3298Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
Edwin Vane3abf7782013-02-25 14:49:29 +00003299 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
3300 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;
3301</pre></td></tr>
3302
3303
Samuel Benzaquend36e4632013-08-27 15:11:16 +00003304<tr><td>Matcher&lt;T&gt;</td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher&lt;T&gt; Matcher</td></tr>
3305<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches.
3306
3307Generates results for each match.
3308
3309For example, in:
3310 class A { class B {}; class C {}; };
3311The matcher:
3312 recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m")))
3313will generate results for A, B and C.
3314
3315Usable as: Any Matcher
3316</pre></td></tr>
3317
3318
Edwin Vane3abf7782013-02-25 14:49:29 +00003319<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('loc0')"><a name="loc0Anchor">loc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
3320<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner
3321QualType-matcher matches.
3322</pre></td></tr>
3323
3324
3325<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration1')"><a name="hasDeclaration1Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek03a83232013-06-10 08:52:15 +00003326<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node
3327matches the given matcher.
Edwin Vane3abf7782013-02-25 14:49:29 +00003328
Manuel Klimek03a83232013-06-10 08:52:15 +00003329The associated declaration is:
3330- for type nodes, the declaration of the underlying type
3331- for CallExpr, the declaration of the callee
3332- for MemberExpr, the declaration of the referenced member
3333- for CXXConstructExpr, the declaration of the constructor
3334
3335Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
3336function. e.g. various subtypes of clang::Type and various expressions.
3337FIXME: Add all node types for which this is matcher is usable due to
3338getDecl().
Edwin Vane3abf7782013-02-25 14:49:29 +00003339
3340Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
3341 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
3342 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;
Daniel Jaspere0b89972012-12-04 12:08:08 +00003343</pre></td></tr>
3344
3345
Manuel Klimek67619ff2012-09-07 13:10:32 +00003346<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt;</td><td class="name" onclick="toggle('hasArgumentOfType0')"><a name="hasArgumentOfType0Anchor">hasArgumentOfType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00003347<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument.
3348
3349Given
3350 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
3351unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
3352 matches sizeof(a) and alignof(c)
3353</pre></td></tr>
3354
3355
Manuel Klimek67619ff2012-09-07 13:10:32 +00003356<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasUnaryOperand0')"><a name="hasUnaryOperand0Anchor">hasUnaryOperand</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00003357<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches.
3358
Daniel Jaspere0b89972012-12-04 12:08:08 +00003359Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true))))
Manuel Klimek1da79332012-08-20 20:54:03 +00003360 !true
3361</pre></td></tr>
3362
3363
Manuel Klimek67619ff2012-09-07 13:10:32 +00003364<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html">UsingDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyUsingShadowDecl0')"><a name="hasAnyUsingShadowDecl0Anchor">hasAnyUsingShadowDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00003365<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration.
3366
3367Given
3368 namespace X { void b(); }
3369 using X::b;
3370usingDecl(hasAnyUsingShadowDecl(hasName("b"))))
3371 matches using X::b </pre></td></tr>
3372
3373
Manuel Klimek67619ff2012-09-07 13:10:32 +00003374<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>&gt;</td><td class="name" onclick="toggle('hasTargetDecl0')"><a name="hasTargetDecl0Anchor">hasTargetDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00003375<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is
3376matched by the given matcher.
3377
3378Given
3379 namespace X { int a; void b(); }
3380 using X::a;
3381 using X::b;
Manuel Klimeke44a0062012-08-26 23:55:24 +00003382usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
Manuel Klimek1da79332012-08-20 20:54:03 +00003383 matches using X::b but not using X::a </pre></td></tr>
3384
3385
Manuel Klimek532870f2013-07-24 05:46:07 +00003386<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;</td><td class="name" onclick="toggle('hasType3')"><a name="hasType3Anchor">hasType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
3387<tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value
Manuel Klimek1da79332012-08-20 20:54:03 +00003388declaration's type.
3389
3390In case of a value declaration (for example a variable declaration),
3391this resolves one layer of indirection. For example, in the value
Manuel Klimeke44a0062012-08-26 23:55:24 +00003392declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
3393while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
Manuel Klimek1da79332012-08-20 20:54:03 +00003394of x."
3395
Manuel Klimeke44a0062012-08-26 23:55:24 +00003396Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
3397 and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00003398 class X {};
3399 void y(X &amp;x) { x; X z; }
3400
3401Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;
3402</pre></td></tr>
3403
3404
Manuel Klimek67619ff2012-09-07 13:10:32 +00003405<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('hasInitializer0')"><a name="hasInitializer0Anchor">hasInitializer</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00003406<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression
3407that matches the given matcher.
3408
Manuel Klimeke44a0062012-08-26 23:55:24 +00003409Example matches x (matcher = varDecl(hasInitializer(callExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00003410 bool y() { return true; }
3411 bool x = y();
3412</pre></td></tr>
3413
3414
Daniel Jaspere0b89972012-12-04 12:08:08 +00003415<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VariableArrayType.html">VariableArrayType</a>&gt;</td><td class="name" onclick="toggle('hasSizeExpr0')"><a name="hasSizeExpr0Anchor">hasSizeExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
3416<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size
3417expression.
3418
3419Given
3420 void f(int b) {
3421 int a[b];
3422 }
3423variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
3424 varDecl(hasName("b")))))))
3425 matches "int a[b]"
3426</pre></td></tr>
3427
3428
Manuel Klimek67619ff2012-09-07 13:10:32 +00003429<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>&gt;</td><td class="name" onclick="toggle('hasBody2')"><a name="hasBody2Anchor">hasBody</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00003430<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has
3431a given body.
3432
3433Given
3434 for (;;) {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00003435hasBody(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00003436 matches 'for (;;) {}'
Manuel Klimeke44a0062012-08-26 23:55:24 +00003437with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00003438 matching '{}'
3439</pre></td></tr>
3440
3441
Manuel Klimek67619ff2012-09-07 13:10:32 +00003442<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>&gt;</td><td class="name" onclick="toggle('hasCondition2')"><a name="hasCondition2Anchor">hasCondition</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00003443<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop,
3444or conditional operator.
3445
3446Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
3447 if (true) {}
3448</pre></td></tr>
3449
3450<!--END_TRAVERSAL_MATCHERS -->
3451</table>
3452
3453</div>
3454</body>
3455</html>
3456
3457