blob: 31799008bcdee1561c85b108585a04f50b263ed1 [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
Edwin Vane742d9e72013-02-25 20:43:32 +0000933<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('elaboratedTypeLoc0')"><a name="elaboratedTypeLoc0Anchor">elaboratedTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedTypeLoc.html">ElaboratedTypeLoc</a>&gt;...</td></tr>
934<tr><td colspan="4" class="doc" id="elaboratedTypeLoc0"><pre>Matches types specified with an elaborated type keyword or with a
935qualified name.
936
937Given
938 namespace N {
939 namespace M {
940 class D {};
941 }
942 }
943 class C {};
944
945 class C c;
946 N::M::D d;
947
948elaboratedType() matches the type of the variable declarations of both
949c and d.
950</pre></td></tr>
951
952
Manuel Klimek41df16e2013-01-09 09:38:21 +0000953<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>
954<tr><td colspan="4" class="doc" id="functionTypeLoc0"><pre>Matches FunctionType nodes.
955
956Given
957 int (*f)(int);
958 void g();
959functionType()
960 matches "int (*f)(int)" and the type of "g".
961</pre></td></tr>
962
963
964<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>
965<tr><td colspan="4" class="doc" id="incompleteArrayTypeLoc0"><pre>Matches C arrays with unspecified size.
966
967Given
968 int a[] = { 2, 3 };
969 int b[42];
970 void f(int c[]) { int d[a[0]]; };
971incompleteArrayType()
972 matches "int a[]" and "int c[]"
973</pre></td></tr>
974
975
976<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>
977<tr><td colspan="4" class="doc" id="memberPointerTypeLoc0"><pre>Matches member pointer types.
978Given
979 struct A { int i; }
980 A::* ptr = A::i;
981memberPointerType()
982 matches "A::* ptr"
983</pre></td></tr>
984
985
986<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>
987<tr><td colspan="4" class="doc" id="pointerTypeLoc0"><pre>Matches pointer types.
988
989Given
990 int *a;
991 int &amp;b = *a;
992 int c = 5;
993pointerType()
994 matches "int *a"
995</pre></td></tr>
996
997
Edwin Vane742d9e72013-02-25 20:43:32 +0000998<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('recordTypeLoc0')"><a name="recordTypeLoc0Anchor">recordTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordTypeLoc.html">RecordTypeLoc</a>&gt;...</td></tr>
999<tr><td colspan="4" class="doc" id="recordTypeLoc0"><pre>Matches record types (e.g. structs, classes).
1000
1001Given
1002 class C {};
1003 struct S {};
1004
1005 C c;
1006 S s;
1007
1008recordType() matches the type of the variable declarations of both c
1009and s.
1010</pre></td></tr>
1011
1012
Manuel Klimek41df16e2013-01-09 09:38:21 +00001013<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>
1014<tr><td colspan="4" class="doc" id="referenceTypeLoc0"><pre>Matches reference types.
1015
1016Given
1017 int *a;
1018 int &amp;b = *a;
1019 int c = 5;
1020pointerType()
1021 matches "int &amp;b"
1022</pre></td></tr>
1023
1024
Edwin Vane3abf7782013-02-25 14:49:29 +00001025<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('templateSpecializationTypeLoc0')"><a name="templateSpecializationTypeLoc0Anchor">templateSpecializationTypeLoc</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>&gt;...</td></tr>
1026<tr><td colspan="4" class="doc" id="templateSpecializationTypeLoc0"><pre>Matches template specialization types.
1027
1028Given
1029 template &lt;typename T&gt;
1030 class C { };
1031
1032 template class C&lt;int&gt;; A
1033 C&lt;char&gt; var; B
1034
1035templateSpecializationType() matches the type of the explicit
1036instantiation in A and the type of the variable declaration in B.
1037</pre></td></tr>
1038
1039
Daniel Jaspere0b89972012-12-04 12:08:08 +00001040<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>
1041<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST.
1042</pre></td></tr>
1043
1044
Manuel Klimek41df16e2013-01-09 09:38:21 +00001045<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>
1046<tr><td colspan="4" class="doc" id="typedefTypeLoc0"><pre>Matches typedef types.
1047
1048Given
1049 typedef int X;
1050typedefType()
1051 matches "typedef int X"
1052</pre></td></tr>
1053
1054
1055<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>
1056<tr><td colspan="4" class="doc" id="variableArrayTypeLoc0"><pre>Matches C arrays with a specified size that is not an
1057integer-constant-expression.
1058
1059Given
1060 void f() {
1061 int a[] = { 2, 3 }
1062 int b[42];
1063 int c[a[0]];
1064variableArrayType()
1065 matches "int c[a[0]]"
1066</pre></td></tr>
1067
1068
1069<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>
1070<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays.
1071
1072Given
1073 int a[] = { 2, 3 };
1074 int b[4];
1075 void f() { int c[a[0]]; }
1076arrayType()
1077 matches "int a[]", "int b[4]" and "int c[a[0]]";
1078</pre></td></tr>
1079
1080
1081<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>
1082<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types.
1083
1084Given
1085 _Atomic(int) i;
1086atomicType()
1087 matches "_Atomic(int) i"
1088</pre></td></tr>
1089
1090
1091<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('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>
1092<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types.
1093
1094Given:
1095 auto n = 4;
1096 int v[] = { 2, 3 }
1097 for (auto i : v) { }
1098autoType()
1099 matches "auto n" and "auto i"
1100</pre></td></tr>
1101
1102
1103<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>
1104<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as
1105"void (^)(int)".
1106
1107The pointee is always required to be a FunctionType.
1108</pre></td></tr>
1109
1110
1111<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>
1112<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types.
1113
1114Given
1115 struct A {};
1116 A a;
1117 int b;
1118 float c;
1119 bool d;
1120builtinType()
1121 matches "int b", "float c" and "bool d"
1122</pre></td></tr>
1123
1124
1125<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>
1126<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types.
1127
1128Given
1129 _Complex float f;
1130complexType()
1131 matches "_Complex float f"
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('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>
1136<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size.
1137
1138Given
1139 void() {
1140 int a[2];
1141 int b[] = { 2, 3 };
1142 int c[b[0]];
1143 }
1144constantArrayType()
1145 matches "int a[2]"
1146</pre></td></tr>
1147
1148
1149<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>
1150<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression.
1151
1152Given
1153 template&lt;typename T, int Size&gt;
1154 class array {
1155 T data[Size];
1156 };
1157dependentSizedArrayType
1158 matches "T data[Size]"
1159</pre></td></tr>
1160
1161
Edwin Vane742d9e72013-02-25 20:43:32 +00001162<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('elaboratedType0')"><a name="elaboratedType0Anchor">elaboratedType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>&gt;...</td></tr>
1163<tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a
1164qualified name.
1165
1166Given
1167 namespace N {
1168 namespace M {
1169 class D {};
1170 }
1171 }
1172 class C {};
1173
1174 class C c;
1175 N::M::D d;
1176
1177elaboratedType() matches the type of the variable declarations of both
1178c and d.
1179</pre></td></tr>
1180
1181
Manuel Klimek41df16e2013-01-09 09:38:21 +00001182<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>
1183<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes.
1184
1185Given
1186 int (*f)(int);
1187 void g();
1188functionType()
1189 matches "int (*f)(int)" and the type of "g".
1190</pre></td></tr>
1191
1192
1193<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>
1194<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size.
1195
1196Given
1197 int a[] = { 2, 3 };
1198 int b[42];
1199 void f(int c[]) { int d[a[0]]; };
1200incompleteArrayType()
1201 matches "int a[]" and "int c[]"
1202</pre></td></tr>
1203
1204
1205<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>
1206<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types.
1207Given
1208 struct A { int i; }
1209 A::* ptr = A::i;
1210memberPointerType()
1211 matches "A::* ptr"
1212</pre></td></tr>
1213
1214
1215<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>
1216<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types.
1217
1218Given
1219 int *a;
1220 int &amp;b = *a;
1221 int c = 5;
1222pointerType()
1223 matches "int *a"
1224</pre></td></tr>
1225
1226
Edwin Vane742d9e72013-02-25 20:43:32 +00001227<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('recordType0')"><a name="recordType0Anchor">recordType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;...</td></tr>
1228<tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes).
1229
1230Given
1231 class C {};
1232 struct S {};
1233
1234 C c;
1235 S s;
1236
1237recordType() matches the type of the variable declarations of both c
1238and s.
1239</pre></td></tr>
1240
1241
Manuel Klimek41df16e2013-01-09 09:38:21 +00001242<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>
1243<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches reference types.
1244
1245Given
1246 int *a;
1247 int &amp;b = *a;
1248 int c = 5;
1249pointerType()
1250 matches "int &amp;b"
1251</pre></td></tr>
1252
1253
Edwin Vane3abf7782013-02-25 14:49:29 +00001254<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('templateSpecializationType0')"><a name="templateSpecializationType0Anchor">templateSpecializationType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;...</td></tr>
1255<tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types.
1256
1257Given
1258 template &lt;typename T&gt;
1259 class C { };
1260
1261 template class C&lt;int&gt;; A
1262 C&lt;char&gt; var; B
1263
1264templateSpecializationType() matches the type of the explicit
1265instantiation in A and the type of the variable declaration in B.
1266</pre></td></tr>
1267
1268
Daniel Jaspere0b89972012-12-04 12:08:08 +00001269<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>
1270<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST.
1271</pre></td></tr>
1272
Manuel Klimek41df16e2013-01-09 09:38:21 +00001273
1274<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>
1275<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types.
1276
1277Given
1278 typedef int X;
1279typedefType()
1280 matches "typedef int X"
1281</pre></td></tr>
1282
1283
1284<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>
1285<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an
1286integer-constant-expression.
1287
1288Given
1289 void f() {
1290 int a[] = { 2, 3 }
1291 int b[42];
1292 int c[a[0]];
1293variableArrayType()
1294 matches "int c[a[0]]"
1295</pre></td></tr>
1296
Manuel Klimek1da79332012-08-20 20:54:03 +00001297<!--END_DECL_MATCHERS -->
1298</table>
1299
1300<!-- ======================================================================= -->
1301<h2 id="narrowing-matchers">Narrowing Matchers</h2>
1302<!-- ======================================================================= -->
1303
1304<p>Narrowing matchers match certain attributes on the current node, thus
1305narrowing down the set of nodes of the current type to match on.</p>
1306
1307<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless)
1308which allow users to create more powerful match expressions.</p>
1309
1310<table>
1311<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
1312<!-- START_NARROWING_MATCHERS -->
1313
Manuel Klimek67619ff2012-09-07 13:10:32 +00001314<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 +00001315<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match.
1316
1317Usable as: Any Matcher
1318</pre></td></tr>
1319
1320
Manuel Klimek67619ff2012-09-07 13:10:32 +00001321<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 +00001322<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches.
1323
1324Usable as: Any Matcher
1325</pre></td></tr>
1326
1327
Manuel Klimek67619ff2012-09-07 13:10:32 +00001328<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 +00001329<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node.
1330
1331Useful when another matcher requires a child matcher, but there's no
1332additional constraint. This will often be used with an explicit conversion
1333to an internal::Matcher&lt;&gt; type such as TypeMatcher.
1334
1335Example: DeclarationMatcher(anything()) matches all declarations, e.g.,
1336"int* p" and "void f()" in
1337 int* p;
1338 void f();
1339
1340Usable as: Any Matcher
1341</pre></td></tr>
1342
1343
Manuel Klimek67619ff2012-09-07 13:10:32 +00001344<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 +00001345<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match.
1346
Manuel Klimeke44a0062012-08-26 23:55:24 +00001347Example matches Y (matcher = recordDecl(unless(hasName("X"))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001348 class X {};
1349 class Y {};
1350
1351Usable as: Any Matcher
1352</pre></td></tr>
1353
1354
Manuel Klimek67619ff2012-09-07 13:10:32 +00001355<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 +00001356<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or
1357unary).
1358
1359Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
1360 !(a || b)
1361</pre></td></tr>
1362
1363
Manuel Klimek67619ff2012-09-07 13:10:32 +00001364<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 +00001365<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value.
1366
1367Example matches true (matcher = boolLiteral(equals(true)))
1368 true
1369
1370Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1371 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;
1372</pre></td></tr>
1373
1374
Manuel Klimek67619ff2012-09-07 13:10:32 +00001375<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 +00001376<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a constructor declaration that has been implicitly added
1377by the compiler (eg. implicit defaultcopy constructors).
1378</pre></td></tr>
1379
1380
Manuel Klimek67619ff2012-09-07 13:10:32 +00001381<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 +00001382<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a contructor initializer if it is explicitly written in
1383code (as opposed to implicitly added by the compiler).
1384
1385Given
1386 struct Foo {
1387 Foo() { }
1388 Foo(int) : foo_("A") { }
1389 string foo_;
1390 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00001391constructorDecl(hasAnyConstructorInitializer(isWritten()))
Manuel Klimek1da79332012-08-20 20:54:03 +00001392 will match Foo(int), but not Foo()
1393</pre></td></tr>
1394
1395
Manuel Klimek67619ff2012-09-07 13:10:32 +00001396<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 +00001397<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names.
1398
1399Matches overloaded operator names specified in strings without the
1400"operator" prefix, such as "&lt;&lt;", for OverloadedOperatorCall's.
1401
1402Example matches a &lt;&lt; b
Manuel Klimeke44a0062012-08-26 23:55:24 +00001403 (matcher == operatorCallExpr(hasOverloadedOperatorName("&lt;&lt;")))
Manuel Klimek1da79332012-08-20 20:54:03 +00001404 a &lt;&lt; b;
1405 c &amp;&amp; d; assuming both operator&lt;&lt;
1406 and operator&amp;&amp; are overloaded somewhere.
1407</pre></td></tr>
1408
1409
Manuel Klimek67619ff2012-09-07 13:10:32 +00001410<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 +00001411<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
1412</pre></td></tr>
1413
1414
Manuel Klimek415514d2013-02-06 20:36:22 +00001415<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>
1416<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or
Manuel Klimek1da79332012-08-20 20:54:03 +00001417static member variable template instantiations.
1418
1419Given
1420 template&lt;typename T&gt; void A(T t) { }
1421 template&lt;&gt; void A(int N) { }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001422functionDecl(isExplicitTemplateSpecialization())
Manuel Klimek1da79332012-08-20 20:54:03 +00001423 matches the specialization A&lt;int&gt;().
1424
1425Usable 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;
1426</pre></td></tr>
1427
1428
Daniel Jaspere0b89972012-12-04 12:08:08 +00001429<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>
1430<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for
1431isSameOrDerivedFrom(hasName(...)).
1432</pre></td></tr>
1433
1434
Manuel Klimek415514d2013-02-06 20:36:22 +00001435<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>
1436<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static
Manuel Klimek1da79332012-08-20 20:54:03 +00001437member variable template instantiations.
1438
1439Given
1440 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
1441or
1442 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001443recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001444 matches the template instantiation of X&lt;A&gt;.
1445
1446But given
1447 template &lt;typename T&gt; class X {}; class A {};
1448 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001449recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001450 does not match, as X&lt;A&gt; is an explicit template specialization.
1451
1452Usable 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;
1453</pre></td></tr>
1454
1455
Manuel Klimek67619ff2012-09-07 13:10:32 +00001456<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 +00001457<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has
1458a specific number of arguments (including absent default arguments).
1459
Manuel Klimeke44a0062012-08-26 23:55:24 +00001460Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
Manuel Klimek1da79332012-08-20 20:54:03 +00001461 void f(int x, int y);
1462 f(0, 0);
1463</pre></td></tr>
1464
1465
Manuel Klimek67619ff2012-09-07 13:10:32 +00001466<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 +00001467<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value.
1468
1469Example matches true (matcher = boolLiteral(equals(true)))
1470 true
1471
1472Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1473 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;
1474</pre></td></tr>
1475
1476
Manuel Klimek67619ff2012-09-07 13:10:32 +00001477<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00001478<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of
1479child statements.
1480
1481Example: Given
1482 { for (;;) {} }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001483compoundStmt(statementCountIs(0)))
Manuel Klimek1da79332012-08-20 20:54:03 +00001484 matches '{}'
1485 but does not match the outer compound statement.
1486</pre></td></tr>
1487
1488
Daniel Jaspere0b89972012-12-04 12:08:08 +00001489<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>
1490<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size.
1491
1492Given
1493 int a[42];
1494 int b[2 * 21];
1495 int c[41], d[43];
1496constantArrayType(hasSize(42))
1497 matches "int a[42]" and "int b[2 * 21]"
1498</pre></td></tr>
1499
1500
Manuel Klimek67619ff2012-09-07 13:10:32 +00001501<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 +00001502<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of
1503declarations.
1504
1505Example: Given
1506 int a, b;
1507 int c;
1508 int d = 2, e;
1509declCountIs(2)
1510 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.
1511</pre></td></tr>
1512
1513
Manuel Klimekfa37c5c2013-02-07 12:42:10 +00001514<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>
1515<tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node.
1516
1517Decl has pointer identity in the AST.
1518</pre></td></tr>
1519
1520
Daniel Jasperc7093d92013-02-25 12:39:41 +00001521<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>
1522<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations.
1523
1524Given
1525 class C {
1526 public: int a;
1527 protected: int b;
1528 private: int c;
1529 };
1530fieldDecl(isPrivate())
1531 matches 'int c;'
1532</pre></td></tr>
1533
1534
1535<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>
1536<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations.
1537
1538Given
1539 class C {
1540 public: int a;
1541 protected: int b;
1542 private: int c;
1543 };
1544fieldDecl(isProtected())
1545 matches 'int b;'
1546</pre></td></tr>
1547
1548
1549<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>
1550<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations.
1551
1552Given
1553 class C {
1554 public: int a;
1555 protected: int b;
1556 private: int c;
1557 };
1558fieldDecl(isPublic())
1559 matches 'int a;'
1560</pre></td></tr>
1561
1562
Manuel Klimek67619ff2012-09-07 13:10:32 +00001563<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 +00001564<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value.
1565
1566Example matches true (matcher = boolLiteral(equals(true)))
1567 true
1568
1569Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1570 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;
1571</pre></td></tr>
1572
1573
Manuel Klimek415514d2013-02-06 20:36:22 +00001574<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>
1575<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached.
Manuel Klimek1da79332012-08-20 20:54:03 +00001576
1577Example matches A, va, fa
1578 class A {};
1579 class B; Doesn't match, as it has no body.
1580 int va;
1581 extern int vb; Doesn't match, as it doesn't define the variable.
1582 void fa() {}
1583 void fb(); Doesn't match, as it has no body.
1584
1585Usable 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;
1586</pre></td></tr>
1587
1588
Manuel Klimek415514d2013-02-06 20:36:22 +00001589<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>
1590<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or
Manuel Klimek1da79332012-08-20 20:54:03 +00001591static member variable template instantiations.
1592
1593Given
1594 template&lt;typename T&gt; void A(T t) { }
1595 template&lt;&gt; void A(int N) { }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001596functionDecl(isExplicitTemplateSpecialization())
Manuel Klimek1da79332012-08-20 20:54:03 +00001597 matches the specialization A&lt;int&gt;().
1598
1599Usable 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;
1600</pre></td></tr>
1601
1602
Manuel Klimek67619ff2012-09-07 13:10:32 +00001603<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 +00001604<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations.
1605
1606Given:
1607 extern "C" void f() {}
1608 extern "C" { void g() {} }
1609 void h() {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00001610functionDecl(isExternC())
Manuel Klimek1da79332012-08-20 20:54:03 +00001611 matches the declaration of f and g, but not the declaration h
1612</pre></td></tr>
1613
1614
Manuel Klimek415514d2013-02-06 20:36:22 +00001615<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>
1616<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static
Manuel Klimek1da79332012-08-20 20:54:03 +00001617member variable template instantiations.
1618
1619Given
1620 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
1621or
1622 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001623recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001624 matches the template instantiation of X&lt;A&gt;.
1625
1626But given
1627 template &lt;typename T&gt; class X {}; class A {};
1628 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001629recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001630 does not match, as X&lt;A&gt; is an explicit template specialization.
1631
1632Usable 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;
1633</pre></td></tr>
1634
1635
Daniel Jaspere0b89972012-12-04 12:08:08 +00001636<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('parameterCountIs0')"><a name="parameterCountIs0Anchor">parameterCountIs</a></td><td>unsigned N</td></tr>
1637<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count.
1638
1639Given
1640 void f(int i) {}
1641 void g(int i, int j) {}
1642functionDecl(parameterCountIs(2))
1643 matches g(int i, int j) {}
1644</pre></td></tr>
1645
1646
Manuel Klimek67619ff2012-09-07 13:10:32 +00001647<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 +00001648<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value.
1649
1650Example matches true (matcher = boolLiteral(equals(true)))
1651 true
1652
1653Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;CXXBoolLiteral&gt;,
1654 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;
1655</pre></td></tr>
1656
1657
Manuel Klimek67619ff2012-09-07 13:10:32 +00001658<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 +00001659<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '-&gt;' as opposed
1660to '.'.
1661
1662Member calls on the implicit this pointer match as called with '-&gt;'.
1663
1664Given
1665 class Y {
1666 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
1667 int a;
1668 static int b;
1669 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00001670memberExpr(isArrow())
Manuel Klimek1da79332012-08-20 20:54:03 +00001671 matches this-&gt;x, x, y.x, a, this-&gt;b
1672</pre></td></tr>
1673
1674
Manuel Klimek67619ff2012-09-07 13:10:32 +00001675<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 +00001676<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name.
1677
1678Supports specifying enclosing namespaces or classes by prefixing the name
1679with '&lt;enclosing&gt;::'.
1680Does not match typedefs of an underlying type with the given name.
1681
1682Example matches X (Name == "X")
1683 class X;
1684
1685Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
1686 namespace a { namespace b { class X; } }
1687</pre></td></tr>
1688
1689
Manuel Klimek67619ff2012-09-07 13:10:32 +00001690<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 +00001691<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain
1692a substring matched by the given RegExp.
Manuel Klimek1da79332012-08-20 20:54:03 +00001693
1694Supports specifying enclosing namespaces or classes by
1695prefixing the name with '&lt;enclosing&gt;::'. Does not match typedefs
1696of an underlying type with the given name.
1697
1698Example matches X (regexp == "::X")
1699 class X;
1700
1701Example matches X (regexp is one of "::X", "^foo::.*X", among others)
1702 namespace foo { namespace bar { class X; } }
1703</pre></td></tr>
1704
1705
Manuel Klimek67619ff2012-09-07 13:10:32 +00001706<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 +00001707<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string.
1708
1709Given
1710 class Y { public: void x(); };
1711 void z() { Y* y; y-&gt;x(); }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001712callExpr(on(hasType(asString("class Y *"))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001713 matches y-&gt;x()
1714</pre></td></tr>
1715
1716
Manuel Klimek67619ff2012-09-07 13:10:32 +00001717<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 +00001718<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that
1719include "top-level" const.
1720
1721Given
1722 void a(int);
1723 void b(int const);
1724 void c(const int);
1725 void d(const int*);
1726 void e(int const) {};
Manuel Klimeke44a0062012-08-26 23:55:24 +00001727functionDecl(hasAnyParameter(hasType(isConstQualified())))
Manuel Klimek1da79332012-08-20 20:54:03 +00001728 matches "void b(int const)", "void c(const int)" and
1729 "void e(int const) {}". It does not match d as there
1730 is no top-level const on the parameter type "const int *".
1731</pre></td></tr>
1732
1733
Manuel Klimek67619ff2012-09-07 13:10:32 +00001734<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 +00001735<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type.
1736
1737Given
1738 void a(int);
1739 void b(long);
1740 void c(double);
Manuel Klimeke44a0062012-08-26 23:55:24 +00001741functionDecl(hasAnyParameter(hasType(isInteger())))
Manuel Klimek1da79332012-08-20 20:54:03 +00001742matches "a(int)", "b(long)", but not "c(double)".
1743</pre></td></tr>
1744
1745
Manuel Klimekfa37c5c2013-02-07 12:42:10 +00001746<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>
1747<tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node.
1748
1749Stmt has pointer identity in the AST.
1750
1751</pre></td></tr>
1752
1753
Manuel Klimek415514d2013-02-06 20:36:22 +00001754<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>
1755<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached.
Manuel Klimek1da79332012-08-20 20:54:03 +00001756
1757Example matches A, va, fa
1758 class A {};
1759 class B; Doesn't match, as it has no body.
1760 int va;
1761 extern int vb; Doesn't match, as it doesn't define the variable.
1762 void fa() {}
1763 void fb(); Doesn't match, as it has no body.
1764
1765Usable 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;
1766</pre></td></tr>
1767
1768
Manuel Klimek67619ff2012-09-07 13:10:32 +00001769<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 +00001770<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind.
1771
1772Given
1773 int x;
1774 int s = sizeof(x) + alignof(x)
1775unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
1776 matches sizeof(x)
1777</pre></td></tr>
1778
1779
Manuel Klimek67619ff2012-09-07 13:10:32 +00001780<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 +00001781<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or
1782unary).
1783
1784Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
1785 !(a || b)
1786</pre></td></tr>
1787
1788
Manuel Klimek67619ff2012-09-07 13:10:32 +00001789<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 +00001790<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached.
1791
1792Example matches A, va, fa
1793 class A {};
1794 class B; Doesn't match, as it has no body.
1795 int va;
1796 extern int vb; Doesn't match, as it doesn't define the variable.
1797 void fa() {}
1798 void fb(); Doesn't match, as it has no body.
1799
1800Usable 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;
1801</pre></td></tr>
1802
1803
Manuel Klimek67619ff2012-09-07 13:10:32 +00001804<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 +00001805<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or
1806static member variable template instantiations.
1807
1808Given
1809 template&lt;typename T&gt; void A(T t) { }
1810 template&lt;&gt; void A(int N) { }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001811functionDecl(isExplicitTemplateSpecialization())
Manuel Klimek1da79332012-08-20 20:54:03 +00001812 matches the specialization A&lt;int&gt;().
1813
1814Usable 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;
1815</pre></td></tr>
1816
1817
Manuel Klimek67619ff2012-09-07 13:10:32 +00001818<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 +00001819<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static
1820member variable template instantiations.
1821
1822Given
1823 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
1824or
1825 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001826recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001827 matches the template instantiation of X&lt;A&gt;.
1828
1829But given
1830 template &lt;typename T&gt; class X {}; class A {};
1831 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
Manuel Klimeke44a0062012-08-26 23:55:24 +00001832recordDecl(hasName("::X"), isTemplateInstantiation())
Manuel Klimek1da79332012-08-20 20:54:03 +00001833 does not match, as X&lt;A&gt; is an explicit template specialization.
1834
1835Usable 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;
1836</pre></td></tr>
1837
1838<!--END_NARROWING_MATCHERS -->
1839</table>
1840
1841<!-- ======================================================================= -->
1842<h2 id="traversal-matchers">AST Traversal Matchers</h2>
1843<!-- ======================================================================= -->
1844
1845<p>Traversal matchers specify the relationship to other nodes that are
1846reachable from the current node.</p>
1847
1848<p>Note that there are special traversal matchers (has, hasDescendant, forEach and
1849forEachDescendant) which work on all nodes and allow users to write more generic
1850match expressions.</p>
1851
1852<table>
1853<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
1854<!-- START_TRAVERSAL_MATCHERS -->
1855
Manuel Klimek152ea0e2013-02-04 10:59:20 +00001856<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>
1857<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches.
1858
1859Unlike anyOf, eachOf will generate a match result for each
1860matching submatcher.
1861
1862For example, in:
1863 class A { int a; int b; };
1864The matcher:
1865 recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
1866 has(fieldDecl(hasName("b")).bind("v"))))
1867will generate two results binding "v", the first of which binds
1868the field declaration of a, the second the field declaration of
1869b.
1870
1871Usable as: Any Matcher
1872</pre></td></tr>
1873
1874
1875<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>
1876<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches.
1877
1878Generates results for each match.
1879
1880For example, in:
1881 class A { class B {}; class C {}; };
1882The matcher:
1883 recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m")))
1884will generate results for A, B and C.
1885
1886Usable as: Any Matcher
1887</pre></td></tr>
1888
1889
Manuel Klimek67619ff2012-09-07 13:10:32 +00001890<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 +00001891<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the
1892provided matcher.
1893
Manuel Klimeke44a0062012-08-26 23:55:24 +00001894Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X")))
Manuel Klimek1da79332012-08-20 20:54:03 +00001895 class X {}; Matches X, because X::X is a class of name X inside X.
1896 class Y { class X {}; };
1897 class Z { class Y { class X {}; }; }; Does not match Z.
1898
1899ChildT must be an AST base type.
1900
1901As opposed to 'has', 'forEach' will cause a match for each result that
1902matches instead of only on the first one.
1903
1904Usable as: Any Matcher
1905</pre></td></tr>
1906
1907
Manuel Klimek67619ff2012-09-07 13:10:32 +00001908<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 +00001909<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
1910provided matcher.
1911
1912Example matches X, A, B, C
Manuel Klimeke44a0062012-08-26 23:55:24 +00001913 (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001914 class X {}; Matches X, because X::X is a class of name X inside X.
1915 class A { class X {}; };
1916 class B { class C { class X {}; }; };
1917
1918DescendantT must be an AST base type.
1919
1920As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
1921each result that matches instead of only on the first one.
1922
1923Note: Recursively combined ForEachDescendant can cause many matches:
Manuel Klimeke44a0062012-08-26 23:55:24 +00001924 recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl()))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001925will match 10 times (plus injected class name matches) on:
1926 class A { class B { class C { class D { class E {}; }; }; }; };
1927
1928Usable as: Any Matcher
1929</pre></td></tr>
1930
1931
Manuel Klimek67619ff2012-09-07 13:10:32 +00001932<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 +00001933<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the
1934provided matcher.
1935
Manuel Klimeke44a0062012-08-26 23:55:24 +00001936Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X")))
Manuel Klimek1da79332012-08-20 20:54:03 +00001937 class X {}; Matches X, because X::X is a class of name X inside X.
1938 class Y { class X {}; };
1939 class Z { class Y { class X {}; }; }; Does not match Z.
1940
1941ChildT must be an AST base type.
1942
1943Usable as: Any Matcher
1944</pre></td></tr>
1945
1946
Manuel Klimek67619ff2012-09-07 13:10:32 +00001947<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>
1948<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided
1949matcher.
1950
1951Given
1952void f() { if (true) { int x = 42; } }
1953void g() { for (;;) { int x = 43; } }
Daniel Jaspere0b89972012-12-04 12:08:08 +00001954expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.
Manuel Klimek67619ff2012-09-07 13:10:32 +00001955
1956Usable as: Any Matcher
1957</pre></td></tr>
1958
1959
1960<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 +00001961<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
1962provided matcher.
1963
1964Example matches X, Y, Z
Manuel Klimeke44a0062012-08-26 23:55:24 +00001965 (matcher = recordDecl(hasDescendant(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00001966 class X {}; Matches X, because X::X is a class of name X inside X.
1967 class Y { class X {}; };
1968 class Z { class Y { class X {}; }; };
1969
1970DescendantT must be an AST base type.
1971
1972Usable as: Any Matcher
1973</pre></td></tr>
1974
1975
Daniel Jaspere0b89972012-12-04 12:08:08 +00001976<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>
1977<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided
1978matcher.
1979
1980Given
1981void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
1982compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".
1983
1984Usable as: Any Matcher
1985</pre></td></tr>
1986
1987
Manuel Klimek67619ff2012-09-07 13:10:32 +00001988<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00001989<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression.
1990
1991Given
1992 int i[5];
1993 void f() { i[1] = 42; }
Manuel Klimeke44a0062012-08-26 23:55:24 +00001994arraySubscriptExpression(hasBase(implicitCastExpr(
1995 hasSourceExpression(declRefExpr()))))
1996 matches i[1] with the declRefExpr() matching i
Manuel Klimek1da79332012-08-20 20:54:03 +00001997</pre></td></tr>
1998
1999
Manuel Klimek67619ff2012-09-07 13:10:32 +00002000<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 +00002001<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression.
2002
2003Given
2004 int i[5];
2005 void f() { i[1] = 42; }
2006arraySubscriptExpression(hasIndex(integerLiteral()))
2007 matches i[1] with the integerLiteral() matching 1
2008</pre></td></tr>
2009
2010
Manuel Klimek41df16e2013-01-09 09:38:21 +00002011<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>
2012<tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element
2013type.
2014
2015Given
2016 struct A {};
2017 A a[7];
2018 int b[7];
2019arrayType(hasElementType(builtinType()))
2020 matches "int b[7]"
2021
2022Usable 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;
2023</pre></td></tr>
2024
2025
2026<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>
2027<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element
2028type.
2029
2030Given
2031 struct A {};
2032 A a[7];
2033 int b[7];
2034arrayType(hasElementType(builtinType()))
2035 matches "int b[7]"
2036
2037Usable 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;
2038</pre></td></tr>
2039
2040
2041<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>
2042<tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type.
2043
2044Given
2045 _Atomic(int) i;
2046 _Atomic(float) f;
2047atomicType(hasValueType(isInteger()))
2048 matches "_Atomic(int) i"
2049
2050Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
2051</pre></td></tr>
2052
2053
2054<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>
2055<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type.
2056
2057Given
2058 _Atomic(int) i;
2059 _Atomic(float) f;
2060atomicType(hasValueType(isInteger()))
2061 matches "_Atomic(int) i"
2062
2063Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
2064</pre></td></tr>
2065
2066
2067<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>
2068<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type.
2069
2070Note: There is no TypeLoc for the deduced type and thus no
2071getDeducedLoc() matcher.
2072
2073Given
2074 auto a = 1;
2075 auto b = 2.0;
2076autoType(hasDeducedType(isInteger()))
2077 matches "auto a"
2078
2079Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>&gt;
2080</pre></td></tr>
2081
2082
Manuel Klimek67619ff2012-09-07 13:10:32 +00002083<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 +00002084<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a
2085binary operator matches.
2086</pre></td></tr>
2087
2088
Manuel Klimek67619ff2012-09-07 13:10:32 +00002089<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 +00002090<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions.
2091
2092Example matches a (matcher = binaryOperator(hasLHS()))
2093 a || b
2094</pre></td></tr>
2095
2096
Manuel Klimek67619ff2012-09-07 13:10:32 +00002097<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 +00002098<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions.
2099
2100Example matches b (matcher = binaryOperator(hasRHS()))
2101 a || b
2102</pre></td></tr>
2103
2104
Manuel Klimek41df16e2013-01-09 09:38:21 +00002105<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>
2106<tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the
2107pointee matches a given matcher.
2108
2109Given
2110 int *a;
2111 int const *b;
2112 float const *f;
2113pointerType(pointee(isConstQualified(), isInteger()))
2114 matches "int const *b"
2115
2116Usable 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;,
2117 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;
2118</pre></td></tr>
2119
2120
2121<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>
2122<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the
2123pointee matches a given matcher.
2124
2125Given
2126 int *a;
2127 int const *b;
2128 float const *f;
2129pointerType(pointee(isConstQualified(), isInteger()))
2130 matches "int const *b"
2131
2132Usable 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;,
2133 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;
2134</pre></td></tr>
2135
2136
Edwin Vane3abf7782013-02-25 14:49:29 +00002137<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration3')"><a name="hasDeclaration3Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
2138<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 +00002139matcher.
2140
Edwin Vane52380602013-02-19 17:14:34 +00002141In addition to being usable as Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, also usable as
2142Matcher&lt;T&gt; for any T supporting the getDecl() member function. e.g. various
2143subtypes of clang::Type.
2144
Daniel Jaspere0b89972012-12-04 12:08:08 +00002145Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
Edwin Vane3abf7782013-02-25 14:49:29 +00002146 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;,
2147 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;
Manuel Klimek1da79332012-08-20 20:54:03 +00002148</pre></td></tr>
2149
2150
Manuel Klimek67619ff2012-09-07 13:10:32 +00002151<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 +00002152<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer.
2153
2154Given
2155 struct Foo {
2156 Foo() : foo_(1) { }
2157 int foo_;
2158 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002159recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything()))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002160 record matches Foo, hasAnyConstructorInitializer matches foo_(1)
2161</pre></td></tr>
2162
2163
Manuel Klimek67619ff2012-09-07 13:10:32 +00002164<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 +00002165<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer.
2166
2167Given
2168 struct Foo {
2169 Foo() : foo_(1) { }
2170 int foo_;
2171 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002172recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
Manuel Klimek1da79332012-08-20 20:54:03 +00002173 forField(hasName("foo_"))))))
2174 matches Foo
2175with forField matching foo_
2176</pre></td></tr>
2177
2178
Manuel Klimek67619ff2012-09-07 13:10:32 +00002179<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 +00002180<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer.
2181
2182Given
2183 struct Foo {
2184 Foo() : foo_(1) { }
2185 int foo_;
2186 };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002187recordDecl(has(constructorDecl(hasAnyConstructorInitializer(
Manuel Klimek1da79332012-08-20 20:54:03 +00002188 withInitializer(integerLiteral(equals(1)))))))
2189 matches Foo
2190with withInitializer matching (1)
2191</pre></td></tr>
2192
2193
Manuel Klimek67619ff2012-09-07 13:10:32 +00002194<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 +00002195<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression.
2196
Manuel Klimeke44a0062012-08-26 23:55:24 +00002197Example matches y.x() (matcher = callExpr(on(hasType(recordDecl(hasName("Y"))))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002198 class Y { public: void x(); };
2199 void z() { Y y; y.x(); }",
2200
2201FIXME: Overload to allow directly matching types?
2202</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_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 +00002206<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr>
2207
2208
Manuel Klimek67619ff2012-09-07 13:10:32 +00002209<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00002210<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration.
2211</pre></td></tr>
2212
2213
Manuel Klimek67619ff2012-09-07 13:10:32 +00002214<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00002215<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration
2216belongs to.
2217
2218FIXME: Generalize this for other kinds of declarations.
2219FIXME: What other kind of declarations would we need to generalize
2220this to?
2221
2222Example matches A() in the last line
Manuel Klimeke44a0062012-08-26 23:55:24 +00002223 (matcher = constructExpr(hasDeclaration(methodDecl(
Manuel Klimek1da79332012-08-20 20:54:03 +00002224 ofClass(hasName("A"))))))
2225 class A {
2226 public:
2227 A();
2228 };
2229 A a = A();
2230</pre></td></tr>
2231
2232
Manuel Klimek67619ff2012-09-07 13:10:32 +00002233<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 +00002234<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from
2235a class matching Base.
2236
Manuel Klimek67619ff2012-09-07 13:10:32 +00002237Note that a class is not considered to be derived from itself.
Manuel Klimek1da79332012-08-20 20:54:03 +00002238
Manuel Klimek67619ff2012-09-07 13:10:32 +00002239Example matches Y, Z, C (Base == hasName("X"))
2240 class X;
Manuel Klimek1da79332012-08-20 20:54:03 +00002241 class Y : public X {}; directly derived
2242 class Z : public Y {}; indirectly derived
2243 typedef X A;
2244 typedef A B;
2245 class C : public B {}; derived from a typedef of X
2246
2247In the following example, Bar matches isDerivedFrom(hasName("X")):
2248 class Foo;
2249 typedef Foo X;
2250 class Bar : public Foo {}; derived from a type that X is a typedef of
2251</pre></td></tr>
2252
2253
Daniel Jaspere0b89972012-12-04 12:08:08 +00002254<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>
2255<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly
2256match Base.
2257</pre></td></tr>
2258
2259
Manuel Klimek67619ff2012-09-07 13:10:32 +00002260<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 +00002261<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the
2262given matcher.
2263
Manuel Klimeke44a0062012-08-26 23:55:24 +00002264Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002265 class Y { public: void x(); };
2266 void z() { Y y; y.x();
2267</pre></td></tr>
2268
2269
Manuel Klimek67619ff2012-09-07 13:10:32 +00002270<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 +00002271<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call
2272expression.
2273
2274Given
2275 void x(int, int, int) { int y; x(1, y, 42); }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002276callExpr(hasAnyArgument(declRefExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002277 matches x(1, y, 42)
2278with hasAnyArgument(...)
2279 matching y
2280</pre></td></tr>
2281
2282
Manuel Klimek67619ff2012-09-07 13:10:32 +00002283<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 +00002284<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor
2285call expression.
2286
2287Example matches y in x(y)
Manuel Klimeke44a0062012-08-26 23:55:24 +00002288 (matcher = callExpr(hasArgument(0, declRefExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002289 void x(int) { int y; x(y); }
2290</pre></td></tr>
2291
2292
Edwin Vane3abf7782013-02-25 14:49:29 +00002293<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration4')"><a name="hasDeclaration4Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
2294<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 +00002295matcher.
2296
Edwin Vane52380602013-02-19 17:14:34 +00002297In addition to being usable as Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, also usable as
2298Matcher&lt;T&gt; for any T supporting the getDecl() member function. e.g. various
2299subtypes of clang::Type.
2300
Daniel Jaspere0b89972012-12-04 12:08:08 +00002301Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
Edwin Vane3abf7782013-02-25 14:49:29 +00002302 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;,
2303 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;
Manuel Klimek1da79332012-08-20 20:54:03 +00002304</pre></td></tr>
2305
2306
Manuel Klimek67619ff2012-09-07 13:10:32 +00002307<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 +00002308<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher.
2309
2310Example: matches "a string" (matcher =
Manuel Klimeke44a0062012-08-26 23:55:24 +00002311 hasSourceExpression(constructExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002312class URL { URL(string); };
2313URL url = "a string";
2314</pre></td></tr>
2315
2316
Manuel Klimek67619ff2012-09-07 13:10:32 +00002317<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 +00002318<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one
2319TemplateArgument matching the given InnerMatcher.
2320
2321Given
2322 template&lt;typename T&gt; class A {};
2323 template&lt;&gt; class A&lt;double&gt; {};
2324 A&lt;int&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002325classTemplateSpecializationDecl(hasAnyTemplateArgument(
Manuel Klimek1da79332012-08-20 20:54:03 +00002326 refersToType(asString("int"))))
2327 matches the specialization A&lt;int&gt;
2328</pre></td></tr>
2329
2330
Manuel Klimek67619ff2012-09-07 13:10:32 +00002331<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 +00002332<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument
2333matches the given InnerMatcher.
2334
2335Given
2336 template&lt;typename T, typename U&gt; class A {};
2337 A&lt;bool, int&gt; b;
2338 A&lt;int, bool&gt; c;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002339classTemplateSpecializationDecl(hasTemplateArgument(
Manuel Klimek1da79332012-08-20 20:54:03 +00002340 1, refersToType(asString("int"))))
2341 matches the specialization A&lt;bool, int&gt;
2342</pre></td></tr>
2343
2344
Manuel Klimek41df16e2013-01-09 09:38:21 +00002345<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>
2346<tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element
2347type.
2348
2349Given
2350 struct A {};
2351 A a[7];
2352 int b[7];
2353arrayType(hasElementType(builtinType()))
2354 matches "int b[7]"
2355
2356Usable 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;
2357</pre></td></tr>
2358
2359
2360<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>
2361<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element
2362type.
2363
2364Given
2365 struct A {};
2366 A a[7];
2367 int b[7];
2368arrayType(hasElementType(builtinType()))
2369 matches "int b[7]"
2370
2371Usable 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;
2372</pre></td></tr>
2373
2374
Manuel Klimek67619ff2012-09-07 13:10:32 +00002375<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 +00002376<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches
2377a given matcher.
2378
2379Given
2380 { {}; 1+2; }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002381hasAnySubstatement(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00002382 matches '{ {}; 1+2; }'
Manuel Klimeke44a0062012-08-26 23:55:24 +00002383with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00002384 matching '{}'
2385</pre></td></tr>
2386
2387
Manuel Klimek67619ff2012-09-07 13:10:32 +00002388<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 +00002389<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop,
2390or conditional operator.
2391
2392Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2393 if (true) {}
2394</pre></td></tr>
2395
2396
Manuel Klimek67619ff2012-09-07 13:10:32 +00002397<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 +00002398<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator.
2399
2400Example matches b
2401 condition ? a : b
2402</pre></td></tr>
2403
2404
Manuel Klimek67619ff2012-09-07 13:10:32 +00002405<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 +00002406<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator.
2407
2408Example matches a
2409 condition ? a : b
2410</pre></td></tr>
2411
2412
Manuel Klimek67619ff2012-09-07 13:10:32 +00002413<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 +00002414<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a
2415specific using shadow declaration.
2416
2417FIXME: This currently only works for functions. Fix.
2418
2419Given
2420 namespace a { void f() {} }
2421 using a::f;
2422 void g() {
2423 f(); Matches this ..
2424 a::f(); .. but not this.
2425 }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002426declRefExpr(throughUsingDeclaration(anything()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002427 matches f()
2428</pre></td></tr>
2429
2430
Manuel Klimek67619ff2012-09-07 13:10:32 +00002431<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 +00002432<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the
2433specified matcher.
2434
2435Example matches x in if(x)
Manuel Klimeke44a0062012-08-26 23:55:24 +00002436 (matcher = declRefExpr(to(varDecl(hasName("x")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002437 bool x;
2438 if (x) {}
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_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 +00002443<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement.
2444
2445Note that this does not work for global declarations because the AST
2446breaks up multiple-declaration DeclStmt's into multiple single-declaration
2447DeclStmt's.
2448Example: Given non-global declarations
2449 int a, b = 0;
2450 int c;
2451 int d = 2, e;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002452declStmt(containsDeclaration(
2453 0, varDecl(hasInitializer(anything()))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002454 matches only 'int d = 2, e;', and
Manuel Klimeke44a0062012-08-26 23:55:24 +00002455declStmt(containsDeclaration(1, varDecl()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002456 matches 'int a, b = 0' as well as 'int d = 2, e;'
2457 but 'int c;' is not matched.
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_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 +00002462<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration.
2463
2464Given
2465 int a, b;
2466 int c;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002467declStmt(hasSingleDecl(anything()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002468 matches 'int c;' but not 'int a, b;'.
2469</pre></td></tr>
2470
2471
Edwin Vane742d9e72013-02-25 20:43:32 +00002472<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('hasDeclContext0')"><a name="hasDeclContext0Anchor">hasDeclContext</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
2473<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a
2474Decl, matches InnerMatcher.
2475
2476Given
2477 namespace N {
2478 namespace M {
2479 class D {};
2480 }
2481 }
2482
2483recordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
2484declaration of class D.
2485</pre></td></tr>
2486
2487
Manuel Klimek67619ff2012-09-07 13:10:32 +00002488<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 +00002489<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has
2490a given body.
2491
2492Given
2493 for (;;) {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00002494hasBody(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00002495 matches 'for (;;) {}'
Manuel Klimeke44a0062012-08-26 23:55:24 +00002496with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00002497 matching '{}'
2498</pre></td></tr>
2499
2500
Manuel Klimek67619ff2012-09-07 13:10:32 +00002501<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 +00002502<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop,
2503or conditional operator.
2504
2505Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2506 if (true) {}
2507</pre></td></tr>
2508
2509
Edwin Vane742d9e72013-02-25 20:43:32 +00002510<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>&gt;</td><td class="name" onclick="toggle('hasQualifier0')"><a name="hasQualifier0Anchor">hasQualifier</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt; InnerMatcher</td></tr>
2511<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
2512matches InnerMatcher.
2513
2514Given
2515 namespace N {
2516 namespace M {
2517 class D {};
2518 }
2519 }
2520 N::M::D d;
2521
2522elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N"))))
2523matches the type of the variable declaration of d.
2524</pre></td></tr>
2525
2526
2527<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>&gt;</td><td class="name" onclick="toggle('namesType0')"><a name="namesType0Anchor">namesType</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
2528<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher.
2529
2530Given
2531 namespace N {
2532 namespace M {
2533 class D {};
2534 }
2535 }
2536 N::M::D d;
2537
2538elaboratedType(namesType(recordType(
2539hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable
2540declaration of d.
2541</pre></td></tr>
2542
2543
Manuel Klimek67619ff2012-09-07 13:10:32 +00002544<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 +00002545<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher.
2546
2547(Note: Clang's AST refers to other conversions as "casts" too, and calls
2548actual casts "explicit" casts.)
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_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 +00002553<tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value
2554declaration's type.
2555
2556In case of a value declaration (for example a variable declaration),
2557this resolves one layer of indirection. For example, in the value
Manuel Klimeke44a0062012-08-26 23:55:24 +00002558declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
2559while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
Manuel Klimek1da79332012-08-20 20:54:03 +00002560of x."
2561
Manuel Klimeke44a0062012-08-26 23:55:24 +00002562Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
2563 and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002564 class X {};
2565 void y(X &amp;x) { x; X z; }
2566
2567Usable 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;
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_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 +00002572<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts
2573are stripped off.
2574
2575Parentheses and explicit casts are not discarded.
2576Given
2577 int arr[5];
2578 int a = 0;
2579 char b = 0;
2580 const int c = a;
2581 int *d = arr;
2582 long e = (long) 0l;
2583The matchers
Manuel Klimeke44a0062012-08-26 23:55:24 +00002584 varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
2585 varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002586would match the declarations for a, b, c, and d, but not e.
2587While
Manuel Klimeke44a0062012-08-26 23:55:24 +00002588 varDecl(hasInitializer(integerLiteral()))
2589 varDecl(hasInitializer(declRefExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002590only match the declarations for b, c, and d.
2591</pre></td></tr>
2592
2593
Manuel Klimek67619ff2012-09-07 13:10:32 +00002594<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 +00002595<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and
2596casts are stripped off.
2597
2598Implicit and non-C Style casts are also discarded.
2599Given
2600 int a = 0;
2601 char b = (0);
2602 void* c = reinterpret_cast&lt;char*&gt;(0);
2603 char d = char(0);
2604The matcher
Manuel Klimeke44a0062012-08-26 23:55:24 +00002605 varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002606would match the declarations for a, b, c, and d.
2607while
Manuel Klimeke44a0062012-08-26 23:55:24 +00002608 varDecl(hasInitializer(integerLiteral()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002609only match the declaration for a.
2610</pre></td></tr>
2611
2612
Manuel Klimek67619ff2012-09-07 13:10:32 +00002613<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 +00002614<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and
2615parentheses are stripped off.
2616
2617Explicit casts are not discarded.
2618Given
2619 int arr[5];
2620 int a = 0;
2621 char b = (0);
2622 const int c = a;
2623 int *d = (arr);
2624 long e = ((long) 0l);
2625The matchers
Manuel Klimeke44a0062012-08-26 23:55:24 +00002626 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
2627 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002628would match the declarations for a, b, c, and d, but not e.
2629while
Manuel Klimeke44a0062012-08-26 23:55:24 +00002630 varDecl(hasInitializer(integerLiteral()))
2631 varDecl(hasInitializer(declRefExpr()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002632would only match the declaration for a.
2633</pre></td></tr>
2634
2635
Manuel Klimek67619ff2012-09-07 13:10:32 +00002636<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 +00002637<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has
2638a given body.
2639
2640Given
2641 for (;;) {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00002642hasBody(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00002643 matches 'for (;;) {}'
Manuel Klimeke44a0062012-08-26 23:55:24 +00002644with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00002645 matching '{}'
2646</pre></td></tr>
2647
2648
Manuel Klimek67619ff2012-09-07 13:10:32 +00002649<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00002650<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop,
2651or conditional operator.
2652
2653Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2654 if (true) {}
2655</pre></td></tr>
2656
2657
Manuel Klimek67619ff2012-09-07 13:10:32 +00002658<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 +00002659<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop.
2660
2661Example:
2662 forStmt(hasIncrement(unaryOperator(hasOperatorName("++"))))
2663matches '++x' in
2664 for (x; x &lt; N; ++x) { }
2665</pre></td></tr>
2666
2667
Manuel Klimek67619ff2012-09-07 13:10:32 +00002668<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 +00002669<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop.
2670
2671Example:
Manuel Klimeke44a0062012-08-26 23:55:24 +00002672 forStmt(hasLoopInit(declStmt()))
Manuel Klimek1da79332012-08-20 20:54:03 +00002673matches 'int x = 0' in
2674 for (int x = 0; x &lt; N; ++x) { }
2675</pre></td></tr>
2676
2677
Manuel Klimek67619ff2012-09-07 13:10:32 +00002678<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 +00002679<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration.
2680
2681Does not match the 'this' parameter of a method.
2682
2683Given
2684 class X { void f(int x, int y, int z) {} };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002685methodDecl(hasAnyParameter(hasName("y")))
Manuel Klimek1da79332012-08-20 20:54:03 +00002686 matches f(int x, int y, int z) {}
2687with hasAnyParameter(...)
2688 matching int y
2689</pre></td></tr>
2690
2691
Manuel Klimek67619ff2012-09-07 13:10:32 +00002692<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00002693<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration.
2694
2695Given
2696 class X { void f(int x) {} };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002697methodDecl(hasParameter(0, hasType(varDecl())))
Manuel Klimek1da79332012-08-20 20:54:03 +00002698 matches f(int x) {}
2699with hasParameter(...)
2700 matching int x
2701</pre></td></tr>
2702
2703
Manuel Klimek67619ff2012-09-07 13:10:32 +00002704<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 +00002705<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration.
2706
2707Given:
2708 class X { int f() { return 1; } };
Manuel Klimeke44a0062012-08-26 23:55:24 +00002709methodDecl(returns(asString("int")))
Manuel Klimek1da79332012-08-20 20:54:03 +00002710 matches int f() { return 1; }
2711</pre></td></tr>
2712
2713
Manuel Klimek67619ff2012-09-07 13:10:32 +00002714<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 +00002715<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop,
2716or conditional operator.
2717
2718Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
2719 if (true) {}
2720</pre></td></tr>
2721
2722
Manuel Klimek67619ff2012-09-07 13:10:32 +00002723<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00002724<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement.
2725
2726Given
2727 if (A* a = GetAPointer()) {}
2728hasConditionVariableStatment(...)
2729 matches 'A* a = GetAPointer()'.
2730</pre></td></tr>
2731
2732
Manuel Klimek67619ff2012-09-07 13:10:32 +00002733<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 +00002734<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given
2735matcher.
2736
2737FIXME: Unit test this matcher
2738</pre></td></tr>
2739
2740
Edwin Vane3abf7782013-02-25 14:49:29 +00002741<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration2')"><a name="hasDeclaration2Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
2742<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a type if the declaration of the type matches the given
Daniel Jaspere0b89972012-12-04 12:08:08 +00002743matcher.
2744
Edwin Vane52380602013-02-19 17:14:34 +00002745In addition to being usable as Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, also usable as
2746Matcher&lt;T&gt; for any T supporting the getDecl() member function. e.g. various
2747subtypes of clang::Type.
2748
Daniel Jaspere0b89972012-12-04 12:08:08 +00002749Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
Edwin Vane3abf7782013-02-25 14:49:29 +00002750 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;,
2751 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;
Daniel Jaspere0b89972012-12-04 12:08:08 +00002752</pre></td></tr>
2753
2754
Manuel Klimek67619ff2012-09-07 13:10:32 +00002755<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00002756<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is
2757matched by a given matcher.
2758
2759Given
2760 struct X { int m; };
2761 void f(X x) { x.m; m; }
Manuel Klimeke44a0062012-08-26 23:55:24 +00002762memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X")))))))
Manuel Klimek1da79332012-08-20 20:54:03 +00002763 matches "x.m" and "m"
2764with hasObjectExpression(...)
2765 matching "x" and the implicit object expression of "m" which has type X*.
2766</pre></td></tr>
2767
2768
Manuel Klimek67619ff2012-09-07 13:10:32 +00002769<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 +00002770<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a
2771given matcher.
2772
2773Given
2774 struct { int first, second; } first, second;
2775 int i(second.first);
2776 int j(first.second);
Manuel Klimeke44a0062012-08-26 23:55:24 +00002777memberExpr(member(hasName("first")))
Manuel Klimek1da79332012-08-20 20:54:03 +00002778 matches second.first
2779 but not first.second (because the member name there is "second").
2780</pre></td></tr>
2781
2782
Manuel Klimek41df16e2013-01-09 09:38:21 +00002783<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>
2784<tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the
2785pointee matches a given matcher.
2786
2787Given
2788 int *a;
2789 int const *b;
2790 float const *f;
2791pointerType(pointee(isConstQualified(), isInteger()))
2792 matches "int const *b"
2793
2794Usable 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;,
2795 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;
2796</pre></td></tr>
2797
2798
2799<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>
2800<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the
2801pointee matches a given matcher.
2802
2803Given
2804 int *a;
2805 int const *b;
2806 float const *f;
2807pointerType(pointee(isConstQualified(), isInteger()))
2808 matches "int const *b"
2809
2810Usable 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;,
2811 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;
2812</pre></td></tr>
2813
2814
Manuel Klimek415514d2013-02-06 20:36:22 +00002815<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 +00002816<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc.
2817
2818Given
2819 struct A { struct B { struct C {}; }; };
2820 A::B::C c;
2821nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A")))))
2822 matches "A::"
2823</pre></td></tr>
2824
2825
Manuel Klimek41df16e2013-01-09 09:38:21 +00002826<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>
2827<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner
2828NestedNameSpecifier-matcher matches.
2829</pre></td></tr>
2830
2831
Daniel Jaspere0b89972012-12-04 12:08:08 +00002832<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>
2833<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the
2834given TypeLoc.
2835
2836Given
2837 struct A { struct B { struct C {}; }; };
2838 A::B::C c;
2839nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
2840 hasDeclaration(recordDecl(hasName("A")))))))
2841 matches "A::"
2842</pre></td></tr>
2843
2844
Manuel Klimek415514d2013-02-06 20:36:22 +00002845<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 +00002846<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier.
2847
2848Given
2849 struct A { struct B { struct C {}; }; };
2850 A::B::C c;
2851nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and
2852 matches "A::"
2853</pre></td></tr>
2854
2855
2856<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>
2857<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the
2858given namespace matcher.
2859
2860Given
2861 namespace ns { struct A {}; }
2862 ns::A a;
2863nestedNameSpecifier(specifiesNamespace(hasName("ns")))
2864 matches "ns::"
2865</pre></td></tr>
2866
2867
2868<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>
2869<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the
2870given QualType matcher without qualifiers.
2871
2872Given
2873 struct A { struct B { struct C {}; }; };
2874 A::B::C c;
2875nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A")))))
2876 matches "A::"
2877</pre></td></tr>
2878
2879
Manuel Klimek41df16e2013-01-09 09:38:21 +00002880<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>
2881<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the
2882pointee matches a given matcher.
2883
2884Given
2885 int *a;
2886 int const *b;
2887 float const *f;
2888pointerType(pointee(isConstQualified(), isInteger()))
2889 matches "int const *b"
2890
2891Usable 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;,
2892 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;
2893</pre></td></tr>
2894
2895
2896<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>
2897<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the
2898pointee matches a given matcher.
2899
2900Given
2901 int *a;
2902 int const *b;
2903 float const *f;
2904pointerType(pointee(isConstQualified(), isInteger()))
2905 matches "int const *b"
2906
2907Usable 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;,
2908 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;
2909</pre></td></tr>
2910
2911
Edwin Vane3abf7782013-02-25 14:49:29 +00002912<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration5')"><a name="hasDeclaration5Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
2913<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a type if the declaration of the type matches the given
Manuel Klimek1da79332012-08-20 20:54:03 +00002914matcher.
2915
Edwin Vane52380602013-02-19 17:14:34 +00002916In addition to being usable as Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, also usable as
2917Matcher&lt;T&gt; for any T supporting the getDecl() member function. e.g. various
2918subtypes of clang::Type.
2919
Daniel Jaspere0b89972012-12-04 12:08:08 +00002920Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
Edwin Vane3abf7782013-02-25 14:49:29 +00002921 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;,
2922 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;
Manuel Klimek1da79332012-08-20 20:54:03 +00002923</pre></td></tr>
2924
2925
Manuel Klimek67619ff2012-09-07 13:10:32 +00002926<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_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 +00002927<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration.
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_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 +00002932<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration.
2933</pre></td></tr>
2934
2935
Manuel Klimek41df16e2013-01-09 09:38:21 +00002936<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>
2937<tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the
2938pointee matches a given matcher.
2939
2940Given
2941 int *a;
2942 int const *b;
2943 float const *f;
2944pointerType(pointee(isConstQualified(), isInteger()))
2945 matches "int const *b"
2946
2947Usable 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;,
2948 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;
2949</pre></td></tr>
2950
2951
2952<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>
2953<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the
2954pointee matches a given matcher.
2955
2956Given
2957 int *a;
2958 int const *b;
2959 float const *f;
2960pointerType(pointee(isConstQualified(), isInteger()))
2961 matches "int const *b"
2962
2963Usable 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;,
2964 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;
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_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 +00002969<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
2970alignof.
2971</pre></td></tr>
2972
2973
Manuel Klimek67619ff2012-09-07 13:10:32 +00002974<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 +00002975<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
2976sizeof.
2977</pre></td></tr>
2978
2979
Manuel Klimek67619ff2012-09-07 13:10:32 +00002980<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 +00002981<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a TemplateArgument that refers to a certain declaration.
2982
2983Given
2984 template&lt;typename T&gt; struct A {};
2985 struct B { B* next; };
2986 A&lt;&amp;B::next&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +00002987classTemplateSpecializationDecl(hasAnyTemplateArgument(
2988 refersToDeclaration(fieldDecl(hasName("next"))))
2989 matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
Manuel Klimek1da79332012-08-20 20:54:03 +00002990 B::next
2991</pre></td></tr>
2992
2993
Manuel Klimek67619ff2012-09-07 13:10:32 +00002994<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 +00002995<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type.
2996
2997Given
2998 struct X {};
2999 template&lt;typename T&gt; struct A {};
3000 A&lt;X&gt; a;
Manuel Klimeke44a0062012-08-26 23:55:24 +00003001classTemplateSpecializationDecl(hasAnyTemplateArgument(
Manuel Klimek1da79332012-08-20 20:54:03 +00003002 refersToType(class(hasName("X")))))
3003 matches the specialization A&lt;X&gt;
3004</pre></td></tr>
3005
3006
Edwin Vane3abf7782013-02-25 14:49:29 +00003007<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration0')"><a name="hasDeclaration0Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
Edwin Vane52380602013-02-19 17:14:34 +00003008<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a type if the declaration of the type matches the given
3009matcher.
3010
3011In addition to being usable as Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, also usable as
3012Matcher&lt;T&gt; for any T supporting the getDecl() member function. e.g. various
3013subtypes of clang::Type.
3014
3015Usable as: Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;, Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;,
Edwin Vane3abf7782013-02-25 14:49:29 +00003016 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;,
3017 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;
3018</pre></td></tr>
3019
3020
3021<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>
3022<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner
3023QualType-matcher matches.
3024</pre></td></tr>
3025
3026
3027<tr><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration1')"><a name="hasDeclaration1Anchor">hasDeclaration</a></td><td>Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
3028<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a type if the declaration of the type matches the given
3029matcher.
3030
3031In addition to being usable as Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;, also usable as
3032Matcher&lt;T&gt; for any T supporting the getDecl() member function. e.g. various
3033subtypes of clang::Type.
3034
3035Usable 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;,
3036 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;,
3037 Matcher&lt<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;
Daniel Jaspere0b89972012-12-04 12:08:08 +00003038</pre></td></tr>
3039
3040
Manuel Klimek67619ff2012-09-07 13:10:32 +00003041<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 +00003042<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument.
3043
3044Given
3045 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
3046unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
3047 matches sizeof(a) and alignof(c)
3048</pre></td></tr>
3049
3050
Manuel Klimek67619ff2012-09-07 13:10:32 +00003051<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 +00003052<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches.
3053
Daniel Jaspere0b89972012-12-04 12:08:08 +00003054Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true))))
Manuel Klimek1da79332012-08-20 20:54:03 +00003055 !true
3056</pre></td></tr>
3057
3058
Manuel Klimek67619ff2012-09-07 13:10:32 +00003059<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 +00003060<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration.
3061
3062Given
3063 namespace X { void b(); }
3064 using X::b;
3065usingDecl(hasAnyUsingShadowDecl(hasName("b"))))
3066 matches using X::b </pre></td></tr>
3067
3068
Manuel Klimek67619ff2012-09-07 13:10:32 +00003069<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 +00003070<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is
3071matched by the given matcher.
3072
3073Given
3074 namespace X { int a; void b(); }
3075 using X::a;
3076 using X::b;
Manuel Klimeke44a0062012-08-26 23:55:24 +00003077usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
Manuel Klimek1da79332012-08-20 20:54:03 +00003078 matches using X::b but not using X::a </pre></td></tr>
3079
3080
Manuel Klimek67619ff2012-09-07 13:10:32 +00003081<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 +00003082<tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value
3083declaration's type.
3084
3085In case of a value declaration (for example a variable declaration),
3086this resolves one layer of indirection. For example, in the value
Manuel Klimeke44a0062012-08-26 23:55:24 +00003087declaration "X x;", recordDecl(hasName("X")) matches the declaration of X,
3088while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration
Manuel Klimek1da79332012-08-20 20:54:03 +00003089of x."
3090
Manuel Klimeke44a0062012-08-26 23:55:24 +00003091Example matches x (matcher = expr(hasType(recordDecl(hasName("X")))))
3092 and z (matcher = varDecl(hasType(recordDecl(hasName("X")))))
Manuel Klimek1da79332012-08-20 20:54:03 +00003093 class X {};
3094 void y(X &amp;x) { x; X z; }
3095
3096Usable 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;
3097</pre></td></tr>
3098
3099
Manuel Klimek67619ff2012-09-07 13:10:32 +00003100<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 +00003101<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression
3102that matches the given matcher.
3103
Manuel Klimeke44a0062012-08-26 23:55:24 +00003104Example matches x (matcher = varDecl(hasInitializer(callExpr())))
Manuel Klimek1da79332012-08-20 20:54:03 +00003105 bool y() { return true; }
3106 bool x = y();
3107</pre></td></tr>
3108
3109
Daniel Jaspere0b89972012-12-04 12:08:08 +00003110<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>
3111<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size
3112expression.
3113
3114Given
3115 void f(int b) {
3116 int a[b];
3117 }
3118variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
3119 varDecl(hasName("b")))))))
3120 matches "int a[b]"
3121</pre></td></tr>
3122
3123
Manuel Klimek67619ff2012-09-07 13:10:32 +00003124<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 +00003125<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has
3126a given body.
3127
3128Given
3129 for (;;) {}
Manuel Klimeke44a0062012-08-26 23:55:24 +00003130hasBody(compoundStmt())
Manuel Klimek1da79332012-08-20 20:54:03 +00003131 matches 'for (;;) {}'
Manuel Klimeke44a0062012-08-26 23:55:24 +00003132with compoundStmt()
Manuel Klimek1da79332012-08-20 20:54:03 +00003133 matching '{}'
3134</pre></td></tr>
3135
3136
Manuel Klimek67619ff2012-09-07 13:10:32 +00003137<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 +00003138<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop,
3139or conditional operator.
3140
3141Example matches true (matcher = hasCondition(boolLiteral(equals(true))))
3142 if (true) {}
3143</pre></td></tr>
3144
3145<!--END_TRAVERSAL_MATCHERS -->
3146</table>
3147
3148</div>
3149</body>
3150</html>
3151
3152