blob: 10b7339165fd3f8ff517cd41a987022eaa178bdd [file] [log] [blame]
Aaron Ballman11825f22015-08-18 19:55:20 +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) {
23 if (!id) return;
24 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>
32<body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))">
33
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
60<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
72<!-- ======================================================================= -->
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
88<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
99<table>
100<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
101<!-- START_DECL_MATCHERS -->
102
Aaron Ballman512fb642015-09-17 13:30:52 +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('cxxCtorInitializer0')"><a name="cxxCtorInitializer0Anchor">cxxCtorInitializer</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="cxxCtorInitializer0"><pre>Matches constructor initializers.
Aaron Ballman11825f22015-08-18 19:55:20 +0000105
106Examples matches i(42).
107 class C {
108 C() : i(42) {}
109 int i;
110 };
111</pre></td></tr>
112
113
114<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
127<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>
128<tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations.
129
130Example matches Z
131 template&lt;class T&gt; class Z {};
132</pre></td></tr>
133
134
135<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>
136<tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations.
137
138Given
139 template&lt;typename T&gt; class A {};
140 template&lt;&gt; class A&lt;double&gt; {};
141 A&lt;int&gt; a;
142classTemplateSpecializationDecl()
143 matches the specializations A&lt;int&gt; and A&lt;double&gt;
144</pre></td></tr>
145
146
Aaron Ballman512fb642015-09-17 13:30:52 +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('cxxConstructorDecl0')"><a name="cxxConstructorDecl0Anchor">cxxConstructorDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;...</td></tr>
148<tr><td colspan="4" class="doc" id="cxxConstructorDecl0"><pre>Matches C++ constructor declarations.
Aaron Ballman11825f22015-08-18 19:55:20 +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
Aaron Ballman512fb642015-09-17 13:30:52 +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('cxxConversionDecl0')"><a name="cxxConversionDecl0Anchor">cxxConversionDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>&gt;...</td></tr>
161<tr><td colspan="4" class="doc" id="cxxConversionDecl0"><pre>Matches conversion operator declarations.
Aaron Ballman11825f22015-08-18 19:55:20 +0000162
163Example matches the operator.
164 class X { operator int() const; };
165</pre></td></tr>
166
167
Aaron Ballman512fb642015-09-17 13:30:52 +0000168<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('cxxDestructorDecl0')"><a name="cxxDestructorDecl0Anchor">cxxDestructorDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>&gt;...</td></tr>
169<tr><td colspan="4" class="doc" id="cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations.
170
171Example matches Foo::~Foo()
172 class Foo {
173 public:
174 virtual ~Foo();
175 };
176</pre></td></tr>
177
178
179<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('cxxMethodDecl0')"><a name="cxxMethodDecl0Anchor">cxxMethodDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;...</td></tr>
180<tr><td colspan="4" class="doc" id="cxxMethodDecl0"><pre>Matches method declarations.
181
182Example matches y
183 class X { void y(); };
184</pre></td></tr>
185
186
187<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('cxxRecordDecl0')"><a name="cxxRecordDecl0Anchor">cxxRecordDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;...</td></tr>
188<tr><td colspan="4" class="doc" id="cxxRecordDecl0"><pre>Matches C++ class declarations.
189
190Example matches X, Z
191 class X;
192 template&lt;class T&gt; class Z {};
193</pre></td></tr>
194
195
Aaron Ballman11825f22015-08-18 19:55:20 +0000196<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>
197<tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations.
198
199Examples matches X, C, and the friend declaration inside C;
200 void X();
201 class C {
202 friend X;
203 };
204</pre></td></tr>
205
206
207<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>
208<tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function
209and non-type template parameter declarations).
210
211Given
212 class X { int y; };
213declaratorDecl()
214 matches int y.
215</pre></td></tr>
216
217
Aaron Ballman11825f22015-08-18 19:55:20 +0000218<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>
219<tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants.
220
221Example matches A, B, C
222 enum X {
223 A, B, C
224 };
225</pre></td></tr>
226
227
228<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>
229<tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations.
230
231Example matches X
232 enum X {
233 A, B, C
234 };
235</pre></td></tr>
236
237
238<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>
239<tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations.
240
241Given
242 class X { int m; };
243fieldDecl()
244 matches 'm'.
245</pre></td></tr>
246
247
248<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>
249<tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations.
250
251Given
252 class X { friend void foo(); };
253friendDecl()
254 matches 'friend void foo()'.
255</pre></td></tr>
256
257
258<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>
259<tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations.
260
261Example matches f
262 void f();
263</pre></td></tr>
264
265
266<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>
267<tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations.
268
269Example matches f
270 template&lt;class T&gt; void f(T t) {}
271</pre></td></tr>
272
273
274<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('linkageSpecDecl0')"><a name="linkageSpecDecl0Anchor">linkageSpecDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LinkageSpecDecl.html">LinkageSpecDecl</a>&gt;...</td></tr>
275<tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification.
276
277Given
278 extern "C" {}
279linkageSpecDecl()
280 matches "extern "C" {}"
281</pre></td></tr>
282
283
Aaron Ballman11825f22015-08-18 19:55:20 +0000284<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>
285<tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name.
286
287Example matches X, S, the anonymous union type, i, and U;
288 typedef int X;
289 struct S {
290 union {
291 int i;
292 } U;
293 };
294</pre></td></tr>
295
296
Aaron Ballman6c79f352015-08-28 19:39:21 +0000297<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('namespaceAliasDecl0')"><a name="namespaceAliasDecl0Anchor">namespaceAliasDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceAliasDecl.html">NamespaceAliasDecl</a>&gt;...</td></tr>
298<tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias.
299
300Given
301 namespace test {}
302 namespace alias = ::test;
303namespaceAliasDecl()
304 matches "namespace alias" but not "namespace test"
305</pre></td></tr>
306
307
Aaron Ballman11825f22015-08-18 19:55:20 +0000308<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>
309<tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace.
310
311Given
312 namespace {}
313 namespace test {}
314namespaceDecl()
315 matches "namespace {}" and "namespace test {}"
316</pre></td></tr>
317
318
Aaron Ballman478a8eb2015-10-05 19:44:42 +0000319<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('nonTypeTemplateParmDecl0')"><a name="nonTypeTemplateParmDecl0Anchor">nonTypeTemplateParmDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NonTypeTemplateParmDecl.html">NonTypeTemplateParmDecl</a>&gt;...</td></tr>
320<tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations.
321
322Given
323 template &lt;typename T, int N&gt; struct C {};
324templateArgument()
325 matches 'N', but not 'T'.
326</pre></td></tr>
327
328
Aaron Ballmanb85be662015-09-11 11:51:24 +0000329<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('objcInterfaceDecl0')"><a name="objcInterfaceDecl0Anchor">objcInterfaceDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>&gt;...</td></tr>
330<tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations.
331
332Example matches Foo
333 @interface Foo
334 @end
335</pre></td></tr>
336
337
Aaron Ballman11825f22015-08-18 19:55:20 +0000338<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>
339<tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations.
340
341Given
342 void f(int x);
343parmVarDecl()
344 matches int x.
345</pre></td></tr>
346
347
Aaron Ballman512fb642015-09-17 13:30:52 +0000348<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_1RecordDecl.html">RecordDecl</a>&gt;...</td></tr>
349<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations.
Aaron Ballman11825f22015-08-18 19:55:20 +0000350
Aaron Ballman512fb642015-09-17 13:30:52 +0000351Example matches X, Z, U, and S
Aaron Ballman11825f22015-08-18 19:55:20 +0000352 class X;
353 template&lt;class T&gt; class Z {};
Aaron Ballman512fb642015-09-17 13:30:52 +0000354 struct S {};
355 union U {};
Aaron Ballman11825f22015-08-18 19:55:20 +0000356</pre></td></tr>
357
358
359<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('staticAssertDecl0')"><a name="staticAssertDecl0Anchor">staticAssertDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1StaticAssertDecl.html">StaticAssertDecl</a>&gt;...</td></tr>
360<tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration.
361
362Example:
363 staticAssertExpr()
364matches
365 static_assert(sizeof(S) == sizeof(int))
366in
367 struct S {
368 int x;
369 };
370 static_assert(sizeof(S) == sizeof(int));
371</pre></td></tr>
372
373
374<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('translationUnitDecl0')"><a name="translationUnitDecl0Anchor">translationUnitDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TranslationUnitDecl.html">TranslationUnitDecl</a>&gt;...</td></tr>
375<tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context.
376
377Given
378 int X;
379 namespace NS {
380 int Y;
381 } namespace NS
382decl(hasDeclContext(translationUnitDecl()))
383 matches "int X", but not "int Y".
384</pre></td></tr>
385
386
387<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('typedefDecl0')"><a name="typedefDecl0Anchor">typedefDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html">TypedefDecl</a>&gt;...</td></tr>
388<tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations.
389
390Given
391 typedef int X;
392typedefDecl()
393 matches "typedef int X"
394</pre></td></tr>
395
396
Aaron Ballmanb85be662015-09-11 11:51:24 +0000397<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('unresolvedUsingTypenameDecl0')"><a name="unresolvedUsingTypenameDecl0Anchor">unresolvedUsingTypenameDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingTypenameDecl.html">UnresolvedUsingTypenameDecl</a>&gt;...</td></tr>
398<tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the
399typename.
400
401Given
402 template &lt;typename T&gt;
403 struct Base { typedef T Foo; };
404
405 template&lt;typename T&gt;
406 struct S : private Base&lt;T&gt; {
407 using typename Base&lt;T&gt;::Foo;
408 };
409unresolvedUsingTypenameDecl()
410 matches using Base&lt;T&gt;::Foo </pre></td></tr>
411
412
Aaron Ballman11825f22015-08-18 19:55:20 +0000413<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>
414<tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations.
415
416Given
417 template&lt;typename X&gt;
418 class C : private X {
419 using X::x;
420 };
421unresolvedUsingValueDecl()
422 matches using X::x </pre></td></tr>
423
424
425<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>
426<tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations.
427
428Given
429 namespace X { int x; }
430 using X::x;
431usingDecl()
432 matches using X::x </pre></td></tr>
433
434
435<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('usingDirectiveDecl0')"><a name="usingDirectiveDecl0Anchor">usingDirectiveDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingDirectiveDecl.html">UsingDirectiveDecl</a>&gt;...</td></tr>
436<tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations.
437
438Given
439 namespace X { int x; }
440 using namespace X;
441usingDirectiveDecl()
442 matches using namespace X </pre></td></tr>
443
444
445<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('valueDecl0')"><a name="valueDecl0Anchor">valueDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;...</td></tr>
446<tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration.
447
448Example matches A, B, C and F
449 enum X { A, B, C };
450 void F();
451</pre></td></tr>
452
453
454<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>
455<tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations.
456
457Note: this does not match declarations of member variables, which are
458"field" declarations in Clang parlance.
459
460Example matches a
461 int a;
462</pre></td></tr>
463
464
465<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>
466<tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
467</pre></td></tr>
468
469
470<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>
471<tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers.
472
473Given
474 namespace ns {
475 struct A { static void f(); };
476 void A::f() {}
477 void g() { A::f(); }
478 }
479 ns::A a;
480nestedNameSpecifier()
481 matches "ns::" and both "A::"
482</pre></td></tr>
483
484
485<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>
486<tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST.
487</pre></td></tr>
488
489
Aaron Ballman11825f22015-08-18 19:55:20 +0000490<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>
491<tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions.
492
493Given
494 int i = a[1];
495arraySubscriptExpr()
496 matches "a[1]"
497</pre></td></tr>
498
499
500<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>
501<tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements.
502
503 int i = 100;
504 __asm("mov al, 2");
505asmStmt()
506 matches '__asm("mov al, 2")'
507</pre></td></tr>
508
509
510<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>
511<tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions.
512
513Example matches a || b
514 !(a || b)
515</pre></td></tr>
516
517
Aaron Ballman11825f22015-08-18 19:55:20 +0000518<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>
519<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements.
520
521Given
522 while (true) { break; }
523breakStmt()
524 matches 'break'
525</pre></td></tr>
526
527
528<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>
529<tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression.
530
531Example: Matches (int*) 2.2f in
532 int i = (int) 2.2f;
533</pre></td></tr>
534
535
536<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>
537<tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions.
538
539Example matches x.y() and y()
540 X x;
541 x.y();
542 y();
543</pre></td></tr>
544
545
546<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>
547<tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements.
548
549Given
550 switch(a) { case 42: break; default: break; }
551caseStmt()
552 matches 'case 42: break;'.
553</pre></td></tr>
554
555
556<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>
557<tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST.
558
559Example: castExpr() matches each of the following:
560 (int) 3;
561 const_cast&lt;Expr *&gt;(SubExpr);
562 char c = 0;
563but does not match
564 int i = (0);
565 int k = 0;
566</pre></td></tr>
567
568
Aaron Ballman11825f22015-08-18 19:55:20 +0000569<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>
570<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t).
571
572Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
573though.
574
575Example matches 'a', L'a'
576 char ch = 'a'; wchar_t chw = L'a';
577</pre></td></tr>
578
579
580<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>
581<tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals
582
583Example match: {1}, (1, 2)
584 int array[4] = {1}; vector int myvec = (vector int)(1, 2);
585</pre></td></tr>
586
587
588<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>
589<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements.
590
591Example matches '{}' and '{{}}'in 'for (;;) {{}}'
592 for (;;) {{}}
593</pre></td></tr>
594
595
596<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>
597<tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions.
598
599Example matches a ? b : c
600 (a ? b : c) + 42
601</pre></td></tr>
602
603
Aaron Ballman512fb642015-09-17 13:30:52 +0000604<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>
605<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements.
606
607Given
608 while (true) { continue; }
609continueStmt()
610 matches 'continue'
611</pre></td></tr>
612
613
614<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cudaKernelCallExpr0')"><a name="cudaKernelCallExpr0Anchor">cudaKernelCallExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html">CUDAKernelCallExpr</a>&gt;...</td></tr>
615<tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression.
616
617Example matches,
618 kernel&lt;&lt;&lt;i,j&gt;&gt;&gt;();
619</pre></td></tr>
620
621
622<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxBindTemporaryExpr0')"><a name="cxxBindTemporaryExpr0Anchor">cxxBindTemporaryExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>&gt;...</td></tr>
623<tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created.
624
625Example matches FunctionTakesString(GetStringByValue())
626 (matcher = cxxBindTemporaryExpr())
627 FunctionTakesString(GetStringByValue());
628 FunctionTakesStringByPointer(GetStringPointer());
629</pre></td></tr>
630
631
632<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxBoolLiteral0')"><a name="cxxBoolLiteral0Anchor">cxxBoolLiteral</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>&gt;...</td></tr>
633<tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals.
634
635Example matches true
636 true
637</pre></td></tr>
638
639
640<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxCatchStmt0')"><a name="cxxCatchStmt0Anchor">cxxCatchStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>&gt;...</td></tr>
641<tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements.
642
643 try {} catch(int i) {}
644cxxCatchStmt()
645 matches 'catch(int i)'
646</pre></td></tr>
647
648
649<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxConstCastExpr0')"><a name="cxxConstCastExpr0Anchor">cxxConstCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>&gt;...</td></tr>
650<tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression.
Aaron Ballman11825f22015-08-18 19:55:20 +0000651
652Example: Matches const_cast&lt;int*&gt;(&amp;r) in
653 int n = 42;
654 const int &amp;r(n);
655 int* p = const_cast&lt;int*&gt;(&amp;r);
656</pre></td></tr>
657
658
Aaron Ballman512fb642015-09-17 13:30:52 +0000659<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxConstructExpr0')"><a name="cxxConstructExpr0Anchor">cxxConstructExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;...</td></tr>
660<tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones).
Aaron Ballman11825f22015-08-18 19:55:20 +0000661
662Example matches string(ptr, n) and ptr within arguments of f
Aaron Ballman512fb642015-09-17 13:30:52 +0000663 (matcher = cxxConstructExpr())
Aaron Ballman11825f22015-08-18 19:55:20 +0000664 void f(const string &amp;a, const string &amp;b);
665 char *ptr;
666 int n;
667 f(string(ptr, n), ptr);
668</pre></td></tr>
669
670
Aaron Ballman512fb642015-09-17 13:30:52 +0000671<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxDefaultArgExpr0')"><a name="cxxDefaultArgExpr0Anchor">cxxDefaultArgExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>&gt;...</td></tr>
672<tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site.
673
674Example matches the CXXDefaultArgExpr placeholder inserted for the
675 default value of the second parameter in the call expression f(42)
676 (matcher = cxxDefaultArgExpr())
677 void f(int x, int y = 0);
678 f(42);
679</pre></td></tr>
680
681
682<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxDeleteExpr0')"><a name="cxxDeleteExpr0Anchor">cxxDeleteExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>&gt;...</td></tr>
683<tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions.
Aaron Ballman11825f22015-08-18 19:55:20 +0000684
685Given
Aaron Ballman512fb642015-09-17 13:30:52 +0000686 delete X;
687cxxDeleteExpr()
688 matches 'delete X'.
689</pre></td></tr>
690
691
692<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxDynamicCastExpr0')"><a name="cxxDynamicCastExpr0Anchor">cxxDynamicCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>&gt;...</td></tr>
693<tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression.
694
695Example:
696 cxxDynamicCastExpr()
697matches
698 dynamic_cast&lt;D*&gt;(&amp;b);
699in
700 struct B { virtual ~B() {} }; struct D : B {};
701 B b;
702 D* p = dynamic_cast&lt;D*&gt;(&amp;b);
703</pre></td></tr>
704
705
706<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxForRangeStmt0')"><a name="cxxForRangeStmt0Anchor">cxxForRangeStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>&gt;...</td></tr>
707<tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements.
708
709cxxForRangeStmt() matches 'for (auto a : i)'
710 int i[] = {1, 2, 3}; for (auto a : i);
711 for(int j = 0; j &lt; 5; ++j);
712</pre></td></tr>
713
714
715<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxFunctionalCastExpr0')"><a name="cxxFunctionalCastExpr0Anchor">cxxFunctionalCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;...</td></tr>
716<tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions
717
718Example: Matches Foo(bar);
719 Foo f = bar;
720 Foo g = (Foo) bar;
721 Foo h = Foo(bar);
722</pre></td></tr>
723
724
725<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxMemberCallExpr0')"><a name="cxxMemberCallExpr0Anchor">cxxMemberCallExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>&gt;...</td></tr>
726<tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions.
727
728Example matches x.y()
729 X x;
730 x.y();
731</pre></td></tr>
732
733
734<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxNewExpr0')"><a name="cxxNewExpr0Anchor">cxxNewExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;...</td></tr>
735<tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions.
736
737Given
738 new X;
739cxxNewExpr()
740 matches 'new X'.
741</pre></td></tr>
742
743
744<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxNullPtrLiteralExpr0')"><a name="cxxNullPtrLiteralExpr0Anchor">cxxNullPtrLiteralExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>&gt;...</td></tr>
745<tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal.
746</pre></td></tr>
747
748
749<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxOperatorCallExpr0')"><a name="cxxOperatorCallExpr0Anchor">cxxOperatorCallExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;...</td></tr>
750<tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls.
751
752Note that if an operator isn't overloaded, it won't match. Instead, use
753binaryOperator matcher.
754Currently it does not match operators such as new delete.
755FIXME: figure out why these do not match?
756
757Example matches both operator&lt;&lt;((o &lt;&lt; b), c) and operator&lt;&lt;(o, b)
758 (matcher = cxxOperatorCallExpr())
759 ostream &amp;operator&lt;&lt; (ostream &amp;out, int i) { };
760 ostream &amp;o; int b = 1, c = 1;
761 o &lt;&lt; b &lt;&lt; c;
762</pre></td></tr>
763
764
765<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxReinterpretCastExpr0')"><a name="cxxReinterpretCastExpr0Anchor">cxxReinterpretCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>&gt;...</td></tr>
766<tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression.
767
768Either the source expression or the destination type can be matched
769using has(), but hasDestinationType() is more specific and can be
770more readable.
771
772Example matches reinterpret_cast&lt;char*&gt;(&amp;p) in
773 void* p = reinterpret_cast&lt;char*&gt;(&amp;p);
774</pre></td></tr>
775
776
777<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxStaticCastExpr0')"><a name="cxxStaticCastExpr0Anchor">cxxStaticCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>&gt;...</td></tr>
778<tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression.
779
780hasDestinationType
781reinterpretCast
782
783Example:
784 cxxStaticCastExpr()
785matches
786 static_cast&lt;long&gt;(8)
787in
788 long eight(static_cast&lt;long&gt;(8));
789</pre></td></tr>
790
791
792<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxTemporaryObjectExpr0')"><a name="cxxTemporaryObjectExpr0Anchor">cxxTemporaryObjectExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;...</td></tr>
793<tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments
794
795Example: Matches Foo(bar, bar)
796 Foo h = Foo(bar, bar);
797</pre></td></tr>
798
799
800<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxThisExpr0')"><a name="cxxThisExpr0Anchor">cxxThisExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>&gt;...</td></tr>
801<tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions.
802
803Example matches the implicit this expression in "return i".
804 (matcher = cxxThisExpr())
805struct foo {
806 int i;
807 int f() { return i; }
808};
809</pre></td></tr>
810
811
812<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxThrowExpr0')"><a name="cxxThrowExpr0Anchor">cxxThrowExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>&gt;...</td></tr>
813<tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions.
814
815 try { throw 5; } catch(int i) {}
816cxxThrowExpr()
817 matches 'throw 5'
818</pre></td></tr>
819
820
821<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxTryStmt0')"><a name="cxxTryStmt0Anchor">cxxTryStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>&gt;...</td></tr>
822<tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements.
823
824 try {} catch(int i) {}
825cxxTryStmt()
826 matches 'try {}'
827</pre></td></tr>
828
829
830<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxUnresolvedConstructExpr0')"><a name="cxxUnresolvedConstructExpr0Anchor">cxxUnresolvedConstructExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;...</td></tr>
831<tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions.
832
833Example matches T(t) in return statement of f
834 (matcher = cxxUnresolvedConstructExpr())
835 template &lt;typename T&gt;
836 void f(const T&amp; t) { return T(t); }
Aaron Ballman11825f22015-08-18 19:55:20 +0000837</pre></td></tr>
838
839
840<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>
841<tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations.
842
843Example matches x in if (x)
844 bool x;
845 if (x) {}
846</pre></td></tr>
847
848
849<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>
850<tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements.
851
852Given
853 int a;
854declStmt()
855 matches 'int a'.
856</pre></td></tr>
857
858
Aaron Ballman11825f22015-08-18 19:55:20 +0000859<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>
860<tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements.
861
862Given
863 switch(a) { case 42: break; default: break; }
864defaultStmt()
865 matches 'default: break;'.
866</pre></td></tr>
867
868
Aaron Ballman11825f22015-08-18 19:55:20 +0000869<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>
870<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements.
871
872Given
873 do {} while (true);
874doStmt()
875 matches 'do {} while(true)'
876</pre></td></tr>
877
878
Aaron Ballman11825f22015-08-18 19:55:20 +0000879<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>
880<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions.
881
882Matches any cast expression written in user code, whether it be a
883C-style cast, a functional-style cast, or a keyword cast.
884
885Does not match implicit conversions.
886
887Note: the name "explicitCast" is chosen to match Clang's terminology, as
888Clang uses the term "cast" to apply to implicit conversions as well as to
889actual cast expressions.
890
891hasDestinationType.
892
893Example: matches all five of the casts in
894 int((int)(reinterpret_cast&lt;int&gt;(static_cast&lt;int&gt;(const_cast&lt;int&gt;(42)))))
895but does not match the implicit conversion in
896 long ell = 42;
897</pre></td></tr>
898
899
900<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>
901<tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions.
902
903Example matches x()
904 void f() { x(); }
905</pre></td></tr>
906
907
908<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('exprWithCleanups0')"><a name="exprWithCleanups0Anchor">exprWithCleanups</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ExprWithCleanups.html">ExprWithCleanups</a>&gt;...</td></tr>
909<tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end
910of the sub-expression's evaluation.
911
912Example matches std::string()
913 const std::string str = std::string();
914</pre></td></tr>
915
916
917<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>
918<tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes encodings, e.g.
9191.0, 1.0f, 1.0L and 1e10.
920
921Does not match implicit conversions such as
922 float a = 10;
923</pre></td></tr>
924
925
Aaron Ballman11825f22015-08-18 19:55:20 +0000926<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>
927<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements.
928
929Example matches 'for (;;) {}'
930 for (;;) {}
931 int i[] = {1, 2, 3}; for (auto a : i);
932</pre></td></tr>
933
934
Aaron Ballman11825f22015-08-18 19:55:20 +0000935<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('gnuNullExpr0')"><a name="gnuNullExpr0Anchor">gnuNullExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1GNUNullExpr.html">GNUNullExpr</a>&gt;...</td></tr>
936<tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression.
937</pre></td></tr>
938
939
940<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>
941<tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements.
942
943Given
944 goto FOO;
945 FOO: bar();
946gotoStmt()
947 matches 'goto FOO'
948</pre></td></tr>
949
950
951<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>
952<tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements.
953
954Example matches 'if (x) {}'
955 if (x) {}
956</pre></td></tr>
957
958
959<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>
960<tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST.
961
962This matches many different places, including function call return value
963eliding, as well as any type conversions.
964</pre></td></tr>
965
966
967<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>
968<tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions.
969
970Given
971 int a[] = { 1, 2 };
972 struct B { int x, y; };
973 B b = { 5, 6 };
974initListExpr()
975 matches "{ 1, 2 }" and "{ 5, 6 }"
976</pre></td></tr>
977
978
979<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>
980<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings, e.g.
9811, 1L, 0x1 and 1U.
982
983Does not match character-encoded integers such as L'a'.
984</pre></td></tr>
985
986
987<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>
988<tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements.
989
990Given
991 goto FOO;
992 FOO: bar();
993labelStmt()
994 matches 'FOO:'
995</pre></td></tr>
996
997
998<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>
999<tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions.
1000
1001Example matches [&amp;](){return 5;}
1002 [&amp;](){return 5;}
1003</pre></td></tr>
1004
1005
1006<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>
1007<tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized.
1008
1009Example: Given
1010 struct T {void func()};
1011 T f();
1012 void g(T);
1013materializeTemporaryExpr() matches 'f()' in these statements
1014 T u(f());
1015 g(f());
1016but does not match
1017 f();
1018 f().func();
1019</pre></td></tr>
1020
1021
Aaron Ballman11825f22015-08-18 19:55:20 +00001022<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>
1023<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions.
1024
1025Given
1026 class Y {
1027 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
1028 int a; static int b;
1029 };
1030memberExpr()
1031 matches this-&gt;x, x, y.x, a, this-&gt;b
1032</pre></td></tr>
1033
1034
Aaron Ballman11825f22015-08-18 19:55:20 +00001035<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>
1036<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements.
1037
1038 foo();;
1039nullStmt()
1040 matches the second ';'
1041</pre></td></tr>
1042
1043
1044<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('objcMessageExpr0')"><a name="objcMessageExpr0Anchor">objcMessageExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;...</td></tr>
1045<tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions.
1046
1047The innermost message send invokes the "alloc" class method on the
1048NSString class, while the outermost message send invokes the
1049"initWithString" instance method on the object returned from
1050NSString's "alloc". This matcher should match both message sends.
1051 [[NSString alloc] initWithString:@"Hello"]
1052</pre></td></tr>
1053
1054
Aaron Ballman11825f22015-08-18 19:55:20 +00001055<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>
1056<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements.
1057
1058Given
1059 return 1;
1060returnStmt()
1061 matches 'return 1'
1062</pre></td></tr>
1063
1064
Aaron Ballman11825f22015-08-18 19:55:20 +00001065<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>
1066<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements.
1067
1068Given
1069 { ++a; }
1070stmt()
1071 matches both the compound statement '{ ++a; }' and '++a'.
1072</pre></td></tr>
1073
1074
1075<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>
1076<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals).
1077
1078Example matches "abcd", L"abcd"
1079 char *s = "abcd"; wchar_t *ws = L"abcd"
1080</pre></td></tr>
1081
1082
1083<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('substNonTypeTemplateParmExpr0')"><a name="substNonTypeTemplateParmExpr0Anchor">substNonTypeTemplateParmExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1SubstNonTypeTemplateParmExpr.html">SubstNonTypeTemplateParmExpr</a>&gt;...</td></tr>
1084<tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters.
1085
1086Given
1087 template &lt;int N&gt;
1088 struct A { static const int n = N; };
1089 struct B : public A&lt;42&gt; {};
1090substNonTypeTemplateParmExpr()
1091 matches "N" in the right-hand side of "static const int n = N;"
1092</pre></td></tr>
1093
1094
1095<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>
1096<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements.
1097
1098Given
1099 switch(a) { case 42: break; default: break; }
1100switchCase()
1101 matches 'case 42: break;' and 'default: break;'.
1102</pre></td></tr>
1103
1104
1105<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>
1106<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements.
1107
1108Given
1109 switch(a) { case 42: break; default: break; }
1110switchStmt()
1111 matches 'switch(a)'.
1112</pre></td></tr>
1113
1114
Aaron Ballman11825f22015-08-18 19:55:20 +00001115<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>
1116<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
1117
1118Given
1119 Foo x = bar;
1120 int y = sizeof(x) + alignof(x);
1121unaryExprOrTypeTraitExpr()
1122 matches sizeof(x) and alignof(x)
1123</pre></td></tr>
1124
1125
1126<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>
1127<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions.
1128
1129Example matches !a
1130 !a || b
1131</pre></td></tr>
1132
1133
Aaron Ballman11825f22015-08-18 19:55:20 +00001134<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>
1135<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call.
1136
1137Example match: "foo"_suffix
1138</pre></td></tr>
1139
1140
1141<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>
1142<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements.
1143
1144Given
1145 while (true) {}
1146whileStmt()
1147 matches 'while (true) {}'.
1148</pre></td></tr>
1149
1150
1151<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('templateArgument0')"><a name="templateArgument0Anchor">templateArgument</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;...</td></tr>
1152<tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments.
1153
1154Given
1155 template &lt;typename T&gt; struct C {};
1156 C&lt;int&gt; c;
1157templateArgument()
1158 matches 'int' in C&lt;int&gt;.
1159</pre></td></tr>
1160
1161
1162<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>
1163<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST.
1164</pre></td></tr>
1165
1166
1167<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>
1168<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays.
1169
1170Given
1171 int a[] = { 2, 3 };
1172 int b[4];
1173 void f() { int c[a[0]]; }
1174arrayType()
1175 matches "int a[]", "int b[4]" and "int c[a[0]]";
1176</pre></td></tr>
1177
1178
1179<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>
1180<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types.
1181
1182Given
1183 _Atomic(int) i;
1184atomicType()
1185 matches "_Atomic(int) i"
1186</pre></td></tr>
1187
1188
1189<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>
1190<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types.
1191
1192Given:
1193 auto n = 4;
1194 int v[] = { 2, 3 }
1195 for (auto i : v) { }
1196autoType()
1197 matches "auto n" and "auto i"
1198</pre></td></tr>
1199
1200
1201<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>
1202<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as
1203"void (^)(int)".
1204
1205The pointee is always required to be a FunctionType.
1206</pre></td></tr>
1207
1208
1209<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>
1210<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types.
1211
1212Given
1213 struct A {};
1214 A a;
1215 int b;
1216 float c;
1217 bool d;
1218builtinType()
1219 matches "int b", "float c" and "bool d"
1220</pre></td></tr>
1221
1222
1223<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>
1224<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types.
1225
1226Given
1227 _Complex float f;
1228complexType()
1229 matches "_Complex float f"
1230</pre></td></tr>
1231
1232
1233<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>
1234<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size.
1235
1236Given
1237 void() {
1238 int a[2];
1239 int b[] = { 2, 3 };
1240 int c[b[0]];
1241 }
1242constantArrayType()
1243 matches "int a[2]"
1244</pre></td></tr>
1245
1246
Matthias Gehre2cf7e802015-10-12 21:46:07 +00001247<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('decayedType0')"><a name="decayedType0Anchor">decayedType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DecayedType.html">DecayedType</a>&gt;...</td></tr>
1248<tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type
1249Example matches i[] in declaration of f.
1250 (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
1251Example matches i[1].
1252 (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())))))
1253 void f(int i[]) {
1254 i[1] = 0;
1255 }
1256</pre></td></tr>
1257
1258
Aaron Ballman11825f22015-08-18 19:55:20 +00001259<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>
1260<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression.
1261
1262Given
1263 template&lt;typename T, int Size&gt;
1264 class array {
1265 T data[Size];
1266 };
1267dependentSizedArrayType
1268 matches "T data[Size]"
1269</pre></td></tr>
1270
1271
1272<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>
1273<tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a
1274qualified name.
1275
1276Given
1277 namespace N {
1278 namespace M {
1279 class D {};
1280 }
1281 }
1282 class C {};
1283
1284 class C c;
1285 N::M::D d;
1286
1287elaboratedType() matches the type of the variable declarations of both
1288c and d.
1289</pre></td></tr>
1290
1291
1292<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>
1293<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes.
1294
1295Given
1296 int (*f)(int);
1297 void g();
1298functionType()
1299 matches "int (*f)(int)" and the type of "g".
1300</pre></td></tr>
1301
1302
1303<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>
1304<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size.
1305
1306Given
1307 int a[] = { 2, 3 };
1308 int b[42];
1309 void f(int c[]) { int d[a[0]]; };
1310incompleteArrayType()
1311 matches "int a[]" and "int c[]"
1312</pre></td></tr>
1313
1314
Aaron Ballmanb85be662015-09-11 11:51:24 +00001315<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('injectedClassNameType0')"><a name="injectedClassNameType0Anchor">injectedClassNameType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;...</td></tr>
1316<tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types.
1317
1318Example matches S s, but not S&lt;T&gt; s.
1319 (matcher = parmVarDecl(hasType(injectedClassNameType())))
1320 template &lt;typename T&gt; struct S {
1321 void f(S s);
1322 void g(S&lt;T&gt; s);
1323 };
1324</pre></td></tr>
1325
1326
Aaron Ballman11825f22015-08-18 19:55:20 +00001327<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>
1328<tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types.
1329
1330Given:
1331 int *a;
1332 int &amp;b = *a;
1333 int &amp;&amp;c = 1;
1334 auto &amp;d = b;
1335 auto &amp;&amp;e = c;
1336 auto &amp;&amp;f = 2;
1337 int g = 5;
1338
1339lValueReferenceType() matches the types of b, d, and e. e is
1340matched since the type is deduced as int&amp; by reference collapsing rules.
1341</pre></td></tr>
1342
1343
1344<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>
1345<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types.
1346Given
1347 struct A { int i; }
1348 A::* ptr = A::i;
1349memberPointerType()
1350 matches "A::* ptr"
1351</pre></td></tr>
1352
1353
Aaron Ballmanb85be662015-09-11 11:51:24 +00001354<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('objcObjectPointerType0')"><a name="objcObjectPointerType0Anchor">objcObjectPointerType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html">ObjCObjectPointerType</a>&gt;...</td></tr>
1355<tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from
1356a pointer type, despite being syntactically similar.
1357
1358Given
1359 int *a;
1360
1361 @interface Foo
1362 @end
1363 Foo *f;
1364pointerType()
1365 matches "Foo *f", but does not match "int *a".
1366</pre></td></tr>
1367
1368
Aaron Ballman11825f22015-08-18 19:55:20 +00001369<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>
1370<tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes.
1371
1372Given
1373 int (*ptr_to_array)[4];
1374 int *array_of_ptrs[4];
1375
1376varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not
1377array_of_ptrs.
1378</pre></td></tr>
1379
1380
1381<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>
Aaron Ballmanb85be662015-09-11 11:51:24 +00001382<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer
1383types.
Aaron Ballman11825f22015-08-18 19:55:20 +00001384
1385Given
1386 int *a;
1387 int &amp;b = *a;
1388 int c = 5;
Aaron Ballmanb85be662015-09-11 11:51:24 +00001389
1390 @interface Foo
1391 @end
1392 Foo *f;
Aaron Ballman11825f22015-08-18 19:55:20 +00001393pointerType()
Aaron Ballmanb85be662015-09-11 11:51:24 +00001394 matches "int *a", but does not match "Foo *f".
Aaron Ballman11825f22015-08-18 19:55:20 +00001395</pre></td></tr>
1396
1397
1398<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>
1399<tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types.
1400
1401Given:
1402 int *a;
1403 int &amp;b = *a;
1404 int &amp;&amp;c = 1;
1405 auto &amp;d = b;
1406 auto &amp;&amp;e = c;
1407 auto &amp;&amp;f = 2;
1408 int g = 5;
1409
1410rValueReferenceType() matches the types of c and f. e is not
1411matched as it is deduced to int&amp; by reference collapsing rules.
1412</pre></td></tr>
1413
1414
1415<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>
1416<tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes).
1417
1418Given
1419 class C {};
1420 struct S {};
1421
1422 C c;
1423 S s;
1424
1425recordType() matches the type of the variable declarations of both c
1426and s.
1427</pre></td></tr>
1428
1429
1430<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>
1431<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types.
1432
1433Given
1434 int *a;
1435 int &amp;b = *a;
1436 int &amp;&amp;c = 1;
1437 auto &amp;d = b;
1438 auto &amp;&amp;e = c;
1439 auto &amp;&amp;f = 2;
1440 int g = 5;
1441
1442referenceType() matches the types of b, c, d, e, and f.
1443</pre></td></tr>
1444
1445
Aaron Ballman6e146522015-08-28 19:39:56 +00001446<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('substTemplateTypeParmType0')"><a name="substTemplateTypeParmType0Anchor">substTemplateTypeParmType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html">SubstTemplateTypeParmType</a>&gt;...</td></tr>
1447<tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a
1448template type parameter.
1449
1450Given
1451 template &lt;typename T&gt;
1452 void F(T t) {
1453 int i = 1 + t;
1454 }
1455
1456substTemplateTypeParmType() matches the type of 't' but not '1'
1457</pre></td></tr>
1458
1459
Aaron Ballman11825f22015-08-18 19:55:20 +00001460<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>
1461<tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types.
1462
1463Given
1464 template &lt;typename T&gt;
1465 class C { };
1466
1467 template class C&lt;int&gt;; A
1468 C&lt;char&gt; var; B
1469
1470templateSpecializationType() matches the type of the explicit
1471instantiation in A and the type of the variable declaration in B.
1472</pre></td></tr>
1473
1474
Aaron Ballmanb85be662015-09-11 11:51:24 +00001475<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('templateTypeParmType0')"><a name="templateTypeParmType0Anchor">templateTypeParmType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;...</td></tr>
1476<tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types.
1477
1478Example matches T, but not int.
1479 (matcher = templateTypeParmType())
1480 template &lt;typename T&gt; void f(int i);
1481</pre></td></tr>
1482
1483
Aaron Ballman11825f22015-08-18 19:55:20 +00001484<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>
1485<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST.
1486</pre></td></tr>
1487
1488
1489<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>
1490<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types.
1491
1492Given
1493 typedef int X;
1494typedefType()
1495 matches "typedef int X"
1496</pre></td></tr>
1497
1498
1499<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>
1500<tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations.
1501
1502Given:
1503 typedef __underlying_type(T) type;
1504unaryTransformType()
1505 matches "__underlying_type(T)"
1506</pre></td></tr>
1507
1508
1509<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>
1510<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an
1511integer-constant-expression.
1512
1513Given
1514 void f() {
1515 int a[] = { 2, 3 }
1516 int b[42];
1517 int c[a[0]];
1518 }
1519variableArrayType()
1520 matches "int c[a[0]]"
1521</pre></td></tr>
1522
1523<!--END_DECL_MATCHERS -->
1524</table>
1525
1526<!-- ======================================================================= -->
1527<h2 id="narrowing-matchers">Narrowing Matchers</h2>
1528<!-- ======================================================================= -->
1529
1530<p>Narrowing matchers match certain attributes on the current node, thus
1531narrowing down the set of nodes of the current type to match on.</p>
1532
1533<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless)
1534which allow users to create more powerful match expressions.</p>
1535
1536<table>
1537<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
1538<!-- START_NARROWING_MATCHERS -->
1539
1540<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>
1541<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match.
1542
1543Usable as: Any Matcher
1544</pre></td></tr>
1545
1546
1547<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>
1548<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches.
1549
1550Usable as: Any Matcher
1551</pre></td></tr>
1552
1553
1554<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr>
1555<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node.
1556
1557Useful when another matcher requires a child matcher, but there's no
1558additional constraint. This will often be used with an explicit conversion
1559to an internal::Matcher&lt;&gt; type such as TypeMatcher.
1560
1561Example: DeclarationMatcher(anything()) matches all declarations, e.g.,
1562"int* p" and "void f()" in
1563 int* p;
1564 void f();
1565
1566Usable as: Any Matcher
1567</pre></td></tr>
1568
1569
1570<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher&lt;*&gt;</td></tr>
1571<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match.
1572
Aaron Ballman512fb642015-09-17 13:30:52 +00001573Example matches Y (matcher = cxxRecordDecl(unless(hasName("X"))))
Aaron Ballman11825f22015-08-18 19:55:20 +00001574 class X {};
1575 class Y {};
1576
1577Usable as: Any Matcher
1578</pre></td></tr>
1579
1580
1581<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>
1582<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or
1583unary).
1584
1585Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
1586 !(a || b)
1587</pre></td></tr>
1588
1589
1590<tr><td>Matcher&lt;CXXBoolLiteral&gt;</td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>ValueT Value</td></tr>
1591<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value.
1592
Aaron Ballman512fb642015-09-17 13:30:52 +00001593Example matches true (matcher = cxxBoolLiteral(equals(true)))
Aaron Ballman11825f22015-08-18 19:55:20 +00001594 true
1595
1596Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1597 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;
1598</pre></td></tr>
1599
1600
1601<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>&gt;</td><td class="name" onclick="toggle('isCatchAll0')"><a name="isCatchAll0Anchor">isCatchAll</a></td><td></td></tr>
1602<tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler.
1603
1604Given
1605 try {
1606 ...
1607 } catch (int) {
1608 ...
1609 } catch (...) {
1610 ...
1611 }
1612endcode
Aaron Ballman512fb642015-09-17 13:30:52 +00001613cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
Aaron Ballman11825f22015-08-18 19:55:20 +00001614</pre></td></tr>
1615
1616
1617<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>
1618<tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has
1619a specific number of arguments (including absent default arguments).
1620
1621Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
1622 void f(int x, int y);
1623 f(0, 0);
1624</pre></td></tr>
1625
1626
1627<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('isListInitialization0')"><a name="isListInitialization0Anchor">isListInitialization</a></td><td></td></tr>
1628<tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization.
1629</pre></td></tr>
1630
1631
1632<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('isCopyConstructor0')"><a name="isCopyConstructor0Anchor">isCopyConstructor</a></td><td></td></tr>
1633<tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors.
1634
1635Given
1636 struct S {
1637 S(); #1
1638 S(const S &amp;); #2
1639 S(S &amp;&amp;); #3
1640 };
Aaron Ballman512fb642015-09-17 13:30:52 +00001641cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
Aaron Ballman11825f22015-08-18 19:55:20 +00001642</pre></td></tr>
1643
1644
1645<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('isDefaultConstructor0')"><a name="isDefaultConstructor0Anchor">isDefaultConstructor</a></td><td></td></tr>
1646<tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors.
1647
1648Given
1649 struct S {
1650 S(); #1
1651 S(const S &amp;); #2
1652 S(S &amp;&amp;); #3
1653 };
Aaron Ballman512fb642015-09-17 13:30:52 +00001654cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
Aaron Ballman11825f22015-08-18 19:55:20 +00001655</pre></td></tr>
1656
1657
1658<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('isExplicit0')"><a name="isExplicit0Anchor">isExplicit</a></td><td></td></tr>
1659<tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor and conversion declarations that are marked with
1660the explicit keyword.
1661
1662Given
1663 struct S {
1664 S(int); #1
1665 explicit S(double); #2
1666 operator int(); #3
1667 explicit operator bool(); #4
1668 };
Aaron Ballman512fb642015-09-17 13:30:52 +00001669cxxConstructorDecl(isExplicit()) will match #2, but not #1.
1670cxxConversionDecl(isExplicit()) will match #4, but not #3.
Aaron Ballman11825f22015-08-18 19:55:20 +00001671</pre></td></tr>
1672
1673
1674<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('isMoveConstructor0')"><a name="isMoveConstructor0Anchor">isMoveConstructor</a></td><td></td></tr>
1675<tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors.
1676
1677Given
1678 struct S {
1679 S(); #1
1680 S(const S &amp;); #2
1681 S(S &amp;&amp;); #3
1682 };
Aaron Ballman512fb642015-09-17 13:30:52 +00001683cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
Aaron Ballman11825f22015-08-18 19:55:20 +00001684</pre></td></tr>
1685
1686
1687<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>&gt;</td><td class="name" onclick="toggle('isExplicit1')"><a name="isExplicit1Anchor">isExplicit</a></td><td></td></tr>
1688<tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor and conversion declarations that are marked with
1689the explicit keyword.
1690
1691Given
1692 struct S {
1693 S(int); #1
1694 explicit S(double); #2
1695 operator int(); #3
1696 explicit operator bool(); #4
1697 };
Aaron Ballman512fb642015-09-17 13:30:52 +00001698cxxConstructorDecl(isExplicit()) will match #2, but not #1.
1699cxxConversionDecl(isExplicit()) will match #4, but not #3.
Aaron Ballman11825f22015-08-18 19:55:20 +00001700</pre></td></tr>
1701
1702
1703<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;</td><td class="name" onclick="toggle('isBaseInitializer0')"><a name="isBaseInitializer0Anchor">isBaseInitializer</a></td><td></td></tr>
1704<tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as
1705opposed to a member.
1706
1707Given
1708 struct B {};
1709 struct D : B {
1710 int I;
1711 D(int i) : I(i) {}
1712 };
1713 struct E : B {
1714 E() : B() {}
1715 };
Aaron Ballman512fb642015-09-17 13:30:52 +00001716cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
Aaron Ballman11825f22015-08-18 19:55:20 +00001717 will match E(), but not match D(int).
1718</pre></td></tr>
1719
1720
1721<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;</td><td class="name" onclick="toggle('isMemberInitializer0')"><a name="isMemberInitializer0Anchor">isMemberInitializer</a></td><td></td></tr>
1722<tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as
1723opposed to a base.
1724
1725Given
1726 struct B {};
1727 struct D : B {
1728 int I;
1729 D(int i) : I(i) {}
1730 };
1731 struct E : B {
1732 E() : B() {}
1733 };
Aaron Ballman512fb642015-09-17 13:30:52 +00001734cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
Aaron Ballman11825f22015-08-18 19:55:20 +00001735 will match D(int), but not match E().
1736</pre></td></tr>
1737
1738
1739<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>
1740<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in
1741code (as opposed to implicitly added by the compiler).
1742
1743Given
1744 struct Foo {
1745 Foo() { }
1746 Foo(int) : foo_("A") { }
1747 string foo_;
1748 };
Aaron Ballman512fb642015-09-17 13:30:52 +00001749cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
Aaron Ballman11825f22015-08-18 19:55:20 +00001750 will match Foo(int), but not Foo()
1751</pre></td></tr>
1752
1753
1754<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>
1755<tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const.
1756
1757Given
1758struct A {
1759 void foo() const;
1760 void bar();
1761};
1762
Aaron Ballman512fb642015-09-17 13:30:52 +00001763cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
Aaron Ballman11825f22015-08-18 19:55:20 +00001764</pre></td></tr>
1765
1766
1767<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isFinal1')"><a name="isFinal1Anchor">isFinal</a></td><td></td></tr>
1768<tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final.
1769
1770Given:
1771 class A final {};
1772
1773 struct B {
1774 virtual void f();
1775 };
1776
1777 struct C : B {
1778 void f() final;
1779 };
1780matches A and C::f, but not B, C, or B::f
1781</pre></td></tr>
1782
1783
1784<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>
1785<tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method.
1786
1787Given
1788 class A {
1789 public:
1790 virtual void x();
1791 };
1792 class B : public A {
1793 public:
1794 virtual void x();
1795 };
1796 matches B::x
1797</pre></td></tr>
1798
1799
1800<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isPure0')"><a name="isPure0Anchor">isPure</a></td><td></td></tr>
1801<tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure.
1802
1803Given
1804 class A {
1805 public:
1806 virtual void x() = 0;
1807 };
1808 matches A::x
1809</pre></td></tr>
1810
1811
1812<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>
1813<tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual.
1814
1815Given
1816 class A {
1817 public:
1818 virtual void x();
1819 };
1820 matches A::x
1821</pre></td></tr>
1822
1823
1824<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>
1825<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names.
1826
1827Matches overloaded operator names specified in strings without the
1828"operator" prefix: e.g. "&lt;&lt;".
1829
1830Given:
1831 class A { int operator*(); };
1832 const A &amp;operator&lt;&lt;(const A &amp;a, const A &amp;b);
1833 A a;
1834 a &lt;&lt; a; &lt;-- This matches
1835
Aaron Ballman512fb642015-09-17 13:30:52 +00001836cxxOperatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the
1837specified line and
1838cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
1839matches the declaration of A.
Aaron Ballman11825f22015-08-18 19:55:20 +00001840
1841Usable 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_1FunctionDecl.html">FunctionDecl</a>&gt;
1842</pre></td></tr>
1843
1844
1845<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>std::string BaseName</td></tr>
1846<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
1847</pre></td></tr>
1848
1849
1850<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>
1851<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or
1852static member variable template instantiations.
1853
1854Given
1855 template&lt;typename T&gt; void A(T t) { }
1856 template&lt;&gt; void A(int N) { }
1857functionDecl(isExplicitTemplateSpecialization())
1858 matches the specialization A&lt;int&gt;().
1859
1860Usable 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;
1861</pre></td></tr>
1862
1863
1864<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isFinal0')"><a name="isFinal0Anchor">isFinal</a></td><td></td></tr>
1865<tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final.
1866
1867Given:
1868 class A final {};
1869
1870 struct B {
1871 virtual void f();
1872 };
1873
1874 struct C : B {
1875 void f() final;
1876 };
1877matches A and C::f, but not B, C, or B::f
1878</pre></td></tr>
1879
1880
1881<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>std::string BaseName</td></tr>
1882<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for
1883isSameOrDerivedFrom(hasName(...)).
1884</pre></td></tr>
1885
1886
1887<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>
1888<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static
1889member variable template instantiations.
1890
1891Given
1892 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
1893or
1894 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Aaron Ballman512fb642015-09-17 13:30:52 +00001895cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
Aaron Ballman11825f22015-08-18 19:55:20 +00001896 matches the template instantiation of X&lt;A&gt;.
1897
1898But given
1899 template &lt;typename T&gt; class X {}; class A {};
1900 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Aaron Ballman512fb642015-09-17 13:30:52 +00001901cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
Aaron Ballman11825f22015-08-18 19:55:20 +00001902 does not match, as X&lt;A&gt; is an explicit template specialization.
1903
1904Usable 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;
1905</pre></td></tr>
1906
1907
1908<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>
1909<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has
1910a specific number of arguments (including absent default arguments).
1911
1912Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
1913 void f(int x, int y);
1914 f(0, 0);
1915</pre></td></tr>
1916
1917
1918<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>
1919<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value.
1920
Aaron Ballman512fb642015-09-17 13:30:52 +00001921Example matches true (matcher = cxxBoolLiteral(equals(true)))
Aaron Ballman11825f22015-08-18 19:55:20 +00001922 true
1923
1924Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1925 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;
1926</pre></td></tr>
1927
1928
1929<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;</td><td class="name" onclick="toggle('templateArgumentCountIs0')"><a name="templateArgumentCountIs0Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr>
1930<tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N.
1931
1932Given
1933 template&lt;typename T&gt; struct C {};
1934 C&lt;int&gt; c;
1935classTemplateSpecializationDecl(templateArgumentCountIs(1))
1936 matches C&lt;int&gt;.
1937</pre></td></tr>
1938
1939
1940<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>
1941<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of
1942child statements.
1943
1944Example: Given
1945 { for (;;) {} }
1946compoundStmt(statementCountIs(0)))
1947 matches '{}'
1948 but does not match the outer compound statement.
1949</pre></td></tr>
1950
1951
1952<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>
1953<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size.
1954
1955Given
1956 int a[42];
1957 int b[2 * 21];
1958 int c[41], d[43];
1959constantArrayType(hasSize(42))
1960 matches "int a[42]" and "int b[2 * 21]"
1961</pre></td></tr>
1962
1963
1964<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>
1965<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of
1966declarations.
1967
1968Example: Given
1969 int a, b;
1970 int c;
1971 int d = 2, e;
1972declCountIs(2)
1973 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.
1974</pre></td></tr>
1975
1976
1977<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>
1978<tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node.
1979
1980Matches a node if it equals the node previously bound to ID.
1981
1982Given
1983 class X { int a; int b; };
Aaron Ballman512fb642015-09-17 13:30:52 +00001984cxxRecordDecl(
Aaron Ballman11825f22015-08-18 19:55:20 +00001985 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
1986 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
1987 matches the class X, as a and b have the same type.
1988
1989Note that when multiple matches are involved via forEach* matchers,
1990equalsBoundNodes acts as a filter.
1991For example:
1992compoundStmt(
1993 forEachDescendant(varDecl().bind("d")),
1994 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
1995will trigger a match for each combination of variable declaration
1996and reference to that variable declaration within a compound statement.
1997</pre></td></tr>
1998
1999
2000<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('hasAttr0')"><a name="hasAttr0Anchor">hasAttr</a></td><td>attr::Kind AttrKind</td></tr>
2001<tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute.
2002
2003Given
2004 __attribute__((device)) void f() { ... }
2005decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
2006f. If the matcher is use from clang-query, attr::Kind parameter should be
2007passed as a quoted string. e.g., hasAttr("attr::CUDADevice").
2008</pre></td></tr>
2009
2010
2011<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isExpansionInFileMatching0')"><a name="isExpansionInFileMatching0Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr>
2012<tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is
2013partially matching a given regex.
2014
2015Example matches Y but not X
Aaron Ballman512fb642015-09-17 13:30:52 +00002016 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
Aaron Ballman11825f22015-08-18 19:55:20 +00002017 #include "ASTMatcher.h"
2018 class X {};
2019ASTMatcher.h:
2020 class Y {};
2021
2022Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
2023</pre></td></tr>
2024
2025
2026<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isExpansionInMainFile0')"><a name="isExpansionInMainFile0Anchor">isExpansionInMainFile</a></td><td></td></tr>
2027<tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file.
2028
Aaron Ballman512fb642015-09-17 13:30:52 +00002029Example matches X but not Y
2030 (matcher = cxxRecordDecl(isExpansionInMainFile())
Aaron Ballman11825f22015-08-18 19:55:20 +00002031 #include &lt;Y.h&gt;
2032 class X {};
2033Y.h:
2034 class Y {};
2035
2036Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
2037</pre></td></tr>
2038
2039
2040<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isExpansionInSystemHeader0')"><a name="isExpansionInSystemHeader0Anchor">isExpansionInSystemHeader</a></td><td></td></tr>
2041<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files.
2042
2043Example matches Y but not X
Aaron Ballman512fb642015-09-17 13:30:52 +00002044 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
Aaron Ballman11825f22015-08-18 19:55:20 +00002045 #include &lt;SystemHeader.h&gt;
2046 class X {};
2047SystemHeader.h:
2048 class Y {};
2049
2050Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
2051</pre></td></tr>
2052
2053
2054<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr>
2055<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added
2056by the compiler (eg. implicit defaultcopy constructors).
2057</pre></td></tr>
2058
2059
2060<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>
2061<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations.
2062
2063Given
2064 class C {
2065 public: int a;
2066 protected: int b;
2067 private: int c;
2068 };
2069fieldDecl(isPrivate())
2070 matches 'int c;'
2071</pre></td></tr>
2072
2073
2074<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>
2075<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations.
2076
2077Given
2078 class C {
2079 public: int a;
2080 protected: int b;
2081 private: int c;
2082 };
2083fieldDecl(isProtected())
2084 matches 'int b;'
2085</pre></td></tr>
2086
2087
2088<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>
2089<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations.
2090
2091Given
2092 class C {
2093 public: int a;
2094 protected: int b;
2095 private: int c;
2096 };
2097fieldDecl(isPublic())
2098 matches 'int a;'
2099</pre></td></tr>
2100
2101
2102<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>
2103<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value.
2104
Aaron Ballman512fb642015-09-17 13:30:52 +00002105Example matches true (matcher = cxxBoolLiteral(equals(true)))
Aaron Ballman11825f22015-08-18 19:55:20 +00002106 true
2107
2108Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
2109 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;
2110</pre></td></tr>
2111
2112
2113<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr>
2114<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names.
2115
2116Matches overloaded operator names specified in strings without the
2117"operator" prefix: e.g. "&lt;&lt;".
2118
2119Given:
2120 class A { int operator*(); };
2121 const A &amp;operator&lt;&lt;(const A &amp;a, const A &amp;b);
2122 A a;
2123 a &lt;&lt; a; &lt;-- This matches
2124
Aaron Ballman512fb642015-09-17 13:30:52 +00002125cxxOperatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the
2126specified line and
2127cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
2128matches the declaration of A.
Aaron Ballman11825f22015-08-18 19:55:20 +00002129
2130Usable 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_1FunctionDecl.html">FunctionDecl</a>&gt;
2131</pre></td></tr>
2132
2133
2134<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isConstexpr1')"><a name="isConstexpr1Anchor">isConstexpr</a></td><td></td></tr>
2135<tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations.
2136
2137Given:
2138 constexpr int foo = 42;
2139 constexpr int bar();
2140varDecl(isConstexpr())
2141 matches the declaration of foo.
2142functionDecl(isConstexpr())
2143 matches the declaration of bar.
2144</pre></td></tr>
2145
2146
2147<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>
2148<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached.
2149
2150Example matches A, va, fa
2151 class A {};
2152 class B; Doesn't match, as it has no body.
2153 int va;
2154 extern int vb; Doesn't match, as it doesn't define the variable.
2155 void fa() {}
2156 void fb(); Doesn't match, as it has no body.
2157
2158Usable 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;
2159</pre></td></tr>
2160
2161
2162<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isDeleted0')"><a name="isDeleted0Anchor">isDeleted</a></td><td></td></tr>
2163<tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations.
2164
2165Given:
2166 void Func();
2167 void DeletedFunc() = delete;
2168functionDecl(isDeleted())
2169 matches the declaration of DeletedFunc, but not Func.
2170</pre></td></tr>
2171
2172
2173<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>
2174<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or
2175static member variable template instantiations.
2176
2177Given
2178 template&lt;typename T&gt; void A(T t) { }
2179 template&lt;&gt; void A(int N) { }
2180functionDecl(isExplicitTemplateSpecialization())
2181 matches the specialization A&lt;int&gt;().
2182
2183Usable 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;
2184</pre></td></tr>
2185
2186
2187<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>
2188<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations.
2189
2190Given:
2191 extern "C" void f() {}
2192 extern "C" { void g() {} }
2193 void h() {}
2194functionDecl(isExternC())
2195 matches the declaration of f and g, but not the declaration h
2196</pre></td></tr>
2197
2198
2199<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isInline1')"><a name="isInline1Anchor">isInline</a></td><td></td></tr>
2200<tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with
2201the inline keyword.
2202
2203Given
2204 inline void f();
2205 void g();
2206 namespace n {
2207 inline namespace m {}
2208 }
2209functionDecl(isInline()) will match ::f().
2210namespaceDecl(isInline()) will match n::m.
2211</pre></td></tr>
2212
2213
2214<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>
2215<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static
2216member variable template instantiations.
2217
2218Given
2219 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
2220or
2221 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Aaron Ballman512fb642015-09-17 13:30:52 +00002222cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
Aaron Ballman11825f22015-08-18 19:55:20 +00002223 matches the template instantiation of X&lt;A&gt;.
2224
2225But given
2226 template &lt;typename T&gt; class X {}; class A {};
2227 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Aaron Ballman512fb642015-09-17 13:30:52 +00002228cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
Aaron Ballman11825f22015-08-18 19:55:20 +00002229 does not match, as X&lt;A&gt; is an explicit template specialization.
2230
2231Usable 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;
2232</pre></td></tr>
2233
2234
Aaron Ballman3fd6c112015-10-05 14:41:27 +00002235<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isVariadic0')"><a name="isVariadic0Anchor">isVariadic</a></td><td></td></tr>
2236<tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic.
2237
Aaron Ballman478a8eb2015-10-05 19:44:42 +00002238Example matches f, but not g or h. The function i will not match, even when
Aaron Ballman3fd6c112015-10-05 14:41:27 +00002239compiled in C mode.
2240 void f(...);
2241 void g(int);
2242 template &lt;typename... Ts&gt; void h(Ts...);
2243 void i();
2244</pre></td></tr>
2245
2246
Aaron Ballman11825f22015-08-18 19:55:20 +00002247<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>
2248<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count.
2249
2250Given
2251 void f(int i) {}
2252 void g(int i, int j) {}
2253functionDecl(parameterCountIs(2))
2254 matches g(int i, int j) {}
2255</pre></td></tr>
2256
2257
2258<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>
2259<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value.
2260
Aaron Ballman512fb642015-09-17 13:30:52 +00002261Example matches true (matcher = cxxBoolLiteral(equals(true)))
Aaron Ballman11825f22015-08-18 19:55:20 +00002262 true
2263
2264Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
2265 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;
2266</pre></td></tr>
2267
2268
2269<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>
2270<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '-&gt;' as opposed
2271to '.'.
2272
2273Member calls on the implicit this pointer match as called with '-&gt;'.
2274
2275Given
2276 class Y {
2277 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
2278 int a;
2279 static int b;
2280 };
2281memberExpr(isArrow())
2282 matches this-&gt;x, x, y.x, a, this-&gt;b
2283</pre></td></tr>
2284
2285
2286<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>
2287<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name.
2288
2289Supports specifying enclosing namespaces or classes by prefixing the name
2290with '&lt;enclosing&gt;::'.
2291Does not match typedefs of an underlying type with the given name.
2292
2293Example matches X (Name == "X")
2294 class X;
2295
2296Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
2297 namespace a { namespace b { class X; } }
2298</pre></td></tr>
2299
2300
2301<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>
2302<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain
2303a substring matched by the given RegExp.
2304
2305Supports specifying enclosing namespaces or classes by
2306prefixing the name with '&lt;enclosing&gt;::'. Does not match typedefs
2307of an underlying type with the given name.
2308
2309Example matches X (regexp == "::X")
2310 class X;
2311
2312Example matches X (regexp is one of "::X", "^foo::.*X", among others)
2313 namespace foo { namespace bar { class X; } }
2314</pre></td></tr>
2315
2316
2317<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>&gt;</td><td class="name" onclick="toggle('isAnonymous0')"><a name="isAnonymous0Anchor">isAnonymous</a></td><td></td></tr>
2318<tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations.
2319
2320Given
2321 namespace n {
2322 namespace {} #1
2323 }
2324namespaceDecl(isAnonymous()) will match #1 but not ::n.
2325</pre></td></tr>
2326
2327
2328<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>&gt;</td><td class="name" onclick="toggle('isInline0')"><a name="isInline0Anchor">isInline</a></td><td></td></tr>
2329<tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with
2330the inline keyword.
2331
2332Given
2333 inline void f();
2334 void g();
2335 namespace n {
2336 inline namespace m {}
2337 }
2338functionDecl(isInline()) will match ::f().
2339namespaceDecl(isInline()) will match n::m.
2340</pre></td></tr>
2341
2342
2343<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('argumentCountIs2')"><a name="argumentCountIs2Anchor">argumentCountIs</a></td><td>unsigned N</td></tr>
2344<tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has
2345a specific number of arguments (including absent default arguments).
2346
2347Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
2348 void f(int x, int y);
2349 f(0, 0);
2350</pre></td></tr>
2351
2352
2353<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasKeywordSelector0')"><a name="hasKeywordSelector0Anchor">hasKeywordSelector</a></td><td></td></tr>
Aaron Ballman512fb642015-09-17 13:30:52 +00002354<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector
2355
2356objCMessageExpr(hasKeywordSelector()) matches the generated setFrame
2357message expression in
2358
2359 UIWebView *webView = ...;
2360 CGRect bodyFrame = webView.frame;
2361 bodyFrame.size.height = self.bodyContentHeight;
2362 webView.frame = bodyFrame;
2363 ^---- matches here
2364</pre></td></tr>
Aaron Ballman11825f22015-08-18 19:55:20 +00002365
2366
2367<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasNullSelector0')"><a name="hasNullSelector0Anchor">hasNullSelector</a></td><td></td></tr>
2368<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector
2369
2370Matches only when the selector of the objCMessageExpr is NULL. This may
2371represent an error condition in the tree!
2372</pre></td></tr>
2373
2374
2375<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasSelector0')"><a name="hasSelector0Anchor">hasSelector</a></td><td>std::string BaseName</td></tr>
2376<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString()
2377
2378 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:"));
2379 matches the outer message expr in the code below, but NOT the message
2380 invocation for self.bodyView.
2381 [self.bodyView loadHTMLString:html baseURL:NULL];
2382</pre></td></tr>
2383
2384
2385<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasUnarySelector0')"><a name="hasUnarySelector0Anchor">hasUnarySelector</a></td><td></td></tr>
2386<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector
2387
2388 matcher = objCMessageExpr(matchesSelector(hasUnarySelector());
2389 matches self.bodyView in the code below, but NOT the outer message
2390 invocation of "loadHTMLString:baseURL:".
2391 [self.bodyView loadHTMLString:html baseURL:NULL];
2392</pre></td></tr>
2393
2394
2395<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('matchesSelector0')"><a name="matchesSelector0Anchor">matchesSelector</a></td><td>std::string RegExp</td></tr>
2396<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains
2397a substring matched by the given RegExp.
2398 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message
2399 invocation for self.bodyView.
2400 [self.bodyView loadHTMLString:html baseURL:NULL];
2401</pre></td></tr>
2402
2403
2404<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('numSelectorArgs0')"><a name="numSelectorArgs0Anchor">numSelectorArgs</a></td><td>unsigned N</td></tr>
2405<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments
2406
Aaron Ballmanb85be662015-09-11 11:51:24 +00002407 matcher = objCMessageExpr(numSelectorArgs(0));
Aaron Ballman11825f22015-08-18 19:55:20 +00002408 matches self.bodyView in the code below
2409
2410 matcher = objCMessageExpr(numSelectorArgs(2));
2411 matches the invocation of "loadHTMLString:baseURL:" but not that
2412 of self.bodyView
2413 [self.bodyView loadHTMLString:html baseURL:NULL];
2414</pre></td></tr>
2415
2416
2417<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>
2418<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string.
2419
2420Given
2421 class Y { public: void x(); };
2422 void z() { Y* y; y-&gt;x(); }
Aaron Ballman512fb642015-09-17 13:30:52 +00002423cxxMemberCallExpr(on(hasType(asString("class Y *"))))
Aaron Ballman11825f22015-08-18 19:55:20 +00002424 matches y-&gt;x()
2425</pre></td></tr>
2426
2427
2428<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>
2429<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node.
2430
2431Matches a node if it equals the node previously bound to ID.
2432
2433Given
2434 class X { int a; int b; };
Aaron Ballman512fb642015-09-17 13:30:52 +00002435cxxRecordDecl(
Aaron Ballman11825f22015-08-18 19:55:20 +00002436 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
2437 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
2438 matches the class X, as a and b have the same type.
2439
2440Note that when multiple matches are involved via forEach* matchers,
2441equalsBoundNodes acts as a filter.
2442For example:
2443compoundStmt(
2444 forEachDescendant(varDecl().bind("d")),
2445 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
2446will trigger a match for each combination of variable declaration
2447and reference to that variable declaration within a compound statement.
2448</pre></td></tr>
2449
2450
2451<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>
2452<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to
2453the node, not hidden within a typedef.
2454
2455Given
2456 typedef const int const_int;
2457 const_int i;
2458 int *const j;
2459 int *volatile k;
2460 int m;
2461varDecl(hasType(hasLocalQualifiers())) matches only j and k.
2462i is const-qualified but the qualifier is not local.
2463</pre></td></tr>
2464
2465
2466<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>
2467<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that
2468include "top-level" const.
2469
2470Given
2471 void a(int);
2472 void b(int const);
2473 void c(const int);
2474 void d(const int*);
2475 void e(int const) {};
2476functionDecl(hasAnyParameter(hasType(isConstQualified())))
2477 matches "void b(int const)", "void c(const int)" and
2478 "void e(int const) {}". It does not match d as there
2479 is no top-level const on the parameter type "const int *".
2480</pre></td></tr>
2481
2482
2483<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>
2484<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type.
2485
2486Given
2487 void a(int);
2488 void b(long);
2489 void c(double);
2490functionDecl(hasAnyParameter(hasType(isInteger())))
2491matches "a(int)", "b(long)", but not "c(double)".
2492</pre></td></tr>
2493
2494
Aaron Ballman512fb642015-09-17 13:30:52 +00002495<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>&gt;</td><td class="name" onclick="toggle('isClass0')"><a name="isClass0Anchor">isClass</a></td><td></td></tr>
2496<tr><td colspan="4" class="doc" id="isClass0"><pre>Matches RecordDecl object that are spelled with "class."
2497
2498Example matches C, but not S or U.
2499 struct S {};
2500 class C {};
2501 union U {};
2502</pre></td></tr>
2503
2504
2505<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>&gt;</td><td class="name" onclick="toggle('isStruct0')"><a name="isStruct0Anchor">isStruct</a></td><td></td></tr>
2506<tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches RecordDecl object that are spelled with "struct."
2507
2508Example matches S, but not C or U.
2509 struct S {};
2510 class C {};
2511 union U {};
2512</pre></td></tr>
2513
2514
2515<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>&gt;</td><td class="name" onclick="toggle('isUnion0')"><a name="isUnion0Anchor">isUnion</a></td><td></td></tr>
2516<tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches RecordDecl object that are spelled with "union."
2517
2518Example matches U, but not C or S.
2519 struct S {};
2520 class C {};
2521 union U {};
2522</pre></td></tr>
2523
2524
Aaron Ballman11825f22015-08-18 19:55:20 +00002525<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>
2526<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node.
2527
2528Matches a node if it equals the node previously bound to ID.
2529
2530Given
2531 class X { int a; int b; };
Aaron Ballman512fb642015-09-17 13:30:52 +00002532cxxRecordDecl(
Aaron Ballman11825f22015-08-18 19:55:20 +00002533 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
2534 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
2535 matches the class X, as a and b have the same type.
2536
2537Note that when multiple matches are involved via forEach* matchers,
2538equalsBoundNodes acts as a filter.
2539For example:
2540compoundStmt(
2541 forEachDescendant(varDecl().bind("d")),
2542 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
2543will trigger a match for each combination of variable declaration
2544and reference to that variable declaration within a compound statement.
2545</pre></td></tr>
2546
2547
2548<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('isExpansionInFileMatching1')"><a name="isExpansionInFileMatching1Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr>
2549<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is
2550partially matching a given regex.
2551
2552Example matches Y but not X
Aaron Ballman512fb642015-09-17 13:30:52 +00002553 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
Aaron Ballman11825f22015-08-18 19:55:20 +00002554 #include "ASTMatcher.h"
2555 class X {};
2556ASTMatcher.h:
2557 class Y {};
2558
2559Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
2560</pre></td></tr>
2561
2562
2563<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('isExpansionInMainFile1')"><a name="isExpansionInMainFile1Anchor">isExpansionInMainFile</a></td><td></td></tr>
2564<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file.
2565
Aaron Ballman512fb642015-09-17 13:30:52 +00002566Example matches X but not Y
2567 (matcher = cxxRecordDecl(isExpansionInMainFile())
Aaron Ballman11825f22015-08-18 19:55:20 +00002568 #include &lt;Y.h&gt;
2569 class X {};
2570Y.h:
2571 class Y {};
2572
2573Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
2574</pre></td></tr>
2575
2576
2577<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('isExpansionInSystemHeader1')"><a name="isExpansionInSystemHeader1Anchor">isExpansionInSystemHeader</a></td><td></td></tr>
2578<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files.
2579
2580Example matches Y but not X
Aaron Ballman512fb642015-09-17 13:30:52 +00002581 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
Aaron Ballman11825f22015-08-18 19:55:20 +00002582 #include &lt;SystemHeader.h&gt;
2583 class X {};
2584SystemHeader.h:
2585 class Y {};
2586
2587Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
2588</pre></td></tr>
2589
2590
2591<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>
2592<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached.
2593
2594Example matches A, va, fa
2595 class A {};
2596 class B; Doesn't match, as it has no body.
2597 int va;
2598 extern int vb; Doesn't match, as it doesn't define the variable.
2599 void fa() {}
2600 void fb(); Doesn't match, as it has no body.
2601
2602Usable 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;
2603</pre></td></tr>
2604
2605
2606<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('equalsIntegralValue0')"><a name="equalsIntegralValue0Anchor">equalsIntegralValue</a></td><td>std::string Value</td></tr>
2607<tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value.
2608
2609Note that 'Value' is a string as the template argument's value is
2610an arbitrary precision integer. 'Value' must be euqal to the canonical
2611representation of that integral value in base 10.
2612
2613Given
2614 template&lt;int T&gt; struct A {};
2615 C&lt;42&gt; c;
2616classTemplateSpecializationDecl(
2617 hasAnyTemplateArgument(equalsIntegralValue("42")))
2618 matches the implicit instantiation of C in C&lt;42&gt;.
2619</pre></td></tr>
2620
2621
2622<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('isIntegral0')"><a name="isIntegral0Anchor">isIntegral</a></td><td></td></tr>
2623<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value.
2624
2625Given
2626 template&lt;int T&gt; struct A {};
2627 C&lt;42&gt; c;
2628classTemplateSpecializationDecl(
2629 hasAnyTemplateArgument(isIntegral()))
2630 matches the implicit instantiation of C in C&lt;42&gt;
2631 with isIntegral() matching 42.
2632</pre></td></tr>
2633
2634
2635<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('templateArgumentCountIs1')"><a name="templateArgumentCountIs1Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr>
2636<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N.
2637
2638Given
2639 template&lt;typename T&gt; struct C {};
2640 C&lt;int&gt; c;
2641classTemplateSpecializationDecl(templateArgumentCountIs(1))
2642 matches C&lt;int&gt;.
2643</pre></td></tr>
2644
2645
2646<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('isExpansionInFileMatching2')"><a name="isExpansionInFileMatching2Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr>
2647<tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is
2648partially matching a given regex.
2649
2650Example matches Y but not X
Aaron Ballman512fb642015-09-17 13:30:52 +00002651 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
Aaron Ballman11825f22015-08-18 19:55:20 +00002652 #include "ASTMatcher.h"
2653 class X {};
2654ASTMatcher.h:
2655 class Y {};
2656
2657Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
2658</pre></td></tr>
2659
2660
2661<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('isExpansionInMainFile2')"><a name="isExpansionInMainFile2Anchor">isExpansionInMainFile</a></td><td></td></tr>
2662<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file.
2663
Aaron Ballman512fb642015-09-17 13:30:52 +00002664Example matches X but not Y
2665 (matcher = cxxRecordDecl(isExpansionInMainFile())
Aaron Ballman11825f22015-08-18 19:55:20 +00002666 #include &lt;Y.h&gt;
2667 class X {};
2668Y.h:
2669 class Y {};
2670
2671Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
2672</pre></td></tr>
2673
2674
2675<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('isExpansionInSystemHeader2')"><a name="isExpansionInSystemHeader2Anchor">isExpansionInSystemHeader</a></td><td></td></tr>
2676<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files.
2677
2678Example matches Y but not X
Aaron Ballman512fb642015-09-17 13:30:52 +00002679 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
Aaron Ballman11825f22015-08-18 19:55:20 +00002680 #include &lt;SystemHeader.h&gt;
2681 class X {};
2682SystemHeader.h:
2683 class Y {};
2684
2685Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
2686</pre></td></tr>
2687
2688
2689<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>
2690<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node.
2691
2692Matches a node if it equals the node previously bound to ID.
2693
2694Given
2695 class X { int a; int b; };
Aaron Ballman512fb642015-09-17 13:30:52 +00002696cxxRecordDecl(
Aaron Ballman11825f22015-08-18 19:55:20 +00002697 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
2698 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
2699 matches the class X, as a and b have the same type.
2700
2701Note that when multiple matches are involved via forEach* matchers,
2702equalsBoundNodes acts as a filter.
2703For example:
2704compoundStmt(
2705 forEachDescendant(varDecl().bind("d")),
2706 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
2707will trigger a match for each combination of variable declaration
2708and reference to that variable declaration within a compound statement.
2709</pre></td></tr>
2710
2711
2712<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('voidType0')"><a name="voidType0Anchor">voidType</a></td><td></td></tr>
2713<tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void.
2714
2715Given
2716 struct S { void func(); };
2717functionDecl(returns(voidType()))
2718 matches "void func();"
2719</pre></td></tr>
2720
2721
2722<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>
2723<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind.
2724
2725Given
2726 int x;
2727 int s = sizeof(x) + alignof(x)
2728unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
2729 matches sizeof(x)
2730</pre></td></tr>
2731
2732
2733<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>
2734<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or
2735unary).
2736
2737Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
2738 !(a || b)
2739</pre></td></tr>
2740
2741
2742<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('hasGlobalStorage0')"><a name="hasGlobalStorage0Anchor">hasGlobalStorage</a></td><td></td></tr>
2743<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage.
2744
2745Example matches y and z (matcher = varDecl(hasGlobalStorage())
2746void f() {
2747 int x;
2748 static int y;
2749}
2750int z;
2751</pre></td></tr>
2752
2753
2754<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('hasLocalStorage0')"><a name="hasLocalStorage0Anchor">hasLocalStorage</a></td><td></td></tr>
2755<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a
2756non-static local variable.
2757
2758Example matches x (matcher = varDecl(hasLocalStorage())
2759void f() {
2760 int x;
2761 static int y;
2762}
2763int z;
2764</pre></td></tr>
2765
2766
2767<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isConstexpr0')"><a name="isConstexpr0Anchor">isConstexpr</a></td><td></td></tr>
2768<tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations.
2769
2770Given:
2771 constexpr int foo = 42;
2772 constexpr int bar();
2773varDecl(isConstexpr())
2774 matches the declaration of foo.
2775functionDecl(isConstexpr())
2776 matches the declaration of bar.
2777</pre></td></tr>
2778
2779
2780<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>
2781<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached.
2782
2783Example matches A, va, fa
2784 class A {};
2785 class B; Doesn't match, as it has no body.
2786 int va;
2787 extern int vb; Doesn't match, as it doesn't define the variable.
2788 void fa() {}
2789 void fb(); Doesn't match, as it has no body.
2790
2791Usable 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;
2792</pre></td></tr>
2793
2794
2795<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isExceptionVariable0')"><a name="isExceptionVariable0Anchor">isExceptionVariable</a></td><td></td></tr>
2796<tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from
2797a C++ catch block, or an Objective-C statement.
2798
2799Example matches x (matcher = varDecl(isExceptionVariable())
2800void f(int y) {
2801 try {
2802 } catch (int x) {
2803 }
2804}
2805</pre></td></tr>
2806
2807
2808<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>
2809<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or
2810static member variable template instantiations.
2811
2812Given
2813 template&lt;typename T&gt; void A(T t) { }
2814 template&lt;&gt; void A(int N) { }
2815functionDecl(isExplicitTemplateSpecialization())
2816 matches the specialization A&lt;int&gt;().
2817
2818Usable 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;
2819</pre></td></tr>
2820
2821
2822<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>
2823<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static
2824member variable template instantiations.
2825
2826Given
2827 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
2828or
2829 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Aaron Ballman512fb642015-09-17 13:30:52 +00002830cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
Aaron Ballman11825f22015-08-18 19:55:20 +00002831 matches the template instantiation of X&lt;A&gt;.
2832
2833But given
2834 template &lt;typename T&gt; class X {}; class A {};
2835 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Aaron Ballman512fb642015-09-17 13:30:52 +00002836cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
Aaron Ballman11825f22015-08-18 19:55:20 +00002837 does not match, as X&lt;A&gt; is an explicit template specialization.
2838
2839Usable 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;
2840</pre></td></tr>
2841
2842
2843<tr><td>Matcher&lt;internal::Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;&gt;</td><td class="name" onclick="toggle('isInstantiated0')"><a name="isInstantiated0Anchor">isInstantiated</a></td><td></td></tr>
2844<tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside
2845template instantiations.
2846
2847Given
2848 template&lt;typename T&gt; void A(T t) { T i; }
2849 A(0);
2850 A(0U);
2851functionDecl(isInstantiated())
2852 matches 'A(int) {...};' and 'A(unsigned) {...}'.
2853</pre></td></tr>
2854
2855
2856<tr><td>Matcher&lt;internal::Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;&gt;</td><td class="name" onclick="toggle('isInTemplateInstantiation0')"><a name="isInTemplateInstantiation0Anchor">isInTemplateInstantiation</a></td><td></td></tr>
2857<tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation.
2858
2859Given
2860 int j;
2861 template&lt;typename T&gt; void A(T t) { T i; j += 42;}
2862 A(0);
2863 A(0U);
2864declStmt(isInTemplateInstantiation())
2865 matches 'int i;' and 'unsigned i'.
2866unless(stmt(isInTemplateInstantiation()))
2867 will NOT match j += 42; as it's shared between the template definition and
2868 instantiation.
2869</pre></td></tr>
2870
2871<!--END_NARROWING_MATCHERS -->
2872</table>
2873
2874<!-- ======================================================================= -->
2875<h2 id="traversal-matchers">AST Traversal Matchers</h2>
2876<!-- ======================================================================= -->
2877
2878<p>Traversal matchers specify the relationship to other nodes that are
2879reachable from the current node.</p>
2880
2881<p>Note that there are special traversal matchers (has, hasDescendant, forEach and
2882forEachDescendant) which work on all nodes and allow users to write more generic
2883match expressions.</p>
2884
2885<table>
2886<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
2887<!-- START_TRAVERSAL_MATCHERS -->
2888
2889<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>
2890<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches.
2891
2892Unlike anyOf, eachOf will generate a match result for each
2893matching submatcher.
2894
2895For example, in:
2896 class A { int a; int b; };
2897The matcher:
Aaron Ballman512fb642015-09-17 13:30:52 +00002898 cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
2899 has(fieldDecl(hasName("b")).bind("v"))))
Aaron Ballman11825f22015-08-18 19:55:20 +00002900will generate two results binding "v", the first of which binds
2901the field declaration of a, the second the field declaration of
2902b.
2903
2904Usable as: Any Matcher
2905</pre></td></tr>
2906
2907
2908<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher&lt;*&gt;</td></tr>
2909<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
2910provided matcher.
2911
2912Example matches X, A, B, C
Aaron Ballman512fb642015-09-17 13:30:52 +00002913 (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))
Aaron Ballman11825f22015-08-18 19:55:20 +00002914 class X {}; Matches X, because X::X is a class of name X inside X.
2915 class A { class X {}; };
2916 class B { class C { class X {}; }; };
2917
2918DescendantT must be an AST base type.
2919
2920As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
2921each result that matches instead of only on the first one.
2922
2923Note: Recursively combined ForEachDescendant can cause many matches:
Aaron Ballman512fb642015-09-17 13:30:52 +00002924 cxxRecordDecl(forEachDescendant(cxxRecordDecl(
2925 forEachDescendant(cxxRecordDecl())
2926 )))
Aaron Ballman11825f22015-08-18 19:55:20 +00002927will match 10 times (plus injected class name matches) on:
2928 class A { class B { class C { class D { class E {}; }; }; }; };
2929
2930Usable as: Any Matcher
2931</pre></td></tr>
2932
2933
2934<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher&lt;*&gt;</td></tr>
2935<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the
2936provided matcher.
2937
Aaron Ballman512fb642015-09-17 13:30:52 +00002938Example matches X, Y
2939 (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
Aaron Ballman11825f22015-08-18 19:55:20 +00002940 class X {}; Matches X, because X::X is a class of name X inside X.
2941 class Y { class X {}; };
2942 class Z { class Y { class X {}; }; }; Does not match Z.
2943
2944ChildT must be an AST base type.
2945
2946As opposed to 'has', 'forEach' will cause a match for each result that
2947matches instead of only on the first one.
2948
2949Usable as: Any Matcher
2950</pre></td></tr>
2951
2952
2953<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher&lt;*&gt;</td></tr>
2954<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided
2955matcher.
2956
2957Given
2958void f() { if (true) { int x = 42; } }
2959void g() { for (;;) { int x = 43; } }
2960expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.
2961
2962Usable as: Any Matcher
2963</pre></td></tr>
2964
2965
2966<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher&lt;*&gt;</td></tr>
2967<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
2968provided matcher.
2969
2970Example matches X, Y, Z
Aaron Ballman512fb642015-09-17 13:30:52 +00002971 (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X")))))
Aaron Ballman11825f22015-08-18 19:55:20 +00002972 class X {}; Matches X, because X::X is a class of name X inside X.
2973 class Y { class X {}; };
2974 class Z { class Y { class X {}; }; };
2975
2976DescendantT must be an AST base type.
2977
2978Usable as: Any Matcher
2979</pre></td></tr>
2980
2981
2982<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher&lt;*&gt;</td></tr>
2983<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the
2984provided matcher.
2985
Aaron Ballman512fb642015-09-17 13:30:52 +00002986Example matches X, Y
2987 (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X")))
Aaron Ballman11825f22015-08-18 19:55:20 +00002988 class X {}; Matches X, because X::X is a class of name X inside X.
2989 class Y { class X {}; };
2990 class Z { class Y { class X {}; }; }; Does not match Z.
2991
2992ChildT must be an AST base type.
2993
2994Usable as: Any Matcher
2995</pre></td></tr>
2996
2997
2998<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher&lt;*&gt;</td></tr>
2999<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided
3000matcher.
3001
3002Given
3003void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
3004compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".
3005
3006Usable as: Any Matcher
3007</pre></td></tr>
3008
3009
3010<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>
3011<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression.
3012
3013Given
3014 int i[5];
3015 void f() { i[1] = 42; }
3016arraySubscriptExpression(hasBase(implicitCastExpr(
3017 hasSourceExpression(declRefExpr()))))
3018 matches i[1] with the declRefExpr() matching i
3019</pre></td></tr>
3020
3021
3022<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>
3023<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression.
3024
3025Given
3026 int i[5];
3027 void f() { i[1] = 42; }
3028arraySubscriptExpression(hasIndex(integerLiteral()))
3029 matches i[1] with the integerLiteral() matching 1
3030</pre></td></tr>
3031
3032
3033<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>
3034<tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element
3035type.
3036
3037Given
3038 struct A {};
3039 A a[7];
3040 int b[7];
3041arrayType(hasElementType(builtinType()))
3042 matches "int b[7]"
3043
3044Usable 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;
3045</pre></td></tr>
3046
3047
3048<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>
3049<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element
3050type.
3051
3052Given
3053 struct A {};
3054 A a[7];
3055 int b[7];
3056arrayType(hasElementType(builtinType()))
3057 matches "int b[7]"
3058
3059Usable 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;
3060</pre></td></tr>
3061
3062
3063<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>
3064<tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type.
3065
3066Given
3067 _Atomic(int) i;
3068 _Atomic(float) f;
3069atomicType(hasValueType(isInteger()))
3070 matches "_Atomic(int) i"
3071
3072Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
3073</pre></td></tr>
3074
3075
3076<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>
3077<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type.
3078
3079Given
3080 _Atomic(int) i;
3081 _Atomic(float) f;
3082atomicType(hasValueType(isInteger()))
3083 matches "_Atomic(int) i"
3084
3085Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
3086</pre></td></tr>
3087
3088
3089<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>
3090<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type.
3091
3092Note: There is no TypeLoc for the deduced type and thus no
3093getDeducedLoc() matcher.
3094
3095Given
3096 auto a = 1;
3097 auto b = 2.0;
3098autoType(hasDeducedType(isInteger()))
3099 matches "auto a"
3100
3101Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>&gt;
3102</pre></td></tr>
3103
3104
3105<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>
3106<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a
3107binary operator matches.
3108</pre></td></tr>
3109
3110
3111<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>
3112<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions.
3113
3114Example matches a (matcher = binaryOperator(hasLHS()))
3115 a || b
3116</pre></td></tr>
3117
3118
3119<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>
3120<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions.
3121
3122Example matches b (matcher = binaryOperator(hasRHS()))
3123 a || b
3124</pre></td></tr>
3125
3126
3127<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>
3128<tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the
3129pointee matches a given matcher.
3130
3131Given
3132 int *a;
3133 int const *b;
3134 float const *f;
3135pointerType(pointee(isConstQualified(), isInteger()))
3136 matches "int const *b"
3137
3138Usable 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;,
3139 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;
3140</pre></td></tr>
3141
3142
3143<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>
3144<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the
3145pointee matches a given matcher.
3146
3147Given
3148 int *a;
3149 int const *b;
3150 float const *f;
3151pointerType(pointee(isConstQualified(), isInteger()))
3152 matches "int const *b"
3153
3154Usable 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;,
3155 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;
3156</pre></td></tr>
3157
3158
3159<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>
3160<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call
3161expression.
3162
3163Given
3164 void x(int, int, int) { int y; x(1, y, 42); }
3165callExpr(hasAnyArgument(declRefExpr()))
3166 matches x(1, y, 42)
3167with hasAnyArgument(...)
3168 matching y
3169
3170FIXME: Currently this will ignore parentheses and implicit casts on
3171the argument before applying the inner matcher. We'll want to remove
3172this to allow for greater control by the user once ignoreImplicit()
3173has been implemented.
3174</pre></td></tr>
3175
3176
3177<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>
3178<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor
3179call expression.
3180
3181Example matches y in x(y)
3182 (matcher = callExpr(hasArgument(0, declRefExpr())))
3183 void x(int) { int y; x(y); }
3184</pre></td></tr>
3185
3186
3187<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration12')"><a name="hasDeclaration12Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
3188<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node
3189matches the given matcher.
3190
3191The associated declaration is:
3192- for type nodes, the declaration of the underlying type
3193- for CallExpr, the declaration of the callee
3194- for MemberExpr, the declaration of the referenced member
3195- for CXXConstructExpr, the declaration of the constructor
3196
3197Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
3198function. e.g. various subtypes of clang::Type and various expressions.
3199
3200Usable as: 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;,
3201 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;,
3202 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;, 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_1QualType.html">QualType</a>&gt;,
3203 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;,
3204 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;,
3205 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
3206</pre></td></tr>
3207
3208
3209<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>
3210<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition.
3211
3212Given
3213 class A { A() : i(42), j(42) {} int i; int j; };
Aaron Ballman512fb642015-09-17 13:30:52 +00003214cxxConstructorDecl(forEachConstructorInitializer(
3215 forField(decl().bind("x"))
3216))
Aaron Ballman11825f22015-08-18 19:55:20 +00003217 will trigger two matches, binding for 'i' and 'j' respectively.
3218</pre></td></tr>
3219
3220
3221<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>
3222<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer.
3223
3224Given
3225 struct Foo {
3226 Foo() : foo_(1) { }
3227 int foo_;
3228 };
Aaron Ballman512fb642015-09-17 13:30:52 +00003229cxxRecordDecl(has(cxxConstructorDecl(
3230 hasAnyConstructorInitializer(anything())
3231)))
Aaron Ballman11825f22015-08-18 19:55:20 +00003232 record matches Foo, hasAnyConstructorInitializer matches foo_(1)
3233</pre></td></tr>
3234
3235
3236<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>
3237<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer.
3238
3239Given
3240 struct Foo {
3241 Foo() : foo_(1) { }
3242 int foo_;
3243 };
Aaron Ballman512fb642015-09-17 13:30:52 +00003244cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
Aaron Ballman11825f22015-08-18 19:55:20 +00003245 forField(hasName("foo_"))))))
3246 matches Foo
3247with forField matching foo_
3248</pre></td></tr>
3249
3250
3251<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>
3252<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer.
3253
3254Given
3255 struct Foo {
3256 Foo() : foo_(1) { }
3257 int foo_;
3258 };
Aaron Ballman512fb642015-09-17 13:30:52 +00003259cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
Aaron Ballman11825f22015-08-18 19:55:20 +00003260 withInitializer(integerLiteral(equals(1)))))))
3261 matches Foo
3262with withInitializer matching (1)
3263</pre></td></tr>
3264
3265
3266<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>&gt;</td><td class="name" onclick="toggle('hasBody3')"><a name="hasBody3Anchor">hasBody</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
3267<tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', or 'do while' statement that has
3268a given body.
3269
3270Given
3271 for (;;) {}
3272hasBody(compoundStmt())
3273 matches 'for (;;) {}'
3274with compoundStmt()
3275 matching '{}'
3276</pre></td></tr>
3277
3278
3279<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>&gt;</td><td class="name" onclick="toggle('hasLoopVariable0')"><a name="hasLoopVariable0Anchor">hasLoopVariable</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt; InnerMatcher</td></tr>
3280<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop.
3281
3282Example:
3283 forStmt(hasLoopVariable(anything()))
3284matches 'int x' in
3285 for (int x : a) { }
3286</pre></td></tr>
3287
3288
3289<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>&gt;</td><td class="name" onclick="toggle('hasRangeInit0')"><a name="hasRangeInit0Anchor">hasRangeInit</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
3290<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop.
3291
3292Example:
3293 forStmt(hasRangeInit(anything()))
3294matches 'a' in
3295 for (int x : a) { }
3296</pre></td></tr>
3297
3298
3299<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>
3300<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr>
3301
3302
3303<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>
3304<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression.
3305
3306Example matches y.x()
Aaron Ballman512fb642015-09-17 13:30:52 +00003307 (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))))))
Aaron Ballman11825f22015-08-18 19:55:20 +00003308 class Y { public: void x(); };
3309 void z() { Y y; y.x(); }",
3310
3311FIXME: Overload to allow directly matching types?
3312</pre></td></tr>
3313
3314
3315<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>
3316<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration.
3317</pre></td></tr>
3318
3319
3320<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>&gt;</td><td class="name" onclick="toggle('thisPointerType0')"><a name="thisPointerType0Anchor">thisPointerType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
3321<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified
3322matcher, or is a pointer to a type that matches the InnerMatcher.
3323</pre></td></tr>
3324
3325
3326<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>
3327<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration
3328belongs to.
3329
3330FIXME: Generalize this for other kinds of declarations.
3331FIXME: What other kind of declarations would we need to generalize
3332this to?
3333
3334Example matches A() in the last line
Aaron Ballman512fb642015-09-17 13:30:52 +00003335 (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl(
Aaron Ballman11825f22015-08-18 19:55:20 +00003336 ofClass(hasName("A"))))))
3337 class A {
3338 public:
3339 A();
3340 };
3341 A a = A();
3342</pre></td></tr>
3343
3344
3345<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>
3346<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher.
3347
3348Given:
3349 class A { void func(); };
3350 class B { void member(); };
3351
Aaron Ballman512fb642015-09-17 13:30:52 +00003352cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of
3353A but not B.
Aaron Ballman11825f22015-08-18 19:55:20 +00003354</pre></td></tr>
3355
3356
3357<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>
3358<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from
3359a class matching Base.
3360
3361Note that a class is not considered to be derived from itself.
3362
3363Example matches Y, Z, C (Base == hasName("X"))
3364 class X;
3365 class Y : public X {}; directly derived
3366 class Z : public Y {}; indirectly derived
3367 typedef X A;
3368 typedef A B;
3369 class C : public B {}; derived from a typedef of X
3370
3371In the following example, Bar matches isDerivedFrom(hasName("X")):
3372 class Foo;
3373 typedef Foo X;
3374 class Bar : public Foo {}; derived from a type that X is a typedef of
3375</pre></td></tr>
3376
3377
3378<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>
3379<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly
3380match Base.
3381</pre></td></tr>
3382
3383
3384<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>
3385<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the
3386given matcher.
3387
Aaron Ballman512fb642015-09-17 13:30:52 +00003388Example matches y.x() (matcher = callExpr(callee(
3389 cxxMethodDecl(hasName("x")))))
Aaron Ballman11825f22015-08-18 19:55:20 +00003390 class Y { public: void x(); };
3391 void z() { Y y; y.x(); }
3392</pre></td></tr>
3393
3394
3395<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('callee0')"><a name="callee0Anchor">callee</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
3396<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches.
3397
3398Given
3399 class Y { void x() { this-&gt;x(); x(); Y y; y.x(); } };
3400 void f() { f(); }
3401callExpr(callee(expr()))
3402 matches this-&gt;x(), x(), y.x(), f()
3403with callee(...)
3404 matching this-&gt;x, x, y.x, f respectively
3405
3406Note: Callee cannot take the more general internal::Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;
3407because this introduces ambiguous overloads with calls to Callee taking a
3408internal::Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, as the matcher hierarchy is purely
3409implemented in terms of implicit casts.
3410</pre></td></tr>
3411
3412
3413<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>
3414<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call
3415expression.
3416
3417Given
3418 void x(int, int, int) { int y; x(1, y, 42); }
3419callExpr(hasAnyArgument(declRefExpr()))
3420 matches x(1, y, 42)
3421with hasAnyArgument(...)
3422 matching y
3423
3424FIXME: Currently this will ignore parentheses and implicit casts on
3425the argument before applying the inner matcher. We'll want to remove
3426this to allow for greater control by the user once ignoreImplicit()
3427has been implemented.
3428</pre></td></tr>
3429
3430
3431<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>
3432<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor
3433call expression.
3434
3435Example matches y in x(y)
3436 (matcher = callExpr(hasArgument(0, declRefExpr())))
3437 void x(int) { int y; x(y); }
3438</pre></td></tr>
3439
3440
3441<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration13')"><a name="hasDeclaration13Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
3442<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node
3443matches the given matcher.
3444
3445The associated declaration is:
3446- for type nodes, the declaration of the underlying type
3447- for CallExpr, the declaration of the callee
3448- for MemberExpr, the declaration of the referenced member
3449- for CXXConstructExpr, the declaration of the constructor
3450
3451Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
3452function. e.g. various subtypes of clang::Type and various expressions.
3453
3454Usable as: 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;,
3455 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;,
3456 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;, 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_1QualType.html">QualType</a>&gt;,
3457 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;,
3458 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;,
3459 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
3460</pre></td></tr>
3461
3462
3463<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>
3464<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range
3465extension, matches the constant given in the statement.
3466
3467Given
3468 switch (1) { case 1: case 1+1: case 3 ... 4: ; }
3469caseStmt(hasCaseConstant(integerLiteral()))
3470 matches "case 1:"
3471</pre></td></tr>
3472
3473
3474<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>
3475<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher.
3476
3477Example: matches "a string" (matcher =
Aaron Ballman512fb642015-09-17 13:30:52 +00003478 hasSourceExpression(cxxConstructExpr()))
Aaron Ballman11825f22015-08-18 19:55:20 +00003479class URL { URL(string); };
3480URL url = "a string";
3481</pre></td></tr>
3482
3483
3484<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>
3485<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one
3486TemplateArgument matching the given InnerMatcher.
3487
3488Given
3489 template&lt;typename T&gt; class A {};
3490 template&lt;&gt; class A&lt;double&gt; {};
3491 A&lt;int&gt; a;
3492classTemplateSpecializationDecl(hasAnyTemplateArgument(
3493 refersToType(asString("int"))))
3494 matches the specialization A&lt;int&gt;
3495</pre></td></tr>
3496
3497
3498<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>
3499<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument
3500matches the given InnerMatcher.
3501
3502Given
3503 template&lt;typename T, typename U&gt; class A {};
3504 A&lt;bool, int&gt; b;
3505 A&lt;int, bool&gt; c;
3506classTemplateSpecializationDecl(hasTemplateArgument(
3507 1, refersToType(asString("int"))))
3508 matches the specialization A&lt;bool, int&gt;
3509</pre></td></tr>
3510
3511
3512<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>
3513<tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element
3514type.
3515
3516Given
3517 struct A {};
3518 A a[7];
3519 int b[7];
3520arrayType(hasElementType(builtinType()))
3521 matches "int b[7]"
3522
3523Usable 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;
3524</pre></td></tr>
3525
3526
3527<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>
3528<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element
3529type.
3530
3531Given
3532 struct A {};
3533 A a[7];
3534 int b[7];
3535arrayType(hasElementType(builtinType()))
3536 matches "int b[7]"
3537
3538Usable 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;
3539</pre></td></tr>
3540
3541
3542<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>
3543<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches
3544a given matcher.
3545
3546Given
3547 { {}; 1+2; }
3548hasAnySubstatement(compoundStmt())
3549 matches '{ {}; 1+2; }'
3550with compoundStmt()
3551 matching '{}'
3552</pre></td></tr>
3553
3554
3555<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>
3556<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop,
3557or conditional operator.
3558
Aaron Ballman512fb642015-09-17 13:30:52 +00003559Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
Aaron Ballman11825f22015-08-18 19:55:20 +00003560 if (true) {}
3561</pre></td></tr>
3562
3563
3564<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>
3565<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator.
3566
3567Example matches b
3568 condition ? a : b
3569</pre></td></tr>
3570
3571
3572<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>
3573<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator.
3574
3575Example matches a
3576 condition ? a : b
3577</pre></td></tr>
3578
3579
Matthias Gehre2cf7e802015-10-12 21:46:07 +00003580<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DecayedType.html">DecayedType</a>&gt;</td><td class="name" onclick="toggle('hasDecayedType0')"><a name="hasDecayedType0Anchor">hasDecayedType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerType</td></tr>
3581<tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whos decayed type matches InnerMatcher
3582</pre></td></tr>
3583
3584
Aaron Ballman11825f22015-08-18 19:55:20 +00003585<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration11')"><a name="hasDeclaration11Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
3586<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node
3587matches the given matcher.
3588
3589The associated declaration is:
3590- for type nodes, the declaration of the underlying type
3591- for CallExpr, the declaration of the callee
3592- for MemberExpr, the declaration of the referenced member
3593- for CXXConstructExpr, the declaration of the constructor
3594
3595Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
3596function. e.g. various subtypes of clang::Type and various expressions.
3597
3598Usable as: 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;,
3599 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;,
3600 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;, 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_1QualType.html">QualType</a>&gt;,
3601 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;,
3602 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;,
3603 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
3604</pre></td></tr>
3605
3606
3607<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>
3608<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a
3609specific using shadow declaration.
3610
3611Given
3612 namespace a { void f() {} }
3613 using a::f;
3614 void g() {
3615 f(); Matches this ..
3616 a::f(); .. but not this.
3617 }
3618declRefExpr(throughUsingDecl(anything()))
3619 matches f()
3620</pre></td></tr>
3621
3622
3623<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>
3624<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the
3625specified matcher.
3626
3627Example matches x in if(x)
3628 (matcher = declRefExpr(to(varDecl(hasName("x")))))
3629 bool x;
3630 if (x) {}
3631</pre></td></tr>
3632
3633
3634<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>
3635<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement.
3636
3637Note that this does not work for global declarations because the AST
3638breaks up multiple-declaration DeclStmt's into multiple single-declaration
3639DeclStmt's.
3640Example: Given non-global declarations
3641 int a, b = 0;
3642 int c;
3643 int d = 2, e;
3644declStmt(containsDeclaration(
3645 0, varDecl(hasInitializer(anything()))))
3646 matches only 'int d = 2, e;', and
3647declStmt(containsDeclaration(1, varDecl()))
3648 matches 'int a, b = 0' as well as 'int d = 2, e;'
3649 but 'int c;' is not matched.
3650</pre></td></tr>
3651
3652
3653<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>
3654<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration.
3655
3656Given
3657 int a, b;
3658 int c;
3659declStmt(hasSingleDecl(anything()))
3660 matches 'int c;' but not 'int a, b;'.
3661</pre></td></tr>
3662
3663
3664<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>
3665<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches
3666the inner matcher.
3667
3668Given
3669 int x;
3670declaratorDecl(hasTypeLoc(loc(asString("int"))))
3671 matches int x
3672</pre></td></tr>
3673
3674
3675<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>
3676<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a
3677Decl, matches InnerMatcher.
3678
3679Given
3680 namespace N {
3681 namespace M {
3682 class D {};
3683 }
3684 }
3685
Aaron Ballman512fb642015-09-17 13:30:52 +00003686cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
Aaron Ballman11825f22015-08-18 19:55:20 +00003687declaration of class D.
3688</pre></td></tr>
3689
3690
3691<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>
3692<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has
3693a given body.
3694
3695Given
3696 for (;;) {}
3697hasBody(compoundStmt())
3698 matches 'for (;;) {}'
3699with compoundStmt()
3700 matching '{}'
3701</pre></td></tr>
3702
3703
3704<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>
3705<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop,
3706or conditional operator.
3707
Aaron Ballman512fb642015-09-17 13:30:52 +00003708Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
Aaron Ballman11825f22015-08-18 19:55:20 +00003709 if (true) {}
3710</pre></td></tr>
3711
3712
3713<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>
3714<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
3715matches InnerMatcher if the qualifier exists.
3716
3717Given
3718 namespace N {
3719 namespace M {
3720 class D {};
3721 }
3722 }
3723 N::M::D d;
3724
3725elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N"))))
3726matches the type of the variable declaration of d.
3727</pre></td></tr>
3728
3729
3730<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>
3731<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher.
3732
3733Given
3734 namespace N {
3735 namespace M {
3736 class D {};
3737 }
3738 }
3739 N::M::D d;
3740
3741elaboratedType(namesType(recordType(
3742hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable
3743declaration of d.
3744</pre></td></tr>
3745
3746
3747<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration10')"><a name="hasDeclaration10Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
3748<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node
3749matches the given matcher.
3750
3751The associated declaration is:
3752- for type nodes, the declaration of the underlying type
3753- for CallExpr, the declaration of the callee
3754- for MemberExpr, the declaration of the referenced member
3755- for CXXConstructExpr, the declaration of the constructor
3756
3757Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
3758function. e.g. various subtypes of clang::Type and various expressions.
3759
3760Usable as: 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;,
3761 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;,
3762 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;, 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_1QualType.html">QualType</a>&gt;,
3763 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;,
3764 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;,
3765 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
3766</pre></td></tr>
3767
3768
3769<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>
3770<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher.
3771
3772(Note: Clang's AST refers to other conversions as "casts" too, and calls
3773actual casts "explicit" casts.)
3774</pre></td></tr>
3775
3776
3777<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>
3778<tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value
3779declaration's type.
3780
3781In case of a value declaration (for example a variable declaration),
3782this resolves one layer of indirection. For example, in the value
Aaron Ballman512fb642015-09-17 13:30:52 +00003783declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
3784X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
3785declaration of x.
Aaron Ballman11825f22015-08-18 19:55:20 +00003786
Aaron Ballman512fb642015-09-17 13:30:52 +00003787Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
3788 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
Aaron Ballman11825f22015-08-18 19:55:20 +00003789 class X {};
3790 void y(X &amp;x) { x; X z; }
3791
3792Usable 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;
3793</pre></td></tr>
3794
3795
3796<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('hasType0')"><a name="hasType0Anchor">hasType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
3797<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type
3798matcher.
3799
Aaron Ballman512fb642015-09-17 13:30:52 +00003800Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
3801 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
Aaron Ballman11825f22015-08-18 19:55:20 +00003802 class X {};
3803 void y(X &amp;x) { x; X z; }
3804</pre></td></tr>
3805
3806
3807<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>
3808<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts
3809are stripped off.
3810
3811Parentheses and explicit casts are not discarded.
3812Given
3813 int arr[5];
3814 int a = 0;
3815 char b = 0;
3816 const int c = a;
3817 int *d = arr;
3818 long e = (long) 0l;
3819The matchers
3820 varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
3821 varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
3822would match the declarations for a, b, c, and d, but not e.
3823While
3824 varDecl(hasInitializer(integerLiteral()))
3825 varDecl(hasInitializer(declRefExpr()))
3826only match the declarations for b, c, and d.
3827</pre></td></tr>
3828
3829
3830<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>
3831<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and
3832casts are stripped off.
3833
3834Implicit and non-C Style casts are also discarded.
3835Given
3836 int a = 0;
3837 char b = (0);
3838 void* c = reinterpret_cast&lt;char*&gt;(0);
3839 char d = char(0);
3840The matcher
3841 varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
3842would match the declarations for a, b, c, and d.
3843while
3844 varDecl(hasInitializer(integerLiteral()))
3845only match the declaration for a.
3846</pre></td></tr>
3847
3848
3849<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>
3850<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and
3851parentheses are stripped off.
3852
3853Explicit casts are not discarded.
3854Given
3855 int arr[5];
3856 int a = 0;
3857 char b = (0);
3858 const int c = a;
3859 int *d = (arr);
3860 long e = ((long) 0l);
3861The matchers
3862 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
3863 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
3864would match the declarations for a, b, c, and d, but not e.
3865while
3866 varDecl(hasInitializer(integerLiteral()))
3867 varDecl(hasInitializer(declRefExpr()))
3868would only match the declaration for a.
3869</pre></td></tr>
3870
3871
3872<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>
3873<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has
3874a given body.
3875
3876Given
3877 for (;;) {}
3878hasBody(compoundStmt())
3879 matches 'for (;;) {}'
3880with compoundStmt()
3881 matching '{}'
3882</pre></td></tr>
3883
3884
3885<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>
3886<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop,
3887or conditional operator.
3888
Aaron Ballman512fb642015-09-17 13:30:52 +00003889Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
Aaron Ballman11825f22015-08-18 19:55:20 +00003890 if (true) {}
3891</pre></td></tr>
3892
3893
3894<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>
3895<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop.
3896
3897Example:
3898 forStmt(hasIncrement(unaryOperator(hasOperatorName("++"))))
3899matches '++x' in
3900 for (x; x &lt; N; ++x) { }
3901</pre></td></tr>
3902
3903
3904<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>
3905<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop.
3906
3907Example:
3908 forStmt(hasLoopInit(declStmt()))
3909matches 'int x = 0' in
3910 for (int x = 0; x &lt; N; ++x) { }
3911</pre></td></tr>
3912
3913
3914<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>
3915<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration.
3916
3917Does not match the 'this' parameter of a method.
3918
3919Given
3920 class X { void f(int x, int y, int z) {} };
Aaron Ballman512fb642015-09-17 13:30:52 +00003921cxxMethodDecl(hasAnyParameter(hasName("y")))
Aaron Ballman11825f22015-08-18 19:55:20 +00003922 matches f(int x, int y, int z) {}
3923with hasAnyParameter(...)
3924 matching int y
3925</pre></td></tr>
3926
3927
3928<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>
3929<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration.
3930
3931Given
3932 class X { void f(int x) {} };
Aaron Ballman512fb642015-09-17 13:30:52 +00003933cxxMethodDecl(hasParameter(0, hasType(varDecl())))
Aaron Ballman11825f22015-08-18 19:55:20 +00003934 matches f(int x) {}
3935with hasParameter(...)
3936 matching int x
3937</pre></td></tr>
3938
3939
3940<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>
3941<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration.
3942
3943Given:
3944 class X { int f() { return 1; } };
Aaron Ballman512fb642015-09-17 13:30:52 +00003945cxxMethodDecl(returns(asString("int")))
Aaron Ballman11825f22015-08-18 19:55:20 +00003946 matches int f() { return 1; }
3947</pre></td></tr>
3948
3949
3950<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>
3951<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop,
3952or conditional operator.
3953
Aaron Ballman512fb642015-09-17 13:30:52 +00003954Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
Aaron Ballman11825f22015-08-18 19:55:20 +00003955 if (true) {}
3956</pre></td></tr>
3957
3958
3959<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>
3960<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement.
3961
3962Given
3963 if (A* a = GetAPointer()) {}
3964hasConditionVariableStatement(...)
3965 matches 'A* a = GetAPointer()'.
3966</pre></td></tr>
3967
3968
3969<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>&gt;</td><td class="name" onclick="toggle('hasElse0')"><a name="hasElse0Anchor">hasElse</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
3970<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement.
3971
3972Examples matches the if statement
Aaron Ballman512fb642015-09-17 13:30:52 +00003973 (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true)))))
Aaron Ballman11825f22015-08-18 19:55:20 +00003974 if (false) false; else true;
3975</pre></td></tr>
3976
3977
3978<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>&gt;</td><td class="name" onclick="toggle('hasThen0')"><a name="hasThen0Anchor">hasThen</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
3979<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement.
3980
3981Examples matches the if statement
Aaron Ballman512fb642015-09-17 13:30:52 +00003982 (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true)))))
Aaron Ballman11825f22015-08-18 19:55:20 +00003983 if (false) true; else false;
3984</pre></td></tr>
3985
3986
3987<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>
3988<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given
3989matcher.
3990
3991FIXME: Unit test this matcher
3992</pre></td></tr>
3993
3994
3995<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration9')"><a name="hasDeclaration9Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
3996<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node
3997matches the given matcher.
3998
3999The associated declaration is:
4000- for type nodes, the declaration of the underlying type
4001- for CallExpr, the declaration of the callee
4002- for MemberExpr, the declaration of the referenced member
4003- for CXXConstructExpr, the declaration of the constructor
4004
4005Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
4006function. e.g. various subtypes of clang::Type and various expressions.
4007
4008Usable as: 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;,
4009 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;,
4010 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;, 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_1QualType.html">QualType</a>&gt;,
4011 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;,
4012 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;,
4013 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
4014</pre></td></tr>
4015
4016
4017<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration8')"><a name="hasDeclaration8Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
4018<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node
4019matches the given matcher.
4020
4021The associated declaration is:
4022- for type nodes, the declaration of the underlying type
4023- for CallExpr, the declaration of the callee
4024- for MemberExpr, the declaration of the referenced member
4025- for CXXConstructExpr, the declaration of the constructor
4026
4027Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
4028function. e.g. various subtypes of clang::Type and various expressions.
4029
4030Usable as: 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;,
4031 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;,
4032 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;, 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_1QualType.html">QualType</a>&gt;,
4033 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;,
4034 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;,
4035 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
4036</pre></td></tr>
4037
4038
4039<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration7')"><a name="hasDeclaration7Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
4040<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node
4041matches the given matcher.
4042
4043The associated declaration is:
4044- for type nodes, the declaration of the underlying type
4045- for CallExpr, the declaration of the callee
4046- for MemberExpr, the declaration of the referenced member
4047- for CXXConstructExpr, the declaration of the constructor
4048
4049Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
4050function. e.g. various subtypes of clang::Type and various expressions.
4051
4052Usable as: 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;,
4053 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;,
4054 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;, 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_1QualType.html">QualType</a>&gt;,
4055 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;,
4056 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;,
4057 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
4058</pre></td></tr>
4059
4060
4061<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>
4062<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is
4063matched by a given matcher.
4064
4065Given
4066 struct X { int m; };
4067 void f(X x) { x.m; m; }
Aaron Ballman512fb642015-09-17 13:30:52 +00004068memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))))
Aaron Ballman11825f22015-08-18 19:55:20 +00004069 matches "x.m" and "m"
4070with hasObjectExpression(...)
4071 matching "x" and the implicit object expression of "m" which has type X*.
4072</pre></td></tr>
4073
4074
4075<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>
4076<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a
4077given matcher.
4078
4079Given
4080 struct { int first, second; } first, second;
4081 int i(second.first);
4082 int j(first.second);
4083memberExpr(member(hasName("first")))
4084 matches second.first
4085 but not first.second (because the member name there is "second").
4086</pre></td></tr>
4087
4088
4089<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>
4090<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the
4091pointee matches a given matcher.
4092
4093Given
4094 int *a;
4095 int const *b;
4096 float const *f;
4097pointerType(pointee(isConstQualified(), isInteger()))
4098 matches "int const *b"
4099
4100Usable 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;,
4101 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;
4102</pre></td></tr>
4103
4104
4105<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>
4106<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the
4107pointee matches a given matcher.
4108
4109Given
4110 int *a;
4111 int const *b;
4112 float const *f;
4113pointerType(pointee(isConstQualified(), isInteger()))
4114 matches "int const *b"
4115
4116Usable 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;,
4117 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;
4118</pre></td></tr>
4119
4120
4121<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>
4122<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc.
4123
4124Given
4125 struct A { struct B { struct C {}; }; };
4126 A::B::C c;
4127nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A")))))
4128 matches "A::"
4129</pre></td></tr>
4130
4131
4132<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>
4133<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the
4134given TypeLoc.
4135
4136Given
4137 struct A { struct B { struct C {}; }; };
4138 A::B::C c;
4139nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
Aaron Ballman512fb642015-09-17 13:30:52 +00004140 hasDeclaration(cxxRecordDecl(hasName("A")))))))
Aaron Ballman11825f22015-08-18 19:55:20 +00004141 matches "A::"
4142</pre></td></tr>
4143
4144
4145<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>
4146<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier.
4147
4148Given
4149 struct A { struct B { struct C {}; }; };
4150 A::B::C c;
4151nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and
4152 matches "A::"
4153</pre></td></tr>
4154
4155
4156<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>
4157<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the
4158given namespace matcher.
4159
4160Given
4161 namespace ns { struct A {}; }
4162 ns::A a;
4163nestedNameSpecifier(specifiesNamespace(hasName("ns")))
4164 matches "ns::"
4165</pre></td></tr>
4166
4167
4168<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>
4169<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the
4170given QualType matcher without qualifiers.
4171
4172Given
4173 struct A { struct B { struct C {}; }; };
4174 A::B::C c;
Aaron Ballman512fb642015-09-17 13:30:52 +00004175nestedNameSpecifier(specifiesType(
4176 hasDeclaration(cxxRecordDecl(hasName("A")))
4177))
Aaron Ballman11825f22015-08-18 19:55:20 +00004178 matches "A::"
4179</pre></td></tr>
4180
4181
4182<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasArgument2')"><a name="hasArgument2Anchor">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>
4183<tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor
4184call expression.
4185
4186Example matches y in x(y)
4187 (matcher = callExpr(hasArgument(0, declRefExpr())))
4188 void x(int) { int y; x(y); }
4189</pre></td></tr>
4190
4191
4192<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasReceiverType0')"><a name="hasReceiverType0Anchor">hasReceiverType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
4193<tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression.
4194
4195Example
4196matcher = objCMessageExpr(hasRecieverType(asString("UIWebView *")));
4197matches the [webView ...] message invocation.
4198 NSString *webViewJavaScript = ...
4199 UIWebView *webView = ...
4200 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript];
4201</pre></td></tr>
4202
4203
4204<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>
4205<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type.
4206
4207Given
4208 int (*ptr_to_array)[4];
4209 int (*ptr_to_func)(int);
4210
4211varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
4212ptr_to_func but not ptr_to_array.
4213
4214Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>&gt;
4215</pre></td></tr>
4216
4217
4218<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>
4219<tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the
4220pointee matches a given matcher.
4221
4222Given
4223 int *a;
4224 int const *b;
4225 float const *f;
4226pointerType(pointee(isConstQualified(), isInteger()))
4227 matches "int const *b"
4228
4229Usable 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;,
4230 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;
4231</pre></td></tr>
4232
4233
4234<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>
4235<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the
4236pointee matches a given matcher.
4237
4238Given
4239 int *a;
4240 int const *b;
4241 float const *f;
4242pointerType(pointee(isConstQualified(), isInteger()))
4243 matches "int const *b"
4244
4245Usable 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;,
4246 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;
4247</pre></td></tr>
4248
4249
4250<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>
4251<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher.
4252
4253Given:
4254 typedef int &amp;int_ref;
4255 int a;
4256 int_ref b = a;
4257
4258varDecl(hasType(qualType(referenceType()))))) will not match the
4259declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does.
4260</pre></td></tr>
4261
4262
4263<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration6')"><a name="hasDeclaration6Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
4264<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node
4265matches the given matcher.
4266
4267The associated declaration is:
4268- for type nodes, the declaration of the underlying type
4269- for CallExpr, the declaration of the callee
4270- for MemberExpr, the declaration of the referenced member
4271- for CXXConstructExpr, the declaration of the constructor
4272
4273Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
4274function. e.g. various subtypes of clang::Type and various expressions.
4275
4276Usable as: 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;,
4277 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;,
4278 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;, 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_1QualType.html">QualType</a>&gt;,
4279 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;,
4280 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;,
4281 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
4282</pre></td></tr>
4283
4284
4285<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>
4286<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration.
4287</pre></td></tr>
4288
4289
4290<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('pointsTo0')"><a name="pointsTo0Anchor">pointsTo</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
4291<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type
4292matches the specified matcher.
4293
4294Example matches y-&gt;x()
Aaron Ballman512fb642015-09-17 13:30:52 +00004295 (matcher = cxxMemberCallExpr(on(hasType(pointsTo
4296 cxxRecordDecl(hasName("Y")))))))
Aaron Ballman11825f22015-08-18 19:55:20 +00004297 class Y { public: void x(); };
4298 void z() { Y *y; y-&gt;x(); }
4299</pre></td></tr>
4300
4301
4302<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>
4303<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration.
4304</pre></td></tr>
4305
4306
4307<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('references0')"><a name="references0Anchor">references</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
4308<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced
4309type matches the specified matcher.
4310
4311Example matches X &amp;x and const X &amp;y
Aaron Ballman512fb642015-09-17 13:30:52 +00004312 (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X"))))))
Aaron Ballman11825f22015-08-18 19:55:20 +00004313 class X {
4314 void a(X b) {
4315 X &amp;x = b;
4316 const X &amp;y = b;
4317 }
4318 };
4319</pre></td></tr>
4320
4321
4322<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</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>
4323<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node
4324matches the given matcher.
4325
4326The associated declaration is:
4327- for type nodes, the declaration of the underlying type
4328- for CallExpr, the declaration of the callee
4329- for MemberExpr, the declaration of the referenced member
4330- for CXXConstructExpr, the declaration of the constructor
4331
4332Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
4333function. e.g. various subtypes of clang::Type and various expressions.
4334
4335Usable as: 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;,
4336 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;,
4337 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;, 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_1QualType.html">QualType</a>&gt;,
4338 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;,
4339 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;,
4340 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
4341</pre></td></tr>
4342
4343
4344<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>
4345<tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the
4346pointee matches a given matcher.
4347
4348Given
4349 int *a;
4350 int const *b;
4351 float const *f;
4352pointerType(pointee(isConstQualified(), isInteger()))
4353 matches "int const *b"
4354
4355Usable 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;,
4356 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;
4357</pre></td></tr>
4358
4359
4360<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>
4361<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the
4362pointee matches a given matcher.
4363
4364Given
4365 int *a;
4366 int const *b;
4367 float const *f;
4368pointerType(pointee(isConstQualified(), isInteger()))
4369 matches "int const *b"
4370
4371Usable 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;,
4372 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;
4373</pre></td></tr>
4374
4375
4376<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>
4377<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
4378alignof.
4379</pre></td></tr>
4380
4381
4382<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>
4383<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
4384sizeof.
4385</pre></td></tr>
4386
4387
4388<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>
4389<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch
4390statement. This matcher may produce multiple matches.
4391
4392Given
4393 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }
4394switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s")
4395 matches four times, with "c" binding each of "case 1:", "case 2:",
4396"case 3:" and "case 4:", and "s" respectively binding "switch (1)",
4397"switch (1)", "switch (2)" and "switch (2)".
4398</pre></td></tr>
4399
4400
4401<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</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>
4402<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node
4403matches the given matcher.
4404
4405The associated declaration is:
4406- for type nodes, the declaration of the underlying type
4407- for CallExpr, the declaration of the callee
4408- for MemberExpr, the declaration of the referenced member
4409- for CXXConstructExpr, the declaration of the constructor
4410
4411Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
4412function. e.g. various subtypes of clang::Type and various expressions.
4413
4414Usable as: 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;,
4415 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;,
4416 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;, 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_1QualType.html">QualType</a>&gt;,
4417 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;,
4418 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;,
4419 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
4420</pre></td></tr>
4421
4422
4423<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('isExpr0')"><a name="isExpr0Anchor">isExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4424<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression.
4425
4426Given
4427 template&lt;typename T&gt; struct A {};
4428 struct B { B* next; };
4429 A&lt;&amp;B::next&gt; a;
4430templateSpecializationType(hasAnyTemplateArgument(
4431 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next"))))))))
4432 matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
4433 B::next
4434</pre></td></tr>
4435
4436
4437<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>
4438<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain
4439declaration.
4440
4441Given
4442 template&lt;typename T&gt; struct A {};
4443 struct B { B* next; };
4444 A&lt;&amp;B::next&gt; a;
4445classTemplateSpecializationDecl(hasAnyTemplateArgument(
4446 refersToDeclaration(fieldDecl(hasName("next"))))
4447 matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
4448 B::next
4449</pre></td></tr>
4450
4451
4452<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('refersToIntegralType0')"><a name="refersToIntegralType0Anchor">refersToIntegralType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
4453<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type.
4454
4455Given
4456 template&lt;int T&gt; struct A {};
4457 C&lt;42&gt; c;
4458classTemplateSpecializationDecl(
4459 hasAnyTemplateArgument(refersToIntegralType(asString("int"))))
4460 matches the implicit instantiation of C in C&lt;42&gt;.
4461</pre></td></tr>
4462
4463
4464<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>
4465<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type.
4466
4467Given
4468 struct X {};
4469 template&lt;typename T&gt; struct A {};
4470 A&lt;X&gt; a;
4471classTemplateSpecializationDecl(hasAnyTemplateArgument(
4472 refersToType(class(hasName("X")))))
4473 matches the specialization A&lt;X&gt;
4474</pre></td></tr>
4475
4476
4477<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('hasAnyTemplateArgument1')"><a name="hasAnyTemplateArgument1Anchor">hasAnyTemplateArgument</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
4478<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations that have at least one
4479TemplateArgument matching the given InnerMatcher.
4480
4481Given
4482 template&lt;typename T&gt; class A {};
4483 template&lt;&gt; class A&lt;double&gt; {};
4484 A&lt;int&gt; a;
4485classTemplateSpecializationDecl(hasAnyTemplateArgument(
4486 refersToType(asString("int"))))
4487 matches the specialization A&lt;int&gt;
4488</pre></td></tr>
4489
4490
4491<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</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>
4492<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node
4493matches the given matcher.
4494
4495The associated declaration is:
4496- for type nodes, the declaration of the underlying type
4497- for CallExpr, the declaration of the callee
4498- for MemberExpr, the declaration of the referenced member
4499- for CXXConstructExpr, the declaration of the constructor
4500
4501Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
4502function. e.g. various subtypes of clang::Type and various expressions.
4503
4504Usable as: 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;,
4505 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;,
4506 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;, 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_1QualType.html">QualType</a>&gt;,
4507 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;,
4508 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;,
4509 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
4510</pre></td></tr>
4511
4512
4513<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('hasTemplateArgument1')"><a name="hasTemplateArgument1Anchor">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>
4514<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument
4515matches the given InnerMatcher.
4516
4517Given
4518 template&lt;typename T, typename U&gt; class A {};
4519 A&lt;bool, int&gt; b;
4520 A&lt;int, bool&gt; c;
4521classTemplateSpecializationDecl(hasTemplateArgument(
4522 1, refersToType(asString("int"))))
4523 matches the specialization A&lt;bool, int&gt;
4524</pre></td></tr>
4525
4526
4527<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</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>
4528<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node
4529matches the given matcher.
4530
4531The associated declaration is:
4532- for type nodes, the declaration of the underlying type
4533- for CallExpr, the declaration of the callee
4534- for MemberExpr, the declaration of the referenced member
4535- for CXXConstructExpr, the declaration of the constructor
4536
4537Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
4538function. e.g. various subtypes of clang::Type and various expressions.
4539
4540Usable as: 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;,
4541 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;,
4542 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;, 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_1QualType.html">QualType</a>&gt;,
4543 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;,
4544 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;,
4545 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
4546</pre></td></tr>
4547
4548
4549<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>
4550<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches.
4551
4552Generates results for each match.
4553
4554For example, in:
4555 class A { class B {}; class C {}; };
4556The matcher:
Aaron Ballman512fb642015-09-17 13:30:52 +00004557 cxxRecordDecl(hasName("::A"),
4558 findAll(cxxRecordDecl(isDefinition()).bind("m")))
Aaron Ballman11825f22015-08-18 19:55:20 +00004559will generate results for A, B and C.
4560
4561Usable as: Any Matcher
4562</pre></td></tr>
4563
4564
4565<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>
4566<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node
4567matches the given matcher.
4568
4569The associated declaration is:
4570- for type nodes, the declaration of the underlying type
4571- for CallExpr, the declaration of the callee
4572- for MemberExpr, the declaration of the referenced member
4573- for CXXConstructExpr, the declaration of the constructor
4574
4575Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
4576function. e.g. various subtypes of clang::Type and various expressions.
4577
4578Usable as: 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;,
4579 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;,
4580 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;, 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_1QualType.html">QualType</a>&gt;,
4581 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;,
4582 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;,
4583 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
4584</pre></td></tr>
4585
4586
4587<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>
4588<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument.
4589
4590Given
4591 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
4592unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
4593 matches sizeof(a) and alignof(c)
4594</pre></td></tr>
4595
4596
4597<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>
4598<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches.
4599
Aaron Ballman512fb642015-09-17 13:30:52 +00004600Example matches true (matcher = hasUnaryOperand(
4601 cxxBoolLiteral(equals(true))))
Aaron Ballman11825f22015-08-18 19:55:20 +00004602 !true
4603</pre></td></tr>
4604
4605
4606<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</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>
4607<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node
4608matches the given matcher.
4609
4610The associated declaration is:
4611- for type nodes, the declaration of the underlying type
4612- for CallExpr, the declaration of the callee
4613- for MemberExpr, the declaration of the referenced member
4614- for CXXConstructExpr, the declaration of the constructor
4615
4616Also usable as Matcher&lt;T&gt; for any T supporting the getDecl() member
4617function. e.g. various subtypes of clang::Type and various expressions.
4618
4619Usable as: 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;,
4620 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;,
4621 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;, 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_1QualType.html">QualType</a>&gt;,
4622 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;,
4623 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;,
4624 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
4625</pre></td></tr>
4626
4627
4628<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>
4629<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration.
4630
4631Given
4632 namespace X { void b(); }
4633 using X::b;
4634usingDecl(hasAnyUsingShadowDecl(hasName("b"))))
4635 matches using X::b </pre></td></tr>
4636
4637
4638<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>
4639<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is
4640matched by the given matcher.
4641
4642Given
4643 namespace X { int a; void b(); }
4644 using X::a;
4645 using X::b;
4646usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
4647 matches using X::b but not using X::a </pre></td></tr>
4648
4649
4650<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>
4651<tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value
4652declaration's type.
4653
4654In case of a value declaration (for example a variable declaration),
4655this resolves one layer of indirection. For example, in the value
Aaron Ballman512fb642015-09-17 13:30:52 +00004656declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
4657X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
4658declaration of x.
Aaron Ballman11825f22015-08-18 19:55:20 +00004659
Aaron Ballman512fb642015-09-17 13:30:52 +00004660Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
4661 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
Aaron Ballman11825f22015-08-18 19:55:20 +00004662 class X {};
4663 void y(X &amp;x) { x; X z; }
4664
4665Usable 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;
4666</pre></td></tr>
4667
4668
4669<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;</td><td class="name" onclick="toggle('hasType1')"><a name="hasType1Anchor">hasType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
4670<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type
4671matcher.
4672
Aaron Ballman512fb642015-09-17 13:30:52 +00004673Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
4674 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
Aaron Ballman11825f22015-08-18 19:55:20 +00004675 class X {};
4676 void y(X &amp;x) { x; X z; }
4677</pre></td></tr>
4678
4679
4680<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>
4681<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression
4682that matches the given matcher.
4683
4684Example matches x (matcher = varDecl(hasInitializer(callExpr())))
4685 bool y() { return true; }
4686 bool x = y();
4687</pre></td></tr>
4688
4689
4690<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>
4691<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size
4692expression.
4693
4694Given
4695 void f(int b) {
4696 int a[b];
4697 }
4698variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
4699 varDecl(hasName("b")))))))
4700 matches "int a[b]"
4701</pre></td></tr>
4702
4703
4704<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>
4705<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has
4706a given body.
4707
4708Given
4709 for (;;) {}
4710hasBody(compoundStmt())
4711 matches 'for (;;) {}'
4712with compoundStmt()
4713 matching '{}'
4714</pre></td></tr>
4715
4716
4717<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>
4718<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop,
4719or conditional operator.
4720
Aaron Ballman512fb642015-09-17 13:30:52 +00004721Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
Aaron Ballman11825f22015-08-18 19:55:20 +00004722 if (true) {}
4723</pre></td></tr>
4724
4725
4726<tr><td>Matcher&lt;internal::BindableMatcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>&gt;&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>
4727<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner
4728NestedNameSpecifier-matcher matches.
4729</pre></td></tr>
4730
4731
4732<tr><td>Matcher&lt;internal::BindableMatcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;&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>
4733<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner
4734QualType-matcher matches.
4735</pre></td></tr>
4736
4737<!--END_TRAVERSAL_MATCHERS -->
4738</table>
4739
4740</div>
4741</body>
4742</html>
4743
4744