1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2          "http://www.w3.org/TR/html4/strict.dtd">
3<html>
4<head>
5<title>AST Matcher Reference</title>
6<link type="text/css" rel="stylesheet" href="../menu.css" />
7<link type="text/css" rel="stylesheet" href="../content.css" />
8<style type="text/css">
9td {
10  padding: .33em;
11}
12td.doc {
13  display: none;
14  border-bottom: 1px solid black;
15}
16td.name:hover {
17  color: blue;
18  cursor: pointer;
19}
20</style>
21<script type="text/javascript">
22function toggle(id) {
23  if (!id) return;
24  row = document.getElementById(id);
25  if (row.style.display != 'table-cell')
26    row.style.display = 'table-cell';
27  else
28    row.style.display = 'none';
29}
30</script>
31</head>
32<body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))">
33
34<!--#include virtual="../menu.html.incl"-->
35
36<div id="content">
37
38<h1>AST Matcher Reference</h1>
39
40<p>This document shows all currently implemented matchers. The matchers are grouped
41by category and node type they match. You can click on matcher names to show the
42matcher's source documentation.</p>
43
44<p>There are three different basic categories of matchers:
45<ul>
46<li><a href="#decl-matchers">Node Matchers:</a> Matchers that match a specific type of AST node.</li>
47<li><a href="#narrowing-matchers">Narrowing Matchers:</a> Matchers that match attributes on AST nodes.</li>
48<li><a href="#traversal-matchers">Traversal Matchers:</a> Matchers that allow traversal between AST nodes.</li>
49</ul>
50</p>
51
52<p>Within each category the matchers are ordered by node type they match on.
53Note that if a matcher can match multiple node types, it will it will appear
54multiple times. This means that by searching for Matcher&lt;Stmt&gt; you can
55find all matchers that can be used to match on Stmt nodes.</p>
56
57<p>The exception to that rule are matchers that can match on any node. Those
58are marked with a * and are listed in the beginning of each category.</p>
59
60<p>Note that the categorization of matchers is a great help when you combine
61them into matcher expressions. You will usually want to form matcher expressions
62that read like english sentences by alternating between node matchers and
63narrowing or traversal matchers, like this:
64<pre>
65recordDecl(hasDescendant(
66    ifStmt(hasTrueExpression(
67        expr(hasDescendant(
68            ifStmt()))))))
69</pre>
70</p>
71
72<!-- ======================================================================= -->
73<h2 id="decl-matchers">Node Matchers</h2>
74<!-- ======================================================================= -->
75
76<p>Node matchers are at the core of matcher expressions - they specify the type
77of node that is expected. Every match expression starts with a node matcher,
78which can then be further refined with a narrowing or traversal matcher. All
79traversal matchers take node matchers as their arguments.</p>
80
81<p>For convenience, all node matchers take an arbitrary number of arguments
82and implicitly act as allOf matchers.</p>
83
84<p>Node matchers are the only matchers that support the bind("id") call to
85bind the matched node to the given string, to be later retrieved from the
86match callback.</p>
87
88<p>It is important to remember that the arguments to node matchers are
89predicates on the same node, just with additional information about the type.
90This is often useful to make matcher expression more readable by inlining bind
91calls into redundant node matchers inside another node matcher:
92<pre>
93// This binds the CXXRecordDecl to "id", as the decl() matcher will stay on
94// the same node.
95recordDecl(decl().bind("id"), hasName("::MyClass"))
96</pre>
97</p>
98
99<table>
100<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
101<!-- START_DECL_MATCHERS -->
102
103<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;</td><td class="name" onclick="toggle('cxxCtorInitializer0')"><a name="cxxCtorInitializer0Anchor">cxxCtorInitializer</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;...</td></tr>
104<tr><td colspan="4" class="doc" id="cxxCtorInitializer0"><pre>Matches constructor initializers.
105
106Examples matches i(42).
107  class C {
108    C() : i(42) {}
109    int i;
110  };
111</pre></td></tr>
112
113
114<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1AccessSpecDecl.html">AccessSpecDecl</a>&gt;...</td></tr>
115<tr><td colspan="4" class="doc" id="accessSpecDecl0"><pre>Matches C++ access specifier declarations.
116
117Given
118  class C {
119  public:
120    int a;
121  };
122accessSpecDecl()
123  matches 'public:'
124</pre></td></tr>
125
126
127<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('blockDecl0')"><a name="blockDecl0Anchor">blockDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;...</td></tr>
128<tr><td colspan="4" class="doc" id="blockDecl0"><pre>Matches block declarations.
129
130Example matches the declaration of the nameless block printing an input
131integer.
132
133  myFunc(^(int p) {
134    printf("%d", p);
135  })
136</pre></td></tr>
137
138
139<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html">ClassTemplateDecl</a>&gt;...</td></tr>
140<tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations.
141
142Example matches Z
143  template&lt;class T&gt; class Z {};
144</pre></td></tr>
145
146
147<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('classTemplatePartialSpecializationDecl0')"><a name="classTemplatePartialSpecializationDecl0Anchor">classTemplatePartialSpecializationDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplatePartialSpecializationDecl.html">ClassTemplatePartialSpecializationDecl</a>&gt;...</td></tr>
148<tr><td colspan="4" class="doc" id="classTemplatePartialSpecializationDecl0"><pre>Matches C++ class template partial specializations.
149
150Given
151  template&lt;class T1, class T2, int I&gt;
152  class A {};
153
154  template&lt;class T, int I&gt;
155  class A&lt;T, T*, I&gt; {};
156
157  template&lt;&gt;
158  class A&lt;int, int, 1&gt; {};
159classTemplatePartialSpecializationDecl()
160  matches the specialization A&lt;T,T*,I&gt; but not A&lt;int,int,1&gt;
161</pre></td></tr>
162
163
164<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;...</td></tr>
165<tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations.
166
167Given
168  template&lt;typename T&gt; class A {};
169  template&lt;&gt; class A&lt;double&gt; {};
170  A&lt;int&gt; a;
171classTemplateSpecializationDecl()
172  matches the specializations A&lt;int&gt; and A&lt;double&gt;
173</pre></td></tr>
174
175
176<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('cxxConstructorDecl0')"><a name="cxxConstructorDecl0Anchor">cxxConstructorDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;...</td></tr>
177<tr><td colspan="4" class="doc" id="cxxConstructorDecl0"><pre>Matches C++ constructor declarations.
178
179Example matches Foo::Foo() and Foo::Foo(int)
180  class Foo {
181   public:
182    Foo();
183    Foo(int);
184    int DoSomething();
185  };
186</pre></td></tr>
187
188
189<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('cxxConversionDecl0')"><a name="cxxConversionDecl0Anchor">cxxConversionDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>&gt;...</td></tr>
190<tr><td colspan="4" class="doc" id="cxxConversionDecl0"><pre>Matches conversion operator declarations.
191
192Example matches the operator.
193  class X { operator int() const; };
194</pre></td></tr>
195
196
197<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('cxxDestructorDecl0')"><a name="cxxDestructorDecl0Anchor">cxxDestructorDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>&gt;...</td></tr>
198<tr><td colspan="4" class="doc" id="cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations.
199
200Example matches Foo::~Foo()
201  class Foo {
202   public:
203    virtual ~Foo();
204  };
205</pre></td></tr>
206
207
208<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('cxxMethodDecl0')"><a name="cxxMethodDecl0Anchor">cxxMethodDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;...</td></tr>
209<tr><td colspan="4" class="doc" id="cxxMethodDecl0"><pre>Matches method declarations.
210
211Example matches y
212  class X { void y(); };
213</pre></td></tr>
214
215
216<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('cxxRecordDecl0')"><a name="cxxRecordDecl0Anchor">cxxRecordDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;...</td></tr>
217<tr><td colspan="4" class="doc" id="cxxRecordDecl0"><pre>Matches C++ class declarations.
218
219Example matches X, Z
220  class X;
221  template&lt;class T&gt; class Z {};
222</pre></td></tr>
223
224
225<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;...</td></tr>
226<tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations.
227
228Examples matches X, C, and the friend declaration inside C;
229  void X();
230  class C {
231    friend X;
232  };
233</pre></td></tr>
234
235
236<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('declaratorDecl0')"><a name="declaratorDecl0Anchor">declaratorDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;...</td></tr>
237<tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function
238and non-type template parameter declarations).
239
240Given
241  class X { int y; };
242declaratorDecl()
243  matches int y.
244</pre></td></tr>
245
246
247<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1EnumConstantDecl.html">EnumConstantDecl</a>&gt;...</td></tr>
248<tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants.
249
250Example matches A, B, C
251  enum X {
252    A, B, C
253  };
254</pre></td></tr>
255
256
257<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl</a>&gt;...</td></tr>
258<tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations.
259
260Example matches X
261  enum X {
262    A, B, C
263  };
264</pre></td></tr>
265
266
267<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>&gt;...</td></tr>
268<tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations.
269
270Given
271  class X { int m; };
272fieldDecl()
273  matches 'm'.
274</pre></td></tr>
275
276
277<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('friendDecl0')"><a name="friendDecl0Anchor">friendDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>&gt;...</td></tr>
278<tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations.
279
280Given
281  class X { friend void foo(); };
282friendDecl()
283  matches 'friend void foo()'.
284</pre></td></tr>
285
286
287<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;...</td></tr>
288<tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations.
289
290Example matches f
291  void f();
292</pre></td></tr>
293
294
295<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FunctionTemplateDecl.html">FunctionTemplateDecl</a>&gt;...</td></tr>
296<tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations.
297
298Example matches f
299  template&lt;class T&gt; void f(T t) {}
300</pre></td></tr>
301
302
303<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('labelDecl0')"><a name="labelDecl0Anchor">labelDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelDecl.html">LabelDecl</a>&gt;...</td></tr>
304<tr><td colspan="4" class="doc" id="labelDecl0"><pre>Matches a declaration of label.
305
306Given
307  goto FOO;
308  FOO: bar();
309labelDecl()
310  matches 'FOO:'
311</pre></td></tr>
312
313
314<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('linkageSpecDecl0')"><a name="linkageSpecDecl0Anchor">linkageSpecDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LinkageSpecDecl.html">LinkageSpecDecl</a>&gt;...</td></tr>
315<tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification.
316
317Given
318  extern "C" {}
319linkageSpecDecl()
320  matches "extern "C" {}"
321</pre></td></tr>
322
323
324<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt;...</td></tr>
325<tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name.
326
327Example matches X, S, the anonymous union type, i, and U;
328  typedef int X;
329  struct S {
330    union {
331      int i;
332    } U;
333  };
334</pre></td></tr>
335
336
337<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('namespaceAliasDecl0')"><a name="namespaceAliasDecl0Anchor">namespaceAliasDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NamespaceAliasDecl.html">NamespaceAliasDecl</a>&gt;...</td></tr>
338<tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias.
339
340Given
341  namespace test {}
342  namespace alias = ::test;
343namespaceAliasDecl()
344  matches "namespace alias" but not "namespace test"
345</pre></td></tr>
346
347
348<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('namespaceDecl0')"><a name="namespaceDecl0Anchor">namespaceDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>&gt;...</td></tr>
349<tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace.
350
351Given
352  namespace {}
353  namespace test {}
354namespaceDecl()
355  matches "namespace {}" and "namespace test {}"
356</pre></td></tr>
357
358
359<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('nonTypeTemplateParmDecl0')"><a name="nonTypeTemplateParmDecl0Anchor">nonTypeTemplateParmDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NonTypeTemplateParmDecl.html">NonTypeTemplateParmDecl</a>&gt;...</td></tr>
360<tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations.
361
362Given
363  template &lt;typename T, int N&gt; struct C {};
364nonTypeTemplateParmDecl()
365  matches 'N', but not 'T'.
366</pre></td></tr>
367
368
369<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('objcCategoryDecl0')"><a name="objcCategoryDecl0Anchor">objcCategoryDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryDecl.html">ObjCCategoryDecl</a>&gt;...</td></tr>
370<tr><td colspan="4" class="doc" id="objcCategoryDecl0"><pre>Matches Objective-C category declarations.
371
372Example matches Foo (Additions)
373  @interface Foo (Additions)
374  @end
375</pre></td></tr>
376
377
378<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('objcCategoryImplDecl0')"><a name="objcCategoryImplDecl0Anchor">objcCategoryImplDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryImplDecl.html">ObjCCategoryImplDecl</a>&gt;...</td></tr>
379<tr><td colspan="4" class="doc" id="objcCategoryImplDecl0"><pre>Matches Objective-C category definitions.
380
381Example matches Foo (Additions)
382  @implementation Foo (Additions)
383  @end
384</pre></td></tr>
385
386
387<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('objcImplementationDecl0')"><a name="objcImplementationDecl0Anchor">objcImplementationDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCImplementationDecl.html">ObjCImplementationDecl</a>&gt;...</td></tr>
388<tr><td colspan="4" class="doc" id="objcImplementationDecl0"><pre>Matches Objective-C implementation declarations.
389
390Example matches Foo
391  @implementation Foo
392  @end
393</pre></td></tr>
394
395
396<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('objcInterfaceDecl0')"><a name="objcInterfaceDecl0Anchor">objcInterfaceDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>&gt;...</td></tr>
397<tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations.
398
399Example matches Foo
400  @interface Foo
401  @end
402</pre></td></tr>
403
404
405<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('objcIvarDecl0')"><a name="objcIvarDecl0Anchor">objcIvarDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCIvarDecl.html">ObjCIvarDecl</a>&gt;...</td></tr>
406<tr><td colspan="4" class="doc" id="objcIvarDecl0"><pre>Matches Objective-C instance variable declarations.
407
408Example matches _enabled
409  @implementation Foo {
410    BOOL _enabled;
411  }
412  @end
413</pre></td></tr>
414
415
416<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('objcMethodDecl0')"><a name="objcMethodDecl0Anchor">objcMethodDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;...</td></tr>
417<tr><td colspan="4" class="doc" id="objcMethodDecl0"><pre>Matches Objective-C method declarations.
418
419Example matches both declaration and definition of -[Foo method]
420  @interface Foo
421  - (void)method;
422  @end
423
424  @implementation Foo
425  - (void)method {}
426  @end
427</pre></td></tr>
428
429
430<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('objcPropertyDecl0')"><a name="objcPropertyDecl0Anchor">objcPropertyDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;...</td></tr>
431<tr><td colspan="4" class="doc" id="objcPropertyDecl0"><pre>Matches Objective-C property declarations.
432
433Example matches enabled
434  @interface Foo
435  @property BOOL enabled;
436  @end
437</pre></td></tr>
438
439
440<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('objcProtocolDecl0')"><a name="objcProtocolDecl0Anchor">objcProtocolDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCProtocolDecl.html">ObjCProtocolDecl</a>&gt;...</td></tr>
441<tr><td colspan="4" class="doc" id="objcProtocolDecl0"><pre>Matches Objective-C protocol declarations.
442
443Example matches FooDelegate
444  @protocol FooDelegate
445  @end
446</pre></td></tr>
447
448
449<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('parmVarDecl0')"><a name="parmVarDecl0Anchor">parmVarDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt;...</td></tr>
450<tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations.
451
452Given
453  void f(int x);
454parmVarDecl()
455  matches int x.
456</pre></td></tr>
457
458
459<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>&gt;...</td></tr>
460<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations.
461
462Example matches X, Z, U, and S
463  class X;
464  template&lt;class T&gt; class Z {};
465  struct S {};
466  union U {};
467</pre></td></tr>
468
469
470<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('staticAssertDecl0')"><a name="staticAssertDecl0Anchor">staticAssertDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1StaticAssertDecl.html">StaticAssertDecl</a>&gt;...</td></tr>
471<tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration.
472
473Example:
474  staticAssertExpr()
475matches
476  static_assert(sizeof(S) == sizeof(int))
477in
478  struct S {
479    int x;
480  };
481  static_assert(sizeof(S) == sizeof(int));
482</pre></td></tr>
483
484
485<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('templateTypeParmDecl0')"><a name="templateTypeParmDecl0Anchor">templateTypeParmDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmDecl.html">TemplateTypeParmDecl</a>&gt;...</td></tr>
486<tr><td colspan="4" class="doc" id="templateTypeParmDecl0"><pre>Matches template type parameter declarations.
487
488Given
489  template &lt;typename T, int N&gt; struct C {};
490templateTypeParmDecl()
491  matches 'T', but not 'N'.
492</pre></td></tr>
493
494
495<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('translationUnitDecl0')"><a name="translationUnitDecl0Anchor">translationUnitDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TranslationUnitDecl.html">TranslationUnitDecl</a>&gt;...</td></tr>
496<tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context.
497
498Given
499  int X;
500  namespace NS {
501  int Y;
502  }  namespace NS
503decl(hasDeclContext(translationUnitDecl()))
504  matches "int X", but not "int Y".
505</pre></td></tr>
506
507
508<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('typeAliasDecl0')"><a name="typeAliasDecl0Anchor">typeAliasDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeAliasDecl.html">TypeAliasDecl</a>&gt;...</td></tr>
509<tr><td colspan="4" class="doc" id="typeAliasDecl0"><pre>Matches type alias declarations.
510
511Given
512  typedef int X;
513  using Y = int;
514typeAliasDecl()
515  matches "using Y = int", but not "typedef int X"
516</pre></td></tr>
517
518
519<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('typeAliasTemplateDecl0')"><a name="typeAliasTemplateDecl0Anchor">typeAliasTemplateDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeAliasTemplateDecl.html">TypeAliasTemplateDecl</a>&gt;...</td></tr>
520<tr><td colspan="4" class="doc" id="typeAliasTemplateDecl0"><pre>Matches type alias template declarations.
521
522typeAliasTemplateDecl() matches
523  template &lt;typename T&gt;
524  using Y = X&lt;T&gt;;
525</pre></td></tr>
526
527
528<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('typedefDecl0')"><a name="typedefDecl0Anchor">typedefDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html">TypedefDecl</a>&gt;...</td></tr>
529<tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations.
530
531Given
532  typedef int X;
533  using Y = int;
534typedefDecl()
535  matches "typedef int X", but not "using Y = int"
536</pre></td></tr>
537
538
539<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('typedefNameDecl0')"><a name="typedefNameDecl0Anchor">typedefNameDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;...</td></tr>
540<tr><td colspan="4" class="doc" id="typedefNameDecl0"><pre>Matches typedef name declarations.
541
542Given
543  typedef int X;
544  using Y = int;
545typedefNameDecl()
546  matches "typedef int X" and "using Y = int"
547</pre></td></tr>
548
549
550<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('unresolvedUsingTypenameDecl0')"><a name="unresolvedUsingTypenameDecl0Anchor">unresolvedUsingTypenameDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingTypenameDecl.html">UnresolvedUsingTypenameDecl</a>&gt;...</td></tr>
551<tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the
552typename.
553
554Given
555  template &lt;typename T&gt;
556  struct Base { typedef T Foo; };
557
558  template&lt;typename T&gt;
559  struct S : private Base&lt;T&gt; {
560    using typename Base&lt;T&gt;::Foo;
561  };
562unresolvedUsingTypenameDecl()
563  matches using Base&lt;T&gt;::Foo </pre></td></tr>
564
565
566<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('unresolvedUsingValueDecl0')"><a name="unresolvedUsingValueDecl0Anchor">unresolvedUsingValueDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingValueDecl.html">UnresolvedUsingValueDecl</a>&gt;...</td></tr>
567<tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations.
568
569Given
570  template&lt;typename X&gt;
571  class C : private X {
572    using X::x;
573  };
574unresolvedUsingValueDecl()
575  matches using X::x </pre></td></tr>
576
577
578<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html">UsingDecl</a>&gt;...</td></tr>
579<tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations.
580
581Given
582  namespace X { int x; }
583  using X::x;
584usingDecl()
585  matches using X::x </pre></td></tr>
586
587
588<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('usingDirectiveDecl0')"><a name="usingDirectiveDecl0Anchor">usingDirectiveDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingDirectiveDecl.html">UsingDirectiveDecl</a>&gt;...</td></tr>
589<tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations.
590
591Given
592  namespace X { int x; }
593  using namespace X;
594usingDirectiveDecl()
595  matches using namespace X </pre></td></tr>
596
597
598<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('valueDecl0')"><a name="valueDecl0Anchor">valueDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;...</td></tr>
599<tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration.
600
601Example matches A, B, C and F
602  enum X { A, B, C };
603  void F();
604</pre></td></tr>
605
606
607<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;...</td></tr>
608<tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations.
609
610Note: this does not match declarations of member variables, which are
611"field" declarations in Clang parlance.
612
613Example matches a
614  int a;
615</pre></td></tr>
616
617
618<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>&gt;...</td></tr>
619<tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
620</pre></td></tr>
621
622
623<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt;...</td></tr>
624<tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers.
625
626Given
627  namespace ns {
628    struct A { static void f(); };
629    void A::f() {}
630    void g() { A::f(); }
631  }
632  ns::A a;
633nestedNameSpecifier()
634  matches "ns::" and both "A::"
635</pre></td></tr>
636
637
638<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;...</td></tr>
639<tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST.
640</pre></td></tr>
641
642
643<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('addrLabelExpr0')"><a name="addrLabelExpr0Anchor">addrLabelExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;...</td></tr>
644<tr><td colspan="4" class="doc" id="addrLabelExpr0"><pre>Matches address of label statements (GNU extension).
645
646Given
647  FOO: bar();
648  void *ptr = &amp;&amp;FOO;
649  goto *bar;
650addrLabelExpr()
651  matches '&amp;&amp;FOO'
652</pre></td></tr>
653
654
655<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>&gt;...</td></tr>
656<tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions.
657
658Given
659  int i = a[1];
660arraySubscriptExpr()
661  matches "a[1]"
662</pre></td></tr>
663
664
665<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1AsmStmt.html">AsmStmt</a>&gt;...</td></tr>
666<tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements.
667
668 int i = 100;
669  __asm("mov al, 2");
670asmStmt()
671  matches '__asm("mov al, 2")'
672</pre></td></tr>
673
674
675<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('atomicExpr0')"><a name="atomicExpr0Anchor">atomicExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicExpr.html">AtomicExpr</a>&gt;...</td></tr>
676<tr><td colspan="4" class="doc" id="atomicExpr0"><pre>Matches atomic builtins.
677Example matches __atomic_load_n(ptr, 1)
678  void foo() { int *ptr; __atomic_load_n(ptr, 1); }
679</pre></td></tr>
680
681
682<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('autoreleasePoolStmt0')"><a name="autoreleasePoolStmt0Anchor">autoreleasePoolStmt</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCAutoreleasePoolStmt.html">ObjCAutoreleasePoolStmt</a>&gt;...</td></tr>
683<tr><td colspan="4" class="doc" id="autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement.
684
685Given
686  @autoreleasepool {
687    int x = 0;
688  }
689autoreleasePoolStmt(stmt()) matches the declaration of "x"
690inside the autorelease pool.
691</pre></td></tr>
692
693
694<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('binaryConditionalOperator0')"><a name="binaryConditionalOperator0Anchor">binaryConditionalOperator</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryConditionalOperator.html">BinaryConditionalOperator</a>&gt;...</td></tr>
695<tr><td colspan="4" class="doc" id="binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension).
696
697Example matches a ?: b
698  (a ?: b) + 42;
699</pre></td></tr>
700
701
702<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;...</td></tr>
703<tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions.
704
705Example matches a || b
706  !(a || b)
707</pre></td></tr>
708
709
710<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1BreakStmt.html">BreakStmt</a>&gt;...</td></tr>
711<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements.
712
713Given
714  while (true) { break; }
715breakStmt()
716  matches 'break'
717</pre></td></tr>
718
719
720<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CStyleCastExpr.html">CStyleCastExpr</a>&gt;...</td></tr>
721<tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression.
722
723Example: Matches (int) 2.2f in
724  int i = (int) 2.2f;
725</pre></td></tr>
726
727
728<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;...</td></tr>
729<tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions.
730
731Example matches x.y() and y()
732  X x;
733  x.y();
734  y();
735</pre></td></tr>
736
737
738<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('caseStmt0')"><a name="caseStmt0Anchor">caseStmt</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt</a>&gt;...</td></tr>
739<tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements.
740
741Given
742  switch(a) { case 42: break; default: break; }
743caseStmt()
744  matches 'case 42:'.
745</pre></td></tr>
746
747
748<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>&gt;...</td></tr>
749<tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST.
750
751Example: castExpr() matches each of the following:
752  (int) 3;
753  const_cast&lt;Expr *&gt;(SubExpr);
754  char c = 0;
755but does not match
756  int i = (0);
757  int k = 0;
758</pre></td></tr>
759
760
761<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;...</td></tr>
762<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t).
763
764Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
765though.
766
767Example matches 'a', L'a'
768  char ch = 'a';
769  wchar_t chw = L'a';
770</pre></td></tr>
771
772
773<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;...</td></tr>
774<tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals
775
776Example match: {1}, (1, 2)
777  int array[4] = {1};
778  vector int myvec = (vector int)(1, 2);
779</pre></td></tr>
780
781
782<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>&gt;...</td></tr>
783<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements.
784
785Example matches '{}' and '{{}}' in 'for (;;) {{}}'
786  for (;;) {{}}
787</pre></td></tr>
788
789
790<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>&gt;...</td></tr>
791<tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions.
792
793Example matches a ? b : c
794  (a ? b : c) + 42
795</pre></td></tr>
796
797
798<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('constantExpr0')"><a name="constantExpr0Anchor">constantExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ConstantExpr.html">ConstantExpr</a>&gt;...</td></tr>
799<tr><td colspan="4" class="doc" id="constantExpr0"><pre>Matches a constant expression wrapper.
800
801Example matches the constant in the case statement:
802    (matcher = constantExpr())
803  switch (a) {
804  case 37: break;
805  }
806</pre></td></tr>
807
808
809<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ContinueStmt.html">ContinueStmt</a>&gt;...</td></tr>
810<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements.
811
812Given
813  while (true) { continue; }
814continueStmt()
815  matches 'continue'
816</pre></td></tr>
817
818
819<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cudaKernelCallExpr0')"><a name="cudaKernelCallExpr0Anchor">cudaKernelCallExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html">CUDAKernelCallExpr</a>&gt;...</td></tr>
820<tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression.
821
822Example matches,
823  kernel&lt;&lt;&lt;i,j&gt;&gt;&gt;();
824</pre></td></tr>
825
826
827<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxBindTemporaryExpr0')"><a name="cxxBindTemporaryExpr0Anchor">cxxBindTemporaryExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>&gt;...</td></tr>
828<tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created.
829
830Example matches FunctionTakesString(GetStringByValue())
831    (matcher = cxxBindTemporaryExpr())
832  FunctionTakesString(GetStringByValue());
833  FunctionTakesStringByPointer(GetStringPointer());
834</pre></td></tr>
835
836
837<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxBoolLiteral0')"><a name="cxxBoolLiteral0Anchor">cxxBoolLiteral</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>&gt;...</td></tr>
838<tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals.
839
840Example matches true
841  true
842</pre></td></tr>
843
844
845<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxCatchStmt0')"><a name="cxxCatchStmt0Anchor">cxxCatchStmt</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>&gt;...</td></tr>
846<tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements.
847
848  try {} catch(int i) {}
849cxxCatchStmt()
850  matches 'catch(int i)'
851</pre></td></tr>
852
853
854<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxConstCastExpr0')"><a name="cxxConstCastExpr0Anchor">cxxConstCastExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>&gt;...</td></tr>
855<tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression.
856
857Example: Matches const_cast&lt;int*&gt;(&amp;r) in
858  int n = 42;
859  const int &amp;r(n);
860  int* p = const_cast&lt;int*&gt;(&amp;r);
861</pre></td></tr>
862
863
864<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxConstructExpr0')"><a name="cxxConstructExpr0Anchor">cxxConstructExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;...</td></tr>
865<tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones).
866
867Example matches string(ptr, n) and ptr within arguments of f
868    (matcher = cxxConstructExpr())
869  void f(const string &amp;a, const string &amp;b);
870  char *ptr;
871  int n;
872  f(string(ptr, n), ptr);
873</pre></td></tr>
874
875
876<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxDefaultArgExpr0')"><a name="cxxDefaultArgExpr0Anchor">cxxDefaultArgExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>&gt;...</td></tr>
877<tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site.
878
879Example matches the CXXDefaultArgExpr placeholder inserted for the
880    default value of the second parameter in the call expression f(42)
881    (matcher = cxxDefaultArgExpr())
882  void f(int x, int y = 0);
883  f(42);
884</pre></td></tr>
885
886
887<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxDeleteExpr0')"><a name="cxxDeleteExpr0Anchor">cxxDeleteExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>&gt;...</td></tr>
888<tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions.
889
890Given
891  delete X;
892cxxDeleteExpr()
893  matches 'delete X'.
894</pre></td></tr>
895
896
897<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxDependentScopeMemberExpr0')"><a name="cxxDependentScopeMemberExpr0Anchor">cxxDependentScopeMemberExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>&gt;...</td></tr>
898<tr><td colspan="4" class="doc" id="cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be
899resolved because the base expression or the member name was dependent.
900
901Given
902  template &lt;class T&gt; void f() { T t; t.g(); }
903cxxDependentScopeMemberExpr()
904  matches t.g
905</pre></td></tr>
906
907
908<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxDynamicCastExpr0')"><a name="cxxDynamicCastExpr0Anchor">cxxDynamicCastExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>&gt;...</td></tr>
909<tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression.
910
911Example:
912  cxxDynamicCastExpr()
913matches
914  dynamic_cast&lt;D*&gt;(&amp;b);
915in
916  struct B { virtual ~B() {} }; struct D : B {};
917  B b;
918  D* p = dynamic_cast&lt;D*&gt;(&amp;b);
919</pre></td></tr>
920
921
922<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxForRangeStmt0')"><a name="cxxForRangeStmt0Anchor">cxxForRangeStmt</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>&gt;...</td></tr>
923<tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements.
924
925cxxForRangeStmt() matches 'for (auto a : i)'
926  int i[] =  {1, 2, 3}; for (auto a : i);
927  for(int j = 0; j &lt; 5; ++j);
928</pre></td></tr>
929
930
931<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxFunctionalCastExpr0')"><a name="cxxFunctionalCastExpr0Anchor">cxxFunctionalCastExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;...</td></tr>
932<tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions
933
934Example: Matches Foo(bar);
935  Foo f = bar;
936  Foo g = (Foo) bar;
937  Foo h = Foo(bar);
938</pre></td></tr>
939
940
941<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxMemberCallExpr0')"><a name="cxxMemberCallExpr0Anchor">cxxMemberCallExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>&gt;...</td></tr>
942<tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions.
943
944Example matches x.y()
945  X x;
946  x.y();
947</pre></td></tr>
948
949
950<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxNewExpr0')"><a name="cxxNewExpr0Anchor">cxxNewExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;...</td></tr>
951<tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions.
952
953Given
954  new X;
955cxxNewExpr()
956  matches 'new X'.
957</pre></td></tr>
958
959
960<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxNullPtrLiteralExpr0')"><a name="cxxNullPtrLiteralExpr0Anchor">cxxNullPtrLiteralExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>&gt;...</td></tr>
961<tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal.
962</pre></td></tr>
963
964
965<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxOperatorCallExpr0')"><a name="cxxOperatorCallExpr0Anchor">cxxOperatorCallExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;...</td></tr>
966<tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls.
967
968Note that if an operator isn't overloaded, it won't match. Instead, use
969binaryOperator matcher.
970Currently it does not match operators such as new delete.
971FIXME: figure out why these do not match?
972
973Example matches both operator&lt;&lt;((o &lt;&lt; b), c) and operator&lt;&lt;(o, b)
974    (matcher = cxxOperatorCallExpr())
975  ostream &amp;operator&lt;&lt; (ostream &amp;out, int i) { };
976  ostream &amp;o; int b = 1, c = 1;
977  o &lt;&lt; b &lt;&lt; c;
978</pre></td></tr>
979
980
981<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxReinterpretCastExpr0')"><a name="cxxReinterpretCastExpr0Anchor">cxxReinterpretCastExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>&gt;...</td></tr>
982<tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression.
983
984Either the source expression or the destination type can be matched
985using has(), but hasDestinationType() is more specific and can be
986more readable.
987
988Example matches reinterpret_cast&lt;char*&gt;(&amp;p) in
989  void* p = reinterpret_cast&lt;char*&gt;(&amp;p);
990</pre></td></tr>
991
992
993<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxStaticCastExpr0')"><a name="cxxStaticCastExpr0Anchor">cxxStaticCastExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>&gt;...</td></tr>
994<tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression.
995
996See also: hasDestinationType
997See also: reinterpretCast
998
999Example:
1000  cxxStaticCastExpr()
1001matches
1002  static_cast&lt;long&gt;(8)
1003in
1004  long eight(static_cast&lt;long&gt;(8));
1005</pre></td></tr>
1006
1007
1008<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxStdInitializerListExpr0')"><a name="cxxStdInitializerListExpr0Anchor">cxxStdInitializerListExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXStdInitializerListExpr.html">CXXStdInitializerListExpr</a>&gt;...</td></tr>
1009<tr><td colspan="4" class="doc" id="cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions.
1010
1011Given
1012  std::vector&lt;int&gt; a({ 1, 2, 3 });
1013  std::vector&lt;int&gt; b = { 4, 5 };
1014  int c[] = { 6, 7 };
1015  std::pair&lt;int, int&gt; d = { 8, 9 };
1016cxxStdInitializerListExpr()
1017  matches "{ 1, 2, 3 }" and "{ 4, 5 }"
1018</pre></td></tr>
1019
1020
1021<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxTemporaryObjectExpr0')"><a name="cxxTemporaryObjectExpr0Anchor">cxxTemporaryObjectExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;...</td></tr>
1022<tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments
1023
1024Example: Matches Foo(bar, bar)
1025  Foo h = Foo(bar, bar);
1026</pre></td></tr>
1027
1028
1029<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxThisExpr0')"><a name="cxxThisExpr0Anchor">cxxThisExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>&gt;...</td></tr>
1030<tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions.
1031
1032Example matches the implicit this expression in "return i".
1033    (matcher = cxxThisExpr())
1034struct foo {
1035  int i;
1036  int f() { return i; }
1037};
1038</pre></td></tr>
1039
1040
1041<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxThrowExpr0')"><a name="cxxThrowExpr0Anchor">cxxThrowExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>&gt;...</td></tr>
1042<tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions.
1043
1044  try { throw 5; } catch(int i) {}
1045cxxThrowExpr()
1046  matches 'throw 5'
1047</pre></td></tr>
1048
1049
1050<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxTryStmt0')"><a name="cxxTryStmt0Anchor">cxxTryStmt</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>&gt;...</td></tr>
1051<tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements.
1052
1053  try {} catch(int i) {}
1054cxxTryStmt()
1055  matches 'try {}'
1056</pre></td></tr>
1057
1058
1059<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxUnresolvedConstructExpr0')"><a name="cxxUnresolvedConstructExpr0Anchor">cxxUnresolvedConstructExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;...</td></tr>
1060<tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions.
1061
1062Example matches T(t) in return statement of f
1063    (matcher = cxxUnresolvedConstructExpr())
1064  template &lt;typename T&gt;
1065  void f(const T&amp; t) { return T(t); }
1066</pre></td></tr>
1067
1068
1069<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;...</td></tr>
1070<tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations.
1071
1072Example matches x in if (x)
1073  bool x;
1074  if (x) {}
1075</pre></td></tr>
1076
1077
1078<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>&gt;...</td></tr>
1079<tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements.
1080
1081Given
1082  int a;
1083declStmt()
1084  matches 'int a'.
1085</pre></td></tr>
1086
1087
1088<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('defaultStmt0')"><a name="defaultStmt0Anchor">defaultStmt</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DefaultStmt.html">DefaultStmt</a>&gt;...</td></tr>
1089<tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements.
1090
1091Given
1092  switch(a) { case 42: break; default: break; }
1093defaultStmt()
1094  matches 'default:'.
1095</pre></td></tr>
1096
1097
1098<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('designatedInitExpr0')"><a name="designatedInitExpr0Anchor">designatedInitExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DesignatedInitExpr.html">DesignatedInitExpr</a>&gt;...</td></tr>
1099<tr><td colspan="4" class="doc" id="designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99 6.7.8].
1100
1101Example: Matches { [2].y = 1.0, [0].x = 1.0 }
1102  point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
1103</pre></td></tr>
1104
1105
1106<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>&gt;...</td></tr>
1107<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements.
1108
1109Given
1110  do {} while (true);
1111doStmt()
1112  matches 'do {} while(true)'
1113</pre></td></tr>
1114
1115
1116<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;...</td></tr>
1117<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions.
1118
1119Matches any cast expression written in user code, whether it be a
1120C-style cast, a functional-style cast, or a keyword cast.
1121
1122Does not match implicit conversions.
1123
1124Note: the name "explicitCast" is chosen to match Clang's terminology, as
1125Clang uses the term "cast" to apply to implicit conversions as well as to
1126actual cast expressions.
1127
1128See also: hasDestinationType.
1129
1130Example: matches all five of the casts in
1131  int((int)(reinterpret_cast&lt;int&gt;(static_cast&lt;int&gt;(const_cast&lt;int&gt;(42)))))
1132but does not match the implicit conversion in
1133  long ell = 42;
1134</pre></td></tr>
1135
1136
1137<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;...</td></tr>
1138<tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions.
1139
1140Example matches x()
1141  void f() { x(); }
1142</pre></td></tr>
1143
1144
1145<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('exprWithCleanups0')"><a name="exprWithCleanups0Anchor">exprWithCleanups</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExprWithCleanups.html">ExprWithCleanups</a>&gt;...</td></tr>
1146<tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end
1147of the sub-expression's evaluation.
1148
1149Example matches std::string()
1150  const std::string str = std::string();
1151</pre></td></tr>
1152
1153
1154<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('floatLiteral0')"><a name="floatLiteral0Anchor">floatLiteral</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>&gt;...</td></tr>
1155<tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes encodings, e.g.
11561.0, 1.0f, 1.0L and 1e10.
1157
1158Does not match implicit conversions such as
1159  float a = 10;
1160</pre></td></tr>
1161
1162
1163<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>&gt;...</td></tr>
1164<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements.
1165
1166Example matches 'for (;;) {}'
1167  for (;;) {}
1168  int i[] =  {1, 2, 3}; for (auto a : i);
1169</pre></td></tr>
1170
1171
1172<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('gnuNullExpr0')"><a name="gnuNullExpr0Anchor">gnuNullExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1GNUNullExpr.html">GNUNullExpr</a>&gt;...</td></tr>
1173<tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression.
1174</pre></td></tr>
1175
1176
1177<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1GotoStmt.html">GotoStmt</a>&gt;...</td></tr>
1178<tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements.
1179
1180Given
1181  goto FOO;
1182  FOO: bar();
1183gotoStmt()
1184  matches 'goto FOO'
1185</pre></td></tr>
1186
1187
1188<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>&gt;...</td></tr>
1189<tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements.
1190
1191Example matches 'if (x) {}'
1192  if (x) {}
1193</pre></td></tr>
1194
1195
1196<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('imaginaryLiteral0')"><a name="imaginaryLiteral0Anchor">imaginaryLiteral</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ImaginaryLiteral.html">ImaginaryLiteral</a>&gt;...</td></tr>
1197<tr><td colspan="4" class="doc" id="imaginaryLiteral0"><pre>Matches imaginary literals, which are based on integer and floating
1198point literals e.g.: 1i, 1.0i
1199</pre></td></tr>
1200
1201
1202<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ImplicitCastExpr.html">ImplicitCastExpr</a>&gt;...</td></tr>
1203<tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST.
1204
1205This matches many different places, including function call return value
1206eliding, as well as any type conversions.
1207</pre></td></tr>
1208
1209
1210<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('implicitValueInitExpr0')"><a name="implicitValueInitExpr0Anchor">implicitValueInitExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ImplicitValueInitExpr.html">ImplicitValueInitExpr</a>&gt;...</td></tr>
1211<tr><td colspan="4" class="doc" id="implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions.
1212
1213Given
1214  point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 };
1215implicitValueInitExpr()
1216  matches "[0].y" (implicitly)
1217</pre></td></tr>
1218
1219
1220<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>&gt;...</td></tr>
1221<tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions.
1222
1223Given
1224  int a[] = { 1, 2 };
1225  struct B { int x, y; };
1226  B b = { 5, 6 };
1227initListExpr()
1228  matches "{ 1, 2 }" and "{ 5, 6 }"
1229</pre></td></tr>
1230
1231
1232<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;...</td></tr>
1233<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings, e.g.
12341, 1L, 0x1 and 1U.
1235
1236Does not match character-encoded integers such as L'a'.
1237</pre></td></tr>
1238
1239
1240<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;...</td></tr>
1241<tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements.
1242
1243Given
1244  goto FOO;
1245  FOO: bar();
1246labelStmt()
1247  matches 'FOO:'
1248</pre></td></tr>
1249
1250
1251<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>&gt;...</td></tr>
1252<tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions.
1253
1254Example matches [&amp;](){return 5;}
1255  [&amp;](){return 5;}
1256</pre></td></tr>
1257
1258
1259<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1MaterializeTemporaryExpr.html">MaterializeTemporaryExpr</a>&gt;...</td></tr>
1260<tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized.
1261
1262Example: Given
1263  struct T {void func();};
1264  T f();
1265  void g(T);
1266materializeTemporaryExpr() matches 'f()' in these statements
1267  T u(f());
1268  g(f());
1269  f().func();
1270but does not match
1271  f();
1272</pre></td></tr>
1273
1274
1275<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;...</td></tr>
1276<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions.
1277
1278Given
1279  class Y {
1280    void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
1281    int a; static int b;
1282  };
1283memberExpr()
1284  matches this-&gt;x, x, y.x, a, this-&gt;b
1285</pre></td></tr>
1286
1287
1288<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NullStmt.html">NullStmt</a>&gt;...</td></tr>
1289<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements.
1290
1291  foo();;
1292nullStmt()
1293  matches the second ';'
1294</pre></td></tr>
1295
1296
1297<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('objcCatchStmt0')"><a name="objcCatchStmt0Anchor">objcCatchStmt</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCAtCatchStmt.html">ObjCAtCatchStmt</a>&gt;...</td></tr>
1298<tr><td colspan="4" class="doc" id="objcCatchStmt0"><pre>Matches Objective-C @catch statements.
1299
1300Example matches @catch
1301  @try {}
1302  @catch (...) {}
1303</pre></td></tr>
1304
1305
1306<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('objcFinallyStmt0')"><a name="objcFinallyStmt0Anchor">objcFinallyStmt</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCAtFinallyStmt.html">ObjCAtFinallyStmt</a>&gt;...</td></tr>
1307<tr><td colspan="4" class="doc" id="objcFinallyStmt0"><pre>Matches Objective-C @finally statements.
1308
1309Example matches @finally
1310  @try {}
1311  @finally {}
1312</pre></td></tr>
1313
1314
1315<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('objcIvarRefExpr0')"><a name="objcIvarRefExpr0Anchor">objcIvarRefExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCIvarRefExpr.html">ObjCIvarRefExpr</a>&gt;...</td></tr>
1316<tr><td colspan="4" class="doc" id="objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar.
1317
1318Example: matches "a" in "init" method:
1319@implementation A {
1320  NSString *a;
1321}
1322- (void) init {
1323  a = @"hello";
1324}
1325</pre></td></tr>
1326
1327
1328<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('objcMessageExpr0')"><a name="objcMessageExpr0Anchor">objcMessageExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;...</td></tr>
1329<tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions.
1330
1331The innermost message send invokes the "alloc" class method on the
1332NSString class, while the outermost message send invokes the
1333"initWithString" instance method on the object returned from
1334NSString's "alloc". This matcher should match both message sends.
1335  [[NSString alloc] initWithString:@"Hello"]
1336</pre></td></tr>
1337
1338
1339<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('objcThrowStmt0')"><a name="objcThrowStmt0Anchor">objcThrowStmt</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCAtThrowStmt.html">ObjCAtThrowStmt</a>&gt;...</td></tr>
1340<tr><td colspan="4" class="doc" id="objcThrowStmt0"><pre>Matches Objective-C statements.
1341
1342Example matches @throw obj;
1343</pre></td></tr>
1344
1345
1346<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('objcTryStmt0')"><a name="objcTryStmt0Anchor">objcTryStmt</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCAtTryStmt.html">ObjCAtTryStmt</a>&gt;...</td></tr>
1347<tr><td colspan="4" class="doc" id="objcTryStmt0"><pre>Matches Objective-C @try statements.
1348
1349Example matches @try
1350  @try {}
1351  @catch (...) {}
1352</pre></td></tr>
1353
1354
1355<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('opaqueValueExpr0')"><a name="opaqueValueExpr0Anchor">opaqueValueExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OpaqueValueExpr.html">OpaqueValueExpr</a>&gt;...</td></tr>
1356<tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers
1357to reference another expressions and can be met
1358in BinaryConditionalOperators, for example.
1359
1360Example matches 'a'
1361  (a ?: c) + 42;
1362</pre></td></tr>
1363
1364
1365<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('parenExpr0')"><a name="parenExpr0Anchor">parenExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenExpr.html">ParenExpr</a>&gt;...</td></tr>
1366<tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions.
1367
1368Example matches (foo() + 1)
1369  int foo() { return 1; }
1370  int a = (foo() + 1);
1371</pre></td></tr>
1372
1373
1374<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('parenListExpr0')"><a name="parenListExpr0Anchor">parenListExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenListExpr.html">ParenListExpr</a>&gt;...</td></tr>
1375<tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions.
1376ParenListExprs don't have a predefined type and are used for late parsing.
1377In the final AST, they can be met in template declarations.
1378
1379Given
1380  template&lt;typename T&gt; class X {
1381    void f() {
1382      X x(*this);
1383      int a = 0, b = 1; int i = (a, b);
1384    }
1385  };
1386parenListExpr() matches "*this" but NOT matches (a, b) because (a, b)
1387has a predefined type and is a ParenExpr, not a ParenListExpr.
1388</pre></td></tr>
1389
1390
1391<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('predefinedExpr0')"><a name="predefinedExpr0Anchor">predefinedExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1PredefinedExpr.html">PredefinedExpr</a>&gt;...</td></tr>
1392<tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2].
1393
1394Example: Matches __func__
1395  printf("%s", __func__);
1396</pre></td></tr>
1397
1398
1399<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">ReturnStmt</a>&gt;...</td></tr>
1400<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements.
1401
1402Given
1403  return 1;
1404returnStmt()
1405  matches 'return 1'
1406</pre></td></tr>
1407
1408
1409<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;...</td></tr>
1410<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements.
1411
1412Given
1413  { ++a; }
1414stmt()
1415  matches both the compound statement '{ ++a; }' and '++a'.
1416</pre></td></tr>
1417
1418
1419<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('stmtExpr0')"><a name="stmtExpr0Anchor">stmtExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1StmtExpr.html">StmtExpr</a>&gt;...</td></tr>
1420<tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension).
1421
1422Example match: ({ int X = 4; X; })
1423  int C = ({ int X = 4; X; });
1424</pre></td></tr>
1425
1426
1427<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>&gt;...</td></tr>
1428<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals).
1429
1430Example matches "abcd", L"abcd"
1431  char *s = "abcd";
1432  wchar_t *ws = L"abcd";
1433</pre></td></tr>
1434
1435
1436<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('substNonTypeTemplateParmExpr0')"><a name="substNonTypeTemplateParmExpr0Anchor">substNonTypeTemplateParmExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1SubstNonTypeTemplateParmExpr.html">SubstNonTypeTemplateParmExpr</a>&gt;...</td></tr>
1437<tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters.
1438
1439Given
1440  template &lt;int N&gt;
1441  struct A { static const int n = N; };
1442  struct B : public A&lt;42&gt; {};
1443substNonTypeTemplateParmExpr()
1444  matches "N" in the right-hand side of "static const int n = N;"
1445</pre></td></tr>
1446
1447
1448<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>&gt;...</td></tr>
1449<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements.
1450
1451Given
1452  switch(a) { case 42: break; default: break; }
1453switchCase()
1454  matches 'case 42:' and 'default:'.
1455</pre></td></tr>
1456
1457
1458<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>&gt;...</td></tr>
1459<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements.
1460
1461Given
1462  switch(a) { case 42: break; default: break; }
1463switchStmt()
1464  matches 'switch(a)'.
1465</pre></td></tr>
1466
1467
1468<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt;...</td></tr>
1469<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
1470
1471Given
1472  Foo x = bar;
1473  int y = sizeof(x) + alignof(x);
1474unaryExprOrTypeTraitExpr()
1475  matches sizeof(x) and alignof(x)
1476</pre></td></tr>
1477
1478
1479<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>&gt;...</td></tr>
1480<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions.
1481
1482Example matches !a
1483  !a || b
1484</pre></td></tr>
1485
1486
1487<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('unresolvedLookupExpr0')"><a name="unresolvedLookupExpr0Anchor">unresolvedLookupExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedLookupExpr.html">UnresolvedLookupExpr</a>&gt;...</td></tr>
1488<tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing
1489but could not be resolved to a specific declaration.
1490
1491Given
1492  template&lt;typename T&gt;
1493  T foo() { T a; return a; }
1494  template&lt;typename T&gt;
1495  void bar() {
1496    foo&lt;T&gt;();
1497  }
1498unresolvedLookupExpr()
1499  matches foo&lt;T&gt;() </pre></td></tr>
1500
1501
1502<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('unresolvedMemberExpr0')"><a name="unresolvedMemberExpr0Anchor">unresolvedMemberExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html">UnresolvedMemberExpr</a>&gt;...</td></tr>
1503<tr><td colspan="4" class="doc" id="unresolvedMemberExpr0"><pre>Matches unresolved member expressions.
1504
1505Given
1506  struct X {
1507    template &lt;class T&gt; void f();
1508    void g();
1509  };
1510  template &lt;class T&gt; void h() { X x; x.f&lt;T&gt;(); x.g(); }
1511unresolvedMemberExpr()
1512  matches x.f&lt;T&gt;
1513</pre></td></tr>
1514
1515
1516<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UserDefinedLiteral.html">UserDefinedLiteral</a>&gt;...</td></tr>
1517<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call.
1518
1519Example match: "foo"_suffix
1520</pre></td></tr>
1521
1522
1523<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>&gt;...</td></tr>
1524<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements.
1525
1526Given
1527  while (true) {}
1528whileStmt()
1529  matches 'while (true) {}'.
1530</pre></td></tr>
1531
1532
1533<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('templateArgument0')"><a name="templateArgument0Anchor">templateArgument</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;...</td></tr>
1534<tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments.
1535
1536Given
1537  template &lt;typename T&gt; struct C {};
1538  C&lt;int&gt; c;
1539templateArgument()
1540  matches 'int' in C&lt;int&gt;.
1541</pre></td></tr>
1542
1543
1544<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName</a>&gt;</td><td class="name" onclick="toggle('templateName0')"><a name="templateName0Anchor">templateName</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName</a>&gt;...</td></tr>
1545<tr><td colspan="4" class="doc" id="templateName0"><pre>Matches template name.
1546
1547Given
1548  template &lt;typename T&gt; class X { };
1549  X&lt;int&gt; xi;
1550templateName()
1551  matches 'X' in X&lt;int&gt;.
1552</pre></td></tr>
1553
1554
1555<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;...</td></tr>
1556<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST.
1557</pre></td></tr>
1558
1559
1560<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>&gt;...</td></tr>
1561<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays.
1562
1563Given
1564  int a[] = { 2, 3 };
1565  int b[4];
1566  void f() { int c[a[0]]; }
1567arrayType()
1568  matches "int a[]", "int b[4]" and "int c[a[0]]";
1569</pre></td></tr>
1570
1571
1572<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;...</td></tr>
1573<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types.
1574
1575Given
1576  _Atomic(int) i;
1577atomicType()
1578  matches "_Atomic(int) i"
1579</pre></td></tr>
1580
1581
1582<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>&gt;...</td></tr>
1583<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types.
1584
1585Given:
1586  auto n = 4;
1587  int v[] = { 2, 3 }
1588  for (auto i : v) { }
1589autoType()
1590  matches "auto n" and "auto i"
1591</pre></td></tr>
1592
1593
1594<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;...</td></tr>
1595<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as
1596"void (^)(int)".
1597
1598The pointee is always required to be a FunctionType.
1599</pre></td></tr>
1600
1601
1602<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1BuiltinType.html">BuiltinType</a>&gt;...</td></tr>
1603<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types.
1604
1605Given
1606  struct A {};
1607  A a;
1608  int b;
1609  float c;
1610  bool d;
1611builtinType()
1612  matches "int b", "float c" and "bool d"
1613</pre></td></tr>
1614
1615
1616<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>&gt;...</td></tr>
1617<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types.
1618
1619Given
1620  _Complex float f;
1621complexType()
1622  matches "_Complex float f"
1623</pre></td></tr>
1624
1625
1626<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>&gt;...</td></tr>
1627<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size.
1628
1629Given
1630  void() {
1631    int a[2];
1632    int b[] = { 2, 3 };
1633    int c[b[0]];
1634  }
1635constantArrayType()
1636  matches "int a[2]"
1637</pre></td></tr>
1638
1639
1640<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('decayedType0')"><a name="decayedType0Anchor">decayedType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DecayedType.html">DecayedType</a>&gt;...</td></tr>
1641<tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type
1642Example matches i[] in declaration of f.
1643    (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
1644Example matches i[1].
1645    (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())))))
1646  void f(int i[]) {
1647    i[1] = 0;
1648  }
1649</pre></td></tr>
1650
1651
1652<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('decltypeType0')"><a name="decltypeType0Anchor">decltypeType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>&gt;...</td></tr>
1653<tr><td colspan="4" class="doc" id="decltypeType0"><pre>Matches types nodes representing C++11 decltype(&lt;expr&gt;) types.
1654
1655Given:
1656  short i = 1;
1657  int j = 42;
1658  decltype(i + j) result = i + j;
1659decltypeType()
1660  matches "decltype(i + j)"
1661</pre></td></tr>
1662
1663
1664<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayType.html">DependentSizedArrayType</a>&gt;...</td></tr>
1665<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression.
1666
1667Given
1668  template&lt;typename T, int Size&gt;
1669  class array {
1670    T data[Size];
1671  };
1672dependentSizedArrayType
1673  matches "T data[Size]"
1674</pre></td></tr>
1675
1676
1677<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>&gt;...</td></tr>
1678<tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a
1679qualified name.
1680
1681Given
1682  namespace N {
1683    namespace M {
1684      class D {};
1685    }
1686  }
1687  class C {};
1688
1689  class C c;
1690  N::M::D d;
1691
1692elaboratedType() matches the type of the variable declarations of both
1693c and d.
1694</pre></td></tr>
1695
1696
1697<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('enumType0')"><a name="enumType0Anchor">enumType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;...</td></tr>
1698<tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types.
1699
1700Given
1701  enum C { Green };
1702  enum class S { Red };
1703
1704  C c;
1705  S s;
1706
1707enumType() matches the type of the variable declarations of both c and
1708s.
1709</pre></td></tr>
1710
1711
1712<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('functionProtoType0')"><a name="functionProtoType0Anchor">functionProtoType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>&gt;...</td></tr>
1713<tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes.
1714
1715Given
1716  int (*f)(int);
1717  void g();
1718functionProtoType()
1719  matches "int (*f)(int)" and the type of "g" in C++ mode.
1720  In C mode, "g" is not matched because it does not contain a prototype.
1721</pre></td></tr>
1722
1723
1724<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FunctionType.html">FunctionType</a>&gt;...</td></tr>
1725<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes.
1726
1727Given
1728  int (*f)(int);
1729  void g();
1730functionType()
1731  matches "int (*f)(int)" and the type of "g".
1732</pre></td></tr>
1733
1734
1735<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1IncompleteArrayType.html">IncompleteArrayType</a>&gt;...</td></tr>
1736<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size.
1737
1738Given
1739  int a[] = { 2, 3 };
1740  int b[42];
1741  void f(int c[]) { int d[a[0]]; };
1742incompleteArrayType()
1743  matches "int a[]" and "int c[]"
1744</pre></td></tr>
1745
1746
1747<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('injectedClassNameType0')"><a name="injectedClassNameType0Anchor">injectedClassNameType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;...</td></tr>
1748<tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types.
1749
1750Example matches S s, but not S&lt;T&gt; s.
1751    (matcher = parmVarDecl(hasType(injectedClassNameType())))
1752  template &lt;typename T&gt; struct S {
1753    void f(S s);
1754    void g(S&lt;T&gt; s);
1755  };
1756</pre></td></tr>
1757
1758
1759<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('lValueReferenceType0')"><a name="lValueReferenceType0Anchor">lValueReferenceType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LValueReferenceType.html">LValueReferenceType</a>&gt;...</td></tr>
1760<tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types.
1761
1762Given:
1763  int *a;
1764  int &amp;b = *a;
1765  int &amp;&amp;c = 1;
1766  auto &amp;d = b;
1767  auto &amp;&amp;e = c;
1768  auto &amp;&amp;f = 2;
1769  int g = 5;
1770
1771lValueReferenceType() matches the types of b, d, and e. e is
1772matched since the type is deduced as int&amp; by reference collapsing rules.
1773</pre></td></tr>
1774
1775
1776<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;...</td></tr>
1777<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types.
1778Given
1779  struct A { int i; }
1780  A::* ptr = A::i;
1781memberPointerType()
1782  matches "A::* ptr"
1783</pre></td></tr>
1784
1785
1786<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('objcObjectPointerType0')"><a name="objcObjectPointerType0Anchor">objcObjectPointerType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html">ObjCObjectPointerType</a>&gt;...</td></tr>
1787<tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from
1788a pointer type, despite being syntactically similar.
1789
1790Given
1791  int *a;
1792
1793  @interface Foo
1794  @end
1795  Foo *f;
1796pointerType()
1797  matches "Foo *f", but does not match "int *a".
1798</pre></td></tr>
1799
1800
1801<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('parenType0')"><a name="parenType0Anchor">parenType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>&gt;...</td></tr>
1802<tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes.
1803
1804Given
1805  int (*ptr_to_array)[4];
1806  int *array_of_ptrs[4];
1807
1808varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not
1809array_of_ptrs.
1810</pre></td></tr>
1811
1812
1813<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;...</td></tr>
1814<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer
1815types.
1816
1817Given
1818  int *a;
1819  int &amp;b = *a;
1820  int c = 5;
1821
1822  @interface Foo
1823  @end
1824  Foo *f;
1825pointerType()
1826  matches "int *a", but does not match "Foo *f".
1827</pre></td></tr>
1828
1829
1830<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('rValueReferenceType0')"><a name="rValueReferenceType0Anchor">rValueReferenceType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RValueReferenceType.html">RValueReferenceType</a>&gt;...</td></tr>
1831<tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types.
1832
1833Given:
1834  int *a;
1835  int &amp;b = *a;
1836  int &amp;&amp;c = 1;
1837  auto &amp;d = b;
1838  auto &amp;&amp;e = c;
1839  auto &amp;&amp;f = 2;
1840  int g = 5;
1841
1842rValueReferenceType() matches the types of c and f. e is not
1843matched as it is deduced to int&amp; by reference collapsing rules.
1844</pre></td></tr>
1845
1846
1847<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;...</td></tr>
1848<tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes).
1849
1850Given
1851  class C {};
1852  struct S {};
1853
1854  C c;
1855  S s;
1856
1857recordType() matches the type of the variable declarations of both c
1858and s.
1859</pre></td></tr>
1860
1861
1862<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;...</td></tr>
1863<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types.
1864
1865Given
1866  int *a;
1867  int &amp;b = *a;
1868  int &amp;&amp;c = 1;
1869  auto &amp;d = b;
1870  auto &amp;&amp;e = c;
1871  auto &amp;&amp;f = 2;
1872  int g = 5;
1873
1874referenceType() matches the types of b, c, d, e, and f.
1875</pre></td></tr>
1876
1877
1878<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('substTemplateTypeParmType0')"><a name="substTemplateTypeParmType0Anchor">substTemplateTypeParmType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html">SubstTemplateTypeParmType</a>&gt;...</td></tr>
1879<tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a
1880template type parameter.
1881
1882Given
1883  template &lt;typename T&gt;
1884  void F(T t) {
1885    int i = 1 + t;
1886  }
1887
1888substTemplateTypeParmType() matches the type of 't' but not '1'
1889</pre></td></tr>
1890
1891
1892<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('tagType0')"><a name="tagType0Anchor">tagType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;...</td></tr>
1893<tr><td colspan="4" class="doc" id="tagType0"><pre>Matches tag types (record and enum types).
1894
1895Given
1896  enum E {};
1897  class C {};
1898
1899  E e;
1900  C c;
1901
1902tagType() matches the type of the variable declarations of both e
1903and c.
1904</pre></td></tr>
1905
1906
1907<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;...</td></tr>
1908<tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types.
1909
1910Given
1911  template &lt;typename T&gt;
1912  class C { };
1913
1914  template class C&lt;int&gt;;  A
1915  C&lt;char&gt; var;            B
1916
1917templateSpecializationType() matches the type of the explicit
1918instantiation in A and the type of the variable declaration in B.
1919</pre></td></tr>
1920
1921
1922<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('templateTypeParmType0')"><a name="templateTypeParmType0Anchor">templateTypeParmType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;...</td></tr>
1923<tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types.
1924
1925Example matches T, but not int.
1926    (matcher = templateTypeParmType())
1927  template &lt;typename T&gt; void f(int i);
1928</pre></td></tr>
1929
1930
1931<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;...</td></tr>
1932<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST.
1933</pre></td></tr>
1934
1935
1936<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;...</td></tr>
1937<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types.
1938
1939Given
1940  typedef int X;
1941typedefType()
1942  matches "typedef int X"
1943</pre></td></tr>
1944
1945
1946<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('unaryTransformType0')"><a name="unaryTransformType0Anchor">unaryTransformType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryTransformType.html">UnaryTransformType</a>&gt;...</td></tr>
1947<tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations.
1948
1949Given:
1950  typedef __underlying_type(T) type;
1951unaryTransformType()
1952  matches "__underlying_type(T)"
1953</pre></td></tr>
1954
1955
1956<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1VariableArrayType.html">VariableArrayType</a>&gt;...</td></tr>
1957<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an
1958integer-constant-expression.
1959
1960Given
1961  void f() {
1962    int a[] = { 2, 3 }
1963    int b[42];
1964    int c[a[0]];
1965  }
1966variableArrayType()
1967  matches "int c[a[0]]"
1968</pre></td></tr>
1969
1970<!--END_DECL_MATCHERS -->
1971</table>
1972
1973<!-- ======================================================================= -->
1974<h2 id="narrowing-matchers">Narrowing Matchers</h2>
1975<!-- ======================================================================= -->
1976
1977<p>Narrowing matchers match certain attributes on the current node, thus
1978narrowing down the set of nodes of the current type to match on.</p>
1979
1980<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless)
1981which allow users to create more powerful match expressions.</p>
1982
1983<table>
1984<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
1985<!-- START_NARROWING_MATCHERS -->
1986
1987<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher&lt;*&gt;, ..., Matcher&lt;*&gt;</td></tr>
1988<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match.
1989
1990Usable as: Any Matcher
1991</pre></td></tr>
1992
1993
1994<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher&lt;*&gt;, ..., Matcher&lt;*&gt;</td></tr>
1995<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches.
1996
1997Usable as: Any Matcher
1998</pre></td></tr>
1999
2000
2001<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr>
2002<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node.
2003
2004Useful when another matcher requires a child matcher, but there's no
2005additional constraint. This will often be used with an explicit conversion
2006to an internal::Matcher&lt;&gt; type such as TypeMatcher.
2007
2008Example: DeclarationMatcher(anything()) matches all declarations, e.g.,
2009"int* p" and "void f()" in
2010  int* p;
2011  void f();
2012
2013Usable as: Any Matcher
2014</pre></td></tr>
2015
2016
2017<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher&lt;*&gt;</td></tr>
2018<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match.
2019
2020Example matches Y (matcher = cxxRecordDecl(unless(hasName("X"))))
2021  class X {};
2022  class Y {};
2023
2024Usable as: Any Matcher
2025</pre></td></tr>
2026
2027
2028<tr><td>Matcher&lt;<a href="https://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>
2029<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or
2030unary).
2031
2032Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
2033  !(a || b)
2034</pre></td></tr>
2035
2036
2037<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;</td><td class="name" onclick="toggle('isAssignmentOperator0')"><a name="isAssignmentOperator0Anchor">isAssignmentOperator</a></td><td></td></tr>
2038<tr><td colspan="4" class="doc" id="isAssignmentOperator0"><pre>Matches all kinds of assignment operators.
2039
2040Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
2041  if (a == b)
2042    a += b;
2043
2044Example 2: matches s1 = s2
2045           (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
2046  struct S { S&amp; operator=(const S&amp;); };
2047  void x() { S s1, s2; s1 = s2; })
2048</pre></td></tr>
2049
2050
2051<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>&gt;</td><td class="name" onclick="toggle('equals5')"><a name="equals5Anchor">equals</a></td><td>bool Value</td></tr>
2052<tr><td colspan="4" class="doc" id="equals5"><pre></pre></td></tr>
2053
2054
2055<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>&gt;</td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>const ValueT  Value</td></tr>
2056<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value of type ValueT.
2057
2058Given
2059  f('false, 3.14, 42);
2060characterLiteral(equals(0))
2061  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
2062  match false
2063floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
2064  match 3.14
2065integerLiteral(equals(42))
2066  matches 42
2067
2068Note that you cannot directly match a negative numeric literal because the
2069minus sign is not part of the literal: It is a unary operator whose operand
2070is the positive numeric literal. Instead, you must use a unaryOperator()
2071matcher to match the minus sign:
2072
2073unaryOperator(hasOperatorName("-"),
2074              hasUnaryOperand(integerLiteral(equals(13))))
2075
2076Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>&gt;,
2077           Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;
2078</pre></td></tr>
2079
2080
2081<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>&gt;</td><td class="name" onclick="toggle('equals11')"><a name="equals11Anchor">equals</a></td><td>double Value</td></tr>
2082<tr><td colspan="4" class="doc" id="equals11"><pre></pre></td></tr>
2083
2084
2085<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>&gt;</td><td class="name" onclick="toggle('equals8')"><a name="equals8Anchor">equals</a></td><td>unsigned Value</td></tr>
2086<tr><td colspan="4" class="doc" id="equals8"><pre></pre></td></tr>
2087
2088
2089<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>&gt;</td><td class="name" onclick="toggle('isCatchAll0')"><a name="isCatchAll0Anchor">isCatchAll</a></td><td></td></tr>
2090<tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler.
2091
2092Given
2093  try {
2094    ...
2095  } catch (int) {
2096    ...
2097  } catch (...) {
2098    ...
2099  }
2100endcode
2101cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
2102</pre></td></tr>
2103
2104
2105<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('argumentCountIs1')"><a name="argumentCountIs1Anchor">argumentCountIs</a></td><td>unsigned N</td></tr>
2106<tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has
2107a specific number of arguments (including absent default arguments).
2108
2109Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
2110  void f(int x, int y);
2111  f(0, 0);
2112</pre></td></tr>
2113
2114
2115<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('isListInitialization0')"><a name="isListInitialization0Anchor">isListInitialization</a></td><td></td></tr>
2116<tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization.
2117</pre></td></tr>
2118
2119
2120<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('requiresZeroInitialization0')"><a name="requiresZeroInitialization0Anchor">requiresZeroInitialization</a></td><td></td></tr>
2121<tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires
2122zero initialization.
2123
2124Given
2125void foo() {
2126  struct point { double x; double y; };
2127  point pt[2] = { { 1.0, 2.0 } };
2128}
2129initListExpr(has(cxxConstructExpr(requiresZeroInitialization()))
2130will match the implicit array filler for pt[1].
2131</pre></td></tr>
2132
2133
2134<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('isCopyConstructor0')"><a name="isCopyConstructor0Anchor">isCopyConstructor</a></td><td></td></tr>
2135<tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors.
2136
2137Given
2138  struct S {
2139    S(); #1
2140    S(const S &amp;); #2
2141    S(S &amp;&amp;); #3
2142  };
2143cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
2144</pre></td></tr>
2145
2146
2147<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('isDefaultConstructor0')"><a name="isDefaultConstructor0Anchor">isDefaultConstructor</a></td><td></td></tr>
2148<tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors.
2149
2150Given
2151  struct S {
2152    S(); #1
2153    S(const S &amp;); #2
2154    S(S &amp;&amp;); #3
2155  };
2156cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
2157</pre></td></tr>
2158
2159
2160<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('isDelegatingConstructor0')"><a name="isDelegatingConstructor0Anchor">isDelegatingConstructor</a></td><td></td></tr>
2161<tr><td colspan="4" class="doc" id="isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor.
2162
2163Given
2164  struct S {
2165    S(); #1
2166    S(int) {} #2
2167    S(S &amp;&amp;) : S() {} #3
2168  };
2169  S::S() : S(0) {} #4
2170cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not
2171#1 or #2.
2172</pre></td></tr>
2173
2174
2175<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('isExplicit0')"><a name="isExplicit0Anchor">isExplicit</a></td><td></td></tr>
2176<tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor and conversion declarations that are marked with
2177the explicit keyword.
2178
2179Given
2180  struct S {
2181    S(int); #1
2182    explicit S(double); #2
2183    operator int(); #3
2184    explicit operator bool(); #4
2185  };
2186cxxConstructorDecl(isExplicit()) will match #2, but not #1.
2187cxxConversionDecl(isExplicit()) will match #4, but not #3.
2188</pre></td></tr>
2189
2190
2191<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('isMoveConstructor0')"><a name="isMoveConstructor0Anchor">isMoveConstructor</a></td><td></td></tr>
2192<tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors.
2193
2194Given
2195  struct S {
2196    S(); #1
2197    S(const S &amp;); #2
2198    S(S &amp;&amp;); #3
2199  };
2200cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
2201</pre></td></tr>
2202
2203
2204<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>&gt;</td><td class="name" onclick="toggle('isExplicit1')"><a name="isExplicit1Anchor">isExplicit</a></td><td></td></tr>
2205<tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor and conversion declarations that are marked with
2206the explicit keyword.
2207
2208Given
2209  struct S {
2210    S(int); #1
2211    explicit S(double); #2
2212    operator int(); #3
2213    explicit operator bool(); #4
2214  };
2215cxxConstructorDecl(isExplicit()) will match #2, but not #1.
2216cxxConversionDecl(isExplicit()) will match #4, but not #3.
2217</pre></td></tr>
2218
2219
2220<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;</td><td class="name" onclick="toggle('isBaseInitializer0')"><a name="isBaseInitializer0Anchor">isBaseInitializer</a></td><td></td></tr>
2221<tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as
2222opposed to a member.
2223
2224Given
2225  struct B {};
2226  struct D : B {
2227    int I;
2228    D(int i) : I(i) {}
2229  };
2230  struct E : B {
2231    E() : B() {}
2232  };
2233cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
2234  will match E(), but not match D(int).
2235</pre></td></tr>
2236
2237
2238<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;</td><td class="name" onclick="toggle('isMemberInitializer0')"><a name="isMemberInitializer0Anchor">isMemberInitializer</a></td><td></td></tr>
2239<tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as
2240opposed to a base.
2241
2242Given
2243  struct B {};
2244  struct D : B {
2245    int I;
2246    D(int i) : I(i) {}
2247  };
2248  struct E : B {
2249    E() : B() {}
2250  };
2251cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
2252  will match D(int), but not match E().
2253</pre></td></tr>
2254
2255
2256<tr><td>Matcher&lt;<a href="https://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>
2257<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in
2258code (as opposed to implicitly added by the compiler).
2259
2260Given
2261  struct Foo {
2262    Foo() { }
2263    Foo(int) : foo_("A") { }
2264    string foo_;
2265  };
2266cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
2267  will match Foo(int), but not Foo()
2268</pre></td></tr>
2269
2270
2271<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>&gt;</td><td class="name" onclick="toggle('isArrow2')"><a name="isArrow2Anchor">isArrow</a></td><td></td></tr>
2272<tr><td colspan="4" class="doc" id="isArrow2"><pre>Matches member expressions that are called with '-&gt;' as opposed
2273to '.'.
2274
2275Member calls on the implicit this pointer match as called with '-&gt;'.
2276
2277Given
2278  class Y {
2279    void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
2280    template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
2281    int a;
2282    static int b;
2283  };
2284  template &lt;class T&gt;
2285  class Z {
2286    void x() { this-&gt;m; }
2287  };
2288memberExpr(isArrow())
2289  matches this-&gt;x, x, y.x, a, this-&gt;b
2290cxxDependentScopeMemberExpr(isArrow())
2291  matches this-&gt;m
2292unresolvedMemberExpr(isArrow())
2293  matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
2294</pre></td></tr>
2295
2296
2297<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isConst0')"><a name="isConst0Anchor">isConst</a></td><td></td></tr>
2298<tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const.
2299
2300Given
2301struct A {
2302  void foo() const;
2303  void bar();
2304};
2305
2306cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
2307</pre></td></tr>
2308
2309
2310<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isCopyAssignmentOperator0')"><a name="isCopyAssignmentOperator0Anchor">isCopyAssignmentOperator</a></td><td></td></tr>
2311<tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment
2312operator.
2313
2314Given
2315struct A {
2316  A &amp;operator=(const A &amp;);
2317  A &amp;operator=(A &amp;&amp;);
2318};
2319
2320cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not
2321the second one.
2322</pre></td></tr>
2323
2324
2325<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isFinal1')"><a name="isFinal1Anchor">isFinal</a></td><td></td></tr>
2326<tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final.
2327
2328Given:
2329  class A final {};
2330
2331  struct B {
2332    virtual void f();
2333  };
2334
2335  struct C : B {
2336    void f() final;
2337  };
2338matches A and C::f, but not B, C, or B::f
2339</pre></td></tr>
2340
2341
2342<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isMoveAssignmentOperator0')"><a name="isMoveAssignmentOperator0Anchor">isMoveAssignmentOperator</a></td><td></td></tr>
2343<tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment
2344operator.
2345
2346Given
2347struct A {
2348  A &amp;operator=(const A &amp;);
2349  A &amp;operator=(A &amp;&amp;);
2350};
2351
2352cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not
2353the first one.
2354</pre></td></tr>
2355
2356
2357<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isOverride0')"><a name="isOverride0Anchor">isOverride</a></td><td></td></tr>
2358<tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method.
2359
2360Given
2361  class A {
2362   public:
2363    virtual void x();
2364  };
2365  class B : public A {
2366   public:
2367    virtual void x();
2368  };
2369  matches B::x
2370</pre></td></tr>
2371
2372
2373<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isPure0')"><a name="isPure0Anchor">isPure</a></td><td></td></tr>
2374<tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure.
2375
2376Given
2377  class A {
2378   public:
2379    virtual void x() = 0;
2380  };
2381  matches A::x
2382</pre></td></tr>
2383
2384
2385<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isUserProvided0')"><a name="isUserProvided0Anchor">isUserProvided</a></td><td></td></tr>
2386<tr><td colspan="4" class="doc" id="isUserProvided0"><pre>Matches method declarations that are user-provided.
2387
2388Given
2389  struct S {
2390    S(); #1
2391    S(const S &amp;) = default; #2
2392    S(S &amp;&amp;) = delete; #3
2393  };
2394cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
2395</pre></td></tr>
2396
2397
2398<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isVirtual0')"><a name="isVirtual0Anchor">isVirtual</a></td><td></td></tr>
2399<tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual.
2400
2401Given
2402  class A {
2403   public:
2404    virtual void x();
2405  };
2406  matches A::x
2407</pre></td></tr>
2408
2409
2410<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isVirtualAsWritten0')"><a name="isVirtualAsWritten0Anchor">isVirtualAsWritten</a></td><td></td></tr>
2411<tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual".
2412
2413Given
2414  class A {
2415   public:
2416    virtual void x();
2417  };
2418  class B : public A {
2419   public:
2420    void x();
2421  };
2422  matches A::x but not B::x
2423</pre></td></tr>
2424
2425
2426<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;</td><td class="name" onclick="toggle('isArray0')"><a name="isArray0Anchor">isArray</a></td><td></td></tr>
2427<tr><td colspan="4" class="doc" id="isArray0"><pre>Matches array new expressions.
2428
2429Given:
2430  MyClass *p1 = new MyClass[10];
2431cxxNewExpr(isArray())
2432  matches the expression 'new MyClass[10]'.
2433</pre></td></tr>
2434
2435
2436<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;</td><td class="name" onclick="toggle('hasOverloadedOperatorName1')"><a name="hasOverloadedOperatorName1Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr>
2437<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names.
2438
2439Matches overloaded operator names specified in strings without the
2440"operator" prefix: e.g. "&lt;&lt;".
2441
2442Given:
2443  class A { int operator*(); };
2444  const A &amp;operator&lt;&lt;(const A &amp;a, const A &amp;b);
2445  A a;
2446  a &lt;&lt; a;   &lt;-- This matches
2447
2448cxxOperatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the
2449specified line and
2450cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
2451matches the declaration of A.
2452
2453Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;
2454</pre></td></tr>
2455
2456
2457<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;</td><td class="name" onclick="toggle('isAssignmentOperator1')"><a name="isAssignmentOperator1Anchor">isAssignmentOperator</a></td><td></td></tr>
2458<tr><td colspan="4" class="doc" id="isAssignmentOperator1"><pre>Matches all kinds of assignment operators.
2459
2460Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
2461  if (a == b)
2462    a += b;
2463
2464Example 2: matches s1 = s2
2465           (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
2466  struct S { S&amp; operator=(const S&amp;); };
2467  void x() { S s1, s2; s1 = s2; })
2468</pre></td></tr>
2469
2470
2471<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('hasDefinition0')"><a name="hasDefinition0Anchor">hasDefinition</a></td><td></td></tr>
2472<tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined.
2473
2474Example matches x (matcher = cxxRecordDecl(hasDefinition()))
2475class x {};
2476class y;
2477</pre></td></tr>
2478
2479
2480<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isDerivedFrom1')"><a name="isDerivedFrom1Anchor">isDerivedFrom</a></td><td>std::string BaseName</td></tr>
2481<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
2482</pre></td></tr>
2483
2484
2485<tr><td>Matcher&lt;<a href="https://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>
2486<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or
2487static member variable template instantiations.
2488
2489Given
2490  template&lt;typename T&gt; void A(T t) { }
2491  template&lt;&gt; void A(int N) { }
2492functionDecl(isExplicitTemplateSpecialization())
2493  matches the specialization A&lt;int&gt;().
2494
2495Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
2496</pre></td></tr>
2497
2498
2499<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isFinal0')"><a name="isFinal0Anchor">isFinal</a></td><td></td></tr>
2500<tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final.
2501
2502Given:
2503  class A final {};
2504
2505  struct B {
2506    virtual void f();
2507  };
2508
2509  struct C : B {
2510    void f() final;
2511  };
2512matches A and C::f, but not B, C, or B::f
2513</pre></td></tr>
2514
2515
2516<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isLambda0')"><a name="isLambda0Anchor">isLambda</a></td><td></td></tr>
2517<tr><td colspan="4" class="doc" id="isLambda0"><pre>Matches the generated class of lambda expressions.
2518
2519Given:
2520  auto x = []{};
2521
2522cxxRecordDecl(isLambda()) matches the implicit class declaration of
2523decltype(x)
2524</pre></td></tr>
2525
2526
2527<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isSameOrDerivedFrom1')"><a name="isSameOrDerivedFrom1Anchor">isSameOrDerivedFrom</a></td><td>std::string BaseName</td></tr>
2528<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for
2529isSameOrDerivedFrom(hasName(...)).
2530</pre></td></tr>
2531
2532
2533<tr><td>Matcher&lt;<a href="https://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>
2534<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static
2535member variable template instantiations.
2536
2537Given
2538  template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
2539or
2540  template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
2541or
2542  template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
2543cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
2544  matches the template instantiation of X&lt;A&gt;.
2545
2546But given
2547  template &lt;typename T&gt;  class X {}; class A {};
2548  template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
2549cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
2550  does not match, as X&lt;A&gt; is an explicit template specialization.
2551
2552Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
2553</pre></td></tr>
2554
2555
2556<tr><td>Matcher&lt;<a href="https://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>
2557<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has
2558a specific number of arguments (including absent default arguments).
2559
2560Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
2561  void f(int x, int y);
2562  f(0, 0);
2563</pre></td></tr>
2564
2565
2566<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>&gt;</td><td class="name" onclick="toggle('hasCastKind0')"><a name="hasCastKind0Anchor">hasCastKind</a></td><td>CastKind Kind</td></tr>
2567<tr><td colspan="4" class="doc" id="hasCastKind0"><pre>Matches casts that has a given cast kind.
2568
2569Example: matches the implicit cast around 0
2570(matcher = castExpr(hasCastKind(CK_NullToPointer)))
2571  int *p = 0;
2572</pre></td></tr>
2573
2574
2575<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;</td><td class="name" onclick="toggle('equals4')"><a name="equals4Anchor">equals</a></td><td>bool Value</td></tr>
2576<tr><td colspan="4" class="doc" id="equals4"><pre></pre></td></tr>
2577
2578
2579<tr><td>Matcher&lt;<a href="https://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>const ValueT  Value</td></tr>
2580<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value of type ValueT.
2581
2582Given
2583  f('false, 3.14, 42);
2584characterLiteral(equals(0))
2585  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
2586  match false
2587floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
2588  match 3.14
2589integerLiteral(equals(42))
2590  matches 42
2591
2592Note that you cannot directly match a negative numeric literal because the
2593minus sign is not part of the literal: It is a unary operator whose operand
2594is the positive numeric literal. Instead, you must use a unaryOperator()
2595matcher to match the minus sign:
2596
2597unaryOperator(hasOperatorName("-"),
2598              hasUnaryOperand(integerLiteral(equals(13))))
2599
2600Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>&gt;,
2601           Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;
2602</pre></td></tr>
2603
2604
2605<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;</td><td class="name" onclick="toggle('equals10')"><a name="equals10Anchor">equals</a></td><td>double Value</td></tr>
2606<tr><td colspan="4" class="doc" id="equals10"><pre></pre></td></tr>
2607
2608
2609<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;</td><td class="name" onclick="toggle('equals7')"><a name="equals7Anchor">equals</a></td><td>unsigned Value</td></tr>
2610<tr><td colspan="4" class="doc" id="equals7"><pre></pre></td></tr>
2611
2612
2613<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;</td><td class="name" onclick="toggle('templateArgumentCountIs0')"><a name="templateArgumentCountIs0Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr>
2614<tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N.
2615
2616Given
2617  template&lt;typename T&gt; struct C {};
2618  C&lt;int&gt; c;
2619classTemplateSpecializationDecl(templateArgumentCountIs(1))
2620  matches C&lt;int&gt;.
2621</pre></td></tr>
2622
2623
2624<tr><td>Matcher&lt;<a href="https://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>
2625<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of
2626child statements.
2627
2628Example: Given
2629  { for (;;) {} }
2630compoundStmt(statementCountIs(0)))
2631  matches '{}'
2632  but does not match the outer compound statement.
2633</pre></td></tr>
2634
2635
2636<tr><td>Matcher&lt;<a href="https://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>
2637<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches nodes that have the specified size.
2638
2639Given
2640  int a[42];
2641  int b[2 * 21];
2642  int c[41], d[43];
2643  char *s = "abcd";
2644  wchar_t *ws = L"abcd";
2645  char *w = "a";
2646constantArrayType(hasSize(42))
2647  matches "int a[42]" and "int b[2 * 21]"
2648stringLiteral(hasSize(4))
2649  matches "abcd", L"abcd"
2650</pre></td></tr>
2651
2652
2653<tr><td>Matcher&lt;<a href="https://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>
2654<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of
2655declarations.
2656
2657Example: Given
2658  int a, b;
2659  int c;
2660  int d = 2, e;
2661declCountIs(2)
2662  matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.
2663</pre></td></tr>
2664
2665
2666<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('equalsBoundNode1')"><a name="equalsBoundNode1Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr>
2667<tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node.
2668
2669Matches a node if it equals the node previously bound to ID.
2670
2671Given
2672  class X { int a; int b; };
2673cxxRecordDecl(
2674    has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
2675    has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
2676  matches the class X, as a and b have the same type.
2677
2678Note that when multiple matches are involved via forEach* matchers,
2679equalsBoundNodes acts as a filter.
2680For example:
2681compoundStmt(
2682    forEachDescendant(varDecl().bind("d")),
2683    forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
2684will trigger a match for each combination of variable declaration
2685and reference to that variable declaration within a compound statement.
2686</pre></td></tr>
2687
2688
2689<tr><td>Matcher&lt;<a href="https://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>const Decl* Other</td></tr>
2690<tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node.
2691
2692Decl has pointer identity in the AST.
2693</pre></td></tr>
2694
2695
2696<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('hasAttr0')"><a name="hasAttr0Anchor">hasAttr</a></td><td>attr::Kind AttrKind</td></tr>
2697<tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute.
2698
2699Given
2700  __attribute__((device)) void f() { ... }
2701decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
2702f. If the matcher is use from clang-query, attr::Kind parameter should be
2703passed as a quoted string. e.g., hasAttr("attr::CUDADevice").
2704</pre></td></tr>
2705
2706
2707<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isExpansionInFileMatching0')"><a name="isExpansionInFileMatching0Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr>
2708<tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is
2709partially matching a given regex.
2710
2711Example matches Y but not X
2712    (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
2713  #include "ASTMatcher.h"
2714  class X {};
2715ASTMatcher.h:
2716  class Y {};
2717
2718Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
2719</pre></td></tr>
2720
2721
2722<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isExpansionInMainFile0')"><a name="isExpansionInMainFile0Anchor">isExpansionInMainFile</a></td><td></td></tr>
2723<tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file.
2724
2725Example matches X but not Y
2726  (matcher = cxxRecordDecl(isExpansionInMainFile())
2727  #include &lt;Y.h&gt;
2728  class X {};
2729Y.h:
2730  class Y {};
2731
2732Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
2733</pre></td></tr>
2734
2735
2736<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isExpansionInSystemHeader0')"><a name="isExpansionInSystemHeader0Anchor">isExpansionInSystemHeader</a></td><td></td></tr>
2737<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files.
2738
2739Example matches Y but not X
2740    (matcher = cxxRecordDecl(isExpansionInSystemHeader())
2741  #include &lt;SystemHeader.h&gt;
2742  class X {};
2743SystemHeader.h:
2744  class Y {};
2745
2746Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
2747</pre></td></tr>
2748
2749
2750<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr>
2751<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added
2752by the compiler (eg. implicit defaultcopy constructors).
2753</pre></td></tr>
2754
2755
2756<tr><td>Matcher&lt;<a href="https://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>
2757<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations.
2758
2759Given
2760  class C {
2761  public:    int a;
2762  protected: int b;
2763  private:   int c;
2764  };
2765fieldDecl(isPrivate())
2766  matches 'int c;'
2767</pre></td></tr>
2768
2769
2770<tr><td>Matcher&lt;<a href="https://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>
2771<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations.
2772
2773Given
2774  class C {
2775  public:    int a;
2776  protected: int b;
2777  private:   int c;
2778  };
2779fieldDecl(isProtected())
2780  matches 'int b;'
2781</pre></td></tr>
2782
2783
2784<tr><td>Matcher&lt;<a href="https://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>
2785<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations.
2786
2787Given
2788  class C {
2789  public:    int a;
2790  protected: int b;
2791  private:   int c;
2792  };
2793fieldDecl(isPublic())
2794  matches 'int a;'
2795</pre></td></tr>
2796
2797
2798<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DesignatedInitExpr.html">DesignatedInitExpr</a>&gt;</td><td class="name" onclick="toggle('designatorCountIs0')"><a name="designatorCountIs0Anchor">designatorCountIs</a></td><td>unsigned N</td></tr>
2799<tr><td colspan="4" class="doc" id="designatorCountIs0"><pre>Matches designated initializer expressions that contain
2800a specific number of designators.
2801
2802Example: Given
2803  point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
2804  point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 };
2805designatorCountIs(2)
2806  matches '{ [2].y = 1.0, [0].x = 1.0 }',
2807  but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'.
2808</pre></td></tr>
2809
2810
2811<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl</a>&gt;</td><td class="name" onclick="toggle('isScoped0')"><a name="isScoped0Anchor">isScoped</a></td><td></td></tr>
2812<tr><td colspan="4" class="doc" id="isScoped0"><pre>Matches C++11 scoped enum declaration.
2813
2814Example matches Y (matcher = enumDecl(isScoped()))
2815enum X {};
2816enum class Y {};
2817</pre></td></tr>
2818
2819
2820<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('isInstantiationDependent0')"><a name="isInstantiationDependent0Anchor">isInstantiationDependent</a></td><td></td></tr>
2821<tr><td colspan="4" class="doc" id="isInstantiationDependent0"><pre>Matches expressions that are instantiation-dependent even if it is
2822neither type- nor value-dependent.
2823
2824In the following example, the expression sizeof(sizeof(T() + T()))
2825is instantiation-dependent (since it involves a template parameter T),
2826but is neither type- nor value-dependent, since the type of the inner
2827sizeof is known (std::size_t) and therefore the size of the outer
2828sizeof is known.
2829  template&lt;typename T&gt;
2830  void f(T x, T y) { sizeof(sizeof(T() + T()); }
2831expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T())
2832</pre></td></tr>
2833
2834
2835<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('isTypeDependent0')"><a name="isTypeDependent0Anchor">isTypeDependent</a></td><td></td></tr>
2836<tr><td colspan="4" class="doc" id="isTypeDependent0"><pre>Matches expressions that are type-dependent because the template type
2837is not yet instantiated.
2838
2839For example, the expressions "x" and "x + y" are type-dependent in
2840the following code, but "y" is not type-dependent:
2841  template&lt;typename T&gt;
2842  void add(T x, int y) {
2843    x + y;
2844  }
2845expr(isTypeDependent()) matches x + y
2846</pre></td></tr>
2847
2848
2849<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('isValueDependent0')"><a name="isValueDependent0Anchor">isValueDependent</a></td><td></td></tr>
2850<tr><td colspan="4" class="doc" id="isValueDependent0"><pre>Matches expression that are value-dependent because they contain a
2851non-type template parameter.
2852
2853For example, the array bound of "Chars" in the following example is
2854value-dependent.
2855  template&lt;int Size&gt; int f() { return Size; }
2856expr(isValueDependent()) matches return Size
2857</pre></td></tr>
2858
2859
2860<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>&gt;</td><td class="name" onclick="toggle('hasBitWidth0')"><a name="hasBitWidth0Anchor">hasBitWidth</a></td><td>unsigned Width</td></tr>
2861<tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified
2862bit width.
2863
2864Given
2865  class C {
2866    int a : 2;
2867    int b : 4;
2868    int c : 2;
2869  };
2870fieldDecl(hasBitWidth(2))
2871  matches 'int a;' and 'int c;' but not 'int b;'.
2872</pre></td></tr>
2873
2874
2875<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>&gt;</td><td class="name" onclick="toggle('isBitField0')"><a name="isBitField0Anchor">isBitField</a></td><td></td></tr>
2876<tr><td colspan="4" class="doc" id="isBitField0"><pre>Matches non-static data members that are bit-fields.
2877
2878Given
2879  class C {
2880    int a : 2;
2881    int b;
2882  };
2883fieldDecl(isBitField())
2884  matches 'int a;' but not 'int b;'.
2885</pre></td></tr>
2886
2887
2888<tr><td>Matcher&lt;<a href="https://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>const ValueT  Value</td></tr>
2889<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value of type ValueT.
2890
2891Given
2892  f('false, 3.14, 42);
2893characterLiteral(equals(0))
2894  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
2895  match false
2896floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
2897  match 3.14
2898integerLiteral(equals(42))
2899  matches 42
2900
2901Note that you cannot directly match a negative numeric literal because the
2902minus sign is not part of the literal: It is a unary operator whose operand
2903is the positive numeric literal. Instead, you must use a unaryOperator()
2904matcher to match the minus sign:
2905
2906unaryOperator(hasOperatorName("-"),
2907              hasUnaryOperand(integerLiteral(equals(13))))
2908
2909Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>&gt;,
2910           Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;
2911</pre></td></tr>
2912
2913
2914<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>&gt;</td><td class="name" onclick="toggle('equals12')"><a name="equals12Anchor">equals</a></td><td>double Value</td></tr>
2915<tr><td colspan="4" class="doc" id="equals12"><pre></pre></td></tr>
2916
2917
2918<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasDynamicExceptionSpec0')"><a name="hasDynamicExceptionSpec0Anchor">hasDynamicExceptionSpec</a></td><td></td></tr>
2919<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification.
2920
2921Given:
2922  void f();
2923  void g() noexcept;
2924  void h() noexcept(true);
2925  void i() noexcept(false);
2926  void j() throw();
2927  void k() throw(int);
2928  void l() throw(...);
2929functionDecl(hasDynamicExceptionSpec()) and
2930  functionProtoType(hasDynamicExceptionSpec())
2931  match the declarations of j, k, and l, but not f, g, h, or i.
2932</pre></td></tr>
2933
2934
2935<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr>
2936<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names.
2937
2938Matches overloaded operator names specified in strings without the
2939"operator" prefix: e.g. "&lt;&lt;".
2940
2941Given:
2942  class A { int operator*(); };
2943  const A &amp;operator&lt;&lt;(const A &amp;a, const A &amp;b);
2944  A a;
2945  a &lt;&lt; a;   &lt;-- This matches
2946
2947cxxOperatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the
2948specified line and
2949cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
2950matches the declaration of A.
2951
2952Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;
2953</pre></td></tr>
2954
2955
2956<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasTrailingReturn0')"><a name="hasTrailingReturn0Anchor">hasTrailingReturn</a></td><td></td></tr>
2957<tr><td colspan="4" class="doc" id="hasTrailingReturn0"><pre>Matches a function declared with a trailing return type.
2958
2959Example matches Y (matcher = functionDecl(hasTrailingReturn()))
2960int X() {}
2961auto Y() -&gt; int {}
2962</pre></td></tr>
2963
2964
2965<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isConstexpr1')"><a name="isConstexpr1Anchor">isConstexpr</a></td><td></td></tr>
2966<tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations,
2967       and if constexpr.
2968
2969Given:
2970  constexpr int foo = 42;
2971  constexpr int bar();
2972  void baz() { if constexpr(1 &gt; 0) {} }
2973varDecl(isConstexpr())
2974  matches the declaration of foo.
2975functionDecl(isConstexpr())
2976  matches the declaration of bar.
2977ifStmt(isConstexpr())
2978  matches the if statement in baz.
2979</pre></td></tr>
2980
2981
2982<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isDefaulted0')"><a name="isDefaulted0Anchor">isDefaulted</a></td><td></td></tr>
2983<tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations.
2984
2985Given:
2986  class A { ~A(); };
2987  class B { ~B() = default; };
2988functionDecl(isDefaulted())
2989  matches the declaration of ~B, but not ~A.
2990</pre></td></tr>
2991
2992
2993<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isDefinition3')"><a name="isDefinition3Anchor">isDefinition</a></td><td></td></tr>
2994<tr><td colspan="4" class="doc" id="isDefinition3"><pre>Matches if a declaration has a body attached.
2995
2996Example matches A, va, fa
2997  class A {};
2998  class B;  Doesn't match, as it has no body.
2999  int va;
3000  extern int vb;  Doesn't match, as it doesn't define the variable.
3001  void fa() {}
3002  void fb();  Doesn't match, as it has no body.
3003  @interface X
3004  - (void)ma; Doesn't match, interface is declaration.
3005  @end
3006  @implementation X
3007  - (void)ma {}
3008  @end
3009
3010Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;,
3011  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
3012</pre></td></tr>
3013
3014
3015<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isDeleted0')"><a name="isDeleted0Anchor">isDeleted</a></td><td></td></tr>
3016<tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations.
3017
3018Given:
3019  void Func();
3020  void DeletedFunc() = delete;
3021functionDecl(isDeleted())
3022  matches the declaration of DeletedFunc, but not Func.
3023</pre></td></tr>
3024
3025
3026<tr><td>Matcher&lt;<a href="https://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>
3027<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or
3028static member variable template instantiations.
3029
3030Given
3031  template&lt;typename T&gt; void A(T t) { }
3032  template&lt;&gt; void A(int N) { }
3033functionDecl(isExplicitTemplateSpecialization())
3034  matches the specialization A&lt;int&gt;().
3035
3036Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
3037</pre></td></tr>
3038
3039
3040<tr><td>Matcher&lt;<a href="https://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>
3041<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function or variable declarations.
3042
3043Given:
3044  extern "C" void f() {}
3045  extern "C" { void g() {} }
3046  void h() {}
3047  extern "C" int x = 1;
3048  extern "C" int y = 2;
3049  int z = 3;
3050functionDecl(isExternC())
3051  matches the declaration of f and g, but not the declaration of h.
3052varDecl(isExternC())
3053  matches the declaration of x and y, but not the declaration of z.
3054</pre></td></tr>
3055
3056
3057<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isInline1')"><a name="isInline1Anchor">isInline</a></td><td></td></tr>
3058<tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with
3059the inline keyword.
3060
3061Given
3062  inline void f();
3063  void g();
3064  namespace n {
3065  inline namespace m {}
3066  }
3067functionDecl(isInline()) will match ::f().
3068namespaceDecl(isInline()) will match n::m.
3069</pre></td></tr>
3070
3071
3072<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isMain0')"><a name="isMain0Anchor">isMain</a></td><td></td></tr>
3073<tr><td colspan="4" class="doc" id="isMain0"><pre>Determines whether the function is "main", which is the entry point
3074into an executable program.
3075</pre></td></tr>
3076
3077
3078<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isNoReturn0')"><a name="isNoReturn0Anchor">isNoReturn</a></td><td></td></tr>
3079<tr><td colspan="4" class="doc" id="isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute.
3080
3081Given
3082  void nope();
3083  [[noreturn]] void a();
3084  __attribute__((noreturn)) void b();
3085  struct c { [[noreturn]] c(); };
3086functionDecl(isNoReturn())
3087  matches all of those except
3088  void nope();
3089</pre></td></tr>
3090
3091
3092<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isNoThrow0')"><a name="isNoThrow0Anchor">isNoThrow</a></td><td></td></tr>
3093<tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification.
3094
3095Given:
3096  void f();
3097  void g() noexcept;
3098  void h() throw();
3099  void i() throw(int);
3100  void j() noexcept(false);
3101functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
3102  match the declarations of g, and h, but not f, i or j.
3103</pre></td></tr>
3104
3105
3106<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isStaticStorageClass0')"><a name="isStaticStorageClass0Anchor">isStaticStorageClass</a></td><td></td></tr>
3107<tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variablefunction declarations that have "static" storage
3108class specifier ("static" keyword) written in the source.
3109
3110Given:
3111  static void f() {}
3112  static int i = 0;
3113  extern int j;
3114  int k;
3115functionDecl(isStaticStorageClass())
3116  matches the function declaration f.
3117varDecl(isStaticStorageClass())
3118  matches the variable declaration i.
3119</pre></td></tr>
3120
3121
3122<tr><td>Matcher&lt;<a href="https://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>
3123<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static
3124member variable template instantiations.
3125
3126Given
3127  template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
3128or
3129  template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
3130or
3131  template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
3132cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
3133  matches the template instantiation of X&lt;A&gt;.
3134
3135But given
3136  template &lt;typename T&gt;  class X {}; class A {};
3137  template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
3138cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
3139  does not match, as X&lt;A&gt; is an explicit template specialization.
3140
3141Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
3142</pre></td></tr>
3143
3144
3145<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isVariadic0')"><a name="isVariadic0Anchor">isVariadic</a></td><td></td></tr>
3146<tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic.
3147
3148Example matches f, but not g or h. The function i will not match, even when
3149compiled in C mode.
3150  void f(...);
3151  void g(int);
3152  template &lt;typename... Ts&gt; void h(Ts...);
3153  void i();
3154</pre></td></tr>
3155
3156
3157<tr><td>Matcher&lt;<a href="https://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>
3158<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
3159specific parameter count.
3160
3161Given
3162  void f(int i) {}
3163  void g(int i, int j) {}
3164  void h(int i, int j);
3165  void j(int i);
3166  void k(int x, int y, int z, ...);
3167functionDecl(parameterCountIs(2))
3168  matches g and h
3169functionProtoType(parameterCountIs(2))
3170  matches g and h
3171functionProtoType(parameterCountIs(3))
3172  matches k
3173</pre></td></tr>
3174
3175
3176<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>&gt;</td><td class="name" onclick="toggle('hasDynamicExceptionSpec1')"><a name="hasDynamicExceptionSpec1Anchor">hasDynamicExceptionSpec</a></td><td></td></tr>
3177<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification.
3178
3179Given:
3180  void f();
3181  void g() noexcept;
3182  void h() noexcept(true);
3183  void i() noexcept(false);
3184  void j() throw();
3185  void k() throw(int);
3186  void l() throw(...);
3187functionDecl(hasDynamicExceptionSpec()) and
3188  functionProtoType(hasDynamicExceptionSpec())
3189  match the declarations of j, k, and l, but not f, g, h, or i.
3190</pre></td></tr>
3191
3192
3193<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>&gt;</td><td class="name" onclick="toggle('isNoThrow1')"><a name="isNoThrow1Anchor">isNoThrow</a></td><td></td></tr>
3194<tr><td colspan="4" class="doc" id="isNoThrow1"><pre>Matches functions that have a non-throwing exception specification.
3195
3196Given:
3197  void f();
3198  void g() noexcept;
3199  void h() throw();
3200  void i() throw(int);
3201  void j() noexcept(false);
3202functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
3203  match the declarations of g, and h, but not f, i or j.
3204</pre></td></tr>
3205
3206
3207<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>&gt;</td><td class="name" onclick="toggle('parameterCountIs1')"><a name="parameterCountIs1Anchor">parameterCountIs</a></td><td>unsigned N</td></tr>
3208<tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
3209specific parameter count.
3210
3211Given
3212  void f(int i) {}
3213  void g(int i, int j) {}
3214  void h(int i, int j);
3215  void j(int i);
3216  void k(int x, int y, int z, ...);
3217functionDecl(parameterCountIs(2))
3218  matches g and h
3219functionProtoType(parameterCountIs(2))
3220  matches g and h
3221functionProtoType(parameterCountIs(3))
3222  matches k
3223</pre></td></tr>
3224
3225
3226<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>&gt;</td><td class="name" onclick="toggle('isConstexpr2')"><a name="isConstexpr2Anchor">isConstexpr</a></td><td></td></tr>
3227<tr><td colspan="4" class="doc" id="isConstexpr2"><pre>Matches constexpr variable and function declarations,
3228       and if constexpr.
3229
3230Given:
3231  constexpr int foo = 42;
3232  constexpr int bar();
3233  void baz() { if constexpr(1 &gt; 0) {} }
3234varDecl(isConstexpr())
3235  matches the declaration of foo.
3236functionDecl(isConstexpr())
3237  matches the declaration of bar.
3238ifStmt(isConstexpr())
3239  matches the if statement in baz.
3240</pre></td></tr>
3241
3242
3243<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;</td><td class="name" onclick="toggle('equals6')"><a name="equals6Anchor">equals</a></td><td>bool Value</td></tr>
3244<tr><td colspan="4" class="doc" id="equals6"><pre></pre></td></tr>
3245
3246
3247<tr><td>Matcher&lt;<a href="https://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>const ValueT  Value</td></tr>
3248<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value of type ValueT.
3249
3250Given
3251  f('false, 3.14, 42);
3252characterLiteral(equals(0))
3253  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
3254  match false
3255floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
3256  match 3.14
3257integerLiteral(equals(42))
3258  matches 42
3259
3260Note that you cannot directly match a negative numeric literal because the
3261minus sign is not part of the literal: It is a unary operator whose operand
3262is the positive numeric literal. Instead, you must use a unaryOperator()
3263matcher to match the minus sign:
3264
3265unaryOperator(hasOperatorName("-"),
3266              hasUnaryOperand(integerLiteral(equals(13))))
3267
3268Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>&gt;,
3269           Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;
3270</pre></td></tr>
3271
3272
3273<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;</td><td class="name" onclick="toggle('equals13')"><a name="equals13Anchor">equals</a></td><td>double Value</td></tr>
3274<tr><td colspan="4" class="doc" id="equals13"><pre></pre></td></tr>
3275
3276
3277<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>&gt;</td><td class="name" onclick="toggle('equals9')"><a name="equals9Anchor">equals</a></td><td>unsigned Value</td></tr>
3278<tr><td colspan="4" class="doc" id="equals9"><pre></pre></td></tr>
3279
3280
3281<tr><td>Matcher&lt;<a href="https://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>
3282<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '-&gt;' as opposed
3283to '.'.
3284
3285Member calls on the implicit this pointer match as called with '-&gt;'.
3286
3287Given
3288  class Y {
3289    void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
3290    template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
3291    int a;
3292    static int b;
3293  };
3294  template &lt;class T&gt;
3295  class Z {
3296    void x() { this-&gt;m; }
3297  };
3298memberExpr(isArrow())
3299  matches this-&gt;x, x, y.x, a, this-&gt;b
3300cxxDependentScopeMemberExpr(isArrow())
3301  matches this-&gt;m
3302unresolvedMemberExpr(isArrow())
3303  matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
3304</pre></td></tr>
3305
3306
3307<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt;</td><td class="name" onclick="toggle('hasExternalFormalLinkage0')"><a name="hasExternalFormalLinkage0Anchor">hasExternalFormalLinkage</a></td><td></td></tr>
3308<tr><td colspan="4" class="doc" id="hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage.
3309
3310Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))
3311void f() {
3312  int x;
3313  static int y;
3314}
3315int z;
3316
3317Example matches f() because it has external formal linkage despite being
3318unique to the translation unit as though it has internal likage
3319(matcher = functionDecl(hasExternalFormalLinkage()))
3320
3321namespace {
3322void f() {}
3323}
3324</pre></td></tr>
3325
3326
3327<tr><td>Matcher&lt;<a href="https://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>const std::string  Name</td></tr>
3328<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name.
3329
3330Supports specifying enclosing namespaces or classes by prefixing the name
3331with '&lt;enclosing&gt;::'.
3332Does not match typedefs of an underlying type with the given name.
3333
3334Example matches X (Name == "X")
3335  class X;
3336
3337Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
3338  namespace a { namespace b { class X; } }
3339</pre></td></tr>
3340
3341
3342<tr><td>Matcher&lt;<a href="https://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>
3343<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain
3344a substring matched by the given RegExp.
3345
3346Supports specifying enclosing namespaces or classes by
3347prefixing the name with '&lt;enclosing&gt;::'.  Does not match typedefs
3348of an underlying type with the given name.
3349
3350Example matches X (regexp == "::X")
3351  class X;
3352
3353Example matches X (regexp is one of "::X", "^foo::.*X", among others)
3354  namespace foo { namespace bar { class X; } }
3355</pre></td></tr>
3356
3357
3358<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>&gt;</td><td class="name" onclick="toggle('isAnonymous0')"><a name="isAnonymous0Anchor">isAnonymous</a></td><td></td></tr>
3359<tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations.
3360
3361Given
3362  namespace n {
3363  namespace {} #1
3364  }
3365namespaceDecl(isAnonymous()) will match #1 but not ::n.
3366</pre></td></tr>
3367
3368
3369<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>&gt;</td><td class="name" onclick="toggle('isInline0')"><a name="isInline0Anchor">isInline</a></td><td></td></tr>
3370<tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with
3371the inline keyword.
3372
3373Given
3374  inline void f();
3375  void g();
3376  namespace n {
3377  inline namespace m {}
3378  }
3379functionDecl(isInline()) will match ::f().
3380namespaceDecl(isInline()) will match n::m.
3381</pre></td></tr>
3382
3383
3384<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('argumentCountIs2')"><a name="argumentCountIs2Anchor">argumentCountIs</a></td><td>unsigned N</td></tr>
3385<tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has
3386a specific number of arguments (including absent default arguments).
3387
3388Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
3389  void f(int x, int y);
3390  f(0, 0);
3391</pre></td></tr>
3392
3393
3394<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasKeywordSelector0')"><a name="hasKeywordSelector0Anchor">hasKeywordSelector</a></td><td></td></tr>
3395<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector
3396
3397objCMessageExpr(hasKeywordSelector()) matches the generated setFrame
3398message expression in
3399
3400  UIWebView *webView = ...;
3401  CGRect bodyFrame = webView.frame;
3402  bodyFrame.size.height = self.bodyContentHeight;
3403  webView.frame = bodyFrame;
3404      ^---- matches here
3405</pre></td></tr>
3406
3407
3408<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasNullSelector0')"><a name="hasNullSelector0Anchor">hasNullSelector</a></td><td></td></tr>
3409<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector
3410
3411Matches only when the selector of the objCMessageExpr is NULL. This may
3412represent an error condition in the tree!
3413</pre></td></tr>
3414
3415
3416<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasSelector0')"><a name="hasSelector0Anchor">hasSelector</a></td><td>std::string BaseName</td></tr>
3417<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString()
3418
3419 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:"));
3420 matches the outer message expr in the code below, but NOT the message
3421 invocation for self.bodyView.
3422    [self.bodyView loadHTMLString:html baseURL:NULL];
3423</pre></td></tr>
3424
3425
3426<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasUnarySelector0')"><a name="hasUnarySelector0Anchor">hasUnarySelector</a></td><td></td></tr>
3427<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector
3428
3429 matcher = objCMessageExpr(matchesSelector(hasUnarySelector());
3430 matches self.bodyView in the code below, but NOT the outer message
3431 invocation of "loadHTMLString:baseURL:".
3432    [self.bodyView loadHTMLString:html baseURL:NULL];
3433</pre></td></tr>
3434
3435
3436<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('isInstanceMessage0')"><a name="isInstanceMessage0Anchor">isInstanceMessage</a></td><td></td></tr>
3437<tr><td colspan="4" class="doc" id="isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance.
3438
3439Example
3440matcher = objcMessagaeExpr(isInstanceMessage())
3441matches
3442  NSString *x = @"hello";
3443  [x containsString:@"h"];
3444but not
3445  [NSString stringWithFormat:@"format"];
3446</pre></td></tr>
3447
3448
3449<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('matchesSelector0')"><a name="matchesSelector0Anchor">matchesSelector</a></td><td>std::string RegExp</td></tr>
3450<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains
3451a substring matched by the given RegExp.
3452 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message
3453 invocation for self.bodyView.
3454    [self.bodyView loadHTMLString:html baseURL:NULL];
3455</pre></td></tr>
3456
3457
3458<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('numSelectorArgs0')"><a name="numSelectorArgs0Anchor">numSelectorArgs</a></td><td>unsigned N</td></tr>
3459<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments
3460
3461 matcher = objCMessageExpr(numSelectorArgs(0));
3462 matches self.bodyView in the code below
3463
3464 matcher = objCMessageExpr(numSelectorArgs(2));
3465 matches the invocation of "loadHTMLString:baseURL:" but not that
3466 of self.bodyView
3467    [self.bodyView loadHTMLString:html baseURL:NULL];
3468</pre></td></tr>
3469
3470
3471<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isDefinition2')"><a name="isDefinition2Anchor">isDefinition</a></td><td></td></tr>
3472<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached.
3473
3474Example matches A, va, fa
3475  class A {};
3476  class B;  Doesn't match, as it has no body.
3477  int va;
3478  extern int vb;  Doesn't match, as it doesn't define the variable.
3479  void fa() {}
3480  void fb();  Doesn't match, as it has no body.
3481  @interface X
3482  - (void)ma; Doesn't match, interface is declaration.
3483  @end
3484  @implementation X
3485  - (void)ma {}
3486  @end
3487
3488Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;,
3489  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
3490</pre></td></tr>
3491
3492
3493<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt;</td><td class="name" onclick="toggle('hasDefaultArgument0')"><a name="hasDefaultArgument0Anchor">hasDefaultArgument</a></td><td></td></tr>
3494<tr><td colspan="4" class="doc" id="hasDefaultArgument0"><pre>Matches a declaration that has default arguments.
3495
3496Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
3497void x(int val) {}
3498void y(int val = 0) {}
3499</pre></td></tr>
3500
3501
3502<tr><td>Matcher&lt;<a href="https://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>
3503<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string.
3504
3505Given
3506  class Y { public: void x(); };
3507  void z() { Y* y; y-&gt;x(); }
3508cxxMemberCallExpr(on(hasType(asString("class Y *"))))
3509  matches y-&gt;x()
3510</pre></td></tr>
3511
3512
3513<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('equalsBoundNode3')"><a name="equalsBoundNode3Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr>
3514<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node.
3515
3516Matches a node if it equals the node previously bound to ID.
3517
3518Given
3519  class X { int a; int b; };
3520cxxRecordDecl(
3521    has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
3522    has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
3523  matches the class X, as a and b have the same type.
3524
3525Note that when multiple matches are involved via forEach* matchers,
3526equalsBoundNodes acts as a filter.
3527For example:
3528compoundStmt(
3529    forEachDescendant(varDecl().bind("d")),
3530    forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
3531will trigger a match for each combination of variable declaration
3532and reference to that variable declaration within a compound statement.
3533</pre></td></tr>
3534
3535
3536<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('hasLocalQualifiers0')"><a name="hasLocalQualifiers0Anchor">hasLocalQualifiers</a></td><td></td></tr>
3537<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to
3538the node, not hidden within a typedef.
3539
3540Given
3541  typedef const int const_int;
3542  const_int i;
3543  int *const j;
3544  int *volatile k;
3545  int m;
3546varDecl(hasType(hasLocalQualifiers())) matches only j and k.
3547i is const-qualified but the qualifier is not local.
3548</pre></td></tr>
3549
3550
3551<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('isAnyCharacter0')"><a name="isAnyCharacter0Anchor">isAnyCharacter</a></td><td></td></tr>
3552<tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type.
3553
3554Given
3555  void a(char);
3556  void b(wchar_t);
3557  void c(double);
3558functionDecl(hasAnyParameter(hasType(isAnyCharacter())))
3559matches "a(char)", "b(wchar_t)", but not "c(double)".
3560</pre></td></tr>
3561
3562
3563<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('isAnyPointer0')"><a name="isAnyPointer0Anchor">isAnyPointer</a></td><td></td></tr>
3564<tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type; this includes
3565the Objective-C object pointer type, which is different despite being
3566syntactically similar.
3567
3568Given
3569  int *i = nullptr;
3570
3571  @interface Foo
3572  @end
3573  Foo *f;
3574
3575  int j;
3576varDecl(hasType(isAnyPointer()))
3577  matches "int *i" and "Foo *f", but not "int j".
3578</pre></td></tr>
3579
3580
3581<tr><td>Matcher&lt;<a href="https://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>
3582<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that
3583include "top-level" const.
3584
3585Given
3586  void a(int);
3587  void b(int const);
3588  void c(const int);
3589  void d(const int*);
3590  void e(int const) {};
3591functionDecl(hasAnyParameter(hasType(isConstQualified())))
3592  matches "void b(int const)", "void c(const int)" and
3593  "void e(int const) {}". It does not match d as there
3594  is no top-level const on the parameter type "const int *".
3595</pre></td></tr>
3596
3597
3598<tr><td>Matcher&lt;<a href="https://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>
3599<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type.
3600
3601Given
3602  void a(int);
3603  void b(long);
3604  void c(double);
3605functionDecl(hasAnyParameter(hasType(isInteger())))
3606matches "a(int)", "b(long)", but not "c(double)".
3607</pre></td></tr>
3608
3609
3610<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('isSignedInteger0')"><a name="isSignedInteger0Anchor">isSignedInteger</a></td><td></td></tr>
3611<tr><td colspan="4" class="doc" id="isSignedInteger0"><pre>Matches QualType nodes that are of signed integer type.
3612
3613Given
3614  void a(int);
3615  void b(unsigned long);
3616  void c(double);
3617functionDecl(hasAnyParameter(hasType(isSignedInteger())))
3618matches "a(int)", but not "b(unsigned long)" and "c(double)".
3619</pre></td></tr>
3620
3621
3622<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('isUnsignedInteger0')"><a name="isUnsignedInteger0Anchor">isUnsignedInteger</a></td><td></td></tr>
3623<tr><td colspan="4" class="doc" id="isUnsignedInteger0"><pre>Matches QualType nodes that are of unsigned integer type.
3624
3625Given
3626  void a(int);
3627  void b(unsigned long);
3628  void c(double);
3629functionDecl(hasAnyParameter(hasType(isUnsignedInteger())))
3630matches "b(unsigned long)", but not "a(int)" and "c(double)".
3631</pre></td></tr>
3632
3633
3634<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('isVolatileQualified0')"><a name="isVolatileQualified0Anchor">isVolatileQualified</a></td><td></td></tr>
3635<tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that
3636include "top-level" volatile.
3637
3638Given
3639  void a(int);
3640  void b(int volatile);
3641  void c(volatile int);
3642  void d(volatile int*);
3643  void e(int volatile) {};
3644functionDecl(hasAnyParameter(hasType(isVolatileQualified())))
3645  matches "void b(int volatile)", "void c(volatile int)" and
3646  "void e(int volatile) {}". It does not match d as there
3647  is no top-level volatile on the parameter type "volatile int *".
3648</pre></td></tr>
3649
3650
3651<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>&gt;</td><td class="name" onclick="toggle('isClass0')"><a name="isClass0Anchor">isClass</a></td><td></td></tr>
3652<tr><td colspan="4" class="doc" id="isClass0"><pre>Matches RecordDecl object that are spelled with "class."
3653
3654Example matches C, but not S or U.
3655  struct S {};
3656  class C {};
3657  union U {};
3658</pre></td></tr>
3659
3660
3661<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>&gt;</td><td class="name" onclick="toggle('isStruct0')"><a name="isStruct0Anchor">isStruct</a></td><td></td></tr>
3662<tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches RecordDecl object that are spelled with "struct."
3663
3664Example matches S, but not C or U.
3665  struct S {};
3666  class C {};
3667  union U {};
3668</pre></td></tr>
3669
3670
3671<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>&gt;</td><td class="name" onclick="toggle('isUnion0')"><a name="isUnion0Anchor">isUnion</a></td><td></td></tr>
3672<tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches RecordDecl object that are spelled with "union."
3673
3674Example matches U, but not C or S.
3675  struct S {};
3676  class C {};
3677  union U {};
3678</pre></td></tr>
3679
3680
3681<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('equalsBoundNode0')"><a name="equalsBoundNode0Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr>
3682<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node.
3683
3684Matches a node if it equals the node previously bound to ID.
3685
3686Given
3687  class X { int a; int b; };
3688cxxRecordDecl(
3689    has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
3690    has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
3691  matches the class X, as a and b have the same type.
3692
3693Note that when multiple matches are involved via forEach* matchers,
3694equalsBoundNodes acts as a filter.
3695For example:
3696compoundStmt(
3697    forEachDescendant(varDecl().bind("d")),
3698    forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
3699will trigger a match for each combination of variable declaration
3700and reference to that variable declaration within a compound statement.
3701</pre></td></tr>
3702
3703
3704<tr><td>Matcher&lt;<a href="https://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>const Stmt* Other</td></tr>
3705<tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node.
3706
3707Stmt has pointer identity in the AST.
3708</pre></td></tr>
3709
3710
3711<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('isExpansionInFileMatching1')"><a name="isExpansionInFileMatching1Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr>
3712<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is
3713partially matching a given regex.
3714
3715Example matches Y but not X
3716    (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
3717  #include "ASTMatcher.h"
3718  class X {};
3719ASTMatcher.h:
3720  class Y {};
3721
3722Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
3723</pre></td></tr>
3724
3725
3726<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('isExpansionInMainFile1')"><a name="isExpansionInMainFile1Anchor">isExpansionInMainFile</a></td><td></td></tr>
3727<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file.
3728
3729Example matches X but not Y
3730  (matcher = cxxRecordDecl(isExpansionInMainFile())
3731  #include &lt;Y.h&gt;
3732  class X {};
3733Y.h:
3734  class Y {};
3735
3736Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
3737</pre></td></tr>
3738
3739
3740<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('isExpansionInSystemHeader1')"><a name="isExpansionInSystemHeader1Anchor">isExpansionInSystemHeader</a></td><td></td></tr>
3741<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files.
3742
3743Example matches Y but not X
3744    (matcher = cxxRecordDecl(isExpansionInSystemHeader())
3745  #include &lt;SystemHeader.h&gt;
3746  class X {};
3747SystemHeader.h:
3748  class Y {};
3749
3750Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
3751</pre></td></tr>
3752
3753
3754<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>&gt;</td><td class="name" onclick="toggle('hasSize1')"><a name="hasSize1Anchor">hasSize</a></td><td>unsigned N</td></tr>
3755<tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size.
3756
3757Given
3758  int a[42];
3759  int b[2 * 21];
3760  int c[41], d[43];
3761  char *s = "abcd";
3762  wchar_t *ws = L"abcd";
3763  char *w = "a";
3764constantArrayType(hasSize(42))
3765  matches "int a[42]" and "int b[2 * 21]"
3766stringLiteral(hasSize(4))
3767  matches "abcd", L"abcd"
3768</pre></td></tr>
3769
3770
3771<tr><td>Matcher&lt;<a href="https://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>
3772<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached.
3773
3774Example matches A, va, fa
3775  class A {};
3776  class B;  Doesn't match, as it has no body.
3777  int va;
3778  extern int vb;  Doesn't match, as it doesn't define the variable.
3779  void fa() {}
3780  void fb();  Doesn't match, as it has no body.
3781  @interface X
3782  - (void)ma; Doesn't match, interface is declaration.
3783  @end
3784  @implementation X
3785  - (void)ma {}
3786  @end
3787
3788Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;,
3789  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
3790</pre></td></tr>
3791
3792
3793<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('equalsIntegralValue0')"><a name="equalsIntegralValue0Anchor">equalsIntegralValue</a></td><td>std::string Value</td></tr>
3794<tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value.
3795
3796Note that 'Value' is a string as the template argument's value is
3797an arbitrary precision integer. 'Value' must be euqal to the canonical
3798representation of that integral value in base 10.
3799
3800Given
3801  template&lt;int T&gt; struct C {};
3802  C&lt;42&gt; c;
3803classTemplateSpecializationDecl(
3804  hasAnyTemplateArgument(equalsIntegralValue("42")))
3805  matches the implicit instantiation of C in C&lt;42&gt;.
3806</pre></td></tr>
3807
3808
3809<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('isIntegral0')"><a name="isIntegral0Anchor">isIntegral</a></td><td></td></tr>
3810<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value.
3811
3812Given
3813  template&lt;int T&gt; struct C {};
3814  C&lt;42&gt; c;
3815classTemplateSpecializationDecl(
3816  hasAnyTemplateArgument(isIntegral()))
3817  matches the implicit instantiation of C in C&lt;42&gt;
3818  with isIntegral() matching 42.
3819</pre></td></tr>
3820
3821
3822<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('templateArgumentCountIs1')"><a name="templateArgumentCountIs1Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr>
3823<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N.
3824
3825Given
3826  template&lt;typename T&gt; struct C {};
3827  C&lt;int&gt; c;
3828classTemplateSpecializationDecl(templateArgumentCountIs(1))
3829  matches C&lt;int&gt;.
3830</pre></td></tr>
3831
3832
3833<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('isExpansionInFileMatching2')"><a name="isExpansionInFileMatching2Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr>
3834<tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is
3835partially matching a given regex.
3836
3837Example matches Y but not X
3838    (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
3839  #include "ASTMatcher.h"
3840  class X {};
3841ASTMatcher.h:
3842  class Y {};
3843
3844Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
3845</pre></td></tr>
3846
3847
3848<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('isExpansionInMainFile2')"><a name="isExpansionInMainFile2Anchor">isExpansionInMainFile</a></td><td></td></tr>
3849<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file.
3850
3851Example matches X but not Y
3852  (matcher = cxxRecordDecl(isExpansionInMainFile())
3853  #include &lt;Y.h&gt;
3854  class X {};
3855Y.h:
3856  class Y {};
3857
3858Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
3859</pre></td></tr>
3860
3861
3862<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('isExpansionInSystemHeader2')"><a name="isExpansionInSystemHeader2Anchor">isExpansionInSystemHeader</a></td><td></td></tr>
3863<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files.
3864
3865Example matches Y but not X
3866    (matcher = cxxRecordDecl(isExpansionInSystemHeader())
3867  #include &lt;SystemHeader.h&gt;
3868  class X {};
3869SystemHeader.h:
3870  class Y {};
3871
3872Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;
3873</pre></td></tr>
3874
3875
3876<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('booleanType0')"><a name="booleanType0Anchor">booleanType</a></td><td></td></tr>
3877<tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool.
3878
3879Given
3880 struct S { bool func(); };
3881functionDecl(returns(booleanType()))
3882  matches "bool func();"
3883</pre></td></tr>
3884
3885
3886<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('equalsBoundNode2')"><a name="equalsBoundNode2Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr>
3887<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node.
3888
3889Matches a node if it equals the node previously bound to ID.
3890
3891Given
3892  class X { int a; int b; };
3893cxxRecordDecl(
3894    has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
3895    has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
3896  matches the class X, as a and b have the same type.
3897
3898Note that when multiple matches are involved via forEach* matchers,
3899equalsBoundNodes acts as a filter.
3900For example:
3901compoundStmt(
3902    forEachDescendant(varDecl().bind("d")),
3903    forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
3904will trigger a match for each combination of variable declaration
3905and reference to that variable declaration within a compound statement.
3906</pre></td></tr>
3907
3908
3909<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('equalsNode2')"><a name="equalsNode2Anchor">equalsNode</a></td><td>const Type* Other</td></tr>
3910<tr><td colspan="4" class="doc" id="equalsNode2"><pre>Matches if a node equals another node.
3911
3912Type has pointer identity in the AST.
3913</pre></td></tr>
3914
3915
3916<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('realFloatingPointType0')"><a name="realFloatingPointType0Anchor">realFloatingPointType</a></td><td></td></tr>
3917<tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double).
3918
3919Given
3920  int i;
3921  float f;
3922realFloatingPointType()
3923  matches "float f" but not "int i"
3924</pre></td></tr>
3925
3926
3927<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('voidType0')"><a name="voidType0Anchor">voidType</a></td><td></td></tr>
3928<tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void.
3929
3930Given
3931 struct S { void func(); };
3932functionDecl(returns(voidType()))
3933  matches "void func();"
3934</pre></td></tr>
3935
3936
3937<tr><td>Matcher&lt;<a href="https://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>
3938<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind.
3939
3940Given
3941  int x;
3942  int s = sizeof(x) + alignof(x)
3943unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
3944  matches sizeof(x)
3945</pre></td></tr>
3946
3947
3948<tr><td>Matcher&lt;<a href="https://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>
3949<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or
3950unary).
3951
3952Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
3953  !(a || b)
3954</pre></td></tr>
3955
3956
3957<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html">UnresolvedMemberExpr</a>&gt;</td><td class="name" onclick="toggle('isArrow1')"><a name="isArrow1Anchor">isArrow</a></td><td></td></tr>
3958<tr><td colspan="4" class="doc" id="isArrow1"><pre>Matches member expressions that are called with '-&gt;' as opposed
3959to '.'.
3960
3961Member calls on the implicit this pointer match as called with '-&gt;'.
3962
3963Given
3964  class Y {
3965    void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
3966    template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
3967    int a;
3968    static int b;
3969  };
3970  template &lt;class T&gt;
3971  class Z {
3972    void x() { this-&gt;m; }
3973  };
3974memberExpr(isArrow())
3975  matches this-&gt;x, x, y.x, a, this-&gt;b
3976cxxDependentScopeMemberExpr(isArrow())
3977  matches this-&gt;m
3978unresolvedMemberExpr(isArrow())
3979  matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
3980</pre></td></tr>
3981
3982
3983<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('hasAutomaticStorageDuration0')"><a name="hasAutomaticStorageDuration0Anchor">hasAutomaticStorageDuration</a></td><td></td></tr>
3984<tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration.
3985
3986Example matches x, but not y, z, or a.
3987(matcher = varDecl(hasAutomaticStorageDuration())
3988void f() {
3989  int x;
3990  static int y;
3991  thread_local int z;
3992}
3993int a;
3994</pre></td></tr>
3995
3996
3997<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('hasGlobalStorage0')"><a name="hasGlobalStorage0Anchor">hasGlobalStorage</a></td><td></td></tr>
3998<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage.
3999
4000Example matches y and z (matcher = varDecl(hasGlobalStorage())
4001void f() {
4002  int x;
4003  static int y;
4004}
4005int z;
4006</pre></td></tr>
4007
4008
4009<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('hasLocalStorage0')"><a name="hasLocalStorage0Anchor">hasLocalStorage</a></td><td></td></tr>
4010<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a
4011non-static local variable.
4012
4013Example matches x (matcher = varDecl(hasLocalStorage())
4014void f() {
4015  int x;
4016  static int y;
4017}
4018int z;
4019</pre></td></tr>
4020
4021
4022<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('hasStaticStorageDuration0')"><a name="hasStaticStorageDuration0Anchor">hasStaticStorageDuration</a></td><td></td></tr>
4023<tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration.
4024It includes the variable declared at namespace scope and those declared
4025with "static" and "extern" storage class specifiers.
4026
4027void f() {
4028  int x;
4029  static int y;
4030  thread_local int z;
4031}
4032int a;
4033static int b;
4034extern int c;
4035varDecl(hasStaticStorageDuration())
4036  matches the function declaration y, a, b and c.
4037</pre></td></tr>
4038
4039
4040<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('hasThreadStorageDuration0')"><a name="hasThreadStorageDuration0Anchor">hasThreadStorageDuration</a></td><td></td></tr>
4041<tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration.
4042
4043Example matches z, but not x, z, or a.
4044(matcher = varDecl(hasThreadStorageDuration())
4045void f() {
4046  int x;
4047  static int y;
4048  thread_local int z;
4049}
4050int a;
4051</pre></td></tr>
4052
4053
4054<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isConstexpr0')"><a name="isConstexpr0Anchor">isConstexpr</a></td><td></td></tr>
4055<tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations,
4056       and if constexpr.
4057
4058Given:
4059  constexpr int foo = 42;
4060  constexpr int bar();
4061  void baz() { if constexpr(1 &gt; 0) {} }
4062varDecl(isConstexpr())
4063  matches the declaration of foo.
4064functionDecl(isConstexpr())
4065  matches the declaration of bar.
4066ifStmt(isConstexpr())
4067  matches the if statement in baz.
4068</pre></td></tr>
4069
4070
4071<tr><td>Matcher&lt;<a href="https://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>
4072<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached.
4073
4074Example matches A, va, fa
4075  class A {};
4076  class B;  Doesn't match, as it has no body.
4077  int va;
4078  extern int vb;  Doesn't match, as it doesn't define the variable.
4079  void fa() {}
4080  void fb();  Doesn't match, as it has no body.
4081  @interface X
4082  - (void)ma; Doesn't match, interface is declaration.
4083  @end
4084  @implementation X
4085  - (void)ma {}
4086  @end
4087
4088Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;,
4089  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
4090</pre></td></tr>
4091
4092
4093<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isExceptionVariable0')"><a name="isExceptionVariable0Anchor">isExceptionVariable</a></td><td></td></tr>
4094<tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from
4095a C++ catch block, or an Objective-C statement.
4096
4097Example matches x (matcher = varDecl(isExceptionVariable())
4098void f(int y) {
4099  try {
4100  } catch (int x) {
4101  }
4102}
4103</pre></td></tr>
4104
4105
4106<tr><td>Matcher&lt;<a href="https://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>
4107<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or
4108static member variable template instantiations.
4109
4110Given
4111  template&lt;typename T&gt; void A(T t) { }
4112  template&lt;&gt; void A(int N) { }
4113functionDecl(isExplicitTemplateSpecialization())
4114  matches the specialization A&lt;int&gt;().
4115
4116Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
4117</pre></td></tr>
4118
4119
4120<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isExternC1')"><a name="isExternC1Anchor">isExternC</a></td><td></td></tr>
4121<tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function or variable declarations.
4122
4123Given:
4124  extern "C" void f() {}
4125  extern "C" { void g() {} }
4126  void h() {}
4127  extern "C" int x = 1;
4128  extern "C" int y = 2;
4129  int z = 3;
4130functionDecl(isExternC())
4131  matches the declaration of f and g, but not the declaration of h.
4132varDecl(isExternC())
4133  matches the declaration of x and y, but not the declaration of z.
4134</pre></td></tr>
4135
4136
4137<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isStaticLocal0')"><a name="isStaticLocal0Anchor">isStaticLocal</a></td><td></td></tr>
4138<tr><td colspan="4" class="doc" id="isStaticLocal0"><pre>Matches a static variable with local scope.
4139
4140Example matches y (matcher = varDecl(isStaticLocal()))
4141void f() {
4142  int x;
4143  static int y;
4144}
4145static int z;
4146</pre></td></tr>
4147
4148
4149<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isStaticStorageClass1')"><a name="isStaticStorageClass1Anchor">isStaticStorageClass</a></td><td></td></tr>
4150<tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variablefunction declarations that have "static" storage
4151class specifier ("static" keyword) written in the source.
4152
4153Given:
4154  static void f() {}
4155  static int i = 0;
4156  extern int j;
4157  int k;
4158functionDecl(isStaticStorageClass())
4159  matches the function declaration f.
4160varDecl(isStaticStorageClass())
4161  matches the variable declaration i.
4162</pre></td></tr>
4163
4164
4165<tr><td>Matcher&lt;<a href="https://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>
4166<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static
4167member variable template instantiations.
4168
4169Given
4170  template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
4171or
4172  template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
4173or
4174  template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
4175cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
4176  matches the template instantiation of X&lt;A&gt;.
4177
4178But given
4179  template &lt;typename T&gt;  class X {}; class A {};
4180  template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
4181cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
4182  does not match, as X&lt;A&gt; is an explicit template specialization.
4183
4184Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;
4185</pre></td></tr>
4186
4187
4188<tr><td>Matcher&lt;internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;&gt;</td><td class="name" onclick="toggle('isInstantiated0')"><a name="isInstantiated0Anchor">isInstantiated</a></td><td></td></tr>
4189<tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside
4190template instantiations.
4191
4192Given
4193  template&lt;typename T&gt; void A(T t) { T i; }
4194  A(0);
4195  A(0U);
4196functionDecl(isInstantiated())
4197  matches 'A(int) {...};' and 'A(unsigned) {...}'.
4198</pre></td></tr>
4199
4200
4201<tr><td>Matcher&lt;internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;&gt;</td><td class="name" onclick="toggle('nullPointerConstant0')"><a name="nullPointerConstant0Anchor">nullPointerConstant</a></td><td></td></tr>
4202<tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as
4203GNU's __null, C++11's nullptr, or C's NULL macro.
4204
4205Given:
4206  void *v1 = NULL;
4207  void *v2 = nullptr;
4208  void *v3 = __null; GNU extension
4209  char *cp = (char *)0;
4210  int *ip = 0;
4211  int i = 0;
4212expr(nullPointerConstant())
4213  matches the initializer for v1, v2, v3, cp, and ip. Does not match the
4214  initializer for i.
4215</pre></td></tr>
4216
4217
4218<tr><td>Matcher&lt;internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt;&gt;</td><td class="name" onclick="toggle('hasAnyName0')"><a name="hasAnyName0Anchor">hasAnyName</a></td><td>StringRef, ..., StringRef</td></tr>
4219<tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names.
4220
4221This matcher is only provided as a performance optimization of hasName.
4222    hasAnyName(a, b, c)
4223 is equivalent to, but faster than
4224    anyOf(hasName(a), hasName(b), hasName(c))
4225</pre></td></tr>
4226
4227
4228<tr><td>Matcher&lt;internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;&gt;</td><td class="name" onclick="toggle('hasAnySelector0')"><a name="hasAnySelector0Anchor">hasAnySelector</a></td><td>StringRef, ..., StringRef</td></tr>
4229<tr><td colspan="4" class="doc" id="hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the
4230Selector.getAsString()
4231
4232 matcher = objCMessageExpr(hasSelector("methodA:", "methodB:"));
4233 matches both of the expressions below:
4234    [myObj methodA:argA];
4235    [myObj methodB:argB];
4236</pre></td></tr>
4237
4238
4239<tr><td>Matcher&lt;internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;&gt;</td><td class="name" onclick="toggle('isInTemplateInstantiation0')"><a name="isInTemplateInstantiation0Anchor">isInTemplateInstantiation</a></td><td></td></tr>
4240<tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation.
4241
4242Given
4243  int j;
4244  template&lt;typename T&gt; void A(T t) { T i; j += 42;}
4245  A(0);
4246  A(0U);
4247declStmt(isInTemplateInstantiation())
4248  matches 'int i;' and 'unsigned i'.
4249unless(stmt(isInTemplateInstantiation()))
4250  will NOT match j += 42; as it's shared between the template definition and
4251  instantiation.
4252</pre></td></tr>
4253
4254<!--END_NARROWING_MATCHERS -->
4255</table>
4256
4257<!-- ======================================================================= -->
4258<h2 id="traversal-matchers">AST Traversal Matchers</h2>
4259<!-- ======================================================================= -->
4260
4261<p>Traversal matchers specify the relationship to other nodes that are
4262reachable from the current node.</p>
4263
4264<p>Note that there are special traversal matchers (has, hasDescendant, forEach and
4265forEachDescendant) which work on all nodes and allow users to write more generic
4266match expressions.</p>
4267
4268<table>
4269<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
4270<!-- START_TRAVERSAL_MATCHERS -->
4271
4272<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher&lt;*&gt;, ..., Matcher&lt;*&gt;</td></tr>
4273<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches.
4274
4275Unlike anyOf, eachOf will generate a match result for each
4276matching submatcher.
4277
4278For example, in:
4279  class A { int a; int b; };
4280The matcher:
4281  cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
4282                       has(fieldDecl(hasName("b")).bind("v"))))
4283will generate two results binding "v", the first of which binds
4284the field declaration of a, the second the field declaration of
4285b.
4286
4287Usable as: Any Matcher
4288</pre></td></tr>
4289
4290
4291<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher&lt;*&gt;</td></tr>
4292<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
4293provided matcher.
4294
4295Example matches X, A, A::X, B, B::C, B::C::X
4296  (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))
4297  class X {};
4298  class A { class X {}; };  Matches A, because A::X is a class of name
4299                            X inside A.
4300  class B { class C { class X {}; }; };
4301
4302DescendantT must be an AST base type.
4303
4304As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
4305each result that matches instead of only on the first one.
4306
4307Note: Recursively combined ForEachDescendant can cause many matches:
4308  cxxRecordDecl(forEachDescendant(cxxRecordDecl(
4309    forEachDescendant(cxxRecordDecl())
4310  )))
4311will match 10 times (plus injected class name matches) on:
4312  class A { class B { class C { class D { class E {}; }; }; }; };
4313
4314Usable as: Any Matcher
4315</pre></td></tr>
4316
4317
4318<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher&lt;*&gt;</td></tr>
4319<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the
4320provided matcher.
4321
4322Example matches X, Y, Y::X, Z::Y, Z::Y::X
4323  (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
4324  class X {};
4325  class Y { class X {}; };  Matches Y, because Y::X is a class of name X
4326                            inside Y.
4327  class Z { class Y { class X {}; }; };  Does not match Z.
4328
4329ChildT must be an AST base type.
4330
4331As opposed to 'has', 'forEach' will cause a match for each result that
4332matches instead of only on the first one.
4333
4334Usable as: Any Matcher
4335</pre></td></tr>
4336
4337
4338<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher&lt;*&gt;</td></tr>
4339<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided
4340matcher.
4341
4342Given
4343void f() { if (true) { int x = 42; } }
4344void g() { for (;;) { int x = 43; } }
4345expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.
4346
4347Usable as: Any Matcher
4348</pre></td></tr>
4349
4350
4351<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher&lt;*&gt;</td></tr>
4352<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
4353provided matcher.
4354
4355Example matches X, Y, Z
4356    (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X")))))
4357  class X {};  Matches X, because X::X is a class of name X inside X.
4358  class Y { class X {}; };
4359  class Z { class Y { class X {}; }; };
4360
4361DescendantT must be an AST base type.
4362
4363Usable as: Any Matcher
4364</pre></td></tr>
4365
4366
4367<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher&lt;*&gt;</td></tr>
4368<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the
4369provided matcher.
4370
4371Example matches X, Y
4372  (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X")))
4373  class X {};  Matches X, because X::X is a class of name X inside X.
4374  class Y { class X {}; };
4375  class Z { class Y { class X {}; }; };  Does not match Z.
4376
4377ChildT must be an AST base type.
4378
4379Usable as: Any Matcher
4380Note that has is direct matcher, so it also matches things like implicit
4381casts and paren casts. If you are matching with expr then you should
4382probably consider using ignoringParenImpCasts like:
4383has(ignoringParenImpCasts(expr())).
4384</pre></td></tr>
4385
4386
4387<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher&lt;*&gt;</td></tr>
4388<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided
4389matcher.
4390
4391Given
4392void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
4393compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".
4394
4395Usable as: Any Matcher
4396</pre></td></tr>
4397
4398
4399<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html">AbstractConditionalOperator</a>&gt;</td><td class="name" onclick="toggle('hasCondition5')"><a name="hasCondition5Anchor">hasCondition</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4400<tr><td colspan="4" class="doc" id="hasCondition5"><pre>Matches the condition expression of an if statement, for loop,
4401switch statement or conditional operator.
4402
4403Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
4404  if (true) {}
4405</pre></td></tr>
4406
4407
4408<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html">AbstractConditionalOperator</a>&gt;</td><td class="name" onclick="toggle('hasFalseExpression0')"><a name="hasFalseExpression0Anchor">hasFalseExpression</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4409<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator
4410(binary or ternary).
4411
4412Example matches b
4413  condition ? a : b
4414  condition ?: b
4415</pre></td></tr>
4416
4417
4418<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html">AbstractConditionalOperator</a>&gt;</td><td class="name" onclick="toggle('hasTrueExpression0')"><a name="hasTrueExpression0Anchor">hasTrueExpression</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4419<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator.
4420
4421Example 1 (conditional ternary operator): matches a
4422  condition ? a : b
4423
4424Example 2 (conditional binary operator): matches opaqueValueExpr(condition)
4425  condition ?: b
4426</pre></td></tr>
4427
4428
4429<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration15')"><a name="hasDeclaration15Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
4430<tr><td colspan="4" class="doc" id="hasDeclaration15"><pre>Matches a node if the declaration associated with that node
4431matches the given matcher.
4432
4433The associated declaration is:
4434- for type nodes, the declaration of the underlying type
4435- for CallExpr, the declaration of the callee
4436- for MemberExpr, the declaration of the referenced member
4437- for CXXConstructExpr, the declaration of the constructor
4438- for CXXNewExpr, the declaration of the operator new
4439- for ObjCIvarExpr, the declaration of the ivar
4440
4441For type nodes, hasDeclaration will generally match the declaration of the
4442sugared type. Given
4443  class X {};
4444  typedef X Y;
4445  Y y;
4446in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
4447typedefDecl. A common use case is to match the underlying, desugared type.
4448This can be achieved by using the hasUnqualifiedDesugaredType matcher:
4449  varDecl(hasType(hasUnqualifiedDesugaredType(
4450      recordType(hasDeclaration(decl())))))
4451In this matcher, the decl will match the CXXRecordDecl of class X.
4452
4453Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
4454  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
4455  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
4456  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
4457  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
4458  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
4459  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
4460</pre></td></tr>
4461
4462
4463<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4464<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression.
4465
4466Given
4467  int i[5];
4468  void f() { i[1] = 42; }
4469arraySubscriptExpression(hasBase(implicitCastExpr(
4470    hasSourceExpression(declRefExpr()))))
4471  matches i[1] with the declRefExpr() matching i
4472</pre></td></tr>
4473
4474
4475<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4476<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression.
4477
4478Given
4479  int i[5];
4480  void f() { i[1] = 42; }
4481arraySubscriptExpression(hasIndex(integerLiteral()))
4482  matches i[1] with the integerLiteral() matching 1
4483</pre></td></tr>
4484
4485
4486<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>&gt;</td><td class="name" onclick="toggle('hasLHS1')"><a name="hasLHS1Anchor">hasLHS</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4487<tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions.
4488
4489Example matches a (matcher = binaryOperator(hasLHS()))
4490  a || b
4491</pre></td></tr>
4492
4493
4494<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>&gt;</td><td class="name" onclick="toggle('hasRHS1')"><a name="hasRHS1Anchor">hasRHS</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4495<tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions.
4496
4497Example matches b (matcher = binaryOperator(hasRHS()))
4498  a || b
4499</pre></td></tr>
4500
4501
4502<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>&gt;</td><td class="name" onclick="toggle('hasElementType0')"><a name="hasElementType0Anchor">hasElementType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
4503<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element
4504type.
4505
4506Given
4507  struct A {};
4508  A a[7];
4509  int b[7];
4510arrayType(hasElementType(builtinType()))
4511  matches "int b[7]"
4512
4513Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>&gt;
4514</pre></td></tr>
4515
4516
4517<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
4518<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type.
4519
4520Given
4521  _Atomic(int) i;
4522  _Atomic(float) f;
4523atomicType(hasValueType(isInteger()))
4524 matches "_Atomic(int) i"
4525
4526Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
4527</pre></td></tr>
4528
4529
4530<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
4531<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type.
4532
4533Note: There is no TypeLoc for the deduced type and thus no
4534getDeducedLoc() matcher.
4535
4536Given
4537  auto a = 1;
4538  auto b = 2.0;
4539autoType(hasDeducedType(isInteger()))
4540  matches "auto a"
4541
4542Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>&gt;
4543</pre></td></tr>
4544
4545
4546<tr><td>Matcher&lt;<a href="https://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>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;  InnerMatcher</td></tr>
4547<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a
4548binary operator matches.
4549</pre></td></tr>
4550
4551
4552<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4553<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions.
4554
4555Example matches a (matcher = binaryOperator(hasLHS()))
4556  a || b
4557</pre></td></tr>
4558
4559
4560<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4561<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions.
4562
4563Example matches b (matcher = binaryOperator(hasRHS()))
4564  a || b
4565</pre></td></tr>
4566
4567
4568<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyParameter2')"><a name="hasAnyParameter2Anchor">hasAnyParameter</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt; InnerMatcher</td></tr>
4569<tr><td colspan="4" class="doc" id="hasAnyParameter2"><pre>Matches any parameter of a function or an ObjC method declaration or a
4570block.
4571
4572Does not match the 'this' parameter of a method.
4573
4574Given
4575  class X { void f(int x, int y, int z) {} };
4576cxxMethodDecl(hasAnyParameter(hasName("y")))
4577  matches f(int x, int y, int z) {}
4578with hasAnyParameter(...)
4579  matching int y
4580
4581For ObjectiveC, given
4582  @interface I - (void) f:(int) y; @end
4583
4584the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
4585matches the declaration of method f with hasParameter
4586matching y.
4587
4588For blocks, given
4589  b = ^(int y) { printf("%d", y) };
4590
4591the matcher blockDecl(hasAnyParameter(hasName("y")))
4592matches the declaration of the block b with hasParameter
4593matching y.
4594</pre></td></tr>
4595
4596
4597<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;</td><td class="name" onclick="toggle('hasParameter2')"><a name="hasParameter2Anchor">hasParameter</a></td><td>unsigned N, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt; InnerMatcher</td></tr>
4598<tr><td colspan="4" class="doc" id="hasParameter2"><pre>Matches the n'th parameter of a function or an ObjC method
4599declaration or a block.
4600
4601Given
4602  class X { void f(int x) {} };
4603cxxMethodDecl(hasParameter(0, hasType(varDecl())))
4604  matches f(int x) {}
4605with hasParameter(...)
4606  matching int x
4607
4608For ObjectiveC, given
4609  @interface I - (void) f:(int) y; @end
4610
4611the matcher objcMethodDecl(hasParameter(0, hasName("y")))
4612matches the declaration of method f with hasParameter
4613matching y.
4614</pre></td></tr>
4615
4616
4617<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;</td><td class="name" onclick="toggle('pointee0')"><a name="pointee0Anchor">pointee</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
4618<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the
4619pointee matches a given matcher.
4620
4621Given
4622  int *a;
4623  int const *b;
4624  float const *f;
4625pointerType(pointee(isConstQualified(), isInteger()))
4626  matches "int const *b"
4627
4628Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;,
4629  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;
4630</pre></td></tr>
4631
4632
4633<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('forEachArgumentWithParam1')"><a name="forEachArgumentWithParam1Anchor">forEachArgumentWithParam</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; ArgMatcher, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt; ParamMatcher</td></tr>
4634<tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl.
4635
4636Given
4637  void f(int i);
4638  int y;
4639  f(y);
4640callExpr(
4641  forEachArgumentWithParam(
4642    declRefExpr(to(varDecl(hasName("y")))),
4643    parmVarDecl(hasType(isInteger()))
4644))
4645  matches f(y);
4646with declRefExpr(...)
4647  matching int y
4648and parmVarDecl(...)
4649  matching int i
4650</pre></td></tr>
4651
4652
4653<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnyArgument1')"><a name="hasAnyArgument1Anchor">hasAnyArgument</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4654<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call
4655expression, or an ObjC-message-send expression.
4656
4657Given
4658  void x(int, int, int) { int y; x(1, y, 42); }
4659callExpr(hasAnyArgument(declRefExpr()))
4660  matches x(1, y, 42)
4661with hasAnyArgument(...)
4662  matching y
4663
4664For ObjectiveC, given
4665  @interface I - (void) f:(int) y; @end
4666  void foo(I *i) { [i f:12]; }
4667objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
4668  matches [i f:12]
4669</pre></td></tr>
4670
4671
4672<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('hasArgument1')"><a name="hasArgument1Anchor">hasArgument</a></td><td>unsigned N, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4673<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor
4674call expression.
4675
4676Example matches y in x(y)
4677    (matcher = callExpr(hasArgument(0, declRefExpr())))
4678  void x(int) { int y; x(y); }
4679</pre></td></tr>
4680
4681
4682<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration13')"><a name="hasDeclaration13Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
4683<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node
4684matches the given matcher.
4685
4686The associated declaration is:
4687- for type nodes, the declaration of the underlying type
4688- for CallExpr, the declaration of the callee
4689- for MemberExpr, the declaration of the referenced member
4690- for CXXConstructExpr, the declaration of the constructor
4691- for CXXNewExpr, the declaration of the operator new
4692- for ObjCIvarExpr, the declaration of the ivar
4693
4694For type nodes, hasDeclaration will generally match the declaration of the
4695sugared type. Given
4696  class X {};
4697  typedef X Y;
4698  Y y;
4699in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
4700typedefDecl. A common use case is to match the underlying, desugared type.
4701This can be achieved by using the hasUnqualifiedDesugaredType matcher:
4702  varDecl(hasType(hasUnqualifiedDesugaredType(
4703      recordType(hasDeclaration(decl())))))
4704In this matcher, the decl will match the CXXRecordDecl of class X.
4705
4706Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
4707  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
4708  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
4709  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
4710  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
4711  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
4712  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
4713</pre></td></tr>
4714
4715
4716<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('forEachConstructorInitializer0')"><a name="forEachConstructorInitializer0Anchor">forEachConstructorInitializer</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt; InnerMatcher</td></tr>
4717<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition.
4718
4719Given
4720  class A { A() : i(42), j(42) {} int i; int j; };
4721cxxConstructorDecl(forEachConstructorInitializer(
4722  forField(decl().bind("x"))
4723))
4724  will trigger two matches, binding for 'i' and 'j' respectively.
4725</pre></td></tr>
4726
4727
4728<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt; InnerMatcher</td></tr>
4729<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer.
4730
4731Given
4732  struct Foo {
4733    Foo() : foo_(1) { }
4734    int foo_;
4735  };
4736cxxRecordDecl(has(cxxConstructorDecl(
4737  hasAnyConstructorInitializer(anything())
4738)))
4739  record matches Foo, hasAnyConstructorInitializer matches foo_(1)
4740</pre></td></tr>
4741
4742
4743<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>&gt; InnerMatcher</td></tr>
4744<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer.
4745
4746Given
4747  struct Foo {
4748    Foo() : foo_(1) { }
4749    int foo_;
4750  };
4751cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
4752    forField(hasName("foo_"))))))
4753  matches Foo
4754with forField matching foo_
4755</pre></td></tr>
4756
4757
4758<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4759<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer.
4760
4761Given
4762  struct Foo {
4763    Foo() : foo_(1) { }
4764    int foo_;
4765  };
4766cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
4767    withInitializer(integerLiteral(equals(1)))))))
4768  matches Foo
4769with withInitializer matching (1)
4770</pre></td></tr>
4771
4772
4773<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>&gt;</td><td class="name" onclick="toggle('hasObjectExpression2')"><a name="hasObjectExpression2Anchor">hasObjectExpression</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4774<tr><td colspan="4" class="doc" id="hasObjectExpression2"><pre>Matches a member expression where the object expression is
4775matched by a given matcher.
4776
4777Given
4778  struct X { int m; };
4779  void f(X x) { x.m; m; }
4780memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))))
4781  matches "x.m" and "m"
4782with hasObjectExpression(...)
4783  matching "x" and the implicit object expression of "m" which has type X*.
4784</pre></td></tr>
4785
4786
4787<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>&gt;</td><td class="name" onclick="toggle('hasBody3')"><a name="hasBody3Anchor">hasBody</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
4788<tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', 'do while' statement or a function
4789definition that has a given body.
4790
4791Given
4792  for (;;) {}
4793hasBody(compoundStmt())
4794  matches 'for (;;) {}'
4795with compoundStmt()
4796  matching '{}'
4797</pre></td></tr>
4798
4799
4800<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>&gt;</td><td class="name" onclick="toggle('hasLoopVariable0')"><a name="hasLoopVariable0Anchor">hasLoopVariable</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt; InnerMatcher</td></tr>
4801<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop.
4802
4803Example:
4804    forStmt(hasLoopVariable(anything()))
4805matches 'int x' in
4806    for (int x : a) { }
4807</pre></td></tr>
4808
4809
4810<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>&gt;</td><td class="name" onclick="toggle('hasRangeInit0')"><a name="hasRangeInit0Anchor">hasRangeInit</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4811<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop.
4812
4813Example:
4814    forStmt(hasRangeInit(anything()))
4815matches 'a' in
4816    for (int x : a) { }
4817</pre></td></tr>
4818
4819
4820<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4821<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr>
4822
4823
4824<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4825<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression.
4826
4827Example matches y.x()
4828  (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))))))
4829  class Y { public: void x(); };
4830  void z() { Y y; y.x(); }
4831
4832FIXME: Overload to allow directly matching types?
4833</pre></td></tr>
4834
4835
4836<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
4837<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration.
4838</pre></td></tr>
4839
4840
4841<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>&gt;</td><td class="name" onclick="toggle('thisPointerType0')"><a name="thisPointerType0Anchor">thisPointerType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
4842<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified
4843matcher, or is a pointer to a type that matches the InnerMatcher.
4844</pre></td></tr>
4845
4846
4847<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('forEachOverridden0')"><a name="forEachOverridden0Anchor">forEachOverridden</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt; InnerMatcher</td></tr>
4848<tr><td colspan="4" class="doc" id="forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may
4849produce multiple matches.
4850
4851Given
4852  class A { virtual void f(); };
4853  class B : public A { void f(); };
4854  class C : public B { void f(); };
4855cxxMethodDecl(ofClass(hasName("C")),
4856              forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
4857  matches once, with "b" binding "A::f" and "d" binding "C::f" (Note
4858  that B::f is not overridden by C::f).
4859
4860The check can produce multiple matches in case of multiple inheritance, e.g.
4861  class A1 { virtual void f(); };
4862  class A2 { virtual void f(); };
4863  class C : public A1, public A2 { void f(); };
4864cxxMethodDecl(ofClass(hasName("C")),
4865              forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
4866  matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and
4867  once with "b" binding "A2::f" and "d" binding "C::f".
4868</pre></td></tr>
4869
4870
4871<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt; InnerMatcher</td></tr>
4872<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration
4873belongs to.
4874
4875FIXME: Generalize this for other kinds of declarations.
4876FIXME: What other kind of declarations would we need to generalize
4877this to?
4878
4879Example matches A() in the last line
4880    (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl(
4881        ofClass(hasName("A"))))))
4882  class A {
4883   public:
4884    A();
4885  };
4886  A a = A();
4887</pre></td></tr>
4888
4889
4890<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;</td><td class="name" onclick="toggle('hasArraySize0')"><a name="hasArraySize0Anchor">hasArraySize</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4891<tr><td colspan="4" class="doc" id="hasArraySize0"><pre>Matches array new expressions with a given array size.
4892
4893Given:
4894  MyClass *p1 = new MyClass[10];
4895cxxNewExpr(hasArraySize(intgerLiteral(equals(10))))
4896  matches the expression 'new MyClass[10]'.
4897</pre></td></tr>
4898
4899
4900<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration12')"><a name="hasDeclaration12Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
4901<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node
4902matches the given matcher.
4903
4904The associated declaration is:
4905- for type nodes, the declaration of the underlying type
4906- for CallExpr, the declaration of the callee
4907- for MemberExpr, the declaration of the referenced member
4908- for CXXConstructExpr, the declaration of the constructor
4909- for CXXNewExpr, the declaration of the operator new
4910- for ObjCIvarExpr, the declaration of the ivar
4911
4912For type nodes, hasDeclaration will generally match the declaration of the
4913sugared type. Given
4914  class X {};
4915  typedef X Y;
4916  Y y;
4917in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
4918typedefDecl. A common use case is to match the underlying, desugared type.
4919This can be achieved by using the hasUnqualifiedDesugaredType matcher:
4920  varDecl(hasType(hasUnqualifiedDesugaredType(
4921      recordType(hasDeclaration(decl())))))
4922In this matcher, the decl will match the CXXRecordDecl of class X.
4923
4924Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
4925  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
4926  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
4927  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
4928  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
4929  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
4930  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
4931</pre></td></tr>
4932
4933
4934<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('hasMethod0')"><a name="hasMethod0Anchor">hasMethod</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt; InnerMatcher</td></tr>
4935<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher.
4936
4937Given:
4938  class A { void func(); };
4939  class B { void member(); };
4940
4941cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of
4942A but not B.
4943</pre></td></tr>
4944
4945
4946<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt; Base</td></tr>
4947<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from
4948a class matching Base.
4949
4950Note that a class is not considered to be derived from itself.
4951
4952Example matches Y, Z, C (Base == hasName("X"))
4953  class X;
4954  class Y : public X {};  directly derived
4955  class Z : public Y {};  indirectly derived
4956  typedef X A;
4957  typedef A B;
4958  class C : public B {};  derived from a typedef of X
4959
4960In the following example, Bar matches isDerivedFrom(hasName("X")):
4961  class Foo;
4962  typedef Foo X;
4963  class Bar : public Foo {};  derived from a type that X is a typedef of
4964</pre></td></tr>
4965
4966
4967<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt; Base</td></tr>
4968<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly
4969match Base.
4970</pre></td></tr>
4971
4972
4973<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnyArgument2')"><a name="hasAnyArgument2Anchor">hasAnyArgument</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
4974<tr><td colspan="4" class="doc" id="hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call
4975expression, or an ObjC-message-send expression.
4976
4977Given
4978  void x(int, int, int) { int y; x(1, y, 42); }
4979callExpr(hasAnyArgument(declRefExpr()))
4980  matches x(1, y, 42)
4981with hasAnyArgument(...)
4982  matching y
4983
4984For ObjectiveC, given
4985  @interface I - (void) f:(int) y; @end
4986  void foo(I *i) { [i f:12]; }
4987objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
4988  matches [i f:12]
4989</pre></td></tr>
4990
4991
4992<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
4993<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the
4994given matcher.
4995
4996Example matches y.x() (matcher = callExpr(callee(
4997                                   cxxMethodDecl(hasName("x")))))
4998  class Y { public: void x(); };
4999  void z() { Y y; y.x(); }
5000</pre></td></tr>
5001
5002
5003<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('callee0')"><a name="callee0Anchor">callee</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
5004<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches.
5005
5006Given
5007  class Y { void x() { this-&gt;x(); x(); Y y; y.x(); } };
5008  void f() { f(); }
5009callExpr(callee(expr()))
5010  matches this-&gt;x(), x(), y.x(), f()
5011with callee(...)
5012  matching this-&gt;x, x, y.x, f respectively
5013
5014Note: Callee cannot take the more general internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;
5015because this introduces ambiguous overloads with calls to Callee taking a
5016internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, as the matcher hierarchy is purely
5017implemented in terms of implicit casts.
5018</pre></td></tr>
5019
5020
5021<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('forEachArgumentWithParam0')"><a name="forEachArgumentWithParam0Anchor">forEachArgumentWithParam</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; ArgMatcher, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt; ParamMatcher</td></tr>
5022<tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl.
5023
5024Given
5025  void f(int i);
5026  int y;
5027  f(y);
5028callExpr(
5029  forEachArgumentWithParam(
5030    declRefExpr(to(varDecl(hasName("y")))),
5031    parmVarDecl(hasType(isInteger()))
5032))
5033  matches f(y);
5034with declRefExpr(...)
5035  matching int y
5036and parmVarDecl(...)
5037  matching int i
5038</pre></td></tr>
5039
5040
5041<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5042<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call
5043expression, or an ObjC-message-send expression.
5044
5045Given
5046  void x(int, int, int) { int y; x(1, y, 42); }
5047callExpr(hasAnyArgument(declRefExpr()))
5048  matches x(1, y, 42)
5049with hasAnyArgument(...)
5050  matching y
5051
5052For ObjectiveC, given
5053  @interface I - (void) f:(int) y; @end
5054  void foo(I *i) { [i f:12]; }
5055objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
5056  matches [i f:12]
5057</pre></td></tr>
5058
5059
5060<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5061<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor
5062call expression.
5063
5064Example matches y in x(y)
5065    (matcher = callExpr(hasArgument(0, declRefExpr())))
5066  void x(int) { int y; x(y); }
5067</pre></td></tr>
5068
5069
5070<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration14')"><a name="hasDeclaration14Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
5071<tr><td colspan="4" class="doc" id="hasDeclaration14"><pre>Matches a node if the declaration associated with that node
5072matches the given matcher.
5073
5074The associated declaration is:
5075- for type nodes, the declaration of the underlying type
5076- for CallExpr, the declaration of the callee
5077- for MemberExpr, the declaration of the referenced member
5078- for CXXConstructExpr, the declaration of the constructor
5079- for CXXNewExpr, the declaration of the operator new
5080- for ObjCIvarExpr, the declaration of the ivar
5081
5082For type nodes, hasDeclaration will generally match the declaration of the
5083sugared type. Given
5084  class X {};
5085  typedef X Y;
5086  Y y;
5087in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
5088typedefDecl. A common use case is to match the underlying, desugared type.
5089This can be achieved by using the hasUnqualifiedDesugaredType matcher:
5090  varDecl(hasType(hasUnqualifiedDesugaredType(
5091      recordType(hasDeclaration(decl())))))
5092In this matcher, the decl will match the CXXRecordDecl of class X.
5093
5094Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
5095  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
5096  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
5097  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
5098  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
5099  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
5100  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
5101</pre></td></tr>
5102
5103
5104<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt</a>&gt;</td><td class="name" onclick="toggle('hasCaseConstant0')"><a name="hasCaseConstant0Anchor">hasCaseConstant</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5105<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range
5106extension, matches the constant given in the statement.
5107
5108Given
5109  switch (1) { case 1: case 1+1: case 3 ... 4: ; }
5110caseStmt(hasCaseConstant(integerLiteral()))
5111  matches "case 1:"
5112</pre></td></tr>
5113
5114
5115<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5116<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression
5117or opaque value's source expression matches the given matcher.
5118
5119Example 1: matches "a string"
5120(matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
5121class URL { URL(string); };
5122URL url = "a string";
5123
5124Example 2: matches 'b' (matcher =
5125opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
5126int a = b ?: 1;
5127</pre></td></tr>
5128
5129
5130<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
5131<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and
5132functionDecl that have at least one TemplateArgument matching the given
5133InnerMatcher.
5134
5135Given
5136  template&lt;typename T&gt; class A {};
5137  template&lt;&gt; class A&lt;double&gt; {};
5138  A&lt;int&gt; a;
5139
5140  template&lt;typename T&gt; f() {};
5141  void func() { f&lt;int&gt;(); };
5142
5143classTemplateSpecializationDecl(hasAnyTemplateArgument(
5144    refersToType(asString("int"))))
5145  matches the specialization A&lt;int&gt;
5146
5147functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
5148  matches the specialization f&lt;int&gt;
5149</pre></td></tr>
5150
5151
5152<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;</td><td class="name" onclick="toggle('hasSpecializedTemplate0')"><a name="hasSpecializedTemplate0Anchor">hasSpecializedTemplate</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html">ClassTemplateDecl</a>&gt; InnerMatcher</td></tr>
5153<tr><td colspan="4" class="doc" id="hasSpecializedTemplate0"><pre>Matches the specialized template of a specialization declaration.
5154
5155Given
5156  template&lt;typename T&gt; class A {}; #1
5157  template&lt;&gt; class A&lt;int&gt; {}; #2
5158classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl()))
5159  matches '#2' with classTemplateDecl() matching the class template
5160  declaration of 'A' at #1.
5161</pre></td></tr>
5162
5163
5164<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
5165<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and
5166functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
5167
5168Given
5169  template&lt;typename T, typename U&gt; class A {};
5170  A&lt;bool, int&gt; b;
5171  A&lt;int, bool&gt; c;
5172
5173  template&lt;typename T&gt; void f() {}
5174  void func() { f&lt;int&gt;(); };
5175classTemplateSpecializationDecl(hasTemplateArgument(
5176    1, refersToType(asString("int"))))
5177  matches the specialization A&lt;bool, int&gt;
5178
5179functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
5180  matches the specialization f&lt;int&gt;
5181</pre></td></tr>
5182
5183
5184<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>&gt;</td><td class="name" onclick="toggle('hasElementType1')"><a name="hasElementType1Anchor">hasElementType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
5185<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element
5186type.
5187
5188Given
5189  struct A {};
5190  A a[7];
5191  int b[7];
5192arrayType(hasElementType(builtinType()))
5193  matches "int b[7]"
5194
5195Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>&gt;
5196</pre></td></tr>
5197
5198
5199<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
5200<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches
5201a given matcher. Also matches StmtExprs that have CompoundStmt as children.
5202
5203Given
5204  { {}; 1+2; }
5205hasAnySubstatement(compoundStmt())
5206  matches '{ {}; 1+2; }'
5207with compoundStmt()
5208  matching '{}'
5209</pre></td></tr>
5210
5211
5212<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DecayedType.html">DecayedType</a>&gt;</td><td class="name" onclick="toggle('hasDecayedType0')"><a name="hasDecayedType0Anchor">hasDecayedType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerType</td></tr>
5213<tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whos decayed type matches InnerMatcher
5214</pre></td></tr>
5215
5216
5217<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration11')"><a name="hasDeclaration11Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
5218<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node
5219matches the given matcher.
5220
5221The associated declaration is:
5222- for type nodes, the declaration of the underlying type
5223- for CallExpr, the declaration of the callee
5224- for MemberExpr, the declaration of the referenced member
5225- for CXXConstructExpr, the declaration of the constructor
5226- for CXXNewExpr, the declaration of the operator new
5227- for ObjCIvarExpr, the declaration of the ivar
5228
5229For type nodes, hasDeclaration will generally match the declaration of the
5230sugared type. Given
5231  class X {};
5232  typedef X Y;
5233  Y y;
5234in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
5235typedefDecl. A common use case is to match the underlying, desugared type.
5236This can be achieved by using the hasUnqualifiedDesugaredType matcher:
5237  varDecl(hasType(hasUnqualifiedDesugaredType(
5238      recordType(hasDeclaration(decl())))))
5239In this matcher, the decl will match the CXXRecordDecl of class X.
5240
5241Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
5242  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
5243  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
5244  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
5245  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
5246  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
5247  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
5248</pre></td></tr>
5249
5250
5251<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>&gt; InnerMatcher</td></tr>
5252<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a
5253specific using shadow declaration.
5254
5255Given
5256  namespace a { void f() {} }
5257  using a::f;
5258  void g() {
5259    f();     Matches this ..
5260    a::f();  .. but not this.
5261  }
5262declRefExpr(throughUsingDecl(anything()))
5263  matches f()
5264</pre></td></tr>
5265
5266
5267<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
5268<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the
5269specified matcher.
5270
5271Example matches x in if(x)
5272    (matcher = declRefExpr(to(varDecl(hasName("x")))))
5273  bool x;
5274  if (x) {}
5275</pre></td></tr>
5276
5277
5278<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
5279<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement.
5280
5281Note that this does not work for global declarations because the AST
5282breaks up multiple-declaration DeclStmt's into multiple single-declaration
5283DeclStmt's.
5284Example: Given non-global declarations
5285  int a, b = 0;
5286  int c;
5287  int d = 2, e;
5288declStmt(containsDeclaration(
5289      0, varDecl(hasInitializer(anything()))))
5290  matches only 'int d = 2, e;', and
5291declStmt(containsDeclaration(1, varDecl()))
5292  matches 'int a, b = 0' as well as 'int d = 2, e;'
5293  but 'int c;' is not matched.
5294</pre></td></tr>
5295
5296
5297<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
5298<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration.
5299
5300Given
5301  int a, b;
5302  int c;
5303declStmt(hasSingleDecl(anything()))
5304  matches 'int c;' but not 'int a, b;'.
5305</pre></td></tr>
5306
5307
5308<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc0')"><a name="hasTypeLoc0Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
5309<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches
5310the inner matcher.
5311
5312Given
5313  int x;
5314declaratorDecl(hasTypeLoc(loc(asString("int"))))
5315  matches int x
5316</pre></td></tr>
5317
5318
5319<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
5320<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a
5321Decl, matches InnerMatcher.
5322
5323Given
5324  namespace N {
5325    namespace M {
5326      class D {};
5327    }
5328  }
5329
5330cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
5331declaration of class D.
5332</pre></td></tr>
5333
5334
5335<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>&gt;</td><td class="name" onclick="toggle('hasUnderlyingType0')"><a name="hasUnderlyingType0Anchor">hasUnderlyingType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
5336<tr><td colspan="4" class="doc" id="hasUnderlyingType0"><pre>Matches DecltypeType nodes to find out the underlying type.
5337
5338Given
5339  decltype(1) a = 1;
5340  decltype(2.0) b = 2.0;
5341decltypeType(hasUnderlyingType(isInteger()))
5342  matches the type of "a"
5343
5344Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>&gt;
5345</pre></td></tr>
5346
5347
5348<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
5349<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', 'do while' statement or a function
5350definition that has a given body.
5351
5352Given
5353  for (;;) {}
5354hasBody(compoundStmt())
5355  matches 'for (;;) {}'
5356with compoundStmt()
5357  matching '{}'
5358</pre></td></tr>
5359
5360
5361<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5362<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop,
5363switch statement or conditional operator.
5364
5365Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
5366  if (true) {}
5367</pre></td></tr>
5368
5369
5370<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt; InnerMatcher</td></tr>
5371<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
5372matches InnerMatcher if the qualifier exists.
5373
5374Given
5375  namespace N {
5376    namespace M {
5377      class D {};
5378    }
5379  }
5380  N::M::D d;
5381
5382elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N"))))
5383matches the type of the variable declaration of d.
5384</pre></td></tr>
5385
5386
5387<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
5388<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher.
5389
5390Given
5391  namespace N {
5392    namespace M {
5393      class D {};
5394    }
5395  }
5396  N::M::D d;
5397
5398elaboratedType(namesType(recordType(
5399hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable
5400declaration of d.
5401</pre></td></tr>
5402
5403
5404<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration10')"><a name="hasDeclaration10Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
5405<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node
5406matches the given matcher.
5407
5408The associated declaration is:
5409- for type nodes, the declaration of the underlying type
5410- for CallExpr, the declaration of the callee
5411- for MemberExpr, the declaration of the referenced member
5412- for CXXConstructExpr, the declaration of the constructor
5413- for CXXNewExpr, the declaration of the operator new
5414- for ObjCIvarExpr, the declaration of the ivar
5415
5416For type nodes, hasDeclaration will generally match the declaration of the
5417sugared type. Given
5418  class X {};
5419  typedef X Y;
5420  Y y;
5421in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
5422typedefDecl. A common use case is to match the underlying, desugared type.
5423This can be achieved by using the hasUnqualifiedDesugaredType matcher:
5424  varDecl(hasType(hasUnqualifiedDesugaredType(
5425      recordType(hasDeclaration(decl())))))
5426In this matcher, the decl will match the CXXRecordDecl of class X.
5427
5428Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
5429  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
5430  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
5431  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
5432  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
5433  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
5434  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
5435</pre></td></tr>
5436
5437
5438<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
5439<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher.
5440
5441(Note: Clang's AST refers to other conversions as "casts" too, and calls
5442actual casts "explicit" casts.)
5443</pre></td></tr>
5444
5445
5446<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('hasType4')"><a name="hasType4Anchor">hasType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
5447<tr><td colspan="4" class="doc" id="hasType4"><pre>Overloaded to match the declaration of the expression's or value
5448declaration's type.
5449
5450In case of a value declaration (for example a variable declaration),
5451this resolves one layer of indirection. For example, in the value
5452declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
5453X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
5454declaration of x.
5455
5456Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
5457            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
5458            and friend class X (matcher = friendDecl(hasType("X"))
5459 class X {};
5460 void y(X &amp;x) { x; X z; }
5461 class Y { friend class X; };
5462
5463Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;
5464</pre></td></tr>
5465
5466
5467<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('hasType0')"><a name="hasType0Anchor">hasType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
5468<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type
5469matcher.
5470
5471Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
5472            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
5473            and U (matcher = typedefDecl(hasType(asString("int")))
5474            and friend class X (matcher = friendDecl(hasType("X"))
5475 class X {};
5476 void y(X &amp;x) { x; X z; }
5477 typedef int U;
5478 class Y { friend class X; };
5479</pre></td></tr>
5480
5481
5482<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5483<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts
5484are stripped off.
5485
5486Parentheses and explicit casts are not discarded.
5487Given
5488  int arr[5];
5489  int a = 0;
5490  char b = 0;
5491  const int c = a;
5492  int *d = arr;
5493  long e = (long) 0l;
5494The matchers
5495   varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
5496   varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
5497would match the declarations for a, b, c, and d, but not e.
5498While
5499   varDecl(hasInitializer(integerLiteral()))
5500   varDecl(hasInitializer(declRefExpr()))
5501only match the declarations for b, c, and d.
5502</pre></td></tr>
5503
5504
5505<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('ignoringImplicit0')"><a name="ignoringImplicit0Anchor">ignoringImplicit</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5506<tr><td colspan="4" class="doc" id="ignoringImplicit0"><pre>Matches expressions that match InnerMatcher after any implicit AST
5507nodes are stripped off.
5508
5509Parentheses and explicit casts are not discarded.
5510Given
5511  class C {};
5512  C a = C();
5513  C b;
5514  C c = b;
5515The matchers
5516   varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr())))
5517would match the declarations for a, b, and c.
5518While
5519   varDecl(hasInitializer(cxxConstructExpr()))
5520only match the declarations for b and c.
5521</pre></td></tr>
5522
5523
5524<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5525<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and
5526casts are stripped off.
5527
5528Implicit and non-C Style casts are also discarded.
5529Given
5530  int a = 0;
5531  char b = (0);
5532  void* c = reinterpret_cast&lt;char*&gt;(0);
5533  char d = char(0);
5534The matcher
5535   varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
5536would match the declarations for a, b, c, and d.
5537while
5538   varDecl(hasInitializer(integerLiteral()))
5539only match the declaration for a.
5540</pre></td></tr>
5541
5542
5543<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5544<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and
5545parentheses are stripped off.
5546
5547Explicit casts are not discarded.
5548Given
5549  int arr[5];
5550  int a = 0;
5551  char b = (0);
5552  const int c = a;
5553  int *d = (arr);
5554  long e = ((long) 0l);
5555The matchers
5556   varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
5557   varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
5558would match the declarations for a, b, c, and d, but not e.
5559while
5560   varDecl(hasInitializer(integerLiteral()))
5561   varDecl(hasInitializer(declRefExpr()))
5562would only match the declaration for a.
5563</pre></td></tr>
5564
5565
5566<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('ignoringParens1')"><a name="ignoringParens1Anchor">ignoringParens</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5567<tr><td colspan="4" class="doc" id="ignoringParens1"><pre>Overload ignoringParens for Expr.
5568
5569Given
5570  const char* str = ("my-string");
5571The matcher
5572  implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral())))
5573would match the implicit cast resulting from the assignment.
5574</pre></td></tr>
5575
5576
5577<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>&gt;</td><td class="name" onclick="toggle('hasInClassInitializer0')"><a name="hasInClassInitializer0Anchor">hasInClassInitializer</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5578<tr><td colspan="4" class="doc" id="hasInClassInitializer0"><pre>Matches non-static data members that have an in-class initializer.
5579
5580Given
5581  class C {
5582    int a = 2;
5583    int b = 3;
5584    int c;
5585  };
5586fieldDecl(hasInClassInitializer(integerLiteral(equals(2))))
5587  matches 'int a;' but not 'int b;'.
5588fieldDecl(hasInClassInitializer(anything()))
5589  matches 'int a;' and 'int b;' but not 'int c;'.
5590</pre></td></tr>
5591
5592
5593<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
5594<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', 'do while' statement or a function
5595definition that has a given body.
5596
5597Given
5598  for (;;) {}
5599hasBody(compoundStmt())
5600  matches 'for (;;) {}'
5601with compoundStmt()
5602  matching '{}'
5603</pre></td></tr>
5604
5605
5606<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5607<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop,
5608switch statement or conditional operator.
5609
5610Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
5611  if (true) {}
5612</pre></td></tr>
5613
5614
5615<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
5616<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop.
5617
5618Example:
5619    forStmt(hasIncrement(unaryOperator(hasOperatorName("++"))))
5620matches '++x' in
5621    for (x; x &lt; N; ++x) { }
5622</pre></td></tr>
5623
5624
5625<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
5626<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop.
5627
5628Example:
5629    forStmt(hasLoopInit(declStmt()))
5630matches 'int x = 0' in
5631    for (int x = 0; x &lt; N; ++x) { }
5632</pre></td></tr>
5633
5634
5635<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>&gt;</td><td class="name" onclick="toggle('hasType5')"><a name="hasType5Anchor">hasType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
5636<tr><td colspan="4" class="doc" id="hasType5"><pre>Overloaded to match the declaration of the expression's or value
5637declaration's type.
5638
5639In case of a value declaration (for example a variable declaration),
5640this resolves one layer of indirection. For example, in the value
5641declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
5642X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
5643declaration of x.
5644
5645Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
5646            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
5647            and friend class X (matcher = friendDecl(hasType("X"))
5648 class X {};
5649 void y(X &amp;x) { x; X z; }
5650 class Y { friend class X; };
5651
5652Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;
5653</pre></td></tr>
5654
5655
5656<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>&gt;</td><td class="name" onclick="toggle('hasType1')"><a name="hasType1Anchor">hasType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
5657<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type
5658matcher.
5659
5660Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
5661            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
5662            and U (matcher = typedefDecl(hasType(asString("int")))
5663            and friend class X (matcher = friendDecl(hasType("X"))
5664 class X {};
5665 void y(X &amp;x) { x; X z; }
5666 typedef int U;
5667 class Y { friend class X; };
5668</pre></td></tr>
5669
5670
5671<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt; InnerMatcher</td></tr>
5672<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function or an ObjC method declaration or a
5673block.
5674
5675Does not match the 'this' parameter of a method.
5676
5677Given
5678  class X { void f(int x, int y, int z) {} };
5679cxxMethodDecl(hasAnyParameter(hasName("y")))
5680  matches f(int x, int y, int z) {}
5681with hasAnyParameter(...)
5682  matching int y
5683
5684For ObjectiveC, given
5685  @interface I - (void) f:(int) y; @end
5686
5687the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
5688matches the declaration of method f with hasParameter
5689matching y.
5690
5691For blocks, given
5692  b = ^(int y) { printf("%d", y) };
5693
5694the matcher blockDecl(hasAnyParameter(hasName("y")))
5695matches the declaration of the block b with hasParameter
5696matching y.
5697</pre></td></tr>
5698
5699
5700<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyTemplateArgument2')"><a name="hasAnyTemplateArgument2Anchor">hasAnyTemplateArgument</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
5701<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and
5702functionDecl that have at least one TemplateArgument matching the given
5703InnerMatcher.
5704
5705Given
5706  template&lt;typename T&gt; class A {};
5707  template&lt;&gt; class A&lt;double&gt; {};
5708  A&lt;int&gt; a;
5709
5710  template&lt;typename T&gt; f() {};
5711  void func() { f&lt;int&gt;(); };
5712
5713classTemplateSpecializationDecl(hasAnyTemplateArgument(
5714    refersToType(asString("int"))))
5715  matches the specialization A&lt;int&gt;
5716
5717functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
5718  matches the specialization f&lt;int&gt;
5719</pre></td></tr>
5720
5721
5722<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasBody4')"><a name="hasBody4Anchor">hasBody</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
5723<tr><td colspan="4" class="doc" id="hasBody4"><pre>Matches a 'for', 'while', 'do while' statement or a function
5724definition that has a given body.
5725
5726Given
5727  for (;;) {}
5728hasBody(compoundStmt())
5729  matches 'for (;;) {}'
5730with compoundStmt()
5731  matching '{}'
5732</pre></td></tr>
5733
5734
5735<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt; InnerMatcher</td></tr>
5736<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function or an ObjC method
5737declaration or a block.
5738
5739Given
5740  class X { void f(int x) {} };
5741cxxMethodDecl(hasParameter(0, hasType(varDecl())))
5742  matches f(int x) {}
5743with hasParameter(...)
5744  matching int x
5745
5746For ObjectiveC, given
5747  @interface I - (void) f:(int) y; @end
5748
5749the matcher objcMethodDecl(hasParameter(0, hasName("y")))
5750matches the declaration of method f with hasParameter
5751matching y.
5752</pre></td></tr>
5753
5754
5755<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasTemplateArgument2')"><a name="hasTemplateArgument2Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
5756<tr><td colspan="4" class="doc" id="hasTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and
5757functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
5758
5759Given
5760  template&lt;typename T, typename U&gt; class A {};
5761  A&lt;bool, int&gt; b;
5762  A&lt;int, bool&gt; c;
5763
5764  template&lt;typename T&gt; void f() {}
5765  void func() { f&lt;int&gt;(); };
5766classTemplateSpecializationDecl(hasTemplateArgument(
5767    1, refersToType(asString("int"))))
5768  matches the specialization A&lt;bool, int&gt;
5769
5770functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
5771  matches the specialization f&lt;int&gt;
5772</pre></td></tr>
5773
5774
5775<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
5776<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration.
5777
5778Given:
5779  class X { int f() { return 1; } };
5780cxxMethodDecl(returns(asString("int")))
5781  matches int f() { return 1; }
5782</pre></td></tr>
5783
5784
5785<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5786<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop,
5787switch statement or conditional operator.
5788
5789Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
5790  if (true) {}
5791</pre></td></tr>
5792
5793
5794<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>&gt; InnerMatcher</td></tr>
5795<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement.
5796
5797Given
5798  if (A* a = GetAPointer()) {}
5799hasConditionVariableStatement(...)
5800  matches 'A* a = GetAPointer()'.
5801</pre></td></tr>
5802
5803
5804<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>&gt;</td><td class="name" onclick="toggle('hasElse0')"><a name="hasElse0Anchor">hasElse</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
5805<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement.
5806
5807Examples matches the if statement
5808  (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true)))))
5809  if (false) false; else true;
5810</pre></td></tr>
5811
5812
5813<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>&gt;</td><td class="name" onclick="toggle('hasThen0')"><a name="hasThen0Anchor">hasThen</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
5814<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement.
5815
5816Examples matches the if statement
5817  (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true)))))
5818  if (false) true; else false;
5819</pre></td></tr>
5820
5821
5822<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
5823<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given
5824matcher.
5825
5826FIXME: Unit test this matcher
5827</pre></td></tr>
5828
5829
5830<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>&gt;</td><td class="name" onclick="toggle('hasSyntacticForm0')"><a name="hasSyntacticForm0Anchor">hasSyntacticForm</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5831<tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions
5832(if expression have it).
5833</pre></td></tr>
5834
5835
5836<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration9')"><a name="hasDeclaration9Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
5837<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node
5838matches the given matcher.
5839
5840The associated declaration is:
5841- for type nodes, the declaration of the underlying type
5842- for CallExpr, the declaration of the callee
5843- for MemberExpr, the declaration of the referenced member
5844- for CXXConstructExpr, the declaration of the constructor
5845- for CXXNewExpr, the declaration of the operator new
5846- for ObjCIvarExpr, the declaration of the ivar
5847
5848For type nodes, hasDeclaration will generally match the declaration of the
5849sugared type. Given
5850  class X {};
5851  typedef X Y;
5852  Y y;
5853in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
5854typedefDecl. A common use case is to match the underlying, desugared type.
5855This can be achieved by using the hasUnqualifiedDesugaredType matcher:
5856  varDecl(hasType(hasUnqualifiedDesugaredType(
5857      recordType(hasDeclaration(decl())))))
5858In this matcher, the decl will match the CXXRecordDecl of class X.
5859
5860Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
5861  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
5862  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
5863  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
5864  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
5865  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
5866  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
5867</pre></td></tr>
5868
5869
5870<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration8')"><a name="hasDeclaration8Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
5871<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node
5872matches the given matcher.
5873
5874The associated declaration is:
5875- for type nodes, the declaration of the underlying type
5876- for CallExpr, the declaration of the callee
5877- for MemberExpr, the declaration of the referenced member
5878- for CXXConstructExpr, the declaration of the constructor
5879- for CXXNewExpr, the declaration of the operator new
5880- for ObjCIvarExpr, the declaration of the ivar
5881
5882For type nodes, hasDeclaration will generally match the declaration of the
5883sugared type. Given
5884  class X {};
5885  typedef X Y;
5886  Y y;
5887in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
5888typedefDecl. A common use case is to match the underlying, desugared type.
5889This can be achieved by using the hasUnqualifiedDesugaredType matcher:
5890  varDecl(hasType(hasUnqualifiedDesugaredType(
5891      recordType(hasDeclaration(decl())))))
5892In this matcher, the decl will match the CXXRecordDecl of class X.
5893
5894Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
5895  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
5896  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
5897  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
5898  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
5899  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
5900  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
5901</pre></td></tr>
5902
5903
5904<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration7')"><a name="hasDeclaration7Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
5905<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node
5906matches the given matcher.
5907
5908The associated declaration is:
5909- for type nodes, the declaration of the underlying type
5910- for CallExpr, the declaration of the callee
5911- for MemberExpr, the declaration of the referenced member
5912- for CXXConstructExpr, the declaration of the constructor
5913- for CXXNewExpr, the declaration of the operator new
5914- for ObjCIvarExpr, the declaration of the ivar
5915
5916For type nodes, hasDeclaration will generally match the declaration of the
5917sugared type. Given
5918  class X {};
5919  typedef X Y;
5920  Y y;
5921in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
5922typedefDecl. A common use case is to match the underlying, desugared type.
5923This can be achieved by using the hasUnqualifiedDesugaredType matcher:
5924  varDecl(hasType(hasUnqualifiedDesugaredType(
5925      recordType(hasDeclaration(decl())))))
5926In this matcher, the decl will match the CXXRecordDecl of class X.
5927
5928Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
5929  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
5930  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
5931  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
5932  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
5933  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
5934  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
5935</pre></td></tr>
5936
5937
5938<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
5939<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is
5940matched by a given matcher.
5941
5942Given
5943  struct X { int m; };
5944  void f(X x) { x.m; m; }
5945memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))))
5946  matches "x.m" and "m"
5947with hasObjectExpression(...)
5948  matching "x" and the implicit object expression of "m" which has type X*.
5949</pre></td></tr>
5950
5951
5952<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt; InnerMatcher</td></tr>
5953<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a
5954given matcher.
5955
5956Given
5957  struct { int first, second; } first, second;
5958  int i(second.first);
5959  int j(first.second);
5960memberExpr(member(hasName("first")))
5961  matches second.first
5962  but not first.second (because the member name there is "second").
5963</pre></td></tr>
5964
5965
5966<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;</td><td class="name" onclick="toggle('pointee1')"><a name="pointee1Anchor">pointee</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
5967<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the
5968pointee matches a given matcher.
5969
5970Given
5971  int *a;
5972  int const *b;
5973  float const *f;
5974pointerType(pointee(isConstQualified(), isInteger()))
5975  matches "int const *b"
5976
5977Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;,
5978  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;
5979</pre></td></tr>
5980
5981
5982<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt;</td><td class="name" onclick="toggle('hasUnderlyingDecl0')"><a name="hasUnderlyingDecl0Anchor">hasUnderlyingDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt; InnerMatcher</td></tr>
5983<tr><td colspan="4" class="doc" id="hasUnderlyingDecl0"><pre>Matches a NamedDecl whose underlying declaration matches the given
5984matcher.
5985
5986Given
5987  namespace N { template&lt;class T&gt; void f(T t); }
5988  template &lt;class T&gt; void g() { using N::f; f(T()); }
5989unresolvedLookupExpr(hasAnyDeclaration(
5990    namedDecl(hasUnderlyingDecl(hasName("::N::f")))))
5991  matches the use of f in g() .
5992</pre></td></tr>
5993
5994
5995<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>&gt; InnerMatcher</td></tr>
5996<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc.
5997
5998Given
5999  struct A { struct B { struct C {}; }; };
6000  A::B::C c;
6001nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A")))))
6002  matches "A::"
6003</pre></td></tr>
6004
6005
6006<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; InnerMatcher</td></tr>
6007<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the
6008given TypeLoc.
6009
6010Given
6011  struct A { struct B { struct C {}; }; };
6012  A::B::C c;
6013nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
6014  hasDeclaration(cxxRecordDecl(hasName("A")))))))
6015  matches "A::"
6016</pre></td></tr>
6017
6018
6019<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt; InnerMatcher</td></tr>
6020<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier.
6021
6022Given
6023  struct A { struct B { struct C {}; }; };
6024  A::B::C c;
6025nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and
6026  matches "A::"
6027</pre></td></tr>
6028
6029
6030<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>&gt; InnerMatcher</td></tr>
6031<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the
6032given namespace matcher.
6033
6034Given
6035  namespace ns { struct A {}; }
6036  ns::A a;
6037nestedNameSpecifier(specifiesNamespace(hasName("ns")))
6038  matches "ns::"
6039</pre></td></tr>
6040
6041
6042<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
6043<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the
6044given QualType matcher without qualifiers.
6045
6046Given
6047  struct A { struct B { struct C {}; }; };
6048  A::B::C c;
6049nestedNameSpecifier(specifiesType(
6050  hasDeclaration(cxxRecordDecl(hasName("A")))
6051))
6052  matches "A::"
6053</pre></td></tr>
6054
6055
6056<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnyArgument3')"><a name="hasAnyArgument3Anchor">hasAnyArgument</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6057<tr><td colspan="4" class="doc" id="hasAnyArgument3"><pre>Matches any argument of a call expression or a constructor call
6058expression, or an ObjC-message-send expression.
6059
6060Given
6061  void x(int, int, int) { int y; x(1, y, 42); }
6062callExpr(hasAnyArgument(declRefExpr()))
6063  matches x(1, y, 42)
6064with hasAnyArgument(...)
6065  matching y
6066
6067For ObjectiveC, given
6068  @interface I - (void) f:(int) y; @end
6069  void foo(I *i) { [i f:12]; }
6070objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
6071  matches [i f:12]
6072</pre></td></tr>
6073
6074
6075<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasArgument2')"><a name="hasArgument2Anchor">hasArgument</a></td><td>unsigned N, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6076<tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor
6077call expression.
6078
6079Example matches y in x(y)
6080    (matcher = callExpr(hasArgument(0, declRefExpr())))
6081  void x(int) { int y; x(y); }
6082</pre></td></tr>
6083
6084
6085<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasReceiver0')"><a name="hasReceiver0Anchor">hasReceiver</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6086<tr><td colspan="4" class="doc" id="hasReceiver0"><pre>Matches if the Objective-C message is sent to an instance,
6087and the inner matcher matches on that instance.
6088
6089For example the method call in
6090  NSString *x = @"hello";
6091  [x containsString:@"h"];
6092is matched by
6093objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x"))))))
6094</pre></td></tr>
6095
6096
6097<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasReceiverType0')"><a name="hasReceiverType0Anchor">hasReceiverType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
6098<tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression.
6099
6100Example
6101matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *")));
6102matches the [webView ...] message invocation.
6103  NSString *webViewJavaScript = ...
6104  UIWebView *webView = ...
6105  [webView stringByEvaluatingJavaScriptFromString:webViewJavascript];
6106</pre></td></tr>
6107
6108
6109<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyParameter1')"><a name="hasAnyParameter1Anchor">hasAnyParameter</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt; InnerMatcher</td></tr>
6110<tr><td colspan="4" class="doc" id="hasAnyParameter1"><pre>Matches any parameter of a function or an ObjC method declaration or a
6111block.
6112
6113Does not match the 'this' parameter of a method.
6114
6115Given
6116  class X { void f(int x, int y, int z) {} };
6117cxxMethodDecl(hasAnyParameter(hasName("y")))
6118  matches f(int x, int y, int z) {}
6119with hasAnyParameter(...)
6120  matching int y
6121
6122For ObjectiveC, given
6123  @interface I - (void) f:(int) y; @end
6124
6125the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
6126matches the declaration of method f with hasParameter
6127matching y.
6128
6129For blocks, given
6130  b = ^(int y) { printf("%d", y) };
6131
6132the matcher blockDecl(hasAnyParameter(hasName("y")))
6133matches the declaration of the block b with hasParameter
6134matching y.
6135</pre></td></tr>
6136
6137
6138<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;</td><td class="name" onclick="toggle('hasParameter1')"><a name="hasParameter1Anchor">hasParameter</a></td><td>unsigned N, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt; InnerMatcher</td></tr>
6139<tr><td colspan="4" class="doc" id="hasParameter1"><pre>Matches the n'th parameter of a function or an ObjC method
6140declaration or a block.
6141
6142Given
6143  class X { void f(int x) {} };
6144cxxMethodDecl(hasParameter(0, hasType(varDecl())))
6145  matches f(int x) {}
6146with hasParameter(...)
6147  matching int x
6148
6149For ObjectiveC, given
6150  @interface I - (void) f:(int) y; @end
6151
6152the matcher objcMethodDecl(hasParameter(0, hasName("y")))
6153matches the declaration of method f with hasParameter
6154matching y.
6155</pre></td></tr>
6156
6157
6158<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OpaqueValueExpr.html">OpaqueValueExpr</a>&gt;</td><td class="name" onclick="toggle('hasSourceExpression1')"><a name="hasSourceExpression1Anchor">hasSourceExpression</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6159<tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre>Matches if the cast's source expression
6160or opaque value's source expression matches the given matcher.
6161
6162Example 1: matches "a string"
6163(matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
6164class URL { URL(string); };
6165URL url = "a string";
6166
6167Example 2: matches 'b' (matcher =
6168opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
6169int a = b ?: 1;
6170</pre></td></tr>
6171
6172
6173<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OverloadExpr.html">OverloadExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnyDeclaration0')"><a name="hasAnyDeclaration0Anchor">hasAnyDeclaration</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
6174<tr><td colspan="4" class="doc" id="hasAnyDeclaration0"><pre>Matches an OverloadExpr if any of the declarations in the set of
6175overloads matches the given matcher.
6176
6177Given
6178  template &lt;typename T&gt; void foo(T);
6179  template &lt;typename T&gt; void bar(T);
6180  template &lt;typename T&gt; void baz(T t) {
6181    foo(t);
6182    bar(t);
6183  }
6184unresolvedLookupExpr(hasAnyDeclaration(
6185    functionTemplateDecl(hasName("foo"))))
6186  matches foo in foo(t); but not bar in bar(t);
6187</pre></td></tr>
6188
6189
6190<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>&gt;</td><td class="name" onclick="toggle('innerType0')"><a name="innerType0Anchor">innerType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
6191<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type.
6192
6193Given
6194  int (*ptr_to_array)[4];
6195  int (*ptr_to_func)(int);
6196
6197varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
6198ptr_to_func but not ptr_to_array.
6199
6200Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>&gt;
6201</pre></td></tr>
6202
6203
6204<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;</td><td class="name" onclick="toggle('pointee2')"><a name="pointee2Anchor">pointee</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
6205<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the
6206pointee matches a given matcher.
6207
6208Given
6209  int *a;
6210  int const *b;
6211  float const *f;
6212pointerType(pointee(isConstQualified(), isInteger()))
6213  matches "int const *b"
6214
6215Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;,
6216  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;
6217</pre></td></tr>
6218
6219
6220<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('hasCanonicalType0')"><a name="hasCanonicalType0Anchor">hasCanonicalType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
6221<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher.
6222
6223Given:
6224  typedef int &amp;int_ref;
6225  int a;
6226  int_ref b = a;
6227
6228varDecl(hasType(qualType(referenceType()))))) will not match the
6229declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does.
6230</pre></td></tr>
6231
6232
6233<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration6')"><a name="hasDeclaration6Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
6234<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node
6235matches the given matcher.
6236
6237The associated declaration is:
6238- for type nodes, the declaration of the underlying type
6239- for CallExpr, the declaration of the callee
6240- for MemberExpr, the declaration of the referenced member
6241- for CXXConstructExpr, the declaration of the constructor
6242- for CXXNewExpr, the declaration of the operator new
6243- for ObjCIvarExpr, the declaration of the ivar
6244
6245For type nodes, hasDeclaration will generally match the declaration of the
6246sugared type. Given
6247  class X {};
6248  typedef X Y;
6249  Y y;
6250in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6251typedefDecl. A common use case is to match the underlying, desugared type.
6252This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6253  varDecl(hasType(hasUnqualifiedDesugaredType(
6254      recordType(hasDeclaration(decl())))))
6255In this matcher, the decl will match the CXXRecordDecl of class X.
6256
6257Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
6258  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
6259  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
6260  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
6261  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
6262  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
6263  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6264</pre></td></tr>
6265
6266
6267<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('ignoringParens0')"><a name="ignoringParens0Anchor">ignoringParens</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
6268<tr><td colspan="4" class="doc" id="ignoringParens0"><pre>Matches types that match InnerMatcher after any parens are stripped.
6269
6270Given
6271  void (*fp)(void);
6272The matcher
6273  varDecl(hasType(pointerType(pointee(ignoringParens(functionType())))))
6274would match the declaration for fp.
6275</pre></td></tr>
6276
6277
6278<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
6279<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration.
6280</pre></td></tr>
6281
6282
6283<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('pointsTo0')"><a name="pointsTo0Anchor">pointsTo</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
6284<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type
6285matches the specified matcher.
6286
6287Example matches y-&gt;x()
6288  (matcher = cxxMemberCallExpr(on(hasType(pointsTo
6289     cxxRecordDecl(hasName("Y")))))))
6290  class Y { public: void x(); };
6291  void z() { Y *y; y-&gt;x(); }
6292</pre></td></tr>
6293
6294
6295<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
6296<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration.
6297</pre></td></tr>
6298
6299
6300<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;</td><td class="name" onclick="toggle('references0')"><a name="references0Anchor">references</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
6301<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced
6302type matches the specified matcher.
6303
6304Example matches X &amp;x and const X &amp;y
6305    (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X"))))))
6306  class X {
6307    void a(X b) {
6308      X &amp;x = b;
6309      const X &amp;y = b;
6310    }
6311  };
6312</pre></td></tr>
6313
6314
6315<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration5')"><a name="hasDeclaration5Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
6316<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node
6317matches the given matcher.
6318
6319The associated declaration is:
6320- for type nodes, the declaration of the underlying type
6321- for CallExpr, the declaration of the callee
6322- for MemberExpr, the declaration of the referenced member
6323- for CXXConstructExpr, the declaration of the constructor
6324- for CXXNewExpr, the declaration of the operator new
6325- for ObjCIvarExpr, the declaration of the ivar
6326
6327For type nodes, hasDeclaration will generally match the declaration of the
6328sugared type. Given
6329  class X {};
6330  typedef X Y;
6331  Y y;
6332in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6333typedefDecl. A common use case is to match the underlying, desugared type.
6334This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6335  varDecl(hasType(hasUnqualifiedDesugaredType(
6336      recordType(hasDeclaration(decl())))))
6337In this matcher, the decl will match the CXXRecordDecl of class X.
6338
6339Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
6340  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
6341  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
6342  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
6343  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
6344  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
6345  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6346</pre></td></tr>
6347
6348
6349<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;</td><td class="name" onclick="toggle('pointee3')"><a name="pointee3Anchor">pointee</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
6350<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the
6351pointee matches a given matcher.
6352
6353Given
6354  int *a;
6355  int const *b;
6356  float const *f;
6357pointerType(pointee(isConstQualified(), isInteger()))
6358  matches "int const *b"
6359
6360Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>&gt;,
6361  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>&gt;
6362</pre></td></tr>
6363
6364
6365<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">ReturnStmt</a>&gt;</td><td class="name" onclick="toggle('hasReturnValue0')"><a name="hasReturnValue0Anchor">hasReturnValue</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6366<tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement
6367
6368Given
6369  return a + b;
6370hasReturnValue(binaryOperator())
6371  matches 'return a + b'
6372with binaryOperator()
6373  matching 'a + b'
6374</pre></td></tr>
6375
6376
6377<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1StmtExpr.html">StmtExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnySubstatement1')"><a name="hasAnySubstatement1Anchor">hasAnySubstatement</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
6378<tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches
6379a given matcher. Also matches StmtExprs that have CompoundStmt as children.
6380
6381Given
6382  { {}; 1+2; }
6383hasAnySubstatement(compoundStmt())
6384  matches '{ {}; 1+2; }'
6385with compoundStmt()
6386  matching '{}'
6387</pre></td></tr>
6388
6389
6390<tr><td>Matcher&lt;<a href="https://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>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt;  InnerMatcher</td></tr>
6391<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
6392alignof.
6393</pre></td></tr>
6394
6395
6396<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('forFunction0')"><a name="forFunction0Anchor">forFunction</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt; InnerMatcher</td></tr>
6397<tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statement belongs to
6398
6399Given:
6400F&amp; operator=(const F&amp; o) {
6401  std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v &gt; 0; });
6402  return *this;
6403}
6404returnStmt(forFunction(hasName("operator=")))
6405  matches 'return *this'
6406  but does match 'return &gt; 0'
6407</pre></td></tr>
6408
6409
6410<tr><td>Matcher&lt;<a href="https://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>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt;  InnerMatcher</td></tr>
6411<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
6412sizeof.
6413</pre></td></tr>
6414
6415
6416<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html">SubstTemplateTypeParmType</a>&gt;</td><td class="name" onclick="toggle('hasReplacementType0')"><a name="hasReplacementType0Anchor">hasReplacementType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
6417<tr><td colspan="4" class="doc" id="hasReplacementType0"><pre>Matches template type parameter substitutions that have a replacement
6418type that matches the provided matcher.
6419
6420Given
6421  template &lt;typename T&gt;
6422  double F(T t);
6423  int i;
6424  double j = F(i);
6425
6426substTemplateTypeParmType(hasReplacementType(type())) matches int
6427</pre></td></tr>
6428
6429
6430<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>&gt;</td><td class="name" onclick="toggle('forEachSwitchCase0')"><a name="forEachSwitchCase0Anchor">forEachSwitchCase</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>&gt; InnerMatcher</td></tr>
6431<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch
6432statement. This matcher may produce multiple matches.
6433
6434Given
6435  switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }
6436switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s")
6437  matches four times, with "c" binding each of "case 1:", "case 2:",
6438"case 3:" and "case 4:", and "s" respectively binding "switch (1)",
6439"switch (1)", "switch (2)" and "switch (2)".
6440</pre></td></tr>
6441
6442
6443<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>&gt;</td><td class="name" onclick="toggle('hasCondition4')"><a name="hasCondition4Anchor">hasCondition</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6444<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop,
6445switch statement or conditional operator.
6446
6447Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
6448  if (true) {}
6449</pre></td></tr>
6450
6451
6452<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration4')"><a name="hasDeclaration4Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
6453<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node
6454matches the given matcher.
6455
6456The associated declaration is:
6457- for type nodes, the declaration of the underlying type
6458- for CallExpr, the declaration of the callee
6459- for MemberExpr, the declaration of the referenced member
6460- for CXXConstructExpr, the declaration of the constructor
6461- for CXXNewExpr, the declaration of the operator new
6462- for ObjCIvarExpr, the declaration of the ivar
6463
6464For type nodes, hasDeclaration will generally match the declaration of the
6465sugared type. Given
6466  class X {};
6467  typedef X Y;
6468  Y y;
6469in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6470typedefDecl. A common use case is to match the underlying, desugared type.
6471This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6472  varDecl(hasType(hasUnqualifiedDesugaredType(
6473      recordType(hasDeclaration(decl())))))
6474In this matcher, the decl will match the CXXRecordDecl of class X.
6475
6476Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
6477  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
6478  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
6479  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
6480  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
6481  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
6482  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6483</pre></td></tr>
6484
6485
6486<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('isExpr0')"><a name="isExpr0Anchor">isExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6487<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression.
6488
6489Given
6490  struct B { int next; };
6491  template&lt;int(B::*next_ptr)&gt; struct A {};
6492  A&lt;&amp;B::next&gt; a;
6493templateSpecializationType(hasAnyTemplateArgument(
6494  isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next"))))))))
6495  matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
6496    B::next
6497</pre></td></tr>
6498
6499
6500<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
6501<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain
6502declaration.
6503
6504Given
6505  struct B { int next; };
6506  template&lt;int(B::*next_ptr)&gt; struct A {};
6507  A&lt;&amp;B::next&gt; a;
6508classTemplateSpecializationDecl(hasAnyTemplateArgument(
6509    refersToDeclaration(fieldDecl(hasName("next")))))
6510  matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
6511    B::next
6512</pre></td></tr>
6513
6514
6515<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('refersToIntegralType0')"><a name="refersToIntegralType0Anchor">refersToIntegralType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
6516<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type.
6517
6518Given
6519  template&lt;int T&gt; struct C {};
6520  C&lt;42&gt; c;
6521classTemplateSpecializationDecl(
6522  hasAnyTemplateArgument(refersToIntegralType(asString("int"))))
6523  matches the implicit instantiation of C in C&lt;42&gt;.
6524</pre></td></tr>
6525
6526
6527<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt;</td><td class="name" onclick="toggle('refersToTemplate0')"><a name="refersToTemplate0Anchor">refersToTemplate</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName</a>&gt; InnerMatcher</td></tr>
6528<tr><td colspan="4" class="doc" id="refersToTemplate0"><pre>Matches a TemplateArgument that refers to a certain template.
6529
6530Given
6531  template&lt;template &lt;typename&gt; class S&gt; class X {};
6532  template&lt;typename T&gt; class Y {};
6533  X&lt;Y&gt; xi;
6534classTemplateSpecializationDecl(hasAnyTemplateArgument(
6535    refersToTemplate(templateName())))
6536  matches the specialization X&lt;Y&gt;
6537</pre></td></tr>
6538
6539
6540<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
6541<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type.
6542
6543Given
6544  struct X {};
6545  template&lt;typename T&gt; struct A {};
6546  A&lt;X&gt; a;
6547classTemplateSpecializationDecl(hasAnyTemplateArgument(
6548    refersToType(class(hasName("X")))))
6549  matches the specialization A&lt;X&gt;
6550</pre></td></tr>
6551
6552
6553<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('hasAnyTemplateArgument1')"><a name="hasAnyTemplateArgument1Anchor">hasAnyTemplateArgument</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
6554<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and
6555functionDecl that have at least one TemplateArgument matching the given
6556InnerMatcher.
6557
6558Given
6559  template&lt;typename T&gt; class A {};
6560  template&lt;&gt; class A&lt;double&gt; {};
6561  A&lt;int&gt; a;
6562
6563  template&lt;typename T&gt; f() {};
6564  void func() { f&lt;int&gt;(); };
6565
6566classTemplateSpecializationDecl(hasAnyTemplateArgument(
6567    refersToType(asString("int"))))
6568  matches the specialization A&lt;int&gt;
6569
6570functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
6571  matches the specialization f&lt;int&gt;
6572</pre></td></tr>
6573
6574
6575<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration3')"><a name="hasDeclaration3Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
6576<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node
6577matches the given matcher.
6578
6579The associated declaration is:
6580- for type nodes, the declaration of the underlying type
6581- for CallExpr, the declaration of the callee
6582- for MemberExpr, the declaration of the referenced member
6583- for CXXConstructExpr, the declaration of the constructor
6584- for CXXNewExpr, the declaration of the operator new
6585- for ObjCIvarExpr, the declaration of the ivar
6586
6587For type nodes, hasDeclaration will generally match the declaration of the
6588sugared type. Given
6589  class X {};
6590  typedef X Y;
6591  Y y;
6592in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6593typedefDecl. A common use case is to match the underlying, desugared type.
6594This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6595  varDecl(hasType(hasUnqualifiedDesugaredType(
6596      recordType(hasDeclaration(decl())))))
6597In this matcher, the decl will match the CXXRecordDecl of class X.
6598
6599Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
6600  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
6601  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
6602  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
6603  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
6604  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
6605  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6606</pre></td></tr>
6607
6608
6609<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('hasTemplateArgument1')"><a name="hasTemplateArgument1Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
6610<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and
6611functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
6612
6613Given
6614  template&lt;typename T, typename U&gt; class A {};
6615  A&lt;bool, int&gt; b;
6616  A&lt;int, bool&gt; c;
6617
6618  template&lt;typename T&gt; void f() {}
6619  void func() { f&lt;int&gt;(); };
6620classTemplateSpecializationDecl(hasTemplateArgument(
6621    1, refersToType(asString("int"))))
6622  matches the specialization A&lt;bool, int&gt;
6623
6624functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
6625  matches the specialization f&lt;int&gt;
6626</pre></td></tr>
6627
6628
6629<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration2')"><a name="hasDeclaration2Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
6630<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node
6631matches the given matcher.
6632
6633The associated declaration is:
6634- for type nodes, the declaration of the underlying type
6635- for CallExpr, the declaration of the callee
6636- for MemberExpr, the declaration of the referenced member
6637- for CXXConstructExpr, the declaration of the constructor
6638- for CXXNewExpr, the declaration of the operator new
6639- for ObjCIvarExpr, the declaration of the ivar
6640
6641For type nodes, hasDeclaration will generally match the declaration of the
6642sugared type. Given
6643  class X {};
6644  typedef X Y;
6645  Y y;
6646in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6647typedefDecl. A common use case is to match the underlying, desugared type.
6648This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6649  varDecl(hasType(hasUnqualifiedDesugaredType(
6650      recordType(hasDeclaration(decl())))))
6651In this matcher, the decl will match the CXXRecordDecl of class X.
6652
6653Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
6654  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
6655  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
6656  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
6657  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
6658  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
6659  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6660</pre></td></tr>
6661
6662
6663<tr><td>Matcher&lt;T&gt;</td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>const Matcher&lt;T&gt;  Matcher</td></tr>
6664<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches.
6665
6666Generates results for each match.
6667
6668For example, in:
6669  class A { class B {}; class C {}; };
6670The matcher:
6671  cxxRecordDecl(hasName("::A"),
6672                findAll(cxxRecordDecl(isDefinition()).bind("m")))
6673will generate results for A, B and C.
6674
6675Usable as: Any Matcher
6676</pre></td></tr>
6677
6678
6679<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;</td><td class="name" onclick="toggle('hasType2')"><a name="hasType2Anchor">hasType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
6680<tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type
6681matcher.
6682
6683Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
6684            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
6685            and U (matcher = typedefDecl(hasType(asString("int")))
6686            and friend class X (matcher = friendDecl(hasType("X"))
6687 class X {};
6688 void y(X &amp;x) { x; X z; }
6689 typedef int U;
6690 class Y { friend class X; };
6691</pre></td></tr>
6692
6693
6694<tr><td>Matcher&lt;<a href="https://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>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
6695<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node
6696matches the given matcher.
6697
6698The associated declaration is:
6699- for type nodes, the declaration of the underlying type
6700- for CallExpr, the declaration of the callee
6701- for MemberExpr, the declaration of the referenced member
6702- for CXXConstructExpr, the declaration of the constructor
6703- for CXXNewExpr, the declaration of the operator new
6704- for ObjCIvarExpr, the declaration of the ivar
6705
6706For type nodes, hasDeclaration will generally match the declaration of the
6707sugared type. Given
6708  class X {};
6709  typedef X Y;
6710  Y y;
6711in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6712typedefDecl. A common use case is to match the underlying, desugared type.
6713This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6714  varDecl(hasType(hasUnqualifiedDesugaredType(
6715      recordType(hasDeclaration(decl())))))
6716In this matcher, the decl will match the CXXRecordDecl of class X.
6717
6718Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
6719  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
6720  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
6721  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
6722  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
6723  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
6724  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6725</pre></td></tr>
6726
6727
6728<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('hasUnqualifiedDesugaredType0')"><a name="hasUnqualifiedDesugaredType0Anchor">hasUnqualifiedDesugaredType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt; InnerMatcher</td></tr>
6729<tr><td colspan="4" class="doc" id="hasUnqualifiedDesugaredType0"><pre>Matches if the matched type matches the unqualified desugared
6730type of the matched node.
6731
6732For example, in:
6733  class A {};
6734  using B = A;
6735The matcher type(hasUnqualifiedDesugaredType(recordType())) matches
6736both B and A.
6737</pre></td></tr>
6738
6739
6740<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
6741<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument.
6742
6743Given
6744  int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
6745unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
6746  matches sizeof(a) and alignof(c)
6747</pre></td></tr>
6748
6749
6750<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6751<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches.
6752
6753Example matches true (matcher = hasUnaryOperand(
6754                                  cxxBoolLiteral(equals(true))))
6755  !true
6756</pre></td></tr>
6757
6758
6759<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html">UnresolvedMemberExpr</a>&gt;</td><td class="name" onclick="toggle('hasObjectExpression1')"><a name="hasObjectExpression1Anchor">hasObjectExpression</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6760<tr><td colspan="4" class="doc" id="hasObjectExpression1"><pre>Matches a member expression where the object expression is
6761matched by a given matcher.
6762
6763Given
6764  struct X { int m; };
6765  void f(X x) { x.m; m; }
6766memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))))
6767  matches "x.m" and "m"
6768with hasObjectExpression(...)
6769  matching "x" and the implicit object expression of "m" which has type X*.
6770</pre></td></tr>
6771
6772
6773<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;</td><td class="name" onclick="toggle('hasDeclaration0')"><a name="hasDeclaration0Anchor">hasDeclaration</a></td><td>const Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
6774<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node
6775matches the given matcher.
6776
6777The associated declaration is:
6778- for type nodes, the declaration of the underlying type
6779- for CallExpr, the declaration of the callee
6780- for MemberExpr, the declaration of the referenced member
6781- for CXXConstructExpr, the declaration of the constructor
6782- for CXXNewExpr, the declaration of the operator new
6783- for ObjCIvarExpr, the declaration of the ivar
6784
6785For type nodes, hasDeclaration will generally match the declaration of the
6786sugared type. Given
6787  class X {};
6788  typedef X Y;
6789  Y y;
6790in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6791typedefDecl. A common use case is to match the underlying, desugared type.
6792This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6793  varDecl(hasType(hasUnqualifiedDesugaredType(
6794      recordType(hasDeclaration(decl())))))
6795In this matcher, the decl will match the CXXRecordDecl of class X.
6796
6797Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;,
6798  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;,
6799  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>&gt;,
6800  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>&gt;,
6801  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;,
6802  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>&gt;,
6803  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6804</pre></td></tr>
6805
6806
6807<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>&gt; InnerMatcher</td></tr>
6808<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration.
6809
6810Given
6811  namespace X { void b(); }
6812  using X::b;
6813usingDecl(hasAnyUsingShadowDecl(hasName("b"))))
6814  matches using X::b </pre></td></tr>
6815
6816
6817<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt; InnerMatcher</td></tr>
6818<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is
6819matched by the given matcher.
6820
6821Given
6822  namespace X { int a; void b(); }
6823  using X::a;
6824  using X::b;
6825usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
6826  matches using X::b but not using X::a </pre></td></tr>
6827
6828
6829<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;</td><td class="name" onclick="toggle('hasType6')"><a name="hasType6Anchor">hasType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
6830<tr><td colspan="4" class="doc" id="hasType6"><pre>Overloaded to match the declaration of the expression's or value
6831declaration's type.
6832
6833In case of a value declaration (for example a variable declaration),
6834this resolves one layer of indirection. For example, in the value
6835declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
6836X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
6837declaration of x.
6838
6839Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
6840            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
6841            and friend class X (matcher = friendDecl(hasType("X"))
6842 class X {};
6843 void y(X &amp;x) { x; X z; }
6844 class Y { friend class X; };
6845
6846Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;
6847</pre></td></tr>
6848
6849
6850<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;</td><td class="name" onclick="toggle('hasType3')"><a name="hasType3Anchor">hasType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
6851<tr><td colspan="4" class="doc" id="hasType3"><pre>Matches if the expression's or declaration's type matches a type
6852matcher.
6853
6854Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
6855            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
6856            and U (matcher = typedefDecl(hasType(asString("int")))
6857            and friend class X (matcher = friendDecl(hasType("X"))
6858 class X {};
6859 void y(X &amp;x) { x; X z; }
6860 typedef int U;
6861 class Y { friend class X; };
6862</pre></td></tr>
6863
6864
6865<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6866<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression
6867that matches the given matcher.
6868
6869Example matches x (matcher = varDecl(hasInitializer(callExpr())))
6870  bool y() { return true; }
6871  bool x = y();
6872</pre></td></tr>
6873
6874
6875<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6876<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size
6877expression.
6878
6879Given
6880  void f(int b) {
6881    int a[b];
6882  }
6883variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
6884  varDecl(hasName("b")))))))
6885  matches "int a[b]"
6886</pre></td></tr>
6887
6888
6889<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
6890<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', 'do while' statement or a function
6891definition that has a given body.
6892
6893Given
6894  for (;;) {}
6895hasBody(compoundStmt())
6896  matches 'for (;;) {}'
6897with compoundStmt()
6898  matching '{}'
6899</pre></td></tr>
6900
6901
6902<tr><td>Matcher&lt;<a href="https://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="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6903<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop,
6904switch statement or conditional operator.
6905
6906Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
6907  if (true) {}
6908</pre></td></tr>
6909
6910
6911<tr><td>Matcher&lt;internal::BindableMatcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>&gt;&gt;</td><td class="name" onclick="toggle('loc1')"><a name="loc1Anchor">loc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt; InnerMatcher</td></tr>
6912<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner
6913NestedNameSpecifier-matcher matches.
6914</pre></td></tr>
6915
6916
6917<tr><td>Matcher&lt;internal::BindableMatcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;&gt;</td><td class="name" onclick="toggle('loc0')"><a name="loc0Anchor">loc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
6918<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner
6919QualType-matcher matches.
6920</pre></td></tr>
6921
6922<!--END_TRAVERSAL_MATCHERS -->
6923</table>
6924
6925</div>
6926</body>
6927</html>
6928
6929
6930