blob: 163743cdc9db8c9690d172cb8f5cf1b6d4f6fecf [file] [log] [blame]
Manuel Klimek1da79332012-08-20 20:54:03 +00001<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3<html>
4<head>
5<title>AST Matcher Reference</title>
6<link type="text/css" rel="stylesheet" href="../menu.css" />
7<link type="text/css" rel="stylesheet" href="../content.css" />
8<style type="text/css">
9td {
10 padding: .33em;
11}
12td.doc {
13 display: none;
14 border-bottom: 1px solid black;
15}
16td.name:hover {
17 color: blue;
18 cursor: pointer;
19}
20</style>
21<script type="text/javascript">
22function toggle(id) {
Manuel Klimek67619ff2012-09-07 13:10:32 +000023 if (!id) return;
Manuel Klimek1da79332012-08-20 20:54:03 +000024 row = document.getElementById(id);
25 if (row.style.display != 'table-cell')
26 row.style.display = 'table-cell';
27 else
28 row.style.display = 'none';
29}
30</script>
31</head>
Manuel Klimek67619ff2012-09-07 13:10:32 +000032<body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))">
Manuel Klimek1da79332012-08-20 20:54:03 +000033
34<!--#include virtual="../menu.html.incl"-->
35
36<div id="content">
37
38<h1>AST Matcher Reference</h1>
39
40<p>This document shows all currently implemented matchers. The matchers are grouped
41by category and node type they match. You can click on matcher names to show the
42matcher's source documentation.</p>
43
44<p>There are three different basic categories of matchers:
45<ul>
46<li><a href="#decl-matchers">Node Matchers:</a> Matchers that match a specific type of AST node.</li>
47<li><a href="#narrowing-matchers">Narrowing Matchers:</a> Matchers that match attributes on AST nodes.</li>
48<li><a href="#traversal-matchers">Traversal Matchers:</a> Matchers that allow traversal between AST nodes.</li>
49</ul>
50</p>
51
52<p>Within each category the matchers are ordered by node type they match on.
53Note that if a matcher can match multiple node types, it will it will appear
54multiple times. This means that by searching for Matcher&lt;Stmt&gt; you can
55find all matchers that can be used to match on Stmt nodes.</p>
56
57<p>The exception to that rule are matchers that can match on any node. Those
58are marked with a * and are listed in the beginning of each category.</p>
59
60<!-- ======================================================================= -->
61<h2 id="decl-matchers">Node Matchers</h2>
62<!-- ======================================================================= -->
63
64<p>Node matchers are at the core of matcher expressions - they specify the type
65of node that is expected. Every match expression starts with a node matcher,
66which can then be further refined with a narrowing or traversal matcher. All
67traversal matchers take node matchers as their arguments.</p>
68
69<p>For convenience, all node matchers take an arbitrary number of arguments
70and implicitly act as allOf matchers.</p>
71
72<p>Node matchers are the only matchers that support the bind("id") call to
73bind the matched node to the given string, to be later retrieved from the
74match callback.</p>
75
76<table>
77<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
78<!-- START_DECL_MATCHERS -->
79
Manuel Klimek67619ff2012-09-07 13:10:32 +000080<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('classTemplateDecl0')"><a name="classTemplateDecl0Anchor">classTemplateDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html">ClassTemplateDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +000081<tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +000082
83Example matches Z
84 template&lt;class T&gt; class Z {};
85</pre></td></tr>
86
87
Manuel Klimek67619ff2012-09-07 13:10:32 +000088<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('classTemplateSpecializationDecl0')"><a name="classTemplateSpecializationDecl0Anchor">classTemplateSpecializationDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +000089<tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations.
Manuel Klimek1da79332012-08-20 20:54:03 +000090
91Given
92 template&lt;typename T&gt; class A {};
93 template&lt;&gt; class A&lt;double&gt; {};
94 A&lt;int&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +000095classTemplateSpecializationDecl()
Manuel Klimek1da79332012-08-20 20:54:03 +000096 matches the specializations A&lt;int&gt; and A&lt;double&gt;
97</pre></td></tr>
98
99
Manuel Klimek67619ff2012-09-07 13:10:32 +0000100<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('constructorDecl0')"><a name="constructorDecl0Anchor">constructorDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000101<tr><td colspan="4" class="doc" id="constructorDecl0"><pre>Matches C++ constructor declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000102
103Example matches Foo::Foo() and Foo::Foo(int)
104 class Foo {
105 public:
106 Foo();
107 Foo(int);
108 int DoSomething();
109 };
110</pre></td></tr>
111
112
Manuel Klimek67619ff2012-09-07 13:10:32 +0000113<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('decl0')"><a name="decl0Anchor">decl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000114<tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations.
115
116Examples matches X, C, and the friend declaration inside C;
117 void X();
118 class C {
119 friend X;
120 };
121</pre></td></tr>
122
123
Manuel Klimek67619ff2012-09-07 13:10:32 +0000124<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('destructorDecl0')"><a name="destructorDecl0Anchor">destructorDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000125<tr><td colspan="4" class="doc" id="destructorDecl0"><pre>Matches explicit C++ destructor declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000126
127Example matches Foo::~Foo()
128 class Foo {
129 public:
130 virtual ~Foo();
131 };
132</pre></td></tr>
133
134
Manuel Klimek67619ff2012-09-07 13:10:32 +0000135<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('enumConstantDecl0')"><a name="enumConstantDecl0Anchor">enumConstantDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumConstantDecl.html">EnumConstantDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000136<tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants.
Manuel Klimek1da79332012-08-20 20:54:03 +0000137
138Example matches A, B, C
139 enum X {
140 A, B, C
141 };
142</pre></td></tr>
143
144
Manuel Klimek67619ff2012-09-07 13:10:32 +0000145<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('enumDecl0')"><a name="enumDecl0Anchor">enumDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000146<tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations.
147
148Example matches X
149 enum X {
150 A, B, C
151 };
152</pre></td></tr>
153
154
Manuel Klimek67619ff2012-09-07 13:10:32 +0000155<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('fieldDecl0')"><a name="fieldDecl0Anchor">fieldDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000156<tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000157
158Given
159 class X { int m; };
Manuel Klimeke44a0062012-08-26 23:55:24 +0000160fieldDecl()
Manuel Klimek1da79332012-08-20 20:54:03 +0000161 matches 'm'.
162</pre></td></tr>
163
164
Manuel Klimek67619ff2012-09-07 13:10:32 +0000165<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('functionDecl0')"><a name="functionDecl0Anchor">functionDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000166<tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000167
168Example matches f
169 void f();
170</pre></td></tr>
171
172
Manuel Klimek67619ff2012-09-07 13:10:32 +0000173<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('functionTemplateDecl0')"><a name="functionTemplateDecl0Anchor">functionTemplateDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionTemplateDecl.html">FunctionTemplateDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000174<tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000175
176Example matches f
177 template&lt;class T&gt; void f(T t) {}
178</pre></td></tr>
179
180
Manuel Klimek67619ff2012-09-07 13:10:32 +0000181<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('methodDecl0')"><a name="methodDecl0Anchor">methodDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000182<tr><td colspan="4" class="doc" id="methodDecl0"><pre>Matches method declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000183
184Example matches y
185 class X { void y() };
186</pre></td></tr>
187
188
Manuel Klimek67619ff2012-09-07 13:10:32 +0000189<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('namedDecl0')"><a name="namedDecl0Anchor">namedDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000190<tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name.
Manuel Klimek1da79332012-08-20 20:54:03 +0000191
192Example matches X, S, the anonymous union type, i, and U;
193 typedef int X;
194 struct S {
195 union {
196 int i;
197 } U;
198 };
199</pre></td></tr>
200
201
Manuel Klimek67619ff2012-09-07 13:10:32 +0000202<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('recordDecl0')"><a name="recordDecl0Anchor">recordDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000203<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches C++ class declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000204
205Example matches X, Z
206 class X;
207 template&lt;class T&gt; class Z {};
208</pre></td></tr>
209
210
Manuel Klimek67619ff2012-09-07 13:10:32 +0000211<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('usingDecl0')"><a name="usingDecl0Anchor">usingDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html">UsingDecl</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000212<tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations.
213
214Given
215 namespace X { int x; }
216 using X::x;
217usingDecl()
218 matches using X::x </pre></td></tr>
219
220
Manuel Klimek67619ff2012-09-07 13:10:32 +0000221<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('varDecl0')"><a name="varDecl0Anchor">varDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000222<tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000223
224Note: this does not match declarations of member variables, which are
225"field" declarations in Clang parlance.
226
227Example matches a
228 int a;
229</pre></td></tr>
230
231
Manuel Klimek41df16e2013-01-09 09:38:21 +0000232<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>
233<tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
234</pre></td></tr>
235
236
237<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>
238<tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers.
239
240Given
241 namespace ns {
242 struct A { static void f(); };
243 void A::f() {}
244 void g() { A::f(); }
245 }
246 ns::A a;
247nestedNameSpecifier()
248 matches "ns::" and both "A::"
249</pre></td></tr>
250
251
252<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>
253<tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST.
254</pre></td></tr>
255
256
Manuel Klimek67619ff2012-09-07 13:10:32 +0000257<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('arraySubscriptExpr0')"><a name="arraySubscriptExpr0Anchor">arraySubscriptExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000258<tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions.
259
260Given
261 int i = a[1];
262arraySubscriptExpr()
263 matches "a[1]"
264</pre></td></tr>
265
266
Daniel Jaspere0b89972012-12-04 12:08:08 +0000267<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>
268<tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements.
269
270 int i = 100;
271 __asm("mov al, 2");
272asmStmt()
273 matches '__asm("mov al, 2")'
274</pre></td></tr>
275
276
Manuel Klimek67619ff2012-09-07 13:10:32 +0000277<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('binaryOperator0')"><a name="binaryOperator0Anchor">binaryOperator</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000278<tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions.
279
280Example matches a || b
281 !(a || b)
282</pre></td></tr>
283
284
Manuel Klimek67619ff2012-09-07 13:10:32 +0000285<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('bindTemporaryExpr0')"><a name="bindTemporaryExpr0Anchor">bindTemporaryExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000286<tr><td colspan="4" class="doc" id="bindTemporaryExpr0"><pre>Matches nodes where temporaries are created.
Manuel Klimek1da79332012-08-20 20:54:03 +0000287
288Example matches FunctionTakesString(GetStringByValue())
Manuel Klimeke44a0062012-08-26 23:55:24 +0000289 (matcher = bindTemporaryExpr())
Manuel Klimek1da79332012-08-20 20:54:03 +0000290 FunctionTakesString(GetStringByValue());
291 FunctionTakesStringByPointer(GetStringPointer());
292</pre></td></tr>
293
294
Daniel Jaspere0b89972012-12-04 12:08:08 +0000295<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('boolLiteral0')"><a name="boolLiteral0Anchor">boolLiteral</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>&gt;...</td></tr>
296<tr><td colspan="4" class="doc" id="boolLiteral0"><pre>Matches bool literals.
297
298Example matches true
299 true
300</pre></td></tr>
301
302
303<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>
304<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements.
305
306Given
307 while (true) { break; }
308breakStmt()
309 matches 'break'
310</pre></td></tr>
311
312
313<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>
314<tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression.
315
316Example: Matches (int*) 2.2f in
317 int i = (int) 2.2f;
318</pre></td></tr>
319
320
Manuel Klimek67619ff2012-09-07 13:10:32 +0000321<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('callExpr0')"><a name="callExpr0Anchor">callExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000322<tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000323
324Example matches x.y() and y()
325 X x;
326 x.y();
327 y();
328</pre></td></tr>
329
330
Daniel Jaspere0b89972012-12-04 12:08:08 +0000331<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>
332<tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST.
333
334Example: castExpr() matches each of the following:
335 (int) 3;
336 const_cast&lt;Expr *&gt;(SubExpr);
337 char c = 0;
338but does not match
339 int i = (0);
340 int k = 0;
341</pre></td></tr>
342
343
344<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('catchStmt0')"><a name="catchStmt0Anchor">catchStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>&gt;...</td></tr>
345<tr><td colspan="4" class="doc" id="catchStmt0"><pre>Matches catch statements.
346
347 try {} catch(int i) {}
348catchStmt()
349 matches 'catch(int i)'
350</pre></td></tr>
351
352
353<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>
354<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t).
355
356Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
357though.
358
359Example matches 'a', L'a'
360 char ch = 'a'; wchar_t chw = L'a';
361</pre></td></tr>
362
363
Manuel Klimek67619ff2012-09-07 13:10:32 +0000364<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('compoundStmt0')"><a name="compoundStmt0Anchor">compoundStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000365<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements.
Manuel Klimek1da79332012-08-20 20:54:03 +0000366
367Example matches '{}' and '{{}}'in 'for (;;) {{}}'
368 for (;;) {{}}
369</pre></td></tr>
370
371
Manuel Klimek67619ff2012-09-07 13:10:32 +0000372<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('conditionalOperator0')"><a name="conditionalOperator0Anchor">conditionalOperator</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000373<tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions.
374
375Example matches a ? b : c
376 (a ? b : c) + 42
377</pre></td></tr>
378
379
Daniel Jaspere0b89972012-12-04 12:08:08 +0000380<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('constCastExpr0')"><a name="constCastExpr0Anchor">constCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>&gt;...</td></tr>
381<tr><td colspan="4" class="doc" id="constCastExpr0"><pre>Matches a const_cast expression.
382
383Example: Matches const_cast&lt;int*&gt;(&amp;r) in
384 int n = 42;
385 const int &amp;r(n);
386 int* p = const_cast&lt;int*&gt;(&amp;r);
387</pre></td></tr>
388
389
Manuel Klimek67619ff2012-09-07 13:10:32 +0000390<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('constructExpr0')"><a name="constructExpr0Anchor">constructExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000391<tr><td colspan="4" class="doc" id="constructExpr0"><pre>Matches constructor call expressions (including implicit ones).
Manuel Klimek1da79332012-08-20 20:54:03 +0000392
393Example matches string(ptr, n) and ptr within arguments of f
Manuel Klimeke44a0062012-08-26 23:55:24 +0000394 (matcher = constructExpr())
Manuel Klimek1da79332012-08-20 20:54:03 +0000395 void f(const string &amp;a, const string &amp;b);
396 char *ptr;
397 int n;
398 f(string(ptr, n), ptr);
399</pre></td></tr>
400
401
Daniel Jaspere0b89972012-12-04 12:08:08 +0000402<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>
403<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements.
404
405Given
406 while (true) { continue; }
407continueStmt()
408 matches 'continue'
409</pre></td></tr>
410
411
Manuel Klimek67619ff2012-09-07 13:10:32 +0000412<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('declRefExpr0')"><a name="declRefExpr0Anchor">declRefExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000413<tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000414
415Example matches x in if (x)
416 bool x;
417 if (x) {}
418</pre></td></tr>
419
420
Manuel Klimek67619ff2012-09-07 13:10:32 +0000421<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('declStmt0')"><a name="declStmt0Anchor">declStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000422<tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements.
Manuel Klimek1da79332012-08-20 20:54:03 +0000423
424Given
425 int a;
Manuel Klimeke44a0062012-08-26 23:55:24 +0000426declStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +0000427 matches 'int a'.
428</pre></td></tr>
429
430
Manuel Klimek67619ff2012-09-07 13:10:32 +0000431<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('defaultArgExpr0')"><a name="defaultArgExpr0Anchor">defaultArgExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000432<tr><td colspan="4" class="doc" id="defaultArgExpr0"><pre>Matches the value of a default argument at the call site.
Manuel Klimek1da79332012-08-20 20:54:03 +0000433
434Example matches the CXXDefaultArgExpr placeholder inserted for the
435 default value of the second parameter in the call expression f(42)
Manuel Klimeke44a0062012-08-26 23:55:24 +0000436 (matcher = defaultArgExpr())
Manuel Klimek1da79332012-08-20 20:54:03 +0000437 void f(int x, int y = 0);
438 f(42);
439</pre></td></tr>
440
441
Manuel Klimek67619ff2012-09-07 13:10:32 +0000442<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('deleteExpr0')"><a name="deleteExpr0Anchor">deleteExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000443<tr><td colspan="4" class="doc" id="deleteExpr0"><pre>Matches delete expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000444
445Given
446 delete X;
Manuel Klimeke44a0062012-08-26 23:55:24 +0000447deleteExpr()
Manuel Klimek1da79332012-08-20 20:54:03 +0000448 matches 'delete X'.
449</pre></td></tr>
450
451
Manuel Klimek67619ff2012-09-07 13:10:32 +0000452<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('doStmt0')"><a name="doStmt0Anchor">doStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000453<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements.
454
455Given
456 do {} while (true);
457doStmt()
458 matches 'do {} while(true)'
459</pre></td></tr>
460
461
Daniel Jaspere0b89972012-12-04 12:08:08 +0000462<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('dynamicCastExpr0')"><a name="dynamicCastExpr0Anchor">dynamicCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>&gt;...</td></tr>
463<tr><td colspan="4" class="doc" id="dynamicCastExpr0"><pre>Matches a dynamic_cast expression.
464
465Example:
466 dynamicCastExpr()
467matches
468 dynamic_cast&lt;D*&gt;(&amp;b);
469in
470 struct B { virtual ~B() {} }; struct D : B {};
471 B b;
472 D* p = dynamic_cast&lt;D*&gt;(&amp;b);
473</pre></td></tr>
474
475
476<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>
477<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions.
478
479Matches any cast expression written in user code, whether it be a
480C-style cast, a functional-style cast, or a keyword cast.
481
482Does not match implicit conversions.
483
484Note: the name "explicitCast" is chosen to match Clang's terminology, as
485Clang uses the term "cast" to apply to implicit conversions as well as to
486actual cast expressions.
487
488hasDestinationType.
489
490Example: matches all five of the casts in
491 int((int)(reinterpret_cast&lt;int&gt;(static_cast&lt;int&gt;(const_cast&lt;int&gt;(42)))))
492but does not match the implicit conversion in
493 long ell = 42;
494</pre></td></tr>
495
496
Manuel Klimek67619ff2012-09-07 13:10:32 +0000497<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('expr0')"><a name="expr0Anchor">expr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000498<tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000499
500Example matches x()
501 void f() { x(); }
502</pre></td></tr>
503
504
Daniel Jaspere0b89972012-12-04 12:08:08 +0000505<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('forRangeStmt0')"><a name="forRangeStmt0Anchor">forRangeStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>&gt;...</td></tr>
506<tr><td colspan="4" class="doc" id="forRangeStmt0"><pre>Matches range-based for statements.
507
508forRangeStmt() matches 'for (auto a : i)'
509 int i[] = {1, 2, 3}; for (auto a : i);
510 for(int j = 0; j &lt; 5; ++j);
511</pre></td></tr>
512
513
Manuel Klimek67619ff2012-09-07 13:10:32 +0000514<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('forStmt0')"><a name="forStmt0Anchor">forStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000515<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements.
516
517Example matches 'for (;;) {}'
518 for (;;) {}
Daniel Jaspere0b89972012-12-04 12:08:08 +0000519 int i[] = {1, 2, 3}; for (auto a : i);
520</pre></td></tr>
521
522
523<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('functionalCastExpr0')"><a name="functionalCastExpr0Anchor">functionalCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;...</td></tr>
524<tr><td colspan="4" class="doc" id="functionalCastExpr0"><pre>Matches functional cast expressions
525
526Example: Matches Foo(bar);
527 Foo f = bar;
528 Foo g = (Foo) bar;
529 Foo h = Foo(bar);
530</pre></td></tr>
531
532
533<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>
534<tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements.
535
536Given
537 goto FOO;
538 FOO: bar();
539gotoStmt()
540 matches 'goto FOO'
Manuel Klimek1da79332012-08-20 20:54:03 +0000541</pre></td></tr>
542
543
Manuel Klimek67619ff2012-09-07 13:10:32 +0000544<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('ifStmt0')"><a name="ifStmt0Anchor">ifStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000545<tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements.
546
547Example matches 'if (x) {}'
548 if (x) {}
549</pre></td></tr>
550
551
Daniel Jaspere0b89972012-12-04 12:08:08 +0000552<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>
553<tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST.
554
555This matches many different places, including function call return value
556eliding, as well as any type conversions.
557</pre></td></tr>
558
559
Manuel Klimek67619ff2012-09-07 13:10:32 +0000560<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('initListExpr0')"><a name="initListExpr0Anchor">initListExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000561<tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions.
562
563Given
564 int a[] = { 1, 2 };
565 struct B { int x, y; };
566 B b = { 5, 6 };
567initList()
568 matches "{ 1, 2 }" and "{ 5, 6 }"
569</pre></td></tr>
570
571
Daniel Jaspere0b89972012-12-04 12:08:08 +0000572<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>
573<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings.
574
575Not matching character-encoded integers such as L'a'.
576
577Example matches 1, 1L, 0x1, 1U
578</pre></td></tr>
579
580
581<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>
582<tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements.
583
584Given
585 goto FOO;
586 FOO: bar();
587labelStmt()
588 matches 'FOO:'
589</pre></td></tr>
590
591
592<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>
593<tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions.
594
595Example matches [&amp;](){return 5;}
596 [&amp;](){return 5;}
597</pre></td></tr>
598
599
Manuel Klimek67619ff2012-09-07 13:10:32 +0000600<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('materializeTemporaryExpr0')"><a name="materializeTemporaryExpr0Anchor">materializeTemporaryExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MaterializeTemporaryExpr.html">MaterializeTemporaryExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000601<tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized.
602
603Example: Given
604 struct T {void func()};
605 T f();
606 void g(T);
607materializeTemporaryExpr() matches 'f()' in these statements
608 T u(f());
609 g(f());
610but does not match
611 f();
612 f().func();
613</pre></td></tr>
614
615
Manuel Klimek67619ff2012-09-07 13:10:32 +0000616<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('memberCallExpr0')"><a name="memberCallExpr0Anchor">memberCallExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000617<tr><td colspan="4" class="doc" id="memberCallExpr0"><pre>Matches member call expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000618
619Example matches x.y()
620 X x;
621 x.y();
622</pre></td></tr>
623
624
Manuel Klimek67619ff2012-09-07 13:10:32 +0000625<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('memberExpr0')"><a name="memberExpr0Anchor">memberExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000626<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000627
628Given
629 class Y {
630 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
631 int a; static int b;
632 };
Manuel Klimeke44a0062012-08-26 23:55:24 +0000633memberExpr()
Manuel Klimek1da79332012-08-20 20:54:03 +0000634 matches this-&gt;x, x, y.x, a, this-&gt;b
635</pre></td></tr>
636
637
Manuel Klimek67619ff2012-09-07 13:10:32 +0000638<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('newExpr0')"><a name="newExpr0Anchor">newExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000639<tr><td colspan="4" class="doc" id="newExpr0"><pre>Matches new expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000640
641Given
642 new X;
Manuel Klimeke44a0062012-08-26 23:55:24 +0000643newExpr()
Manuel Klimek1da79332012-08-20 20:54:03 +0000644 matches 'new X'.
645</pre></td></tr>
646
647
Daniel Jaspere0b89972012-12-04 12:08:08 +0000648<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('nullPtrLiteralExpr0')"><a name="nullPtrLiteralExpr0Anchor">nullPtrLiteralExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>&gt;...</td></tr>
649<tr><td colspan="4" class="doc" id="nullPtrLiteralExpr0"><pre>Matches nullptr literal.
650</pre></td></tr>
651
652
653<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>
654<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements.
655
656 foo();;
657nullStmt()
658 matches the second ';'
659</pre></td></tr>
660
661
Manuel Klimek67619ff2012-09-07 13:10:32 +0000662<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('operatorCallExpr0')"><a name="operatorCallExpr0Anchor">operatorCallExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000663<tr><td colspan="4" class="doc" id="operatorCallExpr0"><pre>Matches overloaded operator calls.
Manuel Klimek1da79332012-08-20 20:54:03 +0000664
665Note that if an operator isn't overloaded, it won't match. Instead, use
666binaryOperator matcher.
667Currently it does not match operators such as new delete.
668FIXME: figure out why these do not match?
669
670Example matches both operator&lt;&lt;((o &lt;&lt; b), c) and operator&lt;&lt;(o, b)
Manuel Klimeke44a0062012-08-26 23:55:24 +0000671 (matcher = operatorCallExpr())
Manuel Klimek1da79332012-08-20 20:54:03 +0000672 ostream &amp;operator&lt;&lt; (ostream &amp;out, int i) { };
673 ostream &amp;o; int b = 1, c = 1;
674 o &lt;&lt; b &lt;&lt; c;
675</pre></td></tr>
676
677
Daniel Jaspere0b89972012-12-04 12:08:08 +0000678<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('reinterpretCastExpr0')"><a name="reinterpretCastExpr0Anchor">reinterpretCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>&gt;...</td></tr>
679<tr><td colspan="4" class="doc" id="reinterpretCastExpr0"><pre>Matches a reinterpret_cast expression.
680
681Either the source expression or the destination type can be matched
682using has(), but hasDestinationType() is more specific and can be
683more readable.
684
685Example matches reinterpret_cast&lt;char*&gt;(&amp;p) in
686 void* p = reinterpret_cast&lt;char*&gt;(&amp;p);
687</pre></td></tr>
688
689
690<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>
691<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements.
692
693Given
694 return 1;
695returnStmt()
696 matches 'return 1'
697</pre></td></tr>
698
699
700<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('staticCastExpr0')"><a name="staticCastExpr0Anchor">staticCastExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>&gt;...</td></tr>
701<tr><td colspan="4" class="doc" id="staticCastExpr0"><pre>Matches a C++ static_cast expression.
702
703hasDestinationType
704reinterpretCast
705
706Example:
707 staticCastExpr()
708matches
709 static_cast&lt;long&gt;(8)
710in
711 long eight(static_cast&lt;long&gt;(8));
712</pre></td></tr>
713
714
Manuel Klimek67619ff2012-09-07 13:10:32 +0000715<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('stmt0')"><a name="stmt0Anchor">stmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;...</td></tr>
Manuel Klimeke44a0062012-08-26 23:55:24 +0000716<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements.
Manuel Klimek1da79332012-08-20 20:54:03 +0000717
718Given
719 { ++a; }
Manuel Klimeke44a0062012-08-26 23:55:24 +0000720stmt()
Manuel Klimek1da79332012-08-20 20:54:03 +0000721 matches both the compound statement '{ ++a; }' and '++a'.
722</pre></td></tr>
723
724
Daniel Jaspere0b89972012-12-04 12:08:08 +0000725<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>
726<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals).
727
728Example matches "abcd", L"abcd"
729 char *s = "abcd"; wchar_t *ws = L"abcd"
730</pre></td></tr>
731
732
Manuel Klimek67619ff2012-09-07 13:10:32 +0000733<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('switchCase0')"><a name="switchCase0Anchor">switchCase</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000734<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements.
735
736Given
737 switch(a) { case 42: break; default: break; }
738switchCase()
739 matches 'case 42: break;' and 'default: break;'.
740</pre></td></tr>
741
742
Daniel Jaspere0b89972012-12-04 12:08:08 +0000743<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>
744<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements.
745
746Given
747 switch(a) { case 42: break; default: break; }
748switchStmt()
749 matches 'switch(a)'.
750</pre></td></tr>
751
752
753<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('thisExpr0')"><a name="thisExpr0Anchor">thisExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>&gt;...</td></tr>
754<tr><td colspan="4" class="doc" id="thisExpr0"><pre>Matches implicit and explicit this expressions.
755
756Example matches the implicit this expression in "return i".
757 (matcher = thisExpr())
758struct foo {
759 int i;
760 int f() { return i; }
761};
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('throwExpr0')"><a name="throwExpr0Anchor">throwExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>&gt;...</td></tr>
766<tr><td colspan="4" class="doc" id="throwExpr0"><pre>Matches throw expressions.
767
768 try { throw 5; } catch(int i) {}
769throwExpr()
770 matches 'throw 5'
771</pre></td></tr>
772
773
774<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('tryStmt0')"><a name="tryStmt0Anchor">tryStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>&gt;...</td></tr>
775<tr><td colspan="4" class="doc" id="tryStmt0"><pre>Matches try statements.
776
777 try {} catch(int i) {}
778tryStmt()
779 matches 'try {}'
780</pre></td></tr>
781
782
Manuel Klimek67619ff2012-09-07 13:10:32 +0000783<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('unaryExprOrTypeTraitExpr0')"><a name="unaryExprOrTypeTraitExpr0Anchor">unaryExprOrTypeTraitExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000784<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
785
786Given
787 Foo x = bar;
788 int y = sizeof(x) + alignof(x);
789unaryExprOrTypeTraitExpr()
790 matches sizeof(x) and alignof(x)
791</pre></td></tr>
792
793
Manuel Klimek67619ff2012-09-07 13:10:32 +0000794<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('unaryOperator0')"><a name="unaryOperator0Anchor">unaryOperator</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000795<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions.
796
797Example matches !a
798 !a || b
799</pre></td></tr>
800
801
Daniel Jaspere0b89972012-12-04 12:08:08 +0000802<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>
803<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call.
804
805Example match: "foo"_suffix
806</pre></td></tr>
807
808
Manuel Klimek67619ff2012-09-07 13:10:32 +0000809<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('whileStmt0')"><a name="whileStmt0Anchor">whileStmt</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>&gt;...</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +0000810<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements.
811
812Given
813 while (true) {}
814whileStmt()
815 matches 'while (true) {}'.
816</pre></td></tr>
817
Daniel Jaspere0b89972012-12-04 12:08:08 +0000818
Manuel Klimek41df16e2013-01-09 09:38:21 +0000819<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('arrayTypeLoc0')"><a name="arrayTypeLoc0Anchor">arrayTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayTypeLoc.html">ArrayTypeLoc</a>&gt;...</td></tr>
820<tr><td colspan="4" class="doc" id="arrayTypeLoc0"><pre>Matches all kinds of arrays.
821
822Given
823 int a[] = { 2, 3 };
824 int b[4];
825 void f() { int c[a[0]]; }
826arrayType()
827 matches "int a[]", "int b[4]" and "int c[a[0]]";
828</pre></td></tr>
829
830
831<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('atomicTypeLoc0')"><a name="atomicTypeLoc0Anchor">atomicTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicTypeLoc.html">AtomicTypeLoc</a>&gt;...</td></tr>
832<tr><td colspan="4" class="doc" id="atomicTypeLoc0"><pre>Matches atomic types.
833
834Given
835 _Atomic(int) i;
836atomicType()
837 matches "_Atomic(int) i"
838</pre></td></tr>
839
840
841<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('autoTypeLoc0')"><a name="autoTypeLoc0Anchor">autoTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoTypeLoc.html">AutoTypeLoc</a>&gt;...</td></tr>
842<tr><td colspan="4" class="doc" id="autoTypeLoc0"><pre>Matches types nodes representing C++11 auto types.
843
844Given:
845 auto n = 4;
846 int v[] = { 2, 3 }
847 for (auto i : v) { }
848autoType()
849 matches "auto n" and "auto i"
850</pre></td></tr>
851
852
853<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('blockPointerTypeLoc0')"><a name="blockPointerTypeLoc0Anchor">blockPointerTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerTypeLoc.html">BlockPointerTypeLoc</a>&gt;...</td></tr>
854<tr><td colspan="4" class="doc" id="blockPointerTypeLoc0"><pre>Matches block pointer types, i.e. types syntactically represented as
855"void (^)(int)".
856
857The pointee is always required to be a FunctionType.
858</pre></td></tr>
859
860
861<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('builtinTypeLoc0')"><a name="builtinTypeLoc0Anchor">builtinTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BuiltinTypeLoc.html">BuiltinTypeLoc</a>&gt;...</td></tr>
862<tr><td colspan="4" class="doc" id="builtinTypeLoc0"><pre>Matches builtin Types.
863
864Given
865 struct A {};
866 A a;
867 int b;
868 float c;
869 bool d;
870builtinType()
871 matches "int b", "float c" and "bool d"
872</pre></td></tr>
873
874
875<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('complexTypeLoc0')"><a name="complexTypeLoc0Anchor">complexTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexTypeLoc.html">ComplexTypeLoc</a>&gt;...</td></tr>
876<tr><td colspan="4" class="doc" id="complexTypeLoc0"><pre>Matches C99 complex types.
877
878Given
879 _Complex float f;
880complexType()
881 matches "_Complex float f"
882</pre></td></tr>
883
884
885<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('constantArrayTypeLoc0')"><a name="constantArrayTypeLoc0Anchor">constantArrayTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayTypeLoc.html">ConstantArrayTypeLoc</a>&gt;...</td></tr>
886<tr><td colspan="4" class="doc" id="constantArrayTypeLoc0"><pre>Matches C arrays with a specified constant size.
887
888Given
889 void() {
890 int a[2];
891 int b[] = { 2, 3 };
892 int c[b[0]];
893 }
894constantArrayType()
895 matches "int a[2]"
896</pre></td></tr>
897
898
899<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('dependentSizedArrayTypeLoc0')"><a name="dependentSizedArrayTypeLoc0Anchor">dependentSizedArrayTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayTypeLoc.html">DependentSizedArrayTypeLoc</a>&gt;...</td></tr>
900<tr><td colspan="4" class="doc" id="dependentSizedArrayTypeLoc0"><pre>Matches C++ arrays whose size is a value-dependent expression.
901
902Given
903 template&lt;typename T, int Size&gt;
904 class array {
905 T data[Size];
906 };
907dependentSizedArrayType
908 matches "T data[Size]"
909</pre></td></tr>
910
911
912<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('functionTypeLoc0')"><a name="functionTypeLoc0Anchor">functionTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionTypeLoc.html">FunctionTypeLoc</a>&gt;...</td></tr>
913<tr><td colspan="4" class="doc" id="functionTypeLoc0"><pre>Matches FunctionType nodes.
914
915Given
916 int (*f)(int);
917 void g();
918functionType()
919 matches "int (*f)(int)" and the type of "g".
920</pre></td></tr>
921
922
923<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('incompleteArrayTypeLoc0')"><a name="incompleteArrayTypeLoc0Anchor">incompleteArrayTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IncompleteArrayTypeLoc.html">IncompleteArrayTypeLoc</a>&gt;...</td></tr>
924<tr><td colspan="4" class="doc" id="incompleteArrayTypeLoc0"><pre>Matches C arrays with unspecified size.
925
926Given
927 int a[] = { 2, 3 };
928 int b[42];
929 void f(int c[]) { int d[a[0]]; };
930incompleteArrayType()
931 matches "int a[]" and "int c[]"
932</pre></td></tr>
933
934
935<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('memberPointerTypeLoc0')"><a name="memberPointerTypeLoc0Anchor">memberPointerTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerTypeLoc.html">MemberPointerTypeLoc</a>&gt;...</td></tr>
936<tr><td colspan="4" class="doc" id="memberPointerTypeLoc0"><pre>Matches member pointer types.
937Given
938 struct A { int i; }
939 A::* ptr = A::i;
940memberPointerType()
941 matches "A::* ptr"
942</pre></td></tr>
943
944
945<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('pointerTypeLoc0')"><a name="pointerTypeLoc0Anchor">pointerTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>&gt;...</td></tr>
946<tr><td colspan="4" class="doc" id="pointerTypeLoc0"><pre>Matches pointer types.
947
948Given
949 int *a;
950 int &amp;b = *a;
951 int c = 5;
952pointerType()
953 matches "int *a"
954</pre></td></tr>
955
956
957<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('referenceTypeLoc0')"><a name="referenceTypeLoc0Anchor">referenceTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>&gt;...</td></tr>
958<tr><td colspan="4" class="doc" id="referenceTypeLoc0"><pre>Matches reference types.
959
960Given
961 int *a;
962 int &amp;b = *a;
963 int c = 5;
964pointerType()
965 matches "int &amp;b"
966</pre></td></tr>
967
968
Daniel Jaspere0b89972012-12-04 12:08:08 +0000969<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>
970<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST.
971</pre></td></tr>
972
973
Manuel Klimek41df16e2013-01-09 09:38:21 +0000974<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('typedefTypeLoc0')"><a name="typedefTypeLoc0Anchor">typedefTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefTypeLoc.html">TypedefTypeLoc</a>&gt;...</td></tr>
975<tr><td colspan="4" class="doc" id="typedefTypeLoc0"><pre>Matches typedef types.
976
977Given
978 typedef int X;
979typedefType()
980 matches "typedef int X"
981</pre></td></tr>
982
983
984<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('variableArrayTypeLoc0')"><a name="variableArrayTypeLoc0Anchor">variableArrayTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VariableArrayTypeLoc.html">VariableArrayTypeLoc</a>&gt;...</td></tr>
985<tr><td colspan="4" class="doc" id="variableArrayTypeLoc0"><pre>Matches C arrays with a specified size that is not an
986integer-constant-expression.
987
988Given
989 void f() {
990 int a[] = { 2, 3 }
991 int b[42];
992 int c[a[0]];
993variableArrayType()
994 matches "int c[a[0]]"
995</pre></td></tr>
996
997
998<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>
999<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays.
1000
1001Given
1002 int a[] = { 2, 3 };
1003 int b[4];
1004 void f() { int c[a[0]]; }
1005arrayType()
1006 matches "int a[]", "int b[4]" and "int c[a[0]]";
1007</pre></td></tr>
1008
1009
1010<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>
1011<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types.
1012
1013Given
1014 _Atomic(int) i;
1015atomicType()
1016 matches "_Atomic(int) i"
1017</pre></td></tr>
1018
1019
1020<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>
1021<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types.
1022
1023Given:
1024 auto n = 4;
1025 int v[] = { 2, 3 }
1026 for (auto i : v) { }
1027autoType()
1028 matches "auto n" and "auto i"
1029</pre></td></tr>
1030
1031
1032<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>
1033<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as
1034"void (^)(int)".
1035
1036The pointee is always required to be a FunctionType.
1037</pre></td></tr>
1038
1039
1040<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>
1041<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types.
1042
1043Given
1044 struct A {};
1045 A a;
1046 int b;
1047 float c;
1048 bool d;
1049builtinType()
1050 matches "int b", "float c" and "bool d"
1051</pre></td></tr>
1052
1053
1054<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>
1055<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types.
1056
1057Given
1058 _Complex float f;
1059complexType()
1060 matches "_Complex float f"
1061</pre></td></tr>
1062
1063
1064<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>
1065<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size.
1066
1067Given
1068 void() {
1069 int a[2];
1070 int b[] = { 2, 3 };
1071 int c[b[0]];
1072 }
1073constantArrayType()
1074 matches "int a[2]"
1075</pre></td></tr>
1076
1077
1078<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>
1079<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression.
1080
1081Given
1082 template&lt;typename T, int Size&gt;
1083 class array {
1084 T data[Size];
1085 };
1086dependentSizedArrayType
1087 matches "T data[Size]"
1088</pre></td></tr>
1089
1090
1091<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>
1092<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes.
1093
1094Given
1095 int (*f)(int);
1096 void g();
1097functionType()
1098 matches "int (*f)(int)" and the type of "g".
1099</pre></td></tr>
1100
1101
1102<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>
1103<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size.
1104
1105Given
1106 int a[] = { 2, 3 };
1107 int b[42];
1108 void f(int c[]) { int d[a[0]]; };
1109incompleteArrayType()
1110 matches "int a[]" and "int c[]"
1111</pre></td></tr>
1112
1113
1114<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>
1115<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types.
1116Given
1117 struct A { int i; }
1118 A::* ptr = A::i;
1119memberPointerType()
1120 matches "A::* ptr"
1121</pre></td></tr>
1122
1123
1124<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>
1125<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types.
1126
1127Given
1128 int *a;
1129 int &amp;b = *a;
1130 int c = 5;
1131pointerType()
1132 matches "int *a"
1133</pre></td></tr>
1134
1135
1136<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>
1137<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches reference types.
1138
1139Given
1140 int *a;
1141 int &amp;b = *a;
1142 int c = 5;
1143pointerType()
1144 matches "int &amp;b"
1145</pre></td></tr>
1146
1147
Daniel Jaspere0b89972012-12-04 12:08:08 +00001148<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>
1149<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST.
1150</pre></td></tr>
1151
Manuel Klimek41df16e2013-01-09 09:38:21 +00001152
1153<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>
1154<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types.
1155
1156Given
1157 typedef int X;
1158typedefType()
1159 matches "typedef int X"
1160</pre></td></tr>
1161
1162
1163<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>
1164<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an
1165integer-constant-expression.
1166
1167Given
1168 void f() {
1169 int a[] = { 2, 3 }
1170 int b[42];
1171 int c[a[0]];
1172variableArrayType()
1173 matches "int c[a[0]]"
1174</pre></td></tr>
1175
Manuel Klimek1da79332012-08-20 20:54:03 +00001176<!--END_DECL_MATCHERS -->
1177</table>
1178
1179<!-- ======================================================================= -->
1180<h2 id="narrowing-matchers">Narrowing Matchers</h2>
1181<!-- ======================================================================= -->
1182
1183<p>Narrowing matchers match certain attributes on the current node, thus
1184narrowing down the set of nodes of the current type to match on.</p>
1185
1186<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless)
1187which allow users to create more powerful match expressions.</p>
1188
1189<table>
1190<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
1191<!-- START_NARROWING_MATCHERS -->
1192
Manuel Klimek67619ff2012-09-07 13:10:32 +00001193<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher&lt;*&gt; P1, Matcher&lt;*&gt; P2</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001194<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match.
1195
1196Usable as: Any Matcher
1197</pre></td></tr>
1198
1199
Manuel Klimek67619ff2012-09-07 13:10:32 +00001200<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher&lt;*&gt; P1, Matcher&lt;*&gt; P2</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001201<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches.
1202
1203Usable as: Any Matcher
1204</pre></td></tr>
1205
1206
Manuel Klimek67619ff2012-09-07 13:10:32 +00001207<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001208<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node.
1209
1210Useful when another matcher requires a child matcher, but there's no
1211additional constraint. This will often be used with an explicit conversion
1212to an internal::Matcher&lt;&gt; type such as TypeMatcher.
1213
1214Example: DeclarationMatcher(anything()) matches all declarations, e.g.,
1215"int* p" and "void f()" in
1216 int* p;
1217 void f();
1218
1219Usable as: Any Matcher
1220</pre></td></tr>
1221
1222
Manuel Klimek67619ff2012-09-07 13:10:32 +00001223<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher&lt;*&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001224<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match.
1225
Manuel Klimeke44a0062012-08-26 23:55:24 +00001226Example matches Y (matcher = recordDecl(unless(hasName("X"))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001227 class X {};
1228 class Y {};
1229
1230Usable as: Any Matcher
1231</pre></td></tr>
1232
1233
Manuel Klimek67619ff2012-09-07 13:10:32 +00001234<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasOperatorName0')"><a name="hasOperatorName0Anchor">hasOperatorName</a></td><td>std::string Name</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001235<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or
1236unary).
1237
1238Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
1239 !(a || b)
1240</pre></td></tr>
1241
1242
Manuel Klimek67619ff2012-09-07 13:10:32 +00001243<tr><td>Matcher&lt;CXXBoolLiteral&gt;</td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>ValueT Value</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001244<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value.
1245
1246Example matches true (matcher = boolLiteral(equals(true)))
1247 true
1248
1249Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1250 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;
1251</pre></td></tr>
1252
1253
Manuel Klimek67619ff2012-09-07 13:10:32 +00001254<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001255<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a constructor declaration that has been implicitly added
1256by the compiler (eg. implicit defaultcopy constructors).
1257</pre></td></tr>
1258
1259
Manuel Klimek67619ff2012-09-07 13:10:32 +00001260<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>
Manuel Klimek1da79332012-08-20 20:54:03 +00001261<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a contructor initializer if it is explicitly written in
1262code (as opposed to implicitly added by the compiler).
1263
1264Given
1265 struct Foo {
1266 Foo() { }
1267 Foo(int) : foo_("A") { }
1268 string foo_;
1269 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00001270constructorDecl(hasAnyConstructorInitializer(isWritten()))
Manuel Klimek1da79332012-08-20 20:54:03 +00001271 will match Foo(int), but not Foo()
1272</pre></td></tr>
1273
1274
Manuel Klimek67619ff2012-09-07 13:10:32 +00001275<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;</td><td class="name" onclick="toggle('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>std::string Name</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001276<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names.
1277
1278Matches overloaded operator names specified in strings without the
1279"operator" prefix, such as "&lt;&lt;", for OverloadedOperatorCall's.
1280
1281Example matches a &lt;&lt; b
Manuel Klimeke44a0062012-08-26 23:55:24 +00001282 (matcher == operatorCallExpr(hasOverloadedOperatorName("&lt;&lt;")))
Manuel Klimek1da79332012-08-20 20:54:03 +00001283 a &lt;&lt; b;
1284 c &amp;&amp; d; assuming both operator&lt;&lt;
1285 and operator&amp;&amp; are overloaded somewhere.
1286</pre></td></tr>
1287
1288
Manuel Klimek67619ff2012-09-07 13:10:32 +00001289<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isDerivedFrom1')"><a name="isDerivedFrom1Anchor">isDerivedFrom</a></td><td>StringRef BaseName</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001290<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
1291</pre></td></tr>
1292
1293
Manuel Klimek67619ff2012-09-07 13:10:32 +00001294<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isExplicitTemplateSpecialization0')"><a name="isExplicitTemplateSpecialization0Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001295<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or
1296static member variable template instantiations.
1297
1298Given
1299 template&lt;typename T&gt; void A(T t) { }
1300 template&lt;&gt; void A(int N) { }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001301functionDecl(isExplicitTemplateSpecialization())
Manuel Klimek1da79332012-08-20 20:54:03 +00001302 matches the specialization A&lt;int&gt;().
1303
1304Usable 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;
1305</pre></td></tr>
1306
1307
Daniel Jaspere0b89972012-12-04 12:08:08 +00001308<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isSameOrDerivedFrom1')"><a name="isSameOrDerivedFrom1Anchor">isSameOrDerivedFrom</a></td><td>StringRef BaseName</td></tr>
1309<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for
1310isSameOrDerivedFrom(hasName(...)).
1311</pre></td></tr>
1312
1313
Manuel Klimek67619ff2012-09-07 13:10:32 +00001314<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isTemplateInstantiation0')"><a name="isTemplateInstantiation0Anchor">isTemplateInstantiation</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001315<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static
1316member variable template instantiations.
1317
1318Given
1319 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
1320or
1321 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001322recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001323 matches the template instantiation of X&lt;A&gt;.
1324
1325But given
1326 template &lt;typename T&gt; class X {}; class A {};
1327 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001328recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001329 does not match, as X&lt;A&gt; is an explicit template specialization.
1330
1331Usable 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;
1332</pre></td></tr>
1333
1334
Manuel Klimek67619ff2012-09-07 13:10:32 +00001335<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('argumentCountIs0')"><a name="argumentCountIs0Anchor">argumentCountIs</a></td><td>unsigned N</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001336<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has
1337a specific number of arguments (including absent default arguments).
1338
Manuel Klimeke44a0062012-08-26 23:55:24 +00001339Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
Manuel Klimek1da79332012-08-20 20:54:03 +00001340 void f(int x, int y);
1341 f(0, 0);
1342</pre></td></tr>
1343
1344
Manuel Klimek67619ff2012-09-07 13:10:32 +00001345<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;</td><td class="name" onclick="toggle('equals3')"><a name="equals3Anchor">equals</a></td><td>ValueT Value</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001346<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value.
1347
1348Example matches true (matcher = boolLiteral(equals(true)))
1349 true
1350
1351Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1352 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;
1353</pre></td></tr>
1354
1355
Manuel Klimek67619ff2012-09-07 13:10:32 +00001356<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>&gt;</td><td class="name" onclick="toggle('statementCountIs0')"><a name="statementCountIs0Anchor">statementCountIs</a></td><td>unsigned N</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001357<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of
1358child statements.
1359
1360Example: Given
1361 { for (;;) {} }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001362compoundStmt(statementCountIs(0)))
Manuel Klimek1da79332012-08-20 20:54:03 +00001363 matches '{}'
1364 but does not match the outer compound statement.
1365</pre></td></tr>
1366
1367
Daniel Jaspere0b89972012-12-04 12:08:08 +00001368<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>
1369<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size.
1370
1371Given
1372 int a[42];
1373 int b[2 * 21];
1374 int c[41], d[43];
1375constantArrayType(hasSize(42))
1376 matches "int a[42]" and "int b[2 * 21]"
1377</pre></td></tr>
1378
1379
Manuel Klimek67619ff2012-09-07 13:10:32 +00001380<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>&gt;</td><td class="name" onclick="toggle('declCountIs0')"><a name="declCountIs0Anchor">declCountIs</a></td><td>unsigned N</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001381<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of
1382declarations.
1383
1384Example: Given
1385 int a, b;
1386 int c;
1387 int d = 2, e;
1388declCountIs(2)
1389 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.
1390</pre></td></tr>
1391
1392
Manuel Klimek67619ff2012-09-07 13:10:32 +00001393<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>&gt;</td><td class="name" onclick="toggle('equals1')"><a name="equals1Anchor">equals</a></td><td>ValueT Value</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001394<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value.
1395
1396Example matches true (matcher = boolLiteral(equals(true)))
1397 true
1398
1399Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1400 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;
1401</pre></td></tr>
1402
1403
Manuel Klimek67619ff2012-09-07 13:10:32 +00001404<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isDefinition0')"><a name="isDefinition0Anchor">isDefinition</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001405<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached.
1406
1407Example matches A, va, fa
1408 class A {};
1409 class B; Doesn't match, as it has no body.
1410 int va;
1411 extern int vb; Doesn't match, as it doesn't define the variable.
1412 void fa() {}
1413 void fb(); Doesn't match, as it has no body.
1414
1415Usable 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;
1416</pre></td></tr>
1417
1418
Manuel Klimek67619ff2012-09-07 13:10:32 +00001419<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isExplicitTemplateSpecialization2')"><a name="isExplicitTemplateSpecialization2Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001420<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or
1421static member variable template instantiations.
1422
1423Given
1424 template&lt;typename T&gt; void A(T t) { }
1425 template&lt;&gt; void A(int N) { }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001426functionDecl(isExplicitTemplateSpecialization())
Manuel Klimek1da79332012-08-20 20:54:03 +00001427 matches the specialization A&lt;int&gt;().
1428
1429Usable 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;
1430</pre></td></tr>
1431
1432
Manuel Klimek67619ff2012-09-07 13:10:32 +00001433<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isExternC0')"><a name="isExternC0Anchor">isExternC</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001434<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations.
1435
1436Given:
1437 extern "C" void f() {}
1438 extern "C" { void g() {} }
1439 void h() {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00001440functionDecl(isExternC())
Manuel Klimek1da79332012-08-20 20:54:03 +00001441 matches the declaration of f and g, but not the declaration h
1442</pre></td></tr>
1443
1444
Manuel Klimek67619ff2012-09-07 13:10:32 +00001445<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isTemplateInstantiation2')"><a name="isTemplateInstantiation2Anchor">isTemplateInstantiation</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001446<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static
1447member variable template instantiations.
1448
1449Given
1450 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
1451or
1452 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001453recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001454 matches the template instantiation of X&lt;A&gt;.
1455
1456But given
1457 template &lt;typename T&gt; class X {}; class A {};
1458 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001459recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001460 does not match, as X&lt;A&gt; is an explicit template specialization.
1461
1462Usable 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;
1463</pre></td></tr>
1464
1465
Daniel Jaspere0b89972012-12-04 12:08:08 +00001466<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>
1467<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count.
1468
1469Given
1470 void f(int i) {}
1471 void g(int i, int j) {}
1472functionDecl(parameterCountIs(2))
1473 matches g(int i, int j) {}
1474</pre></td></tr>
1475
1476
Manuel Klimek67619ff2012-09-07 13:10:32 +00001477<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;</td><td class="name" onclick="toggle('equals0')"><a name="equals0Anchor">equals</a></td><td>ValueT Value</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001478<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value.
1479
1480Example matches true (matcher = boolLiteral(equals(true)))
1481 true
1482
1483Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1484 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;
1485</pre></td></tr>
1486
1487
Manuel Klimek67619ff2012-09-07 13:10:32 +00001488<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;</td><td class="name" onclick="toggle('isArrow0')"><a name="isArrow0Anchor">isArrow</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001489<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '-&gt;' as opposed
1490to '.'.
1491
1492Member calls on the implicit this pointer match as called with '-&gt;'.
1493
1494Given
1495 class Y {
1496 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
1497 int a;
1498 static int b;
1499 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00001500memberExpr(isArrow())
Manuel Klimek1da79332012-08-20 20:54:03 +00001501 matches this-&gt;x, x, y.x, a, this-&gt;b
1502</pre></td></tr>
1503
1504
Manuel Klimek67619ff2012-09-07 13:10:32 +00001505<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt;</td><td class="name" onclick="toggle('hasName0')"><a name="hasName0Anchor">hasName</a></td><td>std::string Name</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001506<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name.
1507
1508Supports specifying enclosing namespaces or classes by prefixing the name
1509with '&lt;enclosing&gt;::'.
1510Does not match typedefs of an underlying type with the given name.
1511
1512Example matches X (Name == "X")
1513 class X;
1514
1515Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
1516 namespace a { namespace b { class X; } }
1517</pre></td></tr>
1518
1519
Manuel Klimek67619ff2012-09-07 13:10:32 +00001520<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt;</td><td class="name" onclick="toggle('matchesName0')"><a name="matchesName0Anchor">matchesName</a></td><td>std::string RegExp</td></tr>
Manuel Klimek41df16e2013-01-09 09:38:21 +00001521<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain
1522a substring matched by the given RegExp.
Manuel Klimek1da79332012-08-20 20:54:03 +00001523
1524Supports specifying enclosing namespaces or classes by
1525prefixing the name with '&lt;enclosing&gt;::'. Does not match typedefs
1526of an underlying type with the given name.
1527
1528Example matches X (regexp == "::X")
1529 class X;
1530
1531Example matches X (regexp is one of "::X", "^foo::.*X", among others)
1532 namespace foo { namespace bar { class X; } }
1533</pre></td></tr>
1534
1535
Manuel Klimek67619ff2012-09-07 13:10:32 +00001536<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('asString0')"><a name="asString0Anchor">asString</a></td><td>std::string Name</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001537<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string.
1538
1539Given
1540 class Y { public: void x(); };
1541 void z() { Y* y; y-&gt;x(); }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001542callExpr(on(hasType(asString("class Y *"))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001543 matches y-&gt;x()
1544</pre></td></tr>
1545
1546
Manuel Klimek67619ff2012-09-07 13:10:32 +00001547<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('isConstQualified0')"><a name="isConstQualified0Anchor">isConstQualified</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001548<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that
1549include "top-level" const.
1550
1551Given
1552 void a(int);
1553 void b(int const);
1554 void c(const int);
1555 void d(const int*);
1556 void e(int const) {};
Manuel Klimeke44a0062012-08-26 23:55:24 +00001557functionDecl(hasAnyParameter(hasType(isConstQualified())))
Manuel Klimek1da79332012-08-20 20:54:03 +00001558 matches "void b(int const)", "void c(const int)" and
1559 "void e(int const) {}". It does not match d as there
1560 is no top-level const on the parameter type "const int *".
1561</pre></td></tr>
1562
1563
Manuel Klimek67619ff2012-09-07 13:10:32 +00001564<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('isInteger0')"><a name="isInteger0Anchor">isInteger</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001565<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type.
1566
1567Given
1568 void a(int);
1569 void b(long);
1570 void c(double);
Manuel Klimeke44a0062012-08-26 23:55:24 +00001571functionDecl(hasAnyParameter(hasType(isInteger())))
Manuel Klimek1da79332012-08-20 20:54:03 +00001572matches "a(int)", "b(long)", but not "c(double)".
1573</pre></td></tr>
1574
1575
Manuel Klimek67619ff2012-09-07 13:10:32 +00001576<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;</td><td class="name" onclick="toggle('isDefinition2')"><a name="isDefinition2Anchor">isDefinition</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001577<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached.
1578
1579Example matches A, va, fa
1580 class A {};
1581 class B; Doesn't match, as it has no body.
1582 int va;
1583 extern int vb; Doesn't match, as it doesn't define the variable.
1584 void fa() {}
1585 void fb(); Doesn't match, as it has no body.
1586
1587Usable 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;
1588</pre></td></tr>
1589
1590
Manuel Klimek67619ff2012-09-07 13:10:32 +00001591<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt;</td><td class="name" onclick="toggle('ofKind0')"><a name="ofKind0Anchor">ofKind</a></td><td>UnaryExprOrTypeTrait Kind</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001592<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind.
1593
1594Given
1595 int x;
1596 int s = sizeof(x) + alignof(x)
1597unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
1598 matches sizeof(x)
1599</pre></td></tr>
1600
1601
Manuel Klimek67619ff2012-09-07 13:10:32 +00001602<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasOperatorName1')"><a name="hasOperatorName1Anchor">hasOperatorName</a></td><td>std::string Name</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001603<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or
1604unary).
1605
1606Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
1607 !(a || b)
1608</pre></td></tr>
1609
1610
Manuel Klimek67619ff2012-09-07 13:10:32 +00001611<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isDefinition1')"><a name="isDefinition1Anchor">isDefinition</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001612<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached.
1613
1614Example matches A, va, fa
1615 class A {};
1616 class B; Doesn't match, as it has no body.
1617 int va;
1618 extern int vb; Doesn't match, as it doesn't define the variable.
1619 void fa() {}
1620 void fb(); Doesn't match, as it has no body.
1621
1622Usable 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;
1623</pre></td></tr>
1624
1625
Manuel Klimek67619ff2012-09-07 13:10:32 +00001626<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isExplicitTemplateSpecialization1')"><a name="isExplicitTemplateSpecialization1Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001627<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or
1628static member variable template instantiations.
1629
1630Given
1631 template&lt;typename T&gt; void A(T t) { }
1632 template&lt;&gt; void A(int N) { }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001633functionDecl(isExplicitTemplateSpecialization())
Manuel Klimek1da79332012-08-20 20:54:03 +00001634 matches the specialization A&lt;int&gt;().
1635
1636Usable 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;
1637</pre></td></tr>
1638
1639
Manuel Klimek67619ff2012-09-07 13:10:32 +00001640<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isTemplateInstantiation1')"><a name="isTemplateInstantiation1Anchor">isTemplateInstantiation</a></td><td></td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001641<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static
1642member variable template instantiations.
1643
1644Given
1645 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
1646or
1647 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001648recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001649 matches the template instantiation of X&lt;A&gt;.
1650
1651But given
1652 template &lt;typename T&gt; class X {}; class A {};
1653 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001654recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001655 does not match, as X&lt;A&gt; is an explicit template specialization.
1656
1657Usable 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;
1658</pre></td></tr>
1659
1660<!--END_NARROWING_MATCHERS -->
1661</table>
1662
1663<!-- ======================================================================= -->
1664<h2 id="traversal-matchers">AST Traversal Matchers</h2>
1665<!-- ======================================================================= -->
1666
1667<p>Traversal matchers specify the relationship to other nodes that are
1668reachable from the current node.</p>
1669
1670<p>Note that there are special traversal matchers (has, hasDescendant, forEach and
1671forEachDescendant) which work on all nodes and allow users to write more generic
1672match expressions.</p>
1673
1674<table>
1675<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
1676<!-- START_TRAVERSAL_MATCHERS -->
1677
Manuel Klimek67619ff2012-09-07 13:10:32 +00001678<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher&lt;ChildT&gt; ChildMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001679<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the
1680provided matcher.
1681
Manuel Klimeke44a0062012-08-26 23:55:24 +00001682Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X")))
Manuel Klimek1da79332012-08-20 20:54:03 +00001683 class X {}; Matches X, because X::X is a class of name X inside X.
1684 class Y { class X {}; };
1685 class Z { class Y { class X {}; }; }; Does not match Z.
1686
1687ChildT must be an AST base type.
1688
1689As opposed to 'has', 'forEach' will cause a match for each result that
1690matches instead of only on the first one.
1691
1692Usable as: Any Matcher
1693</pre></td></tr>
1694
1695
Manuel Klimek67619ff2012-09-07 13:10:32 +00001696<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher&lt;DescendantT&gt; DescendantMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001697<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
1698provided matcher.
1699
1700Example matches X, A, B, C
Manuel Klimeke44a0062012-08-26 23:55:24 +00001701 (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001702 class X {}; Matches X, because X::X is a class of name X inside X.
1703 class A { class X {}; };
1704 class B { class C { class X {}; }; };
1705
1706DescendantT must be an AST base type.
1707
1708As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
1709each result that matches instead of only on the first one.
1710
1711Note: Recursively combined ForEachDescendant can cause many matches:
Manuel Klimeke44a0062012-08-26 23:55:24 +00001712 recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl()))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001713will match 10 times (plus injected class name matches) on:
1714 class A { class B { class C { class D { class E {}; }; }; }; };
1715
1716Usable as: Any Matcher
1717</pre></td></tr>
1718
1719
Manuel Klimek67619ff2012-09-07 13:10:32 +00001720<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher&lt;ChildT&gt; ChildMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001721<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the
1722provided matcher.
1723
Manuel Klimeke44a0062012-08-26 23:55:24 +00001724Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X")))
Manuel Klimek1da79332012-08-20 20:54:03 +00001725 class X {}; Matches X, because X::X is a class of name X inside X.
1726 class Y { class X {}; };
1727 class Z { class Y { class X {}; }; }; Does not match Z.
1728
1729ChildT must be an AST base type.
1730
1731Usable as: Any Matcher
1732</pre></td></tr>
1733
1734
Manuel Klimek67619ff2012-09-07 13:10:32 +00001735<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher&lt;AncestorT&gt; AncestorMatcher</td></tr>
1736<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided
1737matcher.
1738
1739Given
1740void f() { if (true) { int x = 42; } }
1741void g() { for (;;) { int x = 43; } }
Daniel Jaspere0b89972012-12-04 12:08:08 +00001742expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.
Manuel Klimek67619ff2012-09-07 13:10:32 +00001743
1744Usable as: Any Matcher
1745</pre></td></tr>
1746
1747
1748<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher&lt;DescendantT&gt; DescendantMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001749<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
1750provided matcher.
1751
1752Example matches X, Y, Z
Manuel Klimeke44a0062012-08-26 23:55:24 +00001753 (matcher = recordDecl(hasDescendant(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001754 class X {}; Matches X, because X::X is a class of name X inside X.
1755 class Y { class X {}; };
1756 class Z { class Y { class X {}; }; };
1757
1758DescendantT must be an AST base type.
1759
1760Usable as: Any Matcher
1761</pre></td></tr>
1762
1763
Daniel Jaspere0b89972012-12-04 12:08:08 +00001764<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher&lt;ParentT&gt; ParentMatcher</td></tr>
1765<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided
1766matcher.
1767
1768Given
1769void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
1770compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".
1771
1772Usable as: Any Matcher
1773</pre></td></tr>
1774
1775
Manuel Klimek67619ff2012-09-07 13:10:32 +00001776<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>&gt;</td><td class="name" onclick="toggle('hasBase0')"><a name="hasBase0Anchor">hasBase</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001777<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression.
1778
1779Given
1780 int i[5];
1781 void f() { i[1] = 42; }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001782arraySubscriptExpression(hasBase(implicitCastExpr(
1783 hasSourceExpression(declRefExpr()))))
1784 matches i[1] with the declRefExpr() matching i
Manuel Klimek1da79332012-08-20 20:54:03 +00001785</pre></td></tr>
1786
1787
Manuel Klimek67619ff2012-09-07 13:10:32 +00001788<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>&gt;</td><td class="name" onclick="toggle('hasIndex0')"><a name="hasIndex0Anchor">hasIndex</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001789<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression.
1790
1791Given
1792 int i[5];
1793 void f() { i[1] = 42; }
1794arraySubscriptExpression(hasIndex(integerLiteral()))
1795 matches i[1] with the integerLiteral() matching 1
1796</pre></td></tr>
1797
1798
Manuel Klimek41df16e2013-01-09 09:38:21 +00001799<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayTypeLoc.html">ArrayTypeLoc</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>
1800<tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element
1801type.
1802
1803Given
1804 struct A {};
1805 A a[7];
1806 int b[7];
1807arrayType(hasElementType(builtinType()))
1808 matches "int b[7]"
1809
1810Usable 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;
1811</pre></td></tr>
1812
1813
1814<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</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>
1815<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element
1816type.
1817
1818Given
1819 struct A {};
1820 A a[7];
1821 int b[7];
1822arrayType(hasElementType(builtinType()))
1823 matches "int b[7]"
1824
1825Usable 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;
1826</pre></td></tr>
1827
1828
1829<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>
1830<tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type.
1831
1832Given
1833 _Atomic(int) i;
1834 _Atomic(float) f;
1835atomicType(hasValueType(isInteger()))
1836 matches "_Atomic(int) i"
1837
1838Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
1839</pre></td></tr>
1840
1841
1842<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>
1843<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type.
1844
1845Given
1846 _Atomic(int) i;
1847 _Atomic(float) f;
1848atomicType(hasValueType(isInteger()))
1849 matches "_Atomic(int) i"
1850
1851Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
1852</pre></td></tr>
1853
1854
1855<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>
1856<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type.
1857
1858Note: There is no TypeLoc for the deduced type and thus no
1859getDeducedLoc() matcher.
1860
1861Given
1862 auto a = 1;
1863 auto b = 2.0;
1864autoType(hasDeducedType(isInteger()))
1865 matches "auto a"
1866
1867Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>&gt;
1868</pre></td></tr>
1869
1870
Manuel Klimek67619ff2012-09-07 13:10:32 +00001871<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasEitherOperand0')"><a name="hasEitherOperand0Anchor">hasEitherOperand</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001872<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a
1873binary operator matches.
1874</pre></td></tr>
1875
1876
Manuel Klimek67619ff2012-09-07 13:10:32 +00001877<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasLHS0')"><a name="hasLHS0Anchor">hasLHS</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001878<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions.
1879
1880Example matches a (matcher = binaryOperator(hasLHS()))
1881 a || b
1882</pre></td></tr>
1883
1884
Manuel Klimek67619ff2012-09-07 13:10:32 +00001885<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasRHS0')"><a name="hasRHS0Anchor">hasRHS</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001886<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions.
1887
1888Example matches b (matcher = binaryOperator(hasRHS()))
1889 a || b
1890</pre></td></tr>
1891
1892
Manuel Klimek41df16e2013-01-09 09:38:21 +00001893<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerTypeLoc.html">BlockPointerTypeLoc</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>
1894<tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the
1895pointee matches a given matcher.
1896
1897Given
1898 int *a;
1899 int const *b;
1900 float const *f;
1901pointerType(pointee(isConstQualified(), isInteger()))
1902 matches "int const *b"
1903
1904Usable 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;,
1905 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;
1906</pre></td></tr>
1907
1908
1909<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</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>
1910<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the
1911pointee matches a given matcher.
1912
1913Given
1914 int *a;
1915 int const *b;
1916 float const *f;
1917pointerType(pointee(isConstQualified(), isInteger()))
1918 matches "int const *b"
1919
1920Usable 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;,
1921 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;
1922</pre></td></tr>
1923
1924
Daniel Jaspere0b89972012-12-04 12:08:08 +00001925<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</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>
1926<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a type if the declaration of the type matches the given
Manuel Klimek1da79332012-08-20 20:54:03 +00001927matcher.
1928
Daniel Jaspere0b89972012-12-04 12:08:08 +00001929Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
1930 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;
Manuel Klimek1da79332012-08-20 20:54:03 +00001931</pre></td></tr>
1932
1933
Manuel Klimek67619ff2012-09-07 13:10:32 +00001934<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyConstructorInitializer0')"><a name="hasAnyConstructorInitializer0Anchor">hasAnyConstructorInitializer</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001935<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer.
1936
1937Given
1938 struct Foo {
1939 Foo() : foo_(1) { }
1940 int foo_;
1941 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00001942recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything()))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001943 record matches Foo, hasAnyConstructorInitializer matches foo_(1)
1944</pre></td></tr>
1945
1946
Manuel Klimek67619ff2012-09-07 13:10:32 +00001947<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;</td><td class="name" onclick="toggle('forField0')"><a name="forField0Anchor">forField</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001948<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer.
1949
1950Given
1951 struct Foo {
1952 Foo() : foo_(1) { }
1953 int foo_;
1954 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00001955recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
Manuel Klimek1da79332012-08-20 20:54:03 +00001956 forField(hasName("foo_"))))))
1957 matches Foo
1958with forField matching foo_
1959</pre></td></tr>
1960
1961
Manuel Klimek67619ff2012-09-07 13:10:32 +00001962<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;</td><td class="name" onclick="toggle('withInitializer0')"><a name="withInitializer0Anchor">withInitializer</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001963<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer.
1964
1965Given
1966 struct Foo {
1967 Foo() : foo_(1) { }
1968 int foo_;
1969 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00001970recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
Manuel Klimek1da79332012-08-20 20:54:03 +00001971 withInitializer(integerLiteral(equals(1)))))))
1972 matches Foo
1973with withInitializer matching (1)
1974</pre></td></tr>
1975
1976
Manuel Klimek67619ff2012-09-07 13:10:32 +00001977<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>&gt;</td><td class="name" onclick="toggle('on0')"><a name="on0Anchor">on</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001978<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression.
1979
Manuel Klimeke44a0062012-08-26 23:55:24 +00001980Example matches y.x() (matcher = callExpr(on(hasType(recordDecl(hasName("Y"))))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001981 class Y { public: void x(); };
1982 void z() { Y y; y.x(); }",
1983
1984FIXME: Overload to allow directly matching types?
1985</pre></td></tr>
1986
1987
Manuel Klimek67619ff2012-09-07 13:10:32 +00001988<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>&gt;</td><td class="name" onclick="toggle('onImplicitObjectArgument0')"><a name="onImplicitObjectArgument0Anchor">onImplicitObjectArgument</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001989<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr>
1990
1991
Manuel Klimek67619ff2012-09-07 13:10:32 +00001992<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>&gt;</td><td class="name" onclick="toggle('thisPointerType1')"><a name="thisPointerType1Anchor">thisPointerType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001993<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration.
1994</pre></td></tr>
1995
1996
Manuel Klimek67619ff2012-09-07 13:10:32 +00001997<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('ofClass0')"><a name="ofClass0Anchor">ofClass</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00001998<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration
1999belongs to.
2000
2001FIXME: Generalize this for other kinds of declarations.
2002FIXME: What other kind of declarations would we need to generalize
2003this to?
2004
2005Example matches A() in the last line
Manuel Klimeke44a0062012-08-26 23:55:24 +00002006 (matcher = constructExpr(hasDeclaration(methodDecl(
Manuel Klimek1da79332012-08-20 20:54:03 +00002007 ofClass(hasName("A"))))))
2008 class A {
2009 public:
2010 A();
2011 };
2012 A a = A();
2013</pre></td></tr>
2014
2015
Manuel Klimek67619ff2012-09-07 13:10:32 +00002016<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isDerivedFrom0')"><a name="isDerivedFrom0Anchor">isDerivedFrom</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt; Base</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002017<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from
2018a class matching Base.
2019
Manuel Klimek67619ff2012-09-07 13:10:32 +00002020Note that a class is not considered to be derived from itself.
Manuel Klimek1da79332012-08-20 20:54:03 +00002021
Manuel Klimek67619ff2012-09-07 13:10:32 +00002022Example matches Y, Z, C (Base == hasName("X"))
2023 class X;
Manuel Klimek1da79332012-08-20 20:54:03 +00002024 class Y : public X {}; directly derived
2025 class Z : public Y {}; indirectly derived
2026 typedef X A;
2027 typedef A B;
2028 class C : public B {}; derived from a typedef of X
2029
2030In the following example, Bar matches isDerivedFrom(hasName("X")):
2031 class Foo;
2032 typedef Foo X;
2033 class Bar : public Foo {}; derived from a type that X is a typedef of
2034</pre></td></tr>
2035
2036
Daniel Jaspere0b89972012-12-04 12:08:08 +00002037<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>
2038<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly
2039match Base.
2040</pre></td></tr>
2041
2042
Manuel Klimek67619ff2012-09-07 13:10:32 +00002043<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('callee1')"><a name="callee1Anchor">callee</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002044<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the
2045given matcher.
2046
Manuel Klimeke44a0062012-08-26 23:55:24 +00002047Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002048 class Y { public: void x(); };
2049 void z() { Y y; y.x();
2050</pre></td></tr>
2051
2052
Manuel Klimek67619ff2012-09-07 13:10:32 +00002053<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnyArgument0')"><a name="hasAnyArgument0Anchor">hasAnyArgument</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002054<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call
2055expression.
2056
2057Given
2058 void x(int, int, int) { int y; x(1, y, 42); }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002059callExpr(hasAnyArgument(declRefExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002060 matches x(1, y, 42)
2061with hasAnyArgument(...)
2062 matching y
2063</pre></td></tr>
2064
2065
Manuel Klimek67619ff2012-09-07 13:10:32 +00002066<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('hasArgument0')"><a name="hasArgument0Anchor">hasArgument</a></td><td>unsigned N, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002067<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor
2068call expression.
2069
2070Example matches y in x(y)
Manuel Klimeke44a0062012-08-26 23:55:24 +00002071 (matcher = callExpr(hasArgument(0, declRefExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002072 void x(int) { int y; x(y); }
2073</pre></td></tr>
2074
2075
Daniel Jaspere0b89972012-12-04 12:08:08 +00002076<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</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>
2077<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a type if the declaration of the type matches the given
Manuel Klimek1da79332012-08-20 20:54:03 +00002078matcher.
2079
Daniel Jaspere0b89972012-12-04 12:08:08 +00002080Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
2081 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;
Manuel Klimek1da79332012-08-20 20:54:03 +00002082</pre></td></tr>
2083
2084
Manuel Klimek67619ff2012-09-07 13:10:32 +00002085<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>&gt;</td><td class="name" onclick="toggle('hasSourceExpression0')"><a name="hasSourceExpression0Anchor">hasSourceExpression</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002086<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher.
2087
2088Example: matches "a string" (matcher =
Manuel Klimeke44a0062012-08-26 23:55:24 +00002089 hasSourceExpression(constructExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002090class URL { URL(string); };
2091URL url = "a string";
2092</pre></td></tr>
2093
2094
Manuel Klimek67619ff2012-09-07 13:10:32 +00002095<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyTemplateArgument0')"><a name="hasAnyTemplateArgument0Anchor">hasAnyTemplateArgument</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002096<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one
2097TemplateArgument matching the given InnerMatcher.
2098
2099Given
2100 template&lt;typename T&gt; class A {};
2101 template&lt;&gt; class A&lt;double&gt; {};
2102 A&lt;int&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002103classTemplateSpecializationDecl(hasAnyTemplateArgument(
Manuel Klimek1da79332012-08-20 20:54:03 +00002104 refersToType(asString("int"))))
2105 matches the specialization A&lt;int&gt;
2106</pre></td></tr>
2107
2108
Manuel Klimek67619ff2012-09-07 13:10:32 +00002109<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;</td><td class="name" onclick="toggle('hasTemplateArgument0')"><a name="hasTemplateArgument0Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002110<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument
2111matches the given InnerMatcher.
2112
2113Given
2114 template&lt;typename T, typename U&gt; class A {};
2115 A&lt;bool, int&gt; b;
2116 A&lt;int, bool&gt; c;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002117classTemplateSpecializationDecl(hasTemplateArgument(
Manuel Klimek1da79332012-08-20 20:54:03 +00002118 1, refersToType(asString("int"))))
2119 matches the specialization A&lt;bool, int&gt;
2120</pre></td></tr>
2121
2122
Manuel Klimek41df16e2013-01-09 09:38:21 +00002123<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexTypeLoc.html">ComplexTypeLoc</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>
2124<tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element
2125type.
2126
2127Given
2128 struct A {};
2129 A a[7];
2130 int b[7];
2131arrayType(hasElementType(builtinType()))
2132 matches "int b[7]"
2133
2134Usable 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;
2135</pre></td></tr>
2136
2137
2138<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</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>
2139<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element
2140type.
2141
2142Given
2143 struct A {};
2144 A a[7];
2145 int b[7];
2146arrayType(hasElementType(builtinType()))
2147 matches "int b[7]"
2148
2149Usable 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;
2150</pre></td></tr>
2151
2152
Manuel Klimek67619ff2012-09-07 13:10:32 +00002153<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>&gt;</td><td class="name" onclick="toggle('hasAnySubstatement0')"><a name="hasAnySubstatement0Anchor">hasAnySubstatement</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002154<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches
2155a given matcher.
2156
2157Given
2158 { {}; 1+2; }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002159hasAnySubstatement(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00002160 matches '{ {}; 1+2; }'
Manuel Klimeke44a0062012-08-26 23:55:24 +00002161with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00002162 matching '{}'
2163</pre></td></tr>
2164
2165
Manuel Klimek67619ff2012-09-07 13:10:32 +00002166<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>&gt;</td><td class="name" onclick="toggle('hasCondition4')"><a name="hasCondition4Anchor">hasCondition</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002167<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop,
2168or conditional operator.
2169
2170Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2171 if (true) {}
2172</pre></td></tr>
2173
2174
Manuel Klimek67619ff2012-09-07 13:10:32 +00002175<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>&gt;</td><td class="name" onclick="toggle('hasFalseExpression0')"><a name="hasFalseExpression0Anchor">hasFalseExpression</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002176<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator.
2177
2178Example matches b
2179 condition ? a : b
2180</pre></td></tr>
2181
2182
Manuel Klimek67619ff2012-09-07 13:10:32 +00002183<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>&gt;</td><td class="name" onclick="toggle('hasTrueExpression0')"><a name="hasTrueExpression0Anchor">hasTrueExpression</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002184<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator.
2185
2186Example matches a
2187 condition ? a : b
2188</pre></td></tr>
2189
2190
Manuel Klimek67619ff2012-09-07 13:10:32 +00002191<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;</td><td class="name" onclick="toggle('throughUsingDecl0')"><a name="throughUsingDecl0Anchor">throughUsingDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002192<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a
2193specific using shadow declaration.
2194
2195FIXME: This currently only works for functions. Fix.
2196
2197Given
2198 namespace a { void f() {} }
2199 using a::f;
2200 void g() {
2201 f(); Matches this ..
2202 a::f(); .. but not this.
2203 }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002204declRefExpr(throughUsingDeclaration(anything()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002205 matches f()
2206</pre></td></tr>
2207
2208
Manuel Klimek67619ff2012-09-07 13:10:32 +00002209<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;</td><td class="name" onclick="toggle('to0')"><a name="to0Anchor">to</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002210<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the
2211specified matcher.
2212
2213Example matches x in if(x)
Manuel Klimeke44a0062012-08-26 23:55:24 +00002214 (matcher = declRefExpr(to(varDecl(hasName("x")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002215 bool x;
2216 if (x) {}
2217</pre></td></tr>
2218
2219
Manuel Klimek67619ff2012-09-07 13:10:32 +00002220<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>&gt;</td><td class="name" onclick="toggle('containsDeclaration0')"><a name="containsDeclaration0Anchor">containsDeclaration</a></td><td>unsigned N, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002221<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement.
2222
2223Note that this does not work for global declarations because the AST
2224breaks up multiple-declaration DeclStmt's into multiple single-declaration
2225DeclStmt's.
2226Example: Given non-global declarations
2227 int a, b = 0;
2228 int c;
2229 int d = 2, e;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002230declStmt(containsDeclaration(
2231 0, varDecl(hasInitializer(anything()))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002232 matches only 'int d = 2, e;', and
Manuel Klimeke44a0062012-08-26 23:55:24 +00002233declStmt(containsDeclaration(1, varDecl()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002234 matches 'int a, b = 0' as well as 'int d = 2, e;'
2235 but 'int c;' is not matched.
2236</pre></td></tr>
2237
2238
Manuel Klimek67619ff2012-09-07 13:10:32 +00002239<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>&gt;</td><td class="name" onclick="toggle('hasSingleDecl0')"><a name="hasSingleDecl0Anchor">hasSingleDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002240<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration.
2241
2242Given
2243 int a, b;
2244 int c;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002245declStmt(hasSingleDecl(anything()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002246 matches 'int c;' but not 'int a, b;'.
2247</pre></td></tr>
2248
2249
Manuel Klimek67619ff2012-09-07 13:10:32 +00002250<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>&gt;</td><td class="name" onclick="toggle('hasBody0')"><a name="hasBody0Anchor">hasBody</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002251<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has
2252a given body.
2253
2254Given
2255 for (;;) {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00002256hasBody(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00002257 matches 'for (;;) {}'
Manuel Klimeke44a0062012-08-26 23:55:24 +00002258with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00002259 matching '{}'
2260</pre></td></tr>
2261
2262
Manuel Klimek67619ff2012-09-07 13:10:32 +00002263<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>&gt;</td><td class="name" onclick="toggle('hasCondition3')"><a name="hasCondition3Anchor">hasCondition</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002264<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop,
2265or conditional operator.
2266
2267Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2268 if (true) {}
2269</pre></td></tr>
2270
2271
Manuel Klimek67619ff2012-09-07 13:10:32 +00002272<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;</td><td class="name" onclick="toggle('hasDestinationType0')"><a name="hasDestinationType0Anchor">hasDestinationType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002273<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher.
2274
2275(Note: Clang's AST refers to other conversions as "casts" too, and calls
2276actual casts "explicit" casts.)
2277</pre></td></tr>
2278
2279
Manuel Klimek67619ff2012-09-07 13:10:32 +00002280<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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>
Manuel Klimek1da79332012-08-20 20:54:03 +00002281<tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value
2282declaration's type.
2283
2284In case of a value declaration (for example a variable declaration),
2285this resolves one layer of indirection. For example, in the value
Manuel Klimeke44a0062012-08-26 23:55:24 +00002286declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
2287while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
Manuel Klimek1da79332012-08-20 20:54:03 +00002288of x."
2289
Manuel Klimeke44a0062012-08-26 23:55:24 +00002290Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
2291 and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002292 class X {};
2293 void y(X &amp;x) { x; X z; }
2294
2295Usable 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;
2296</pre></td></tr>
2297
2298
Manuel Klimek67619ff2012-09-07 13:10:32 +00002299<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('ignoringImpCasts0')"><a name="ignoringImpCasts0Anchor">ignoringImpCasts</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002300<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts
2301are stripped off.
2302
2303Parentheses and explicit casts are not discarded.
2304Given
2305 int arr[5];
2306 int a = 0;
2307 char b = 0;
2308 const int c = a;
2309 int *d = arr;
2310 long e = (long) 0l;
2311The matchers
Manuel Klimeke44a0062012-08-26 23:55:24 +00002312 varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
2313 varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002314would match the declarations for a, b, c, and d, but not e.
2315While
Manuel Klimeke44a0062012-08-26 23:55:24 +00002316 varDecl(hasInitializer(integerLiteral()))
2317 varDecl(hasInitializer(declRefExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002318only match the declarations for b, c, and d.
2319</pre></td></tr>
2320
2321
Manuel Klimek67619ff2012-09-07 13:10:32 +00002322<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('ignoringParenCasts0')"><a name="ignoringParenCasts0Anchor">ignoringParenCasts</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002323<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and
2324casts are stripped off.
2325
2326Implicit and non-C Style casts are also discarded.
2327Given
2328 int a = 0;
2329 char b = (0);
2330 void* c = reinterpret_cast&lt;char*&gt;(0);
2331 char d = char(0);
2332The matcher
Manuel Klimeke44a0062012-08-26 23:55:24 +00002333 varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002334would match the declarations for a, b, c, and d.
2335while
Manuel Klimeke44a0062012-08-26 23:55:24 +00002336 varDecl(hasInitializer(integerLiteral()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002337only match the declaration for a.
2338</pre></td></tr>
2339
2340
Manuel Klimek67619ff2012-09-07 13:10:32 +00002341<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('ignoringParenImpCasts0')"><a name="ignoringParenImpCasts0Anchor">ignoringParenImpCasts</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002342<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and
2343parentheses are stripped off.
2344
2345Explicit casts are not discarded.
2346Given
2347 int arr[5];
2348 int a = 0;
2349 char b = (0);
2350 const int c = a;
2351 int *d = (arr);
2352 long e = ((long) 0l);
2353The matchers
Manuel Klimeke44a0062012-08-26 23:55:24 +00002354 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
2355 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002356would match the declarations for a, b, c, and d, but not e.
2357while
Manuel Klimeke44a0062012-08-26 23:55:24 +00002358 varDecl(hasInitializer(integerLiteral()))
2359 varDecl(hasInitializer(declRefExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002360would only match the declaration for a.
2361</pre></td></tr>
2362
2363
Manuel Klimek67619ff2012-09-07 13:10:32 +00002364<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>&gt;</td><td class="name" onclick="toggle('hasBody1')"><a name="hasBody1Anchor">hasBody</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002365<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has
2366a given body.
2367
2368Given
2369 for (;;) {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00002370hasBody(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00002371 matches 'for (;;) {}'
Manuel Klimeke44a0062012-08-26 23:55:24 +00002372with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00002373 matching '{}'
2374</pre></td></tr>
2375
2376
Manuel Klimek67619ff2012-09-07 13:10:32 +00002377<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>&gt;</td><td class="name" onclick="toggle('hasCondition1')"><a name="hasCondition1Anchor">hasCondition</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002378<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop,
2379or conditional operator.
2380
2381Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2382 if (true) {}
2383</pre></td></tr>
2384
2385
Manuel Klimek67619ff2012-09-07 13:10:32 +00002386<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>&gt;</td><td class="name" onclick="toggle('hasIncrement0')"><a name="hasIncrement0Anchor">hasIncrement</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002387<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop.
2388
2389Example:
2390 forStmt(hasIncrement(unaryOperator(hasOperatorName("++"))))
2391matches '++x' in
2392 for (x; x &lt; N; ++x) { }
2393</pre></td></tr>
2394
2395
Manuel Klimek67619ff2012-09-07 13:10:32 +00002396<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>&gt;</td><td class="name" onclick="toggle('hasLoopInit0')"><a name="hasLoopInit0Anchor">hasLoopInit</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002397<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop.
2398
2399Example:
Manuel Klimeke44a0062012-08-26 23:55:24 +00002400 forStmt(hasLoopInit(declStmt()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002401matches 'int x = 0' in
2402 for (int x = 0; x &lt; N; ++x) { }
2403</pre></td></tr>
2404
2405
Manuel Klimek67619ff2012-09-07 13:10:32 +00002406<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyParameter0')"><a name="hasAnyParameter0Anchor">hasAnyParameter</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002407<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration.
2408
2409Does not match the 'this' parameter of a method.
2410
2411Given
2412 class X { void f(int x, int y, int z) {} };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002413methodDecl(hasAnyParameter(hasName("y")))
Manuel Klimek1da79332012-08-20 20:54:03 +00002414 matches f(int x, int y, int z) {}
2415with hasAnyParameter(...)
2416 matching int y
2417</pre></td></tr>
2418
2419
Manuel Klimek67619ff2012-09-07 13:10:32 +00002420<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasParameter0')"><a name="hasParameter0Anchor">hasParameter</a></td><td>unsigned N, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002421<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration.
2422
2423Given
2424 class X { void f(int x) {} };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002425methodDecl(hasParameter(0, hasType(varDecl())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002426 matches f(int x) {}
2427with hasParameter(...)
2428 matching int x
2429</pre></td></tr>
2430
2431
Manuel Klimek67619ff2012-09-07 13:10:32 +00002432<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('returns0')"><a name="returns0Anchor">returns</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002433<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration.
2434
2435Given:
2436 class X { int f() { return 1; } };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002437methodDecl(returns(asString("int")))
Manuel Klimek1da79332012-08-20 20:54:03 +00002438 matches int f() { return 1; }
2439</pre></td></tr>
2440
2441
Manuel Klimek67619ff2012-09-07 13:10:32 +00002442<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>&gt;</td><td class="name" onclick="toggle('hasCondition0')"><a name="hasCondition0Anchor">hasCondition</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002443<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop,
2444or conditional operator.
2445
2446Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2447 if (true) {}
2448</pre></td></tr>
2449
2450
Manuel Klimek67619ff2012-09-07 13:10:32 +00002451<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>&gt;</td><td class="name" onclick="toggle('hasConditionVariableStatement0')"><a name="hasConditionVariableStatement0Anchor">hasConditionVariableStatement</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002452<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement.
2453
2454Given
2455 if (A* a = GetAPointer()) {}
2456hasConditionVariableStatment(...)
2457 matches 'A* a = GetAPointer()'.
2458</pre></td></tr>
2459
2460
Manuel Klimek67619ff2012-09-07 13:10:32 +00002461<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ImplicitCastExpr.html">ImplicitCastExpr</a>&gt;</td><td class="name" onclick="toggle('hasImplicitDestinationType0')"><a name="hasImplicitDestinationType0Anchor">hasImplicitDestinationType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002462<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given
2463matcher.
2464
2465FIXME: Unit test this matcher
2466</pre></td></tr>
2467
2468
Daniel Jaspere0b89972012-12-04 12:08:08 +00002469<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</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>
2470<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a type if the declaration of the type matches the given
2471matcher.
2472
2473Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
2474 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;
2475</pre></td></tr>
2476
2477
Manuel Klimek67619ff2012-09-07 13:10:32 +00002478<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;</td><td class="name" onclick="toggle('hasObjectExpression0')"><a name="hasObjectExpression0Anchor">hasObjectExpression</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002479<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is
2480matched by a given matcher.
2481
2482Given
2483 struct X { int m; };
2484 void f(X x) { x.m; m; }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002485memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002486 matches "x.m" and "m"
2487with hasObjectExpression(...)
2488 matching "x" and the implicit object expression of "m" which has type X*.
2489</pre></td></tr>
2490
2491
Manuel Klimek67619ff2012-09-07 13:10:32 +00002492<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;</td><td class="name" onclick="toggle('member0')"><a name="member0Anchor">member</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002493<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a
2494given matcher.
2495
2496Given
2497 struct { int first, second; } first, second;
2498 int i(second.first);
2499 int j(first.second);
Manuel Klimeke44a0062012-08-26 23:55:24 +00002500memberExpr(member(hasName("first")))
Manuel Klimek1da79332012-08-20 20:54:03 +00002501 matches second.first
2502 but not first.second (because the member name there is "second").
2503</pre></td></tr>
2504
2505
Manuel Klimek41df16e2013-01-09 09:38:21 +00002506<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerTypeLoc.html">MemberPointerTypeLoc</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>
2507<tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the
2508pointee matches a given matcher.
2509
2510Given
2511 int *a;
2512 int const *b;
2513 float const *f;
2514pointerType(pointee(isConstQualified(), isInteger()))
2515 matches "int const *b"
2516
2517Usable 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;,
2518 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;
2519</pre></td></tr>
2520
2521
2522<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</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>
2523<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the
2524pointee matches a given matcher.
2525
2526Given
2527 int *a;
2528 int const *b;
2529 float const *f;
2530pointerType(pointee(isConstQualified(), isInteger()))
2531 matches "int const *b"
2532
2533Usable 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;,
2534 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;
2535</pre></td></tr>
2536
2537
Daniel Jaspere0b89972012-12-04 12:08:08 +00002538<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>
2539<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc.
2540
2541Given
2542 struct A { struct B { struct C {}; }; };
2543 A::B::C c;
2544nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A")))))
2545 matches "A::"
2546</pre></td></tr>
2547
2548
Manuel Klimek41df16e2013-01-09 09:38:21 +00002549<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>&gt;</td><td class="name" onclick="toggle('loc1')"><a name="loc1Anchor">loc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt; InnerMatcher</td></tr>
2550<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner
2551NestedNameSpecifier-matcher matches.
2552</pre></td></tr>
2553
2554
Daniel Jaspere0b89972012-12-04 12:08:08 +00002555<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>
2556<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the
2557given TypeLoc.
2558
2559Given
2560 struct A { struct B { struct C {}; }; };
2561 A::B::C c;
2562nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
2563 hasDeclaration(recordDecl(hasName("A")))))))
2564 matches "A::"
2565</pre></td></tr>
2566
2567
2568<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>
2569<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier.
2570
2571Given
2572 struct A { struct B { struct C {}; }; };
2573 A::B::C c;
2574nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and
2575 matches "A::"
2576</pre></td></tr>
2577
2578
2579<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>
2580<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the
2581given namespace matcher.
2582
2583Given
2584 namespace ns { struct A {}; }
2585 ns::A a;
2586nestedNameSpecifier(specifiesNamespace(hasName("ns")))
2587 matches "ns::"
2588</pre></td></tr>
2589
2590
2591<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>
2592<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the
2593given QualType matcher without qualifiers.
2594
2595Given
2596 struct A { struct B { struct C {}; }; };
2597 A::B::C c;
2598nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A")))))
2599 matches "A::"
2600</pre></td></tr>
2601
2602
Manuel Klimek41df16e2013-01-09 09:38:21 +00002603<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</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>
2604<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the
2605pointee matches a given matcher.
2606
2607Given
2608 int *a;
2609 int const *b;
2610 float const *f;
2611pointerType(pointee(isConstQualified(), isInteger()))
2612 matches "int const *b"
2613
2614Usable 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;,
2615 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;
2616</pre></td></tr>
2617
2618
2619<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</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>
2620<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the
2621pointee matches a given matcher.
2622
2623Given
2624 int *a;
2625 int const *b;
2626 float const *f;
2627pointerType(pointee(isConstQualified(), isInteger()))
2628 matches "int const *b"
2629
2630Usable 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;,
2631 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;
2632</pre></td></tr>
2633
2634
Daniel Jaspere0b89972012-12-04 12:08:08 +00002635<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</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>
2636<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a type if the declaration of the type matches the given
Manuel Klimek1da79332012-08-20 20:54:03 +00002637matcher.
2638
Daniel Jaspere0b89972012-12-04 12:08:08 +00002639Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
2640 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;
Manuel Klimek1da79332012-08-20 20:54:03 +00002641</pre></td></tr>
2642
2643
Manuel Klimek67619ff2012-09-07 13:10:32 +00002644<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('pointsTo1')"><a name="pointsTo1Anchor">pointsTo</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002645<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration.
2646</pre></td></tr>
2647
2648
Manuel Klimek67619ff2012-09-07 13:10:32 +00002649<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('references1')"><a name="references1Anchor">references</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002650<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration.
2651</pre></td></tr>
2652
2653
Manuel Klimek41df16e2013-01-09 09:38:21 +00002654<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</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>
2655<tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the
2656pointee matches a given matcher.
2657
2658Given
2659 int *a;
2660 int const *b;
2661 float const *f;
2662pointerType(pointee(isConstQualified(), isInteger()))
2663 matches "int const *b"
2664
2665Usable 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;,
2666 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;
2667</pre></td></tr>
2668
2669
2670<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</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>
2671<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the
2672pointee matches a given matcher.
2673
2674Given
2675 int *a;
2676 int const *b;
2677 float const *f;
2678pointerType(pointee(isConstQualified(), isInteger()))
2679 matches "int const *b"
2680
2681Usable 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;,
2682 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;
2683</pre></td></tr>
2684
2685
Manuel Klimek67619ff2012-09-07 13:10:32 +00002686<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('alignOfExpr0')"><a name="alignOfExpr0Anchor">alignOfExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002687<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
2688alignof.
2689</pre></td></tr>
2690
2691
Manuel Klimek67619ff2012-09-07 13:10:32 +00002692<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('sizeOfExpr0')"><a name="sizeOfExpr0Anchor">sizeOfExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002693<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
2694sizeof.
2695</pre></td></tr>
2696
2697
Manuel Klimek67619ff2012-09-07 13:10:32 +00002698<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('refersToDeclaration0')"><a name="refersToDeclaration0Anchor">refersToDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002699<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a TemplateArgument that refers to a certain declaration.
2700
2701Given
2702 template&lt;typename T&gt; struct A {};
2703 struct B { B* next; };
2704 A&lt;&amp;B::next&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002705classTemplateSpecializationDecl(hasAnyTemplateArgument(
2706 refersToDeclaration(fieldDecl(hasName("next"))))
2707 matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
Manuel Klimek1da79332012-08-20 20:54:03 +00002708 B::next
2709</pre></td></tr>
2710
2711
Manuel Klimek67619ff2012-09-07 13:10:32 +00002712<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('refersToType0')"><a name="refersToType0Anchor">refersToType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002713<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type.
2714
2715Given
2716 struct X {};
2717 template&lt;typename T&gt; struct A {};
2718 A&lt;X&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002719classTemplateSpecializationDecl(hasAnyTemplateArgument(
Manuel Klimek1da79332012-08-20 20:54:03 +00002720 refersToType(class(hasName("X")))))
2721 matches the specialization A&lt;X&gt;
2722</pre></td></tr>
2723
2724
Manuel Klimek41df16e2013-01-09 09:38:21 +00002725<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('loc0')"><a name="loc0Anchor">loc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
2726<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner
2727QualType-matcher matches.
2728</pre></td></tr>
2729
2730
Daniel Jaspere0b89972012-12-04 12:08:08 +00002731<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;</td><td class="name" onclick="toggle('hasDecl0')"><a name="hasDecl0Anchor">hasDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt; InnerMatcher</td></tr>
2732<tr><td colspan="4" class="doc" id="hasDecl0"><pre>Matches TypedefTypes referring to a specific
2733TypedefNameDecl.
2734</pre></td></tr>
2735
2736
Manuel Klimek67619ff2012-09-07 13:10:32 +00002737<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt;</td><td class="name" onclick="toggle('hasArgumentOfType0')"><a name="hasArgumentOfType0Anchor">hasArgumentOfType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002738<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument.
2739
2740Given
2741 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
2742unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
2743 matches sizeof(a) and alignof(c)
2744</pre></td></tr>
2745
2746
Manuel Klimek67619ff2012-09-07 13:10:32 +00002747<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasUnaryOperand0')"><a name="hasUnaryOperand0Anchor">hasUnaryOperand</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002748<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches.
2749
Daniel Jaspere0b89972012-12-04 12:08:08 +00002750Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002751 !true
2752</pre></td></tr>
2753
2754
Manuel Klimek67619ff2012-09-07 13:10:32 +00002755<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html">UsingDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyUsingShadowDecl0')"><a name="hasAnyUsingShadowDecl0Anchor">hasAnyUsingShadowDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002756<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration.
2757
2758Given
2759 namespace X { void b(); }
2760 using X::b;
2761usingDecl(hasAnyUsingShadowDecl(hasName("b"))))
2762 matches using X::b </pre></td></tr>
2763
2764
Manuel Klimek67619ff2012-09-07 13:10:32 +00002765<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>&gt;</td><td class="name" onclick="toggle('hasTargetDecl0')"><a name="hasTargetDecl0Anchor">hasTargetDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002766<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is
2767matched by the given matcher.
2768
2769Given
2770 namespace X { int a; void b(); }
2771 using X::a;
2772 using X::b;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002773usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002774 matches using X::b but not using X::a </pre></td></tr>
2775
2776
Manuel Klimek67619ff2012-09-07 13:10:32 +00002777<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</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>
Manuel Klimek1da79332012-08-20 20:54:03 +00002778<tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value
2779declaration's type.
2780
2781In case of a value declaration (for example a variable declaration),
2782this resolves one layer of indirection. For example, in the value
Manuel Klimeke44a0062012-08-26 23:55:24 +00002783declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
2784while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
Manuel Klimek1da79332012-08-20 20:54:03 +00002785of x."
2786
Manuel Klimeke44a0062012-08-26 23:55:24 +00002787Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
2788 and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002789 class X {};
2790 void y(X &amp;x) { x; X z; }
2791
2792Usable 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;
2793</pre></td></tr>
2794
2795
Manuel Klimek67619ff2012-09-07 13:10:32 +00002796<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('hasInitializer0')"><a name="hasInitializer0Anchor">hasInitializer</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002797<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression
2798that matches the given matcher.
2799
Manuel Klimeke44a0062012-08-26 23:55:24 +00002800Example matches x (matcher = varDecl(hasInitializer(callExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002801 bool y() { return true; }
2802 bool x = y();
2803</pre></td></tr>
2804
2805
Daniel Jaspere0b89972012-12-04 12:08:08 +00002806<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>
2807<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size
2808expression.
2809
2810Given
2811 void f(int b) {
2812 int a[b];
2813 }
2814variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
2815 varDecl(hasName("b")))))))
2816 matches "int a[b]"
2817</pre></td></tr>
2818
2819
Manuel Klimek67619ff2012-09-07 13:10:32 +00002820<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>&gt;</td><td class="name" onclick="toggle('hasBody2')"><a name="hasBody2Anchor">hasBody</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002821<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has
2822a given body.
2823
2824Given
2825 for (;;) {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00002826hasBody(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00002827 matches 'for (;;) {}'
Manuel Klimeke44a0062012-08-26 23:55:24 +00002828with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00002829 matching '{}'
2830</pre></td></tr>
2831
2832
Manuel Klimek67619ff2012-09-07 13:10:32 +00002833<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>&gt;</td><td class="name" onclick="toggle('hasCondition2')"><a name="hasCondition2Anchor">hasCondition</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
Manuel Klimek1da79332012-08-20 20:54:03 +00002834<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop,
2835or conditional operator.
2836
2837Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2838 if (true) {}
2839</pre></td></tr>
2840
2841<!--END_TRAVERSAL_MATCHERS -->
2842</table>
2843
2844</div>
2845</body>
2846</html>
2847
2848