blob: 3ee44cfe11d1f32b0bb139ddfb7cf601ea8964b6 [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
Daniel Jasperc7093d92013-02-25 12:39:41 +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('accessSpecDecl0')"><a name="accessSpecDecl0Anchor">accessSpecDecl</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AccessSpecDecl.html">AccessSpecDecl</a>&gt;...</td></tr>
81<tr><td colspan="4" class="doc" id="accessSpecDecl0"><pre>Matches C++ access specifier declarations.
82
83Given
84 class C {
85 public:
86 int a;
87 };
88accessSpecDecl()
89 matches 'public:'
90</pre></td></tr>
91
92
Manuel Klimek67619ff2012-09-07 13:10:32 +000093<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 +000094<tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +000095
96Example matches Z
97 template&lt;class T&gt; class Z {};
98</pre></td></tr>
99
100
Manuel Klimek67619ff2012-09-07 13:10:32 +0000101<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 +0000102<tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000103
104Given
105 template&lt;typename T&gt; class A {};
106 template&lt;&gt; class A&lt;double&gt; {};
107 A&lt;int&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +0000108classTemplateSpecializationDecl()
Manuel Klimek1da79332012-08-20 20:54:03 +0000109 matches the specializations A&lt;int&gt; and A&lt;double&gt;
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('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 +0000114<tr><td colspan="4" class="doc" id="constructorDecl0"><pre>Matches C++ constructor declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000115
116Example matches Foo::Foo() and Foo::Foo(int)
117 class Foo {
118 public:
119 Foo();
120 Foo(int);
121 int DoSomething();
122 };
123</pre></td></tr>
124
125
Manuel Klimek67619ff2012-09-07 13:10:32 +0000126<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 +0000127<tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations.
128
129Examples matches X, C, and the friend declaration inside C;
130 void X();
131 class C {
132 friend X;
133 };
134</pre></td></tr>
135
136
Manuel Klimek67619ff2012-09-07 13:10:32 +0000137<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 +0000138<tr><td colspan="4" class="doc" id="destructorDecl0"><pre>Matches explicit C++ destructor declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000139
140Example matches Foo::~Foo()
141 class Foo {
142 public:
143 virtual ~Foo();
144 };
145</pre></td></tr>
146
147
Manuel Klimek67619ff2012-09-07 13:10:32 +0000148<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 +0000149<tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants.
Manuel Klimek1da79332012-08-20 20:54:03 +0000150
151Example matches A, B, C
152 enum X {
153 A, B, C
154 };
155</pre></td></tr>
156
157
Manuel Klimek67619ff2012-09-07 13:10:32 +0000158<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 +0000159<tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations.
160
161Example matches X
162 enum X {
163 A, B, C
164 };
165</pre></td></tr>
166
167
Manuel Klimek67619ff2012-09-07 13:10:32 +0000168<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('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 +0000169<tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000170
171Given
172 class X { int m; };
Manuel Klimeke44a0062012-08-26 23:55:24 +0000173fieldDecl()
Manuel Klimek1da79332012-08-20 20:54:03 +0000174 matches 'm'.
175</pre></td></tr>
176
177
Manuel Klimek67619ff2012-09-07 13:10:32 +0000178<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 +0000179<tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000180
181Example matches f
182 void f();
183</pre></td></tr>
184
185
Manuel Klimek67619ff2012-09-07 13:10:32 +0000186<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 +0000187<tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000188
189Example matches f
190 template&lt;class T&gt; void f(T t) {}
191</pre></td></tr>
192
193
Manuel Klimek67619ff2012-09-07 13:10:32 +0000194<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 +0000195<tr><td colspan="4" class="doc" id="methodDecl0"><pre>Matches method declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000196
197Example matches y
198 class X { void y() };
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('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 +0000203<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 +0000204
205Example matches X, S, the anonymous union type, i, and U;
206 typedef int X;
207 struct S {
208 union {
209 int i;
210 } U;
211 };
212</pre></td></tr>
213
214
Manuel Klimek67619ff2012-09-07 13:10:32 +0000215<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 +0000216<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches C++ class declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000217
218Example matches X, Z
219 class X;
220 template&lt;class T&gt; class Z {};
221</pre></td></tr>
222
223
Manuel Klimek67619ff2012-09-07 13:10:32 +0000224<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 +0000225<tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations.
226
227Given
228 namespace X { int x; }
229 using X::x;
230usingDecl()
231 matches using X::x </pre></td></tr>
232
233
Manuel Klimek67619ff2012-09-07 13:10:32 +0000234<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 +0000235<tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000236
237Note: this does not match declarations of member variables, which are
238"field" declarations in Clang parlance.
239
240Example matches a
241 int a;
242</pre></td></tr>
243
244
Manuel Klimek41df16e2013-01-09 09:38:21 +0000245<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>
246<tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
247</pre></td></tr>
248
249
250<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>
251<tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers.
252
253Given
254 namespace ns {
255 struct A { static void f(); };
256 void A::f() {}
257 void g() { A::f(); }
258 }
259 ns::A a;
260nestedNameSpecifier()
261 matches "ns::" and both "A::"
262</pre></td></tr>
263
264
265<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>
266<tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST.
267</pre></td></tr>
268
269
Manuel Klimek67619ff2012-09-07 13:10:32 +0000270<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 +0000271<tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions.
272
273Given
274 int i = a[1];
275arraySubscriptExpr()
276 matches "a[1]"
277</pre></td></tr>
278
279
Daniel Jaspere0b89972012-12-04 12:08:08 +0000280<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>
281<tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements.
282
283 int i = 100;
284 __asm("mov al, 2");
285asmStmt()
286 matches '__asm("mov al, 2")'
287</pre></td></tr>
288
289
Manuel Klimek67619ff2012-09-07 13:10:32 +0000290<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 +0000291<tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions.
292
293Example matches a || b
294 !(a || b)
295</pre></td></tr>
296
297
Manuel Klimek67619ff2012-09-07 13:10:32 +0000298<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 +0000299<tr><td colspan="4" class="doc" id="bindTemporaryExpr0"><pre>Matches nodes where temporaries are created.
Manuel Klimek1da79332012-08-20 20:54:03 +0000300
301Example matches FunctionTakesString(GetStringByValue())
Manuel Klimeke44a0062012-08-26 23:55:24 +0000302 (matcher = bindTemporaryExpr())
Manuel Klimek1da79332012-08-20 20:54:03 +0000303 FunctionTakesString(GetStringByValue());
304 FunctionTakesStringByPointer(GetStringPointer());
305</pre></td></tr>
306
307
Daniel Jaspere0b89972012-12-04 12:08:08 +0000308<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>
309<tr><td colspan="4" class="doc" id="boolLiteral0"><pre>Matches bool literals.
310
311Example matches true
312 true
313</pre></td></tr>
314
315
316<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>
317<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements.
318
319Given
320 while (true) { break; }
321breakStmt()
322 matches 'break'
323</pre></td></tr>
324
325
326<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>
327<tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression.
328
329Example: Matches (int*) 2.2f in
330 int i = (int) 2.2f;
331</pre></td></tr>
332
333
Manuel Klimek67619ff2012-09-07 13:10:32 +0000334<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 +0000335<tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000336
337Example matches x.y() and y()
338 X x;
339 x.y();
340 y();
341</pre></td></tr>
342
343
Daniel Jaspere0b89972012-12-04 12:08:08 +0000344<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>
345<tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST.
346
347Example: castExpr() matches each of the following:
348 (int) 3;
349 const_cast&lt;Expr *&gt;(SubExpr);
350 char c = 0;
351but does not match
352 int i = (0);
353 int k = 0;
354</pre></td></tr>
355
356
357<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>
358<tr><td colspan="4" class="doc" id="catchStmt0"><pre>Matches catch statements.
359
360 try {} catch(int i) {}
361catchStmt()
362 matches 'catch(int i)'
363</pre></td></tr>
364
365
366<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>
367<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t).
368
369Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
370though.
371
372Example matches 'a', L'a'
373 char ch = 'a'; wchar_t chw = L'a';
374</pre></td></tr>
375
376
Manuel Klimek415514d2013-02-06 20:36:22 +0000377<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('compoundLiteralExpr0')"><a name="compoundLiteralExpr0Anchor">compoundLiteralExpr</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;...</td></tr>
378<tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals
379
380Example match: {1}, (1, 2)
381 int array[4] = {1}; vector int myvec = (vector int)(1, 2);
382</pre></td></tr>
383
384
Manuel Klimek67619ff2012-09-07 13:10:32 +0000385<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 +0000386<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements.
Manuel Klimek1da79332012-08-20 20:54:03 +0000387
388Example matches '{}' and '{{}}'in 'for (;;) {{}}'
389 for (;;) {{}}
390</pre></td></tr>
391
392
Manuel Klimek67619ff2012-09-07 13:10:32 +0000393<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 +0000394<tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions.
395
396Example matches a ? b : c
397 (a ? b : c) + 42
398</pre></td></tr>
399
400
Daniel Jaspere0b89972012-12-04 12:08:08 +0000401<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>
402<tr><td colspan="4" class="doc" id="constCastExpr0"><pre>Matches a const_cast expression.
403
404Example: Matches const_cast&lt;int*&gt;(&amp;r) in
405 int n = 42;
406 const int &amp;r(n);
407 int* p = const_cast&lt;int*&gt;(&amp;r);
408</pre></td></tr>
409
410
Manuel Klimek67619ff2012-09-07 13:10:32 +0000411<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 +0000412<tr><td colspan="4" class="doc" id="constructExpr0"><pre>Matches constructor call expressions (including implicit ones).
Manuel Klimek1da79332012-08-20 20:54:03 +0000413
414Example matches string(ptr, n) and ptr within arguments of f
Manuel Klimeke44a0062012-08-26 23:55:24 +0000415 (matcher = constructExpr())
Manuel Klimek1da79332012-08-20 20:54:03 +0000416 void f(const string &amp;a, const string &amp;b);
417 char *ptr;
418 int n;
419 f(string(ptr, n), ptr);
420</pre></td></tr>
421
422
Daniel Jaspere0b89972012-12-04 12:08:08 +0000423<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>
424<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements.
425
426Given
427 while (true) { continue; }
428continueStmt()
429 matches 'continue'
430</pre></td></tr>
431
432
Manuel Klimek67619ff2012-09-07 13:10:32 +0000433<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 +0000434<tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations.
Manuel Klimek1da79332012-08-20 20:54:03 +0000435
436Example matches x in if (x)
437 bool x;
438 if (x) {}
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('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 +0000443<tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements.
Manuel Klimek1da79332012-08-20 20:54:03 +0000444
445Given
446 int a;
Manuel Klimeke44a0062012-08-26 23:55:24 +0000447declStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +0000448 matches 'int a'.
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('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 +0000453<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 +0000454
455Example matches the CXXDefaultArgExpr placeholder inserted for the
456 default value of the second parameter in the call expression f(42)
Manuel Klimeke44a0062012-08-26 23:55:24 +0000457 (matcher = defaultArgExpr())
Manuel Klimek1da79332012-08-20 20:54:03 +0000458 void f(int x, int y = 0);
459 f(42);
460</pre></td></tr>
461
462
Manuel Klimek67619ff2012-09-07 13:10:32 +0000463<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 +0000464<tr><td colspan="4" class="doc" id="deleteExpr0"><pre>Matches delete expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000465
466Given
467 delete X;
Manuel Klimeke44a0062012-08-26 23:55:24 +0000468deleteExpr()
Manuel Klimek1da79332012-08-20 20:54:03 +0000469 matches 'delete X'.
470</pre></td></tr>
471
472
Manuel Klimek67619ff2012-09-07 13:10:32 +0000473<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 +0000474<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements.
475
476Given
477 do {} while (true);
478doStmt()
479 matches 'do {} while(true)'
480</pre></td></tr>
481
482
Daniel Jaspere0b89972012-12-04 12:08:08 +0000483<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
484<tr><td colspan="4" class="doc" id="dynamicCastExpr0"><pre>Matches a dynamic_cast expression.
485
486Example:
487 dynamicCastExpr()
488matches
489 dynamic_cast&lt;D*&gt;(&amp;b);
490in
491 struct B { virtual ~B() {} }; struct D : B {};
492 B b;
493 D* p = dynamic_cast&lt;D*&gt;(&amp;b);
494</pre></td></tr>
495
496
497<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>
498<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions.
499
500Matches any cast expression written in user code, whether it be a
501C-style cast, a functional-style cast, or a keyword cast.
502
503Does not match implicit conversions.
504
505Note: the name "explicitCast" is chosen to match Clang's terminology, as
506Clang uses the term "cast" to apply to implicit conversions as well as to
507actual cast expressions.
508
509hasDestinationType.
510
511Example: matches all five of the casts in
512 int((int)(reinterpret_cast&lt;int&gt;(static_cast&lt;int&gt;(const_cast&lt;int&gt;(42)))))
513but does not match the implicit conversion in
514 long ell = 42;
515</pre></td></tr>
516
517
Manuel Klimek67619ff2012-09-07 13:10:32 +0000518<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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 +0000519<tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000520
521Example matches x()
522 void f() { x(); }
523</pre></td></tr>
524
525
Daniel Jaspere0b89972012-12-04 12:08:08 +0000526<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>
527<tr><td colspan="4" class="doc" id="forRangeStmt0"><pre>Matches range-based for statements.
528
529forRangeStmt() matches 'for (auto a : i)'
530 int i[] = {1, 2, 3}; for (auto a : i);
531 for(int j = 0; j &lt; 5; ++j);
532</pre></td></tr>
533
534
Manuel Klimek67619ff2012-09-07 13:10:32 +0000535<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 +0000536<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements.
537
538Example matches 'for (;;) {}'
539 for (;;) {}
Daniel Jaspere0b89972012-12-04 12:08:08 +0000540 int i[] = {1, 2, 3}; for (auto a : i);
541</pre></td></tr>
542
543
544<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>
545<tr><td colspan="4" class="doc" id="functionalCastExpr0"><pre>Matches functional cast expressions
546
547Example: Matches Foo(bar);
548 Foo f = bar;
549 Foo g = (Foo) bar;
550 Foo h = Foo(bar);
551</pre></td></tr>
552
553
554<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>
555<tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements.
556
557Given
558 goto FOO;
559 FOO: bar();
560gotoStmt()
561 matches 'goto FOO'
Manuel Klimek1da79332012-08-20 20:54:03 +0000562</pre></td></tr>
563
564
Manuel Klimek67619ff2012-09-07 13:10:32 +0000565<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 +0000566<tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements.
567
568Example matches 'if (x) {}'
569 if (x) {}
570</pre></td></tr>
571
572
Daniel Jaspere0b89972012-12-04 12:08:08 +0000573<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>
574<tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST.
575
576This matches many different places, including function call return value
577eliding, as well as any type conversions.
578</pre></td></tr>
579
580
Manuel Klimek67619ff2012-09-07 13:10:32 +0000581<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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 +0000582<tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions.
583
584Given
585 int a[] = { 1, 2 };
586 struct B { int x, y; };
587 B b = { 5, 6 };
588initList()
589 matches "{ 1, 2 }" and "{ 5, 6 }"
590</pre></td></tr>
591
592
Daniel Jaspere0b89972012-12-04 12:08:08 +0000593<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>
594<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings.
595
596Not matching character-encoded integers such as L'a'.
597
598Example matches 1, 1L, 0x1, 1U
599</pre></td></tr>
600
601
602<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>
603<tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements.
604
605Given
606 goto FOO;
607 FOO: bar();
608labelStmt()
609 matches 'FOO:'
610</pre></td></tr>
611
612
613<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>
614<tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions.
615
616Example matches [&amp;](){return 5;}
617 [&amp;](){return 5;}
618</pre></td></tr>
619
620
Manuel Klimek67619ff2012-09-07 13:10:32 +0000621<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 +0000622<tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized.
623
624Example: Given
625 struct T {void func()};
626 T f();
627 void g(T);
628materializeTemporaryExpr() matches 'f()' in these statements
629 T u(f());
630 g(f());
631but does not match
632 f();
633 f().func();
634</pre></td></tr>
635
636
Manuel Klimek67619ff2012-09-07 13:10:32 +0000637<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 +0000638<tr><td colspan="4" class="doc" id="memberCallExpr0"><pre>Matches member call expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000639
640Example matches x.y()
641 X x;
642 x.y();
643</pre></td></tr>
644
645
Manuel Klimek67619ff2012-09-07 13:10:32 +0000646<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 +0000647<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000648
649Given
650 class Y {
651 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
652 int a; static int b;
653 };
Manuel Klimeke44a0062012-08-26 23:55:24 +0000654memberExpr()
Manuel Klimek1da79332012-08-20 20:54:03 +0000655 matches this-&gt;x, x, y.x, a, this-&gt;b
656</pre></td></tr>
657
658
Manuel Klimek67619ff2012-09-07 13:10:32 +0000659<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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 +0000660<tr><td colspan="4" class="doc" id="newExpr0"><pre>Matches new expressions.
Manuel Klimek1da79332012-08-20 20:54:03 +0000661
662Given
663 new X;
Manuel Klimeke44a0062012-08-26 23:55:24 +0000664newExpr()
Manuel Klimek1da79332012-08-20 20:54:03 +0000665 matches 'new X'.
666</pre></td></tr>
667
668
Daniel Jaspere0b89972012-12-04 12:08:08 +0000669<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>
670<tr><td colspan="4" class="doc" id="nullPtrLiteralExpr0"><pre>Matches nullptr literal.
671</pre></td></tr>
672
673
674<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>
675<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements.
676
677 foo();;
678nullStmt()
679 matches the second ';'
680</pre></td></tr>
681
682
Manuel Klimek67619ff2012-09-07 13:10:32 +0000683<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 +0000684<tr><td colspan="4" class="doc" id="operatorCallExpr0"><pre>Matches overloaded operator calls.
Manuel Klimek1da79332012-08-20 20:54:03 +0000685
686Note that if an operator isn't overloaded, it won't match. Instead, use
687binaryOperator matcher.
688Currently it does not match operators such as new delete.
689FIXME: figure out why these do not match?
690
691Example matches both operator&lt;&lt;((o &lt;&lt; b), c) and operator&lt;&lt;(o, b)
Manuel Klimeke44a0062012-08-26 23:55:24 +0000692 (matcher = operatorCallExpr())
Manuel Klimek1da79332012-08-20 20:54:03 +0000693 ostream &amp;operator&lt;&lt; (ostream &amp;out, int i) { };
694 ostream &amp;o; int b = 1, c = 1;
695 o &lt;&lt; b &lt;&lt; c;
696</pre></td></tr>
697
698
Daniel Jaspere0b89972012-12-04 12:08:08 +0000699<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>
700<tr><td colspan="4" class="doc" id="reinterpretCastExpr0"><pre>Matches a reinterpret_cast expression.
701
702Either the source expression or the destination type can be matched
703using has(), but hasDestinationType() is more specific and can be
704more readable.
705
706Example matches reinterpret_cast&lt;char*&gt;(&amp;p) in
707 void* p = reinterpret_cast&lt;char*&gt;(&amp;p);
708</pre></td></tr>
709
710
711<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>
712<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements.
713
714Given
715 return 1;
716returnStmt()
717 matches 'return 1'
718</pre></td></tr>
719
720
721<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>
722<tr><td colspan="4" class="doc" id="staticCastExpr0"><pre>Matches a C++ static_cast expression.
723
724hasDestinationType
725reinterpretCast
726
727Example:
728 staticCastExpr()
729matches
730 static_cast&lt;long&gt;(8)
731in
732 long eight(static_cast&lt;long&gt;(8));
733</pre></td></tr>
734
735
Manuel Klimek67619ff2012-09-07 13:10:32 +0000736<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 +0000737<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements.
Manuel Klimek1da79332012-08-20 20:54:03 +0000738
739Given
740 { ++a; }
Manuel Klimeke44a0062012-08-26 23:55:24 +0000741stmt()
Manuel Klimek1da79332012-08-20 20:54:03 +0000742 matches both the compound statement '{ ++a; }' and '++a'.
743</pre></td></tr>
744
745
Daniel Jaspere0b89972012-12-04 12:08:08 +0000746<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>
747<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals).
748
749Example matches "abcd", L"abcd"
750 char *s = "abcd"; wchar_t *ws = L"abcd"
751</pre></td></tr>
752
753
Manuel Klimek67619ff2012-09-07 13:10:32 +0000754<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 +0000755<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements.
756
757Given
758 switch(a) { case 42: break; default: break; }
759switchCase()
760 matches 'case 42: break;' and 'default: break;'.
761</pre></td></tr>
762
763
Daniel Jaspere0b89972012-12-04 12:08:08 +0000764<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>
765<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements.
766
767Given
768 switch(a) { case 42: break; default: break; }
769switchStmt()
770 matches 'switch(a)'.
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('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>
775<tr><td colspan="4" class="doc" id="thisExpr0"><pre>Matches implicit and explicit this expressions.
776
777Example matches the implicit this expression in "return i".
778 (matcher = thisExpr())
779struct foo {
780 int i;
781 int f() { return i; }
782};
783</pre></td></tr>
784
785
786<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>
787<tr><td colspan="4" class="doc" id="throwExpr0"><pre>Matches throw expressions.
788
789 try { throw 5; } catch(int i) {}
790throwExpr()
791 matches 'throw 5'
792</pre></td></tr>
793
794
795<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>
796<tr><td colspan="4" class="doc" id="tryStmt0"><pre>Matches try statements.
797
798 try {} catch(int i) {}
799tryStmt()
800 matches 'try {}'
801</pre></td></tr>
802
803
Manuel Klimek67619ff2012-09-07 13:10:32 +0000804<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 +0000805<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
806
807Given
808 Foo x = bar;
809 int y = sizeof(x) + alignof(x);
810unaryExprOrTypeTraitExpr()
811 matches sizeof(x) and alignof(x)
812</pre></td></tr>
813
814
Manuel Klimek67619ff2012-09-07 13:10:32 +0000815<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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 +0000816<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions.
817
818Example matches !a
819 !a || b
820</pre></td></tr>
821
822
Daniel Jaspere0b89972012-12-04 12:08:08 +0000823<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>
824<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call.
825
826Example match: "foo"_suffix
827</pre></td></tr>
828
829
Manuel Klimek67619ff2012-09-07 13:10:32 +0000830<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 +0000831<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements.
832
833Given
834 while (true) {}
835whileStmt()
836 matches 'while (true) {}'.
837</pre></td></tr>
838
Daniel Jaspere0b89972012-12-04 12:08:08 +0000839
Manuel Klimek41df16e2013-01-09 09:38:21 +0000840<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>
841<tr><td colspan="4" class="doc" id="arrayTypeLoc0"><pre>Matches all kinds of arrays.
842
843Given
844 int a[] = { 2, 3 };
845 int b[4];
846 void f() { int c[a[0]]; }
847arrayType()
848 matches "int a[]", "int b[4]" and "int c[a[0]]";
849</pre></td></tr>
850
851
852<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>
853<tr><td colspan="4" class="doc" id="atomicTypeLoc0"><pre>Matches atomic types.
854
855Given
856 _Atomic(int) i;
857atomicType()
858 matches "_Atomic(int) i"
859</pre></td></tr>
860
861
862<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>
863<tr><td colspan="4" class="doc" id="autoTypeLoc0"><pre>Matches types nodes representing C++11 auto types.
864
865Given:
866 auto n = 4;
867 int v[] = { 2, 3 }
868 for (auto i : v) { }
869autoType()
870 matches "auto n" and "auto i"
871</pre></td></tr>
872
873
874<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>
875<tr><td colspan="4" class="doc" id="blockPointerTypeLoc0"><pre>Matches block pointer types, i.e. types syntactically represented as
876"void (^)(int)".
877
878The pointee is always required to be a FunctionType.
879</pre></td></tr>
880
881
882<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>
883<tr><td colspan="4" class="doc" id="builtinTypeLoc0"><pre>Matches builtin Types.
884
885Given
886 struct A {};
887 A a;
888 int b;
889 float c;
890 bool d;
891builtinType()
892 matches "int b", "float c" and "bool d"
893</pre></td></tr>
894
895
896<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>
897<tr><td colspan="4" class="doc" id="complexTypeLoc0"><pre>Matches C99 complex types.
898
899Given
900 _Complex float f;
901complexType()
902 matches "_Complex float f"
903</pre></td></tr>
904
905
906<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>
907<tr><td colspan="4" class="doc" id="constantArrayTypeLoc0"><pre>Matches C arrays with a specified constant size.
908
909Given
910 void() {
911 int a[2];
912 int b[] = { 2, 3 };
913 int c[b[0]];
914 }
915constantArrayType()
916 matches "int a[2]"
917</pre></td></tr>
918
919
920<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>
921<tr><td colspan="4" class="doc" id="dependentSizedArrayTypeLoc0"><pre>Matches C++ arrays whose size is a value-dependent expression.
922
923Given
924 template&lt;typename T, int Size&gt;
925 class array {
926 T data[Size];
927 };
928dependentSizedArrayType
929 matches "T data[Size]"
930</pre></td></tr>
931
932
933<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>
934<tr><td colspan="4" class="doc" id="functionTypeLoc0"><pre>Matches FunctionType nodes.
935
936Given
937 int (*f)(int);
938 void g();
939functionType()
940 matches "int (*f)(int)" and the type of "g".
941</pre></td></tr>
942
943
944<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>
945<tr><td colspan="4" class="doc" id="incompleteArrayTypeLoc0"><pre>Matches C arrays with unspecified size.
946
947Given
948 int a[] = { 2, 3 };
949 int b[42];
950 void f(int c[]) { int d[a[0]]; };
951incompleteArrayType()
952 matches "int a[]" and "int c[]"
953</pre></td></tr>
954
955
956<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>
957<tr><td colspan="4" class="doc" id="memberPointerTypeLoc0"><pre>Matches member pointer types.
958Given
959 struct A { int i; }
960 A::* ptr = A::i;
961memberPointerType()
962 matches "A::* ptr"
963</pre></td></tr>
964
965
966<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('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>
967<tr><td colspan="4" class="doc" id="pointerTypeLoc0"><pre>Matches pointer types.
968
969Given
970 int *a;
971 int &amp;b = *a;
972 int c = 5;
973pointerType()
974 matches "int *a"
975</pre></td></tr>
976
977
978<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>
979<tr><td colspan="4" class="doc" id="referenceTypeLoc0"><pre>Matches reference types.
980
981Given
982 int *a;
983 int &amp;b = *a;
984 int c = 5;
985pointerType()
986 matches "int &amp;b"
987</pre></td></tr>
988
989
Daniel Jaspere0b89972012-12-04 12:08:08 +0000990<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>
991<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST.
992</pre></td></tr>
993
994
Manuel Klimek41df16e2013-01-09 09:38:21 +0000995<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>
996<tr><td colspan="4" class="doc" id="typedefTypeLoc0"><pre>Matches typedef types.
997
998Given
999 typedef int X;
1000typedefType()
1001 matches "typedef int X"
1002</pre></td></tr>
1003
1004
1005<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>
1006<tr><td colspan="4" class="doc" id="variableArrayTypeLoc0"><pre>Matches C arrays with a specified size that is not an
1007integer-constant-expression.
1008
1009Given
1010 void f() {
1011 int a[] = { 2, 3 }
1012 int b[42];
1013 int c[a[0]];
1014variableArrayType()
1015 matches "int c[a[0]]"
1016</pre></td></tr>
1017
1018
1019<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>
1020<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays.
1021
1022Given
1023 int a[] = { 2, 3 };
1024 int b[4];
1025 void f() { int c[a[0]]; }
1026arrayType()
1027 matches "int a[]", "int b[4]" and "int c[a[0]]";
1028</pre></td></tr>
1029
1030
1031<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>
1032<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types.
1033
1034Given
1035 _Atomic(int) i;
1036atomicType()
1037 matches "_Atomic(int) i"
1038</pre></td></tr>
1039
1040
1041<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>
1042<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types.
1043
1044Given:
1045 auto n = 4;
1046 int v[] = { 2, 3 }
1047 for (auto i : v) { }
1048autoType()
1049 matches "auto n" and "auto i"
1050</pre></td></tr>
1051
1052
1053<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>
1054<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as
1055"void (^)(int)".
1056
1057The pointee is always required to be a FunctionType.
1058</pre></td></tr>
1059
1060
1061<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>
1062<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types.
1063
1064Given
1065 struct A {};
1066 A a;
1067 int b;
1068 float c;
1069 bool d;
1070builtinType()
1071 matches "int b", "float c" and "bool d"
1072</pre></td></tr>
1073
1074
1075<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>
1076<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types.
1077
1078Given
1079 _Complex float f;
1080complexType()
1081 matches "_Complex float f"
1082</pre></td></tr>
1083
1084
1085<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>
1086<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size.
1087
1088Given
1089 void() {
1090 int a[2];
1091 int b[] = { 2, 3 };
1092 int c[b[0]];
1093 }
1094constantArrayType()
1095 matches "int a[2]"
1096</pre></td></tr>
1097
1098
1099<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>
1100<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression.
1101
1102Given
1103 template&lt;typename T, int Size&gt;
1104 class array {
1105 T data[Size];
1106 };
1107dependentSizedArrayType
1108 matches "T data[Size]"
1109</pre></td></tr>
1110
1111
1112<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>
1113<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes.
1114
1115Given
1116 int (*f)(int);
1117 void g();
1118functionType()
1119 matches "int (*f)(int)" and the type of "g".
1120</pre></td></tr>
1121
1122
1123<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>
1124<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size.
1125
1126Given
1127 int a[] = { 2, 3 };
1128 int b[42];
1129 void f(int c[]) { int d[a[0]]; };
1130incompleteArrayType()
1131 matches "int a[]" and "int c[]"
1132</pre></td></tr>
1133
1134
1135<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>
1136<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types.
1137Given
1138 struct A { int i; }
1139 A::* ptr = A::i;
1140memberPointerType()
1141 matches "A::* ptr"
1142</pre></td></tr>
1143
1144
1145<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>
1146<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types.
1147
1148Given
1149 int *a;
1150 int &amp;b = *a;
1151 int c = 5;
1152pointerType()
1153 matches "int *a"
1154</pre></td></tr>
1155
1156
1157<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>
1158<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches reference types.
1159
1160Given
1161 int *a;
1162 int &amp;b = *a;
1163 int c = 5;
1164pointerType()
1165 matches "int &amp;b"
1166</pre></td></tr>
1167
1168
Daniel Jaspere0b89972012-12-04 12:08:08 +00001169<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>
1170<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST.
1171</pre></td></tr>
1172
Manuel Klimek41df16e2013-01-09 09:38:21 +00001173
1174<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>
1175<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types.
1176
1177Given
1178 typedef int X;
1179typedefType()
1180 matches "typedef int X"
1181</pre></td></tr>
1182
1183
1184<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>
1185<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an
1186integer-constant-expression.
1187
1188Given
1189 void f() {
1190 int a[] = { 2, 3 }
1191 int b[42];
1192 int c[a[0]];
1193variableArrayType()
1194 matches "int c[a[0]]"
1195</pre></td></tr>
1196
Manuel Klimek1da79332012-08-20 20:54:03 +00001197<!--END_DECL_MATCHERS -->
1198</table>
1199
1200<!-- ======================================================================= -->
1201<h2 id="narrowing-matchers">Narrowing Matchers</h2>
1202<!-- ======================================================================= -->
1203
1204<p>Narrowing matchers match certain attributes on the current node, thus
1205narrowing down the set of nodes of the current type to match on.</p>
1206
1207<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless)
1208which allow users to create more powerful match expressions.</p>
1209
1210<table>
1211<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
1212<!-- START_NARROWING_MATCHERS -->
1213
Manuel Klimek67619ff2012-09-07 13:10:32 +00001214<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 +00001215<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match.
1216
1217Usable as: Any Matcher
1218</pre></td></tr>
1219
1220
Manuel Klimek67619ff2012-09-07 13:10:32 +00001221<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 +00001222<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches.
1223
1224Usable as: Any Matcher
1225</pre></td></tr>
1226
1227
Manuel Klimek67619ff2012-09-07 13:10:32 +00001228<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 +00001229<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node.
1230
1231Useful when another matcher requires a child matcher, but there's no
1232additional constraint. This will often be used with an explicit conversion
1233to an internal::Matcher&lt;&gt; type such as TypeMatcher.
1234
1235Example: DeclarationMatcher(anything()) matches all declarations, e.g.,
1236"int* p" and "void f()" in
1237 int* p;
1238 void f();
1239
1240Usable as: Any Matcher
1241</pre></td></tr>
1242
1243
Manuel Klimek67619ff2012-09-07 13:10:32 +00001244<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 +00001245<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match.
1246
Manuel Klimeke44a0062012-08-26 23:55:24 +00001247Example matches Y (matcher = recordDecl(unless(hasName("X"))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001248 class X {};
1249 class Y {};
1250
1251Usable as: Any Matcher
1252</pre></td></tr>
1253
1254
Manuel Klimek67619ff2012-09-07 13:10:32 +00001255<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 +00001256<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or
1257unary).
1258
1259Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
1260 !(a || b)
1261</pre></td></tr>
1262
1263
Manuel Klimek67619ff2012-09-07 13:10:32 +00001264<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 +00001265<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value.
1266
1267Example matches true (matcher = boolLiteral(equals(true)))
1268 true
1269
1270Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1271 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;
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_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 +00001276<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a constructor declaration that has been implicitly added
1277by the compiler (eg. implicit defaultcopy constructors).
1278</pre></td></tr>
1279
1280
Manuel Klimek67619ff2012-09-07 13:10:32 +00001281<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 +00001282<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a contructor initializer if it is explicitly written in
1283code (as opposed to implicitly added by the compiler).
1284
1285Given
1286 struct Foo {
1287 Foo() { }
1288 Foo(int) : foo_("A") { }
1289 string foo_;
1290 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00001291constructorDecl(hasAnyConstructorInitializer(isWritten()))
Manuel Klimek1da79332012-08-20 20:54:03 +00001292 will match Foo(int), but not Foo()
1293</pre></td></tr>
1294
1295
Manuel Klimek67619ff2012-09-07 13:10:32 +00001296<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 +00001297<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names.
1298
1299Matches overloaded operator names specified in strings without the
1300"operator" prefix, such as "&lt;&lt;", for OverloadedOperatorCall's.
1301
1302Example matches a &lt;&lt; b
Manuel Klimeke44a0062012-08-26 23:55:24 +00001303 (matcher == operatorCallExpr(hasOverloadedOperatorName("&lt;&lt;")))
Manuel Klimek1da79332012-08-20 20:54:03 +00001304 a &lt;&lt; b;
1305 c &amp;&amp; d; assuming both operator&lt;&lt;
1306 and operator&amp;&amp; are overloaded somewhere.
1307</pre></td></tr>
1308
1309
Manuel Klimek67619ff2012-09-07 13:10:32 +00001310<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 +00001311<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
1312</pre></td></tr>
1313
1314
Manuel Klimek415514d2013-02-06 20:36:22 +00001315<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isExplicitTemplateSpecialization2')"><a name="isExplicitTemplateSpecialization2Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr>
1316<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or
Manuel Klimek1da79332012-08-20 20:54:03 +00001317static member variable template instantiations.
1318
1319Given
1320 template&lt;typename T&gt; void A(T t) { }
1321 template&lt;&gt; void A(int N) { }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001322functionDecl(isExplicitTemplateSpecialization())
Manuel Klimek1da79332012-08-20 20:54:03 +00001323 matches the specialization A&lt;int&gt;().
1324
1325Usable 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;
1326</pre></td></tr>
1327
1328
Daniel Jaspere0b89972012-12-04 12:08:08 +00001329<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>
1330<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for
1331isSameOrDerivedFrom(hasName(...)).
1332</pre></td></tr>
1333
1334
Manuel Klimek415514d2013-02-06 20:36:22 +00001335<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isTemplateInstantiation2')"><a name="isTemplateInstantiation2Anchor">isTemplateInstantiation</a></td><td></td></tr>
1336<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static
Manuel Klimek1da79332012-08-20 20:54:03 +00001337member variable template instantiations.
1338
1339Given
1340 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
1341or
1342 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001343recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001344 matches the template instantiation of X&lt;A&gt;.
1345
1346But given
1347 template &lt;typename T&gt; class X {}; class A {};
1348 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001349recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001350 does not match, as X&lt;A&gt; is an explicit template specialization.
1351
1352Usable 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;
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_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 +00001357<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has
1358a specific number of arguments (including absent default arguments).
1359
Manuel Klimeke44a0062012-08-26 23:55:24 +00001360Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
Manuel Klimek1da79332012-08-20 20:54:03 +00001361 void f(int x, int y);
1362 f(0, 0);
1363</pre></td></tr>
1364
1365
Manuel Klimek67619ff2012-09-07 13:10:32 +00001366<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 +00001367<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value.
1368
1369Example matches true (matcher = boolLiteral(equals(true)))
1370 true
1371
1372Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1373 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;
1374</pre></td></tr>
1375
1376
Manuel Klimek67619ff2012-09-07 13:10:32 +00001377<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 +00001378<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of
1379child statements.
1380
1381Example: Given
1382 { for (;;) {} }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001383compoundStmt(statementCountIs(0)))
Manuel Klimek1da79332012-08-20 20:54:03 +00001384 matches '{}'
1385 but does not match the outer compound statement.
1386</pre></td></tr>
1387
1388
Daniel Jaspere0b89972012-12-04 12:08:08 +00001389<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>
1390<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size.
1391
1392Given
1393 int a[42];
1394 int b[2 * 21];
1395 int c[41], d[43];
1396constantArrayType(hasSize(42))
1397 matches "int a[42]" and "int b[2 * 21]"
1398</pre></td></tr>
1399
1400
Manuel Klimek67619ff2012-09-07 13:10:32 +00001401<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 +00001402<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of
1403declarations.
1404
1405Example: Given
1406 int a, b;
1407 int c;
1408 int d = 2, e;
1409declCountIs(2)
1410 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.
1411</pre></td></tr>
1412
1413
Manuel Klimekfa37c5c2013-02-07 12:42:10 +00001414<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('equalsNode0')"><a name="equalsNode0Anchor">equalsNode</a></td><td>Decl* Other</td></tr>
1415<tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node.
1416
1417Decl has pointer identity in the AST.
1418</pre></td></tr>
1419
1420
Daniel Jasperc7093d92013-02-25 12:39:41 +00001421<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isPrivate0')"><a name="isPrivate0Anchor">isPrivate</a></td><td></td></tr>
1422<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations.
1423
1424Given
1425 class C {
1426 public: int a;
1427 protected: int b;
1428 private: int c;
1429 };
1430fieldDecl(isPrivate())
1431 matches 'int c;'
1432</pre></td></tr>
1433
1434
1435<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isProtected0')"><a name="isProtected0Anchor">isProtected</a></td><td></td></tr>
1436<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations.
1437
1438Given
1439 class C {
1440 public: int a;
1441 protected: int b;
1442 private: int c;
1443 };
1444fieldDecl(isProtected())
1445 matches 'int b;'
1446</pre></td></tr>
1447
1448
1449<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isPublic0')"><a name="isPublic0Anchor">isPublic</a></td><td></td></tr>
1450<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations.
1451
1452Given
1453 class C {
1454 public: int a;
1455 protected: int b;
1456 private: int c;
1457 };
1458fieldDecl(isPublic())
1459 matches 'int a;'
1460</pre></td></tr>
1461
1462
Manuel Klimek67619ff2012-09-07 13:10:32 +00001463<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 +00001464<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value.
1465
1466Example matches true (matcher = boolLiteral(equals(true)))
1467 true
1468
1469Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1470 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;
1471</pre></td></tr>
1472
1473
Manuel Klimek415514d2013-02-06 20:36:22 +00001474<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isDefinition2')"><a name="isDefinition2Anchor">isDefinition</a></td><td></td></tr>
1475<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached.
Manuel Klimek1da79332012-08-20 20:54:03 +00001476
1477Example matches A, va, fa
1478 class A {};
1479 class B; Doesn't match, as it has no body.
1480 int va;
1481 extern int vb; Doesn't match, as it doesn't define the variable.
1482 void fa() {}
1483 void fb(); Doesn't match, as it has no body.
1484
1485Usable 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;
1486</pre></td></tr>
1487
1488
Manuel Klimek415514d2013-02-06 20:36:22 +00001489<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isExplicitTemplateSpecialization0')"><a name="isExplicitTemplateSpecialization0Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr>
1490<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or
Manuel Klimek1da79332012-08-20 20:54:03 +00001491static member variable template instantiations.
1492
1493Given
1494 template&lt;typename T&gt; void A(T t) { }
1495 template&lt;&gt; void A(int N) { }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001496functionDecl(isExplicitTemplateSpecialization())
Manuel Klimek1da79332012-08-20 20:54:03 +00001497 matches the specialization A&lt;int&gt;().
1498
1499Usable 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;
1500</pre></td></tr>
1501
1502
Manuel Klimek67619ff2012-09-07 13:10:32 +00001503<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 +00001504<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations.
1505
1506Given:
1507 extern "C" void f() {}
1508 extern "C" { void g() {} }
1509 void h() {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00001510functionDecl(isExternC())
Manuel Klimek1da79332012-08-20 20:54:03 +00001511 matches the declaration of f and g, but not the declaration h
1512</pre></td></tr>
1513
1514
Manuel Klimek415514d2013-02-06 20:36:22 +00001515<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isTemplateInstantiation0')"><a name="isTemplateInstantiation0Anchor">isTemplateInstantiation</a></td><td></td></tr>
1516<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static
Manuel Klimek1da79332012-08-20 20:54:03 +00001517member variable template instantiations.
1518
1519Given
1520 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
1521or
1522 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001523recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001524 matches the template instantiation of X&lt;A&gt;.
1525
1526But given
1527 template &lt;typename T&gt; class X {}; class A {};
1528 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001529recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001530 does not match, as X&lt;A&gt; is an explicit template specialization.
1531
1532Usable 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;
1533</pre></td></tr>
1534
1535
Daniel Jaspere0b89972012-12-04 12:08:08 +00001536<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>
1537<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count.
1538
1539Given
1540 void f(int i) {}
1541 void g(int i, int j) {}
1542functionDecl(parameterCountIs(2))
1543 matches g(int i, int j) {}
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_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 +00001548<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value.
1549
1550Example matches true (matcher = boolLiteral(equals(true)))
1551 true
1552
1553Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1554 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;
1555</pre></td></tr>
1556
1557
Manuel Klimek67619ff2012-09-07 13:10:32 +00001558<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 +00001559<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '-&gt;' as opposed
1560to '.'.
1561
1562Member calls on the implicit this pointer match as called with '-&gt;'.
1563
1564Given
1565 class Y {
1566 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
1567 int a;
1568 static int b;
1569 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00001570memberExpr(isArrow())
Manuel Klimek1da79332012-08-20 20:54:03 +00001571 matches this-&gt;x, x, y.x, a, this-&gt;b
1572</pre></td></tr>
1573
1574
Manuel Klimek67619ff2012-09-07 13:10:32 +00001575<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 +00001576<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name.
1577
1578Supports specifying enclosing namespaces or classes by prefixing the name
1579with '&lt;enclosing&gt;::'.
1580Does not match typedefs of an underlying type with the given name.
1581
1582Example matches X (Name == "X")
1583 class X;
1584
1585Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
1586 namespace a { namespace b { class X; } }
1587</pre></td></tr>
1588
1589
Manuel Klimek67619ff2012-09-07 13:10:32 +00001590<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 +00001591<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain
1592a substring matched by the given RegExp.
Manuel Klimek1da79332012-08-20 20:54:03 +00001593
1594Supports specifying enclosing namespaces or classes by
1595prefixing the name with '&lt;enclosing&gt;::'. Does not match typedefs
1596of an underlying type with the given name.
1597
1598Example matches X (regexp == "::X")
1599 class X;
1600
1601Example matches X (regexp is one of "::X", "^foo::.*X", among others)
1602 namespace foo { namespace bar { class X; } }
1603</pre></td></tr>
1604
1605
Manuel Klimek67619ff2012-09-07 13:10:32 +00001606<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 +00001607<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string.
1608
1609Given
1610 class Y { public: void x(); };
1611 void z() { Y* y; y-&gt;x(); }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001612callExpr(on(hasType(asString("class Y *"))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001613 matches y-&gt;x()
1614</pre></td></tr>
1615
1616
Manuel Klimek67619ff2012-09-07 13:10:32 +00001617<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 +00001618<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that
1619include "top-level" const.
1620
1621Given
1622 void a(int);
1623 void b(int const);
1624 void c(const int);
1625 void d(const int*);
1626 void e(int const) {};
Manuel Klimeke44a0062012-08-26 23:55:24 +00001627functionDecl(hasAnyParameter(hasType(isConstQualified())))
Manuel Klimek1da79332012-08-20 20:54:03 +00001628 matches "void b(int const)", "void c(const int)" and
1629 "void e(int const) {}". It does not match d as there
1630 is no top-level const on the parameter type "const int *".
1631</pre></td></tr>
1632
1633
Manuel Klimek67619ff2012-09-07 13:10:32 +00001634<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 +00001635<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type.
1636
1637Given
1638 void a(int);
1639 void b(long);
1640 void c(double);
Manuel Klimeke44a0062012-08-26 23:55:24 +00001641functionDecl(hasAnyParameter(hasType(isInteger())))
Manuel Klimek1da79332012-08-20 20:54:03 +00001642matches "a(int)", "b(long)", but not "c(double)".
1643</pre></td></tr>
1644
1645
Manuel Klimekfa37c5c2013-02-07 12:42:10 +00001646<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('equalsNode1')"><a name="equalsNode1Anchor">equalsNode</a></td><td>Stmt* Other</td></tr>
1647<tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node.
1648
1649Stmt has pointer identity in the AST.
1650
1651</pre></td></tr>
1652
1653
Manuel Klimek415514d2013-02-06 20:36:22 +00001654<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;</td><td class="name" onclick="toggle('isDefinition0')"><a name="isDefinition0Anchor">isDefinition</a></td><td></td></tr>
1655<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached.
Manuel Klimek1da79332012-08-20 20:54:03 +00001656
1657Example matches A, va, fa
1658 class A {};
1659 class B; Doesn't match, as it has no body.
1660 int va;
1661 extern int vb; Doesn't match, as it doesn't define the variable.
1662 void fa() {}
1663 void fb(); Doesn't match, as it has no body.
1664
1665Usable 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;
1666</pre></td></tr>
1667
1668
Manuel Klimek67619ff2012-09-07 13:10:32 +00001669<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 +00001670<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind.
1671
1672Given
1673 int x;
1674 int s = sizeof(x) + alignof(x)
1675unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
1676 matches sizeof(x)
1677</pre></td></tr>
1678
1679
Manuel Klimek67619ff2012-09-07 13:10:32 +00001680<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 +00001681<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or
1682unary).
1683
1684Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
1685 !(a || b)
1686</pre></td></tr>
1687
1688
Manuel Klimek67619ff2012-09-07 13:10:32 +00001689<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 +00001690<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached.
1691
1692Example matches A, va, fa
1693 class A {};
1694 class B; Doesn't match, as it has no body.
1695 int va;
1696 extern int vb; Doesn't match, as it doesn't define the variable.
1697 void fa() {}
1698 void fb(); Doesn't match, as it has no body.
1699
1700Usable 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;
1701</pre></td></tr>
1702
1703
Manuel Klimek67619ff2012-09-07 13:10:32 +00001704<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 +00001705<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or
1706static member variable template instantiations.
1707
1708Given
1709 template&lt;typename T&gt; void A(T t) { }
1710 template&lt;&gt; void A(int N) { }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001711functionDecl(isExplicitTemplateSpecialization())
Manuel Klimek1da79332012-08-20 20:54:03 +00001712 matches the specialization A&lt;int&gt;().
1713
1714Usable 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;
1715</pre></td></tr>
1716
1717
Manuel Klimek67619ff2012-09-07 13:10:32 +00001718<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 +00001719<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static
1720member variable template instantiations.
1721
1722Given
1723 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
1724or
1725 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001726recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001727 matches the template instantiation of X&lt;A&gt;.
1728
1729But given
1730 template &lt;typename T&gt; class X {}; class A {};
1731 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001732recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001733 does not match, as X&lt;A&gt; is an explicit template specialization.
1734
1735Usable 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;
1736</pre></td></tr>
1737
1738<!--END_NARROWING_MATCHERS -->
1739</table>
1740
1741<!-- ======================================================================= -->
1742<h2 id="traversal-matchers">AST Traversal Matchers</h2>
1743<!-- ======================================================================= -->
1744
1745<p>Traversal matchers specify the relationship to other nodes that are
1746reachable from the current node.</p>
1747
1748<p>Note that there are special traversal matchers (has, hasDescendant, forEach and
1749forEachDescendant) which work on all nodes and allow users to write more generic
1750match expressions.</p>
1751
1752<table>
1753<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
1754<!-- START_TRAVERSAL_MATCHERS -->
1755
Manuel Klimek152ea0e2013-02-04 10:59:20 +00001756<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher&lt;*&gt; P1, Matcher&lt;*&gt; P2</td></tr>
1757<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches.
1758
1759Unlike anyOf, eachOf will generate a match result for each
1760matching submatcher.
1761
1762For example, in:
1763 class A { int a; int b; };
1764The matcher:
1765 recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
1766 has(fieldDecl(hasName("b")).bind("v"))))
1767will generate two results binding "v", the first of which binds
1768the field declaration of a, the second the field declaration of
1769b.
1770
1771Usable as: Any Matcher
1772</pre></td></tr>
1773
1774
1775<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher&lt;T&gt; Matcher</td></tr>
1776<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches.
1777
1778Generates results for each match.
1779
1780For example, in:
1781 class A { class B {}; class C {}; };
1782The matcher:
1783 recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m")))
1784will generate results for A, B and C.
1785
1786Usable as: Any Matcher
1787</pre></td></tr>
1788
1789
Manuel Klimek67619ff2012-09-07 13:10:32 +00001790<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 +00001791<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the
1792provided matcher.
1793
Manuel Klimeke44a0062012-08-26 23:55:24 +00001794Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X")))
Manuel Klimek1da79332012-08-20 20:54:03 +00001795 class X {}; Matches X, because X::X is a class of name X inside X.
1796 class Y { class X {}; };
1797 class Z { class Y { class X {}; }; }; Does not match Z.
1798
1799ChildT must be an AST base type.
1800
1801As opposed to 'has', 'forEach' will cause a match for each result that
1802matches instead of only on the first one.
1803
1804Usable as: Any Matcher
1805</pre></td></tr>
1806
1807
Manuel Klimek67619ff2012-09-07 13:10:32 +00001808<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 +00001809<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
1810provided matcher.
1811
1812Example matches X, A, B, C
Manuel Klimeke44a0062012-08-26 23:55:24 +00001813 (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001814 class X {}; Matches X, because X::X is a class of name X inside X.
1815 class A { class X {}; };
1816 class B { class C { class X {}; }; };
1817
1818DescendantT must be an AST base type.
1819
1820As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
1821each result that matches instead of only on the first one.
1822
1823Note: Recursively combined ForEachDescendant can cause many matches:
Manuel Klimeke44a0062012-08-26 23:55:24 +00001824 recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl()))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001825will match 10 times (plus injected class name matches) on:
1826 class A { class B { class C { class D { class E {}; }; }; }; };
1827
1828Usable as: Any Matcher
1829</pre></td></tr>
1830
1831
Manuel Klimek67619ff2012-09-07 13:10:32 +00001832<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 +00001833<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the
1834provided matcher.
1835
Manuel Klimeke44a0062012-08-26 23:55:24 +00001836Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X")))
Manuel Klimek1da79332012-08-20 20:54:03 +00001837 class X {}; Matches X, because X::X is a class of name X inside X.
1838 class Y { class X {}; };
1839 class Z { class Y { class X {}; }; }; Does not match Z.
1840
1841ChildT must be an AST base type.
1842
1843Usable as: Any Matcher
1844</pre></td></tr>
1845
1846
Manuel Klimek67619ff2012-09-07 13:10:32 +00001847<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>
1848<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided
1849matcher.
1850
1851Given
1852void f() { if (true) { int x = 42; } }
1853void g() { for (;;) { int x = 43; } }
Daniel Jaspere0b89972012-12-04 12:08:08 +00001854expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.
Manuel Klimek67619ff2012-09-07 13:10:32 +00001855
1856Usable as: Any Matcher
1857</pre></td></tr>
1858
1859
1860<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 +00001861<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
1862provided matcher.
1863
1864Example matches X, Y, Z
Manuel Klimeke44a0062012-08-26 23:55:24 +00001865 (matcher = recordDecl(hasDescendant(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001866 class X {}; Matches X, because X::X is a class of name X inside X.
1867 class Y { class X {}; };
1868 class Z { class Y { class X {}; }; };
1869
1870DescendantT must be an AST base type.
1871
1872Usable as: Any Matcher
1873</pre></td></tr>
1874
1875
Daniel Jaspere0b89972012-12-04 12:08:08 +00001876<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>
1877<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided
1878matcher.
1879
1880Given
1881void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
1882compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".
1883
1884Usable as: Any Matcher
1885</pre></td></tr>
1886
1887
Manuel Klimek67619ff2012-09-07 13:10:32 +00001888<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 +00001889<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression.
1890
1891Given
1892 int i[5];
1893 void f() { i[1] = 42; }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001894arraySubscriptExpression(hasBase(implicitCastExpr(
1895 hasSourceExpression(declRefExpr()))))
1896 matches i[1] with the declRefExpr() matching i
Manuel Klimek1da79332012-08-20 20:54:03 +00001897</pre></td></tr>
1898
1899
Manuel Klimek67619ff2012-09-07 13:10:32 +00001900<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 +00001901<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression.
1902
1903Given
1904 int i[5];
1905 void f() { i[1] = 42; }
1906arraySubscriptExpression(hasIndex(integerLiteral()))
1907 matches i[1] with the integerLiteral() matching 1
1908</pre></td></tr>
1909
1910
Manuel Klimek41df16e2013-01-09 09:38:21 +00001911<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>
1912<tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element
1913type.
1914
1915Given
1916 struct A {};
1917 A a[7];
1918 int b[7];
1919arrayType(hasElementType(builtinType()))
1920 matches "int b[7]"
1921
1922Usable 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;
1923</pre></td></tr>
1924
1925
1926<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>
1927<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element
1928type.
1929
1930Given
1931 struct A {};
1932 A a[7];
1933 int b[7];
1934arrayType(hasElementType(builtinType()))
1935 matches "int b[7]"
1936
1937Usable 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;
1938</pre></td></tr>
1939
1940
1941<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>
1942<tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type.
1943
1944Given
1945 _Atomic(int) i;
1946 _Atomic(float) f;
1947atomicType(hasValueType(isInteger()))
1948 matches "_Atomic(int) i"
1949
1950Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
1951</pre></td></tr>
1952
1953
1954<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>
1955<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type.
1956
1957Given
1958 _Atomic(int) i;
1959 _Atomic(float) f;
1960atomicType(hasValueType(isInteger()))
1961 matches "_Atomic(int) i"
1962
1963Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
1964</pre></td></tr>
1965
1966
1967<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>
1968<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type.
1969
1970Note: There is no TypeLoc for the deduced type and thus no
1971getDeducedLoc() matcher.
1972
1973Given
1974 auto a = 1;
1975 auto b = 2.0;
1976autoType(hasDeducedType(isInteger()))
1977 matches "auto a"
1978
1979Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>&gt;
1980</pre></td></tr>
1981
1982
Manuel Klimek67619ff2012-09-07 13:10:32 +00001983<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 +00001984<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a
1985binary operator matches.
1986</pre></td></tr>
1987
1988
Manuel Klimek67619ff2012-09-07 13:10:32 +00001989<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 +00001990<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions.
1991
1992Example matches a (matcher = binaryOperator(hasLHS()))
1993 a || b
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_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 +00001998<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions.
1999
2000Example matches b (matcher = binaryOperator(hasRHS()))
2001 a || b
2002</pre></td></tr>
2003
2004
Manuel Klimek41df16e2013-01-09 09:38:21 +00002005<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>
2006<tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the
2007pointee matches a given matcher.
2008
2009Given
2010 int *a;
2011 int const *b;
2012 float const *f;
2013pointerType(pointee(isConstQualified(), isInteger()))
2014 matches "int const *b"
2015
2016Usable 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;,
2017 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;
2018</pre></td></tr>
2019
2020
2021<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>
2022<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the
2023pointee matches a given matcher.
2024
2025Given
2026 int *a;
2027 int const *b;
2028 float const *f;
2029pointerType(pointee(isConstQualified(), isInteger()))
2030 matches "int const *b"
2031
2032Usable 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;,
2033 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;
2034</pre></td></tr>
2035
2036
Edwin Vane52380602013-02-19 17:14:34 +00002037<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</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>
2038<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 +00002039matcher.
2040
Edwin Vane52380602013-02-19 17:14:34 +00002041In addition to being usable as Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, also usable as
2042Matcher&lt;T&gt; for any T supporting the getDecl() member function. e.g. various
2043subtypes of clang::Type.
2044
Daniel Jaspere0b89972012-12-04 12:08:08 +00002045Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
Edwin Vane52380602013-02-19 17:14:34 +00002046 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;
Manuel Klimek1da79332012-08-20 20:54:03 +00002047</pre></td></tr>
2048
2049
Manuel Klimek67619ff2012-09-07 13:10:32 +00002050<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 +00002051<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer.
2052
2053Given
2054 struct Foo {
2055 Foo() : foo_(1) { }
2056 int foo_;
2057 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002058recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything()))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002059 record matches Foo, hasAnyConstructorInitializer matches foo_(1)
2060</pre></td></tr>
2061
2062
Manuel Klimek67619ff2012-09-07 13:10:32 +00002063<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 +00002064<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer.
2065
2066Given
2067 struct Foo {
2068 Foo() : foo_(1) { }
2069 int foo_;
2070 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002071recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
Manuel Klimek1da79332012-08-20 20:54:03 +00002072 forField(hasName("foo_"))))))
2073 matches Foo
2074with forField matching foo_
2075</pre></td></tr>
2076
2077
Manuel Klimek67619ff2012-09-07 13:10:32 +00002078<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 +00002079<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer.
2080
2081Given
2082 struct Foo {
2083 Foo() : foo_(1) { }
2084 int foo_;
2085 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002086recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
Manuel Klimek1da79332012-08-20 20:54:03 +00002087 withInitializer(integerLiteral(equals(1)))))))
2088 matches Foo
2089with withInitializer matching (1)
2090</pre></td></tr>
2091
2092
Manuel Klimek67619ff2012-09-07 13:10:32 +00002093<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 +00002094<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression.
2095
Manuel Klimeke44a0062012-08-26 23:55:24 +00002096Example matches y.x() (matcher = callExpr(on(hasType(recordDecl(hasName("Y"))))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002097 class Y { public: void x(); };
2098 void z() { Y y; y.x(); }",
2099
2100FIXME: Overload to allow directly matching types?
2101</pre></td></tr>
2102
2103
Manuel Klimek67619ff2012-09-07 13:10:32 +00002104<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 +00002105<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr>
2106
2107
Manuel Klimek67619ff2012-09-07 13:10:32 +00002108<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 +00002109<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration.
2110</pre></td></tr>
2111
2112
Manuel Klimek67619ff2012-09-07 13:10:32 +00002113<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 +00002114<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration
2115belongs to.
2116
2117FIXME: Generalize this for other kinds of declarations.
2118FIXME: What other kind of declarations would we need to generalize
2119this to?
2120
2121Example matches A() in the last line
Manuel Klimeke44a0062012-08-26 23:55:24 +00002122 (matcher = constructExpr(hasDeclaration(methodDecl(
Manuel Klimek1da79332012-08-20 20:54:03 +00002123 ofClass(hasName("A"))))))
2124 class A {
2125 public:
2126 A();
2127 };
2128 A a = A();
2129</pre></td></tr>
2130
2131
Manuel Klimek67619ff2012-09-07 13:10:32 +00002132<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 +00002133<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from
2134a class matching Base.
2135
Manuel Klimek67619ff2012-09-07 13:10:32 +00002136Note that a class is not considered to be derived from itself.
Manuel Klimek1da79332012-08-20 20:54:03 +00002137
Manuel Klimek67619ff2012-09-07 13:10:32 +00002138Example matches Y, Z, C (Base == hasName("X"))
2139 class X;
Manuel Klimek1da79332012-08-20 20:54:03 +00002140 class Y : public X {}; directly derived
2141 class Z : public Y {}; indirectly derived
2142 typedef X A;
2143 typedef A B;
2144 class C : public B {}; derived from a typedef of X
2145
2146In the following example, Bar matches isDerivedFrom(hasName("X")):
2147 class Foo;
2148 typedef Foo X;
2149 class Bar : public Foo {}; derived from a type that X is a typedef of
2150</pre></td></tr>
2151
2152
Daniel Jaspere0b89972012-12-04 12:08:08 +00002153<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>
2154<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly
2155match Base.
2156</pre></td></tr>
2157
2158
Manuel Klimek67619ff2012-09-07 13:10:32 +00002159<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 +00002160<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the
2161given matcher.
2162
Manuel Klimeke44a0062012-08-26 23:55:24 +00002163Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002164 class Y { public: void x(); };
2165 void z() { Y y; y.x();
2166</pre></td></tr>
2167
2168
Manuel Klimek67619ff2012-09-07 13:10:32 +00002169<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 +00002170<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call
2171expression.
2172
2173Given
2174 void x(int, int, int) { int y; x(1, y, 42); }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002175callExpr(hasAnyArgument(declRefExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002176 matches x(1, y, 42)
2177with hasAnyArgument(...)
2178 matching y
2179</pre></td></tr>
2180
2181
Manuel Klimek67619ff2012-09-07 13:10:32 +00002182<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 +00002183<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor
2184call expression.
2185
2186Example matches y in x(y)
Manuel Klimeke44a0062012-08-26 23:55:24 +00002187 (matcher = callExpr(hasArgument(0, declRefExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002188 void x(int) { int y; x(y); }
2189</pre></td></tr>
2190
2191
Edwin Vane52380602013-02-19 17:14:34 +00002192<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</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>
2193<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 +00002194matcher.
2195
Edwin Vane52380602013-02-19 17:14:34 +00002196In addition to being usable as Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, also usable as
2197Matcher&lt;T&gt; for any T supporting the getDecl() member function. e.g. various
2198subtypes of clang::Type.
2199
Daniel Jaspere0b89972012-12-04 12:08:08 +00002200Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
Edwin Vane52380602013-02-19 17:14:34 +00002201 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;
Manuel Klimek1da79332012-08-20 20:54:03 +00002202</pre></td></tr>
2203
2204
Manuel Klimek67619ff2012-09-07 13:10:32 +00002205<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 +00002206<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher.
2207
2208Example: matches "a string" (matcher =
Manuel Klimeke44a0062012-08-26 23:55:24 +00002209 hasSourceExpression(constructExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002210class URL { URL(string); };
2211URL url = "a string";
2212</pre></td></tr>
2213
2214
Manuel Klimek67619ff2012-09-07 13:10:32 +00002215<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 +00002216<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one
2217TemplateArgument matching the given InnerMatcher.
2218
2219Given
2220 template&lt;typename T&gt; class A {};
2221 template&lt;&gt; class A&lt;double&gt; {};
2222 A&lt;int&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002223classTemplateSpecializationDecl(hasAnyTemplateArgument(
Manuel Klimek1da79332012-08-20 20:54:03 +00002224 refersToType(asString("int"))))
2225 matches the specialization A&lt;int&gt;
2226</pre></td></tr>
2227
2228
Manuel Klimek67619ff2012-09-07 13:10:32 +00002229<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 +00002230<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument
2231matches the given InnerMatcher.
2232
2233Given
2234 template&lt;typename T, typename U&gt; class A {};
2235 A&lt;bool, int&gt; b;
2236 A&lt;int, bool&gt; c;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002237classTemplateSpecializationDecl(hasTemplateArgument(
Manuel Klimek1da79332012-08-20 20:54:03 +00002238 1, refersToType(asString("int"))))
2239 matches the specialization A&lt;bool, int&gt;
2240</pre></td></tr>
2241
2242
Manuel Klimek41df16e2013-01-09 09:38:21 +00002243<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>
2244<tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element
2245type.
2246
2247Given
2248 struct A {};
2249 A a[7];
2250 int b[7];
2251arrayType(hasElementType(builtinType()))
2252 matches "int b[7]"
2253
2254Usable 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;
2255</pre></td></tr>
2256
2257
2258<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>
2259<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element
2260type.
2261
2262Given
2263 struct A {};
2264 A a[7];
2265 int b[7];
2266arrayType(hasElementType(builtinType()))
2267 matches "int b[7]"
2268
2269Usable 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;
2270</pre></td></tr>
2271
2272
Manuel Klimek67619ff2012-09-07 13:10:32 +00002273<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 +00002274<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches
2275a given matcher.
2276
2277Given
2278 { {}; 1+2; }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002279hasAnySubstatement(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00002280 matches '{ {}; 1+2; }'
Manuel Klimeke44a0062012-08-26 23:55:24 +00002281with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00002282 matching '{}'
2283</pre></td></tr>
2284
2285
Manuel Klimek67619ff2012-09-07 13:10:32 +00002286<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 +00002287<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop,
2288or conditional operator.
2289
2290Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2291 if (true) {}
2292</pre></td></tr>
2293
2294
Manuel Klimek67619ff2012-09-07 13:10:32 +00002295<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 +00002296<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator.
2297
2298Example matches b
2299 condition ? a : b
2300</pre></td></tr>
2301
2302
Manuel Klimek67619ff2012-09-07 13:10:32 +00002303<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 +00002304<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator.
2305
2306Example matches a
2307 condition ? a : b
2308</pre></td></tr>
2309
2310
Manuel Klimek67619ff2012-09-07 13:10:32 +00002311<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 +00002312<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a
2313specific using shadow declaration.
2314
2315FIXME: This currently only works for functions. Fix.
2316
2317Given
2318 namespace a { void f() {} }
2319 using a::f;
2320 void g() {
2321 f(); Matches this ..
2322 a::f(); .. but not this.
2323 }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002324declRefExpr(throughUsingDeclaration(anything()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002325 matches f()
2326</pre></td></tr>
2327
2328
Manuel Klimek67619ff2012-09-07 13:10:32 +00002329<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 +00002330<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the
2331specified matcher.
2332
2333Example matches x in if(x)
Manuel Klimeke44a0062012-08-26 23:55:24 +00002334 (matcher = declRefExpr(to(varDecl(hasName("x")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002335 bool x;
2336 if (x) {}
2337</pre></td></tr>
2338
2339
Manuel Klimek67619ff2012-09-07 13:10:32 +00002340<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00002341<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement.
2342
2343Note that this does not work for global declarations because the AST
2344breaks up multiple-declaration DeclStmt's into multiple single-declaration
2345DeclStmt's.
2346Example: Given non-global declarations
2347 int a, b = 0;
2348 int c;
2349 int d = 2, e;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002350declStmt(containsDeclaration(
2351 0, varDecl(hasInitializer(anything()))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002352 matches only 'int d = 2, e;', and
Manuel Klimeke44a0062012-08-26 23:55:24 +00002353declStmt(containsDeclaration(1, varDecl()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002354 matches 'int a, b = 0' as well as 'int d = 2, e;'
2355 but 'int c;' is not matched.
2356</pre></td></tr>
2357
2358
Manuel Klimek67619ff2012-09-07 13:10:32 +00002359<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 +00002360<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration.
2361
2362Given
2363 int a, b;
2364 int c;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002365declStmt(hasSingleDecl(anything()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002366 matches 'int c;' but not 'int a, b;'.
2367</pre></td></tr>
2368
2369
Manuel Klimek67619ff2012-09-07 13:10:32 +00002370<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00002371<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has
2372a given body.
2373
2374Given
2375 for (;;) {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00002376hasBody(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00002377 matches 'for (;;) {}'
Manuel Klimeke44a0062012-08-26 23:55:24 +00002378with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00002379 matching '{}'
2380</pre></td></tr>
2381
2382
Manuel Klimek67619ff2012-09-07 13:10:32 +00002383<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 +00002384<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop,
2385or conditional operator.
2386
2387Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2388 if (true) {}
2389</pre></td></tr>
2390
2391
Manuel Klimek67619ff2012-09-07 13:10:32 +00002392<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 +00002393<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher.
2394
2395(Note: Clang's AST refers to other conversions as "casts" too, and calls
2396actual casts "explicit" casts.)
2397</pre></td></tr>
2398
2399
Manuel Klimek67619ff2012-09-07 13:10:32 +00002400<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 +00002401<tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value
2402declaration's type.
2403
2404In case of a value declaration (for example a variable declaration),
2405this resolves one layer of indirection. For example, in the value
Manuel Klimeke44a0062012-08-26 23:55:24 +00002406declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
2407while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
Manuel Klimek1da79332012-08-20 20:54:03 +00002408of x."
2409
Manuel Klimeke44a0062012-08-26 23:55:24 +00002410Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
2411 and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002412 class X {};
2413 void y(X &amp;x) { x; X z; }
2414
2415Usable 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;
2416</pre></td></tr>
2417
2418
Manuel Klimek67619ff2012-09-07 13:10:32 +00002419<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 +00002420<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts
2421are stripped off.
2422
2423Parentheses and explicit casts are not discarded.
2424Given
2425 int arr[5];
2426 int a = 0;
2427 char b = 0;
2428 const int c = a;
2429 int *d = arr;
2430 long e = (long) 0l;
2431The matchers
Manuel Klimeke44a0062012-08-26 23:55:24 +00002432 varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
2433 varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002434would match the declarations for a, b, c, and d, but not e.
2435While
Manuel Klimeke44a0062012-08-26 23:55:24 +00002436 varDecl(hasInitializer(integerLiteral()))
2437 varDecl(hasInitializer(declRefExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002438only match the declarations for b, c, and d.
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_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 +00002443<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and
2444casts are stripped off.
2445
2446Implicit and non-C Style casts are also discarded.
2447Given
2448 int a = 0;
2449 char b = (0);
2450 void* c = reinterpret_cast&lt;char*&gt;(0);
2451 char d = char(0);
2452The matcher
Manuel Klimeke44a0062012-08-26 23:55:24 +00002453 varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002454would match the declarations for a, b, c, and d.
2455while
Manuel Klimeke44a0062012-08-26 23:55:24 +00002456 varDecl(hasInitializer(integerLiteral()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002457only match the declaration for a.
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_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 +00002462<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and
2463parentheses are stripped off.
2464
2465Explicit casts are not discarded.
2466Given
2467 int arr[5];
2468 int a = 0;
2469 char b = (0);
2470 const int c = a;
2471 int *d = (arr);
2472 long e = ((long) 0l);
2473The matchers
Manuel Klimeke44a0062012-08-26 23:55:24 +00002474 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
2475 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002476would match the declarations for a, b, c, and d, but not e.
2477while
Manuel Klimeke44a0062012-08-26 23:55:24 +00002478 varDecl(hasInitializer(integerLiteral()))
2479 varDecl(hasInitializer(declRefExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002480would only match the declaration for a.
2481</pre></td></tr>
2482
2483
Manuel Klimek67619ff2012-09-07 13:10:32 +00002484<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 +00002485<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has
2486a given body.
2487
2488Given
2489 for (;;) {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00002490hasBody(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00002491 matches 'for (;;) {}'
Manuel Klimeke44a0062012-08-26 23:55:24 +00002492with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00002493 matching '{}'
2494</pre></td></tr>
2495
2496
Manuel Klimek67619ff2012-09-07 13:10:32 +00002497<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 +00002498<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop,
2499or conditional operator.
2500
2501Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2502 if (true) {}
2503</pre></td></tr>
2504
2505
Manuel Klimek67619ff2012-09-07 13:10:32 +00002506<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 +00002507<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop.
2508
2509Example:
2510 forStmt(hasIncrement(unaryOperator(hasOperatorName("++"))))
2511matches '++x' in
2512 for (x; x &lt; N; ++x) { }
2513</pre></td></tr>
2514
2515
Manuel Klimek67619ff2012-09-07 13:10:32 +00002516<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 +00002517<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop.
2518
2519Example:
Manuel Klimeke44a0062012-08-26 23:55:24 +00002520 forStmt(hasLoopInit(declStmt()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002521matches 'int x = 0' in
2522 for (int x = 0; x &lt; N; ++x) { }
2523</pre></td></tr>
2524
2525
Manuel Klimek67619ff2012-09-07 13:10:32 +00002526<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 +00002527<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration.
2528
2529Does not match the 'this' parameter of a method.
2530
2531Given
2532 class X { void f(int x, int y, int z) {} };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002533methodDecl(hasAnyParameter(hasName("y")))
Manuel Klimek1da79332012-08-20 20:54:03 +00002534 matches f(int x, int y, int z) {}
2535with hasAnyParameter(...)
2536 matching int y
2537</pre></td></tr>
2538
2539
Manuel Klimek67619ff2012-09-07 13:10:32 +00002540<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 +00002541<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration.
2542
2543Given
2544 class X { void f(int x) {} };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002545methodDecl(hasParameter(0, hasType(varDecl())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002546 matches f(int x) {}
2547with hasParameter(...)
2548 matching int x
2549</pre></td></tr>
2550
2551
Manuel Klimek67619ff2012-09-07 13:10:32 +00002552<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 +00002553<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration.
2554
2555Given:
2556 class X { int f() { return 1; } };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002557methodDecl(returns(asString("int")))
Manuel Klimek1da79332012-08-20 20:54:03 +00002558 matches int f() { return 1; }
2559</pre></td></tr>
2560
2561
Manuel Klimek67619ff2012-09-07 13:10:32 +00002562<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 +00002563<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop,
2564or conditional operator.
2565
2566Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2567 if (true) {}
2568</pre></td></tr>
2569
2570
Manuel Klimek67619ff2012-09-07 13:10:32 +00002571<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 +00002572<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement.
2573
2574Given
2575 if (A* a = GetAPointer()) {}
2576hasConditionVariableStatment(...)
2577 matches 'A* a = GetAPointer()'.
2578</pre></td></tr>
2579
2580
Manuel Klimek67619ff2012-09-07 13:10:32 +00002581<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 +00002582<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given
2583matcher.
2584
2585FIXME: Unit test this matcher
2586</pre></td></tr>
2587
2588
Edwin Vane52380602013-02-19 17:14:34 +00002589<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</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>
2590<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a type if the declaration of the type matches the given
Daniel Jaspere0b89972012-12-04 12:08:08 +00002591matcher.
2592
Edwin Vane52380602013-02-19 17:14:34 +00002593In addition to being usable as Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, also usable as
2594Matcher&lt;T&gt; for any T supporting the getDecl() member function. e.g. various
2595subtypes of clang::Type.
2596
Daniel Jaspere0b89972012-12-04 12:08:08 +00002597Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
Edwin Vane52380602013-02-19 17:14:34 +00002598 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;
Daniel Jaspere0b89972012-12-04 12:08:08 +00002599</pre></td></tr>
2600
2601
Manuel Klimek67619ff2012-09-07 13:10:32 +00002602<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 +00002603<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is
2604matched by a given matcher.
2605
2606Given
2607 struct X { int m; };
2608 void f(X x) { x.m; m; }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002609memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002610 matches "x.m" and "m"
2611with hasObjectExpression(...)
2612 matching "x" and the implicit object expression of "m" which has type X*.
2613</pre></td></tr>
2614
2615
Manuel Klimek67619ff2012-09-07 13:10:32 +00002616<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00002617<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a
2618given matcher.
2619
2620Given
2621 struct { int first, second; } first, second;
2622 int i(second.first);
2623 int j(first.second);
Manuel Klimeke44a0062012-08-26 23:55:24 +00002624memberExpr(member(hasName("first")))
Manuel Klimek1da79332012-08-20 20:54:03 +00002625 matches second.first
2626 but not first.second (because the member name there is "second").
2627</pre></td></tr>
2628
2629
Manuel Klimek41df16e2013-01-09 09:38:21 +00002630<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>
2631<tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the
2632pointee matches a given matcher.
2633
2634Given
2635 int *a;
2636 int const *b;
2637 float const *f;
2638pointerType(pointee(isConstQualified(), isInteger()))
2639 matches "int const *b"
2640
2641Usable 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;,
2642 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;
2643</pre></td></tr>
2644
2645
2646<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>
2647<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the
2648pointee matches a given matcher.
2649
2650Given
2651 int *a;
2652 int const *b;
2653 float const *f;
2654pointerType(pointee(isConstQualified(), isInteger()))
2655 matches "int const *b"
2656
2657Usable 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;,
2658 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;
2659</pre></td></tr>
2660
2661
Manuel Klimek415514d2013-02-06 20:36:22 +00002662<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>&gt;</td><td class="name" onclick="toggle('hasPrefix1')"><a name="hasPrefix1Anchor">hasPrefix</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>&gt; InnerMatcher</td></tr>
Daniel Jaspere0b89972012-12-04 12:08:08 +00002663<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc.
2664
2665Given
2666 struct A { struct B { struct C {}; }; };
2667 A::B::C c;
2668nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A")))))
2669 matches "A::"
2670</pre></td></tr>
2671
2672
Manuel Klimek41df16e2013-01-09 09:38:21 +00002673<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>
2674<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner
2675NestedNameSpecifier-matcher matches.
2676</pre></td></tr>
2677
2678
Daniel Jaspere0b89972012-12-04 12:08:08 +00002679<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>
2680<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the
2681given TypeLoc.
2682
2683Given
2684 struct A { struct B { struct C {}; }; };
2685 A::B::C c;
2686nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
2687 hasDeclaration(recordDecl(hasName("A")))))))
2688 matches "A::"
2689</pre></td></tr>
2690
2691
Manuel Klimek415514d2013-02-06 20:36:22 +00002692<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt;</td><td class="name" onclick="toggle('hasPrefix0')"><a name="hasPrefix0Anchor">hasPrefix</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt; InnerMatcher</td></tr>
Daniel Jaspere0b89972012-12-04 12:08:08 +00002693<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier.
2694
2695Given
2696 struct A { struct B { struct C {}; }; };
2697 A::B::C c;
2698nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and
2699 matches "A::"
2700</pre></td></tr>
2701
2702
2703<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>
2704<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the
2705given namespace matcher.
2706
2707Given
2708 namespace ns { struct A {}; }
2709 ns::A a;
2710nestedNameSpecifier(specifiesNamespace(hasName("ns")))
2711 matches "ns::"
2712</pre></td></tr>
2713
2714
2715<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>
2716<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the
2717given QualType matcher without qualifiers.
2718
2719Given
2720 struct A { struct B { struct C {}; }; };
2721 A::B::C c;
2722nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A")))))
2723 matches "A::"
2724</pre></td></tr>
2725
2726
Manuel Klimek41df16e2013-01-09 09:38:21 +00002727<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>
2728<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the
2729pointee matches a given matcher.
2730
2731Given
2732 int *a;
2733 int const *b;
2734 float const *f;
2735pointerType(pointee(isConstQualified(), isInteger()))
2736 matches "int const *b"
2737
2738Usable 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;,
2739 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;
2740</pre></td></tr>
2741
2742
2743<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>
2744<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the
2745pointee matches a given matcher.
2746
2747Given
2748 int *a;
2749 int const *b;
2750 float const *f;
2751pointerType(pointee(isConstQualified(), isInteger()))
2752 matches "int const *b"
2753
2754Usable 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;,
2755 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;
2756</pre></td></tr>
2757
2758
Edwin Vane52380602013-02-19 17:14:34 +00002759<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration4')"><a name="hasDeclaration4Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
2760<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a type if the declaration of the type matches the given
Manuel Klimek1da79332012-08-20 20:54:03 +00002761matcher.
2762
Edwin Vane52380602013-02-19 17:14:34 +00002763In addition to being usable as Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, also usable as
2764Matcher&lt;T&gt; for any T supporting the getDecl() member function. e.g. various
2765subtypes of clang::Type.
2766
Daniel Jaspere0b89972012-12-04 12:08:08 +00002767Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
Edwin Vane52380602013-02-19 17:14:34 +00002768 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;
Manuel Klimek1da79332012-08-20 20:54:03 +00002769</pre></td></tr>
2770
2771
Manuel Klimek67619ff2012-09-07 13:10:32 +00002772<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 +00002773<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration.
2774</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_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 +00002778<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration.
2779</pre></td></tr>
2780
2781
Manuel Klimek41df16e2013-01-09 09:38:21 +00002782<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>
2783<tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the
2784pointee matches a given matcher.
2785
2786Given
2787 int *a;
2788 int const *b;
2789 float const *f;
2790pointerType(pointee(isConstQualified(), isInteger()))
2791 matches "int const *b"
2792
2793Usable 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;,
2794 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;
2795</pre></td></tr>
2796
2797
2798<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>
2799<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the
2800pointee matches a given matcher.
2801
2802Given
2803 int *a;
2804 int const *b;
2805 float const *f;
2806pointerType(pointee(isConstQualified(), isInteger()))
2807 matches "int const *b"
2808
2809Usable 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;,
2810 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;
2811</pre></td></tr>
2812
2813
Manuel Klimek67619ff2012-09-07 13:10:32 +00002814<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 +00002815<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
2816alignof.
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_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 +00002821<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
2822sizeof.
2823</pre></td></tr>
2824
2825
Manuel Klimek67619ff2012-09-07 13:10:32 +00002826<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 +00002827<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a TemplateArgument that refers to a certain declaration.
2828
2829Given
2830 template&lt;typename T&gt; struct A {};
2831 struct B { B* next; };
2832 A&lt;&amp;B::next&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002833classTemplateSpecializationDecl(hasAnyTemplateArgument(
2834 refersToDeclaration(fieldDecl(hasName("next"))))
2835 matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
Manuel Klimek1da79332012-08-20 20:54:03 +00002836 B::next
2837</pre></td></tr>
2838
2839
Manuel Klimek67619ff2012-09-07 13:10:32 +00002840<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 +00002841<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type.
2842
2843Given
2844 struct X {};
2845 template&lt;typename T&gt; struct A {};
2846 A&lt;X&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002847classTemplateSpecializationDecl(hasAnyTemplateArgument(
Manuel Klimek1da79332012-08-20 20:54:03 +00002848 refersToType(class(hasName("X")))))
2849 matches the specialization A&lt;X&gt;
2850</pre></td></tr>
2851
2852
Manuel Klimek41df16e2013-01-09 09:38:21 +00002853<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>
2854<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner
2855QualType-matcher matches.
2856</pre></td></tr>
2857
2858
Edwin Vane52380602013-02-19 17:14:34 +00002859<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</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>
2860<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a type if the declaration of the type matches the given
2861matcher.
2862
2863In addition to being usable as Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, also usable as
2864Matcher&lt;T&gt; for any T supporting the getDecl() member function. e.g. various
2865subtypes of clang::Type.
2866
2867Usable 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;,
2868 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;
Daniel Jaspere0b89972012-12-04 12:08:08 +00002869</pre></td></tr>
2870
2871
Manuel Klimek67619ff2012-09-07 13:10:32 +00002872<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 +00002873<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument.
2874
2875Given
2876 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
2877unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
2878 matches sizeof(a) and alignof(c)
2879</pre></td></tr>
2880
2881
Manuel Klimek67619ff2012-09-07 13:10:32 +00002882<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 +00002883<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches.
2884
Daniel Jaspere0b89972012-12-04 12:08:08 +00002885Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002886 !true
2887</pre></td></tr>
2888
2889
Manuel Klimek67619ff2012-09-07 13:10:32 +00002890<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00002891<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration.
2892
2893Given
2894 namespace X { void b(); }
2895 using X::b;
2896usingDecl(hasAnyUsingShadowDecl(hasName("b"))))
2897 matches using X::b </pre></td></tr>
2898
2899
Manuel Klimek67619ff2012-09-07 13:10:32 +00002900<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00002901<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is
2902matched by the given matcher.
2903
2904Given
2905 namespace X { int a; void b(); }
2906 using X::a;
2907 using X::b;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002908usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002909 matches using X::b but not using X::a </pre></td></tr>
2910
2911
Manuel Klimek67619ff2012-09-07 13:10:32 +00002912<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 +00002913<tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value
2914declaration's type.
2915
2916In case of a value declaration (for example a variable declaration),
2917this resolves one layer of indirection. For example, in the value
Manuel Klimeke44a0062012-08-26 23:55:24 +00002918declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
2919while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
Manuel Klimek1da79332012-08-20 20:54:03 +00002920of x."
2921
Manuel Klimeke44a0062012-08-26 23:55:24 +00002922Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
2923 and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002924 class X {};
2925 void y(X &amp;x) { x; X z; }
2926
2927Usable 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;
2928</pre></td></tr>
2929
2930
Manuel Klimek67619ff2012-09-07 13:10:32 +00002931<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 +00002932<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression
2933that matches the given matcher.
2934
Manuel Klimeke44a0062012-08-26 23:55:24 +00002935Example matches x (matcher = varDecl(hasInitializer(callExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002936 bool y() { return true; }
2937 bool x = y();
2938</pre></td></tr>
2939
2940
Daniel Jaspere0b89972012-12-04 12:08:08 +00002941<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>
2942<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size
2943expression.
2944
2945Given
2946 void f(int b) {
2947 int a[b];
2948 }
2949variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
2950 varDecl(hasName("b")))))))
2951 matches "int a[b]"
2952</pre></td></tr>
2953
2954
Manuel Klimek67619ff2012-09-07 13:10:32 +00002955<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00002956<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has
2957a given body.
2958
2959Given
2960 for (;;) {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00002961hasBody(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00002962 matches 'for (;;) {}'
Manuel Klimeke44a0062012-08-26 23:55:24 +00002963with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00002964 matching '{}'
2965</pre></td></tr>
2966
2967
Manuel Klimek67619ff2012-09-07 13:10:32 +00002968<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 +00002969<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop,
2970or conditional operator.
2971
2972Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2973 if (true) {}
2974</pre></td></tr>
2975
2976<!--END_TRAVERSAL_MATCHERS -->
2977</table>
2978
2979</div>
2980</body>
2981</html>
2982
2983