xref: /openbsd-src/gnu/llvm/clang/docs/LibASTMatchersReference.html (revision 12c855180aad702bbcca06e0398d774beeafb155)
1e5dd7070Spatrick<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2e5dd7070Spatrick          "http://www.w3.org/TR/html4/strict.dtd">
3e5dd7070Spatrick<html>
4e5dd7070Spatrick<head>
5e5dd7070Spatrick<title>AST Matcher Reference</title>
6e5dd7070Spatrick<link type="text/css" rel="stylesheet" href="../menu.css" />
7e5dd7070Spatrick<link type="text/css" rel="stylesheet" href="../content.css" />
8e5dd7070Spatrick<style type="text/css">
9e5dd7070Spatricktd {
10e5dd7070Spatrick  padding: .33em;
11e5dd7070Spatrick}
12e5dd7070Spatricktd.doc {
13e5dd7070Spatrick  display: none;
14e5dd7070Spatrick  border-bottom: 1px solid black;
15e5dd7070Spatrick}
16e5dd7070Spatricktd.name:hover {
17e5dd7070Spatrick  color: blue;
18e5dd7070Spatrick  cursor: pointer;
19e5dd7070Spatrick}
20a9ac8606Spatrickspan.mono { font-family: monospace; }
21a9ac8606Spatrick
22a9ac8606Spatrick.traverse_compare, .traverse_compare td, .traverse_compare th {
23a9ac8606Spatrick  border: 1px solid black;
24a9ac8606Spatrick  border-collapse: collapse;
25a9ac8606Spatrick}
26e5dd7070Spatrick</style>
27e5dd7070Spatrick<script type="text/javascript">
28e5dd7070Spatrickfunction toggle(id) {
29e5dd7070Spatrick  if (!id) return;
30e5dd7070Spatrick  row = document.getElementById(id);
31e5dd7070Spatrick  if (row.style.display != 'table-cell')
32e5dd7070Spatrick    row.style.display = 'table-cell';
33e5dd7070Spatrick  else
34e5dd7070Spatrick    row.style.display = 'none';
35e5dd7070Spatrick}
36e5dd7070Spatrick</script>
37e5dd7070Spatrick</head>
38e5dd7070Spatrick<body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))">
39e5dd7070Spatrick
40e5dd7070Spatrick<!--#include virtual="../menu.html.incl"-->
41e5dd7070Spatrick
42e5dd7070Spatrick<div id="content">
43e5dd7070Spatrick
44e5dd7070Spatrick<h1>AST Matcher Reference</h1>
45e5dd7070Spatrick
46e5dd7070Spatrick<p>This document shows all currently implemented matchers. The matchers are grouped
47e5dd7070Spatrickby category and node type they match. You can click on matcher names to show the
48e5dd7070Spatrickmatcher's source documentation.</p>
49e5dd7070Spatrick
50e5dd7070Spatrick<p>There are three different basic categories of matchers:
51e5dd7070Spatrick<ul>
52e5dd7070Spatrick<li><a href="#decl-matchers">Node Matchers:</a> Matchers that match a specific type of AST node.</li>
53e5dd7070Spatrick<li><a href="#narrowing-matchers">Narrowing Matchers:</a> Matchers that match attributes on AST nodes.</li>
54e5dd7070Spatrick<li><a href="#traversal-matchers">Traversal Matchers:</a> Matchers that allow traversal between AST nodes.</li>
55e5dd7070Spatrick</ul>
56e5dd7070Spatrick</p>
57e5dd7070Spatrick
58e5dd7070Spatrick<p>Within each category the matchers are ordered by node type they match on.
59ec727ea7SpatrickNote that if a matcher can match multiple node types, it will appear
60e5dd7070Spatrickmultiple times. This means that by searching for Matcher&lt;Stmt&gt; you can
61e5dd7070Spatrickfind all matchers that can be used to match on Stmt nodes.</p>
62e5dd7070Spatrick
63e5dd7070Spatrick<p>The exception to that rule are matchers that can match on any node. Those
64e5dd7070Spatrickare marked with a * and are listed in the beginning of each category.</p>
65e5dd7070Spatrick
66e5dd7070Spatrick<p>Note that the categorization of matchers is a great help when you combine
67e5dd7070Spatrickthem into matcher expressions. You will usually want to form matcher expressions
68e5dd7070Spatrickthat read like english sentences by alternating between node matchers and
69e5dd7070Spatricknarrowing or traversal matchers, like this:
70e5dd7070Spatrick<pre>
71e5dd7070SpatrickrecordDecl(hasDescendant(
72e5dd7070Spatrick    ifStmt(hasTrueExpression(
73e5dd7070Spatrick        expr(hasDescendant(
74e5dd7070Spatrick            ifStmt()))))))
75e5dd7070Spatrick</pre>
76e5dd7070Spatrick</p>
77e5dd7070Spatrick
78e5dd7070Spatrick<!-- ======================================================================= -->
79a9ac8606Spatrick<h2 id="traverse-mode">Traverse Mode</h2>
80a9ac8606Spatrick<!-- ======================================================================= -->
81a9ac8606Spatrick
82a9ac8606Spatrick<p>The default mode of operation of AST Matchers visits all nodes in the AST,
83a9ac8606Spatrickeven if they are not spelled in the source. This is
84a9ac8606Spatrick<span class="mono">AsIs</span> mode.  This mode requires writing AST matchers
85a9ac8606Spatrickthat explicitly traverse or ignore implicit nodes, such as parentheses
86a9ac8606Spatricksurrounding an expression or expressions with cleanups.  These implicit
87a9ac8606Spatricknodes are not always obvious from the syntax of the source code, and so this
88a9ac8606Spatrickmode requires careful consideration and testing to get the desired behavior
89a9ac8606Spatrickfrom an AST matcher.
90a9ac8606Spatrick</p>
91a9ac8606Spatrick
92a9ac8606Spatrick<p>In addition, because template instantiations are matched in the default mode,
93a9ac8606Spatricktransformations can be accidentally made to template declarations. Finally,
94a9ac8606Spatrickbecause implicit nodes are matched by default, transformations can be made on
95a9ac8606Spatrickentirely incorrect places in the code.</p>
96a9ac8606Spatrick
97a9ac8606Spatrick<p>For these reasons, it is possible to ignore AST nodes which are not spelled
98a9ac8606Spatrickin the source using the <span class="mono">IgnoreUnlessSpelledInSource</span>
99a9ac8606Spatrickmode. This is likely to be far less error-prone for users who are not already
100a9ac8606Spatrickvery familiar with where implicit nodes appear in the AST. It is also likely
101a9ac8606Spatrickto be less error-prone for experienced AST users, as difficult cases do not
102a9ac8606Spatrickneed to be encountered and matcher expressions adjusted for these cases.</p>
103a9ac8606Spatrick
104a9ac8606Spatrick<p>In clang-query, the mode can be changed with
105a9ac8606Spatrick<pre>
106a9ac8606Spatrickset traversal IgnoreUnlessSpelledInSource
107a9ac8606Spatrick</pre>
108a9ac8606Spatrick</p>
109a9ac8606SpatrickThis affects both matchers and AST dump output in results.
110a9ac8606Spatrick
111a9ac8606Spatrick<p>When using the C++ API such as in clang-tidy checks, the
112a9ac8606Spatrick<span class="mono">traverse()</span> matcher is used to set the mode:
113a9ac8606Spatrick<pre>
114a9ac8606SpatrickFinder->addMatcher(traverse(TK_IgnoreUnlessSpelledInSource,
115*12c85518Srobert  returnStmt(hasReturnValue(integerLiteral(equals(0))))
116a9ac8606Spatrick  ), this);
117a9ac8606Spatrick</pre>
118a9ac8606Spatrick</p>
119a9ac8606Spatrick<p>The following table compares the <span class="mono">AsIs</span> mode with
120a9ac8606Spatrickthe <span class="mono">IgnoreUnlessSpelledInSource</span> mode:</p>
121a9ac8606Spatrick
122a9ac8606Spatrick<table class="traverse_compare">
123a9ac8606Spatrick<tr>
124a9ac8606Spatrick<th></th>
125a9ac8606Spatrick<th><span class="mono">AsIs</span></th>
126a9ac8606Spatrick<th><span class="mono">IgnoreUnlessSpelledInSource</span></th>
127a9ac8606Spatrick</tr>
128a9ac8606Spatrick<tr>
129a9ac8606Spatrick  <td>AST dump of <span class="mono">func1</span>:
130a9ac8606Spatrick<pre>
131a9ac8606Spatrickstruct B {
132a9ac8606Spatrick  B(int);
133a9ac8606Spatrick};
134a9ac8606Spatrick
135a9ac8606SpatrickB func1() { return 42; }
136a9ac8606Spatrick</pre>
137a9ac8606Spatrick
138a9ac8606Spatrick  </td>
139a9ac8606Spatrick  <td>
140a9ac8606SpatrickC++98 dialect:
141a9ac8606Spatrick<pre>
142a9ac8606SpatrickFunctionDecl
143a9ac8606Spatrick`-CompoundStmt
144a9ac8606Spatrick  `-ReturnStmt
145a9ac8606Spatrick    `-ExprWithCleanups
146a9ac8606Spatrick      `-CXXConstructExpr
147a9ac8606Spatrick        `-MaterializeTemporaryExpr
148a9ac8606Spatrick          `-ImplicitCastExpr
149a9ac8606Spatrick            `-ImplicitCastExpr
150a9ac8606Spatrick              `-CXXConstructExpr
151a9ac8606Spatrick                `-IntegerLiteral 'int' 42
152a9ac8606Spatrick</pre>
153a9ac8606SpatrickC++11, C++14 dialect:
154a9ac8606Spatrick<pre>
155a9ac8606SpatrickFunctionDecl
156a9ac8606Spatrick`-CompoundStmt
157a9ac8606Spatrick  `-ReturnStmt
158a9ac8606Spatrick    `-ExprWithCleanups
159a9ac8606Spatrick      `-CXXConstructExpr
160a9ac8606Spatrick        `-MaterializeTemporaryExpr
161a9ac8606Spatrick          `-ImplicitCastExpr
162a9ac8606Spatrick            `-CXXConstructExpr
163a9ac8606Spatrick              `-IntegerLiteral 'int' 42
164a9ac8606Spatrick</pre>
165a9ac8606SpatrickC++17, C++20 dialect:
166a9ac8606Spatrick<pre>
167a9ac8606SpatrickFunctionDecl
168a9ac8606Spatrick`-CompoundStmt
169a9ac8606Spatrick  `-ReturnStmt
170a9ac8606Spatrick    `-ImplicitCastExpr
171a9ac8606Spatrick      `-CXXConstructExpr
172a9ac8606Spatrick        `-IntegerLiteral 'int' 42
173a9ac8606Spatrick</pre>
174a9ac8606Spatrick</td>
175a9ac8606Spatrick  <td>
176a9ac8606SpatrickAll dialects:
177a9ac8606Spatrick    <pre>
178a9ac8606SpatrickFunctionDecl
179a9ac8606Spatrick`-CompoundStmt
180a9ac8606Spatrick  `-ReturnStmt
181a9ac8606Spatrick    `-IntegerLiteral 'int' 42
182a9ac8606Spatrick</pre></td>
183a9ac8606Spatrick</tr>
184a9ac8606Spatrick
185a9ac8606Spatrick<tr>
186a9ac8606Spatrick<td>Matcher for returned <span class="mono">42</span>:
187a9ac8606Spatrick<pre>
188a9ac8606Spatrickstruct B {
189a9ac8606Spatrick  B(int);
190a9ac8606Spatrick};
191a9ac8606Spatrick
192a9ac8606SpatrickB func1() { return 42; }
193a9ac8606Spatrick</pre>
194a9ac8606Spatrick
195a9ac8606Spatrick  </td>
196a9ac8606Spatrick  <td>
197a9ac8606SpatrickAll dialects:
198a9ac8606Spatrick<pre>
199a9ac8606SpatrickreturnStmt(hasReturnValue(
200a9ac8606Spatrick    ignoringImplicit(
201a9ac8606Spatrick        ignoringElidableConstructorCall(
202a9ac8606Spatrick            ignoringImplicit(
203a9ac8606Spatrick                cxxConstructExpr(hasArgument(0,
204a9ac8606Spatrick                    ignoringImplicit(
205a9ac8606Spatrick                        integerLiteral().bind("returnVal")
206a9ac8606Spatrick                        )
207a9ac8606Spatrick                    ))
208a9ac8606Spatrick                )
209a9ac8606Spatrick            )
210a9ac8606Spatrick        )
211a9ac8606Spatrick    ))
212a9ac8606Spatrick</pre></td>
213a9ac8606Spatrick  <td>
214a9ac8606SpatrickAll dialects:
215a9ac8606Spatrick<pre>
216a9ac8606SpatrickreturnStmt(hasReturnValue(
217a9ac8606Spatrick    integerLiteral().bind("returnVal")
218a9ac8606Spatrick))
219a9ac8606Spatrick</pre></td>
220a9ac8606Spatrick</tr>
221a9ac8606Spatrick<tr>
222a9ac8606Spatrick<td>Match result for
223a9ac8606Spatrick<pre>implicitCastExpr()</pre>
224a9ac8606Spatrickgiven:
225a9ac8606Spatrick<pre>
226a9ac8606Spatrickstruct B {
227a9ac8606Spatrick  B(int);
228a9ac8606Spatrick};
229a9ac8606Spatrick
230a9ac8606SpatrickB func1() { return 42; }
231a9ac8606Spatrick</pre>
232a9ac8606Spatrick
233a9ac8606Spatrick</td>
234a9ac8606Spatrick<td>
235a9ac8606SpatrickMatch found.</td>
236a9ac8606Spatrick  <td>
237a9ac8606SpatrickNo match.</td>
238a9ac8606Spatrick</tr>
239a9ac8606Spatrick<tr>
240a9ac8606Spatrick  <td>Match result for:
241a9ac8606Spatrick<pre>
242a9ac8606SpatrickcxxConstructorDecl(
243a9ac8606Spatrick  isCopyConstructor()
244a9ac8606Spatrick  ).bind("prepend_explicit")
245a9ac8606Spatrick</pre>
246a9ac8606Spatrickgiven:
247a9ac8606Spatrick<pre>
248a9ac8606Spatrickstruct Other {};
249a9ac8606Spatrickstruct Copyable {
250a9ac8606Spatrick  Other m_o;
251a9ac8606Spatrick  Copyable();
252a9ac8606Spatrick};
253a9ac8606Spatrick</pre>
254a9ac8606Spatrick</td>
255a9ac8606Spatrick<td>
256a9ac8606SpatrickMatch found. Insertion produces incorrect output:
257a9ac8606Spatrick<pre>
258a9ac8606Spatrickstruct Other {};
259a9ac8606Spatrickstruct explicit Copyable {
260a9ac8606Spatrick  Other m_o;
261a9ac8606Spatrick  Copyable();
262a9ac8606Spatrick};
263a9ac8606Spatrick</pre>
264a9ac8606Spatrick</td>
265a9ac8606Spatrick<td>
266a9ac8606SpatrickNo match found. Incorrect replacement not possible.
267a9ac8606Spatrick</td>
268a9ac8606Spatrick</tr>
269a9ac8606Spatrick<tr>
270a9ac8606Spatrick  <td>Replacement of <span class="mono">begin()</span>
271a9ac8606Spatrick    with <span class="mono">cbegin()</span>:
272a9ac8606Spatrick<pre>
273a9ac8606SpatrickcxxMemberCallExpr(
274a9ac8606Spatrick  on(ConstContainerExpr),
275a9ac8606Spatrick  callee(cxxMethodDecl(hasName("begin")))
276a9ac8606Spatrick  ).bind("replace_with_cbegin")
277a9ac8606Spatrick</pre>
278a9ac8606Spatrickgiven:
279a9ac8606Spatrick<pre>
280a9ac8606Spatrickvoid foo() {
281a9ac8606Spatrick  const Container c;
282a9ac8606Spatrick  c.begin();
283a9ac8606Spatrick
284a9ac8606Spatrick  for (auto i : c) {
285a9ac8606Spatrick  }
286a9ac8606Spatrick}
287a9ac8606Spatrick</pre>
288a9ac8606Spatrick</td>
289a9ac8606Spatrick<td>
290a9ac8606Spatrick2 matches found. Replacement produces incorrect output:
291a9ac8606Spatrick<pre>
292a9ac8606Spatrickvoid foo() {
293a9ac8606Spatrick  const Container c;
294a9ac8606Spatrick  c.cbegin();
295a9ac8606Spatrick
296a9ac8606Spatrick  for (auto i :.cbegin() c) {
297a9ac8606Spatrick  }
298a9ac8606Spatrick}
299a9ac8606Spatrick</pre>
300a9ac8606Spatrick</td>
301a9ac8606Spatrick<td>
302a9ac8606Spatrick1 match found. Replacement produces correct output:
303a9ac8606Spatrick<pre>
304a9ac8606Spatrickvoid foo() {
305a9ac8606Spatrick  const Container c;
306a9ac8606Spatrick  c.cbegin();
307a9ac8606Spatrick
308a9ac8606Spatrick  for (auto i : c) {
309a9ac8606Spatrick  }
310a9ac8606Spatrick}
311a9ac8606Spatrick</pre>
312a9ac8606Spatrick</td>
313a9ac8606Spatrick</tr>
314a9ac8606Spatrick<tr>
315a9ac8606Spatrick  <td>Replacement of <span class="mono">int</span> member
316a9ac8606Spatrick    with <span class="mono">safe_int</span>:
317a9ac8606Spatrick<pre>
318a9ac8606SpatrickfieldDecl(
319a9ac8606Spatrick  hasType(asString("int"))
320a9ac8606Spatrick  ).bind("use_safe_int")
321a9ac8606Spatrick</pre>
322a9ac8606Spatrickgiven:
323a9ac8606Spatrick<pre>
324a9ac8606Spatrickstruct S {
325a9ac8606Spatrick  int m_i;
326a9ac8606Spatrick};
327a9ac8606Spatrick
328a9ac8606Spatricktemplate &lt;typename T&gt; struct TemplStruct {
329a9ac8606Spatrick  TemplStruct() {}
330a9ac8606Spatrick  ~TemplStruct() {}
331a9ac8606Spatrick
332a9ac8606Spatrickprivate:
333a9ac8606Spatrick  T m_t;
334a9ac8606Spatrick};
335a9ac8606Spatrick
336a9ac8606Spatrickvoid instantiate() { TemplStruct&lt;int&gt; ti; }
337a9ac8606Spatrick</pre>
338a9ac8606Spatrick</td>
339a9ac8606Spatrick<td>
340a9ac8606Spatrick2 matches found. Replacement produces incorrect output:
341a9ac8606Spatrick<pre>
342a9ac8606Spatrickstruct S {
343a9ac8606Spatrick  safe_int m_i;
344a9ac8606Spatrick};
345a9ac8606Spatrick
346a9ac8606Spatricktemplate &lt;typename T&gt; struct TemplStruct {
347a9ac8606Spatrick  TemplStruct() {}
348a9ac8606Spatrick  ~TemplStruct() {}
349a9ac8606Spatrick
350a9ac8606Spatrickprivate:
351a9ac8606Spatrick  safe_int m_t;
352a9ac8606Spatrick};
353a9ac8606Spatrick
354a9ac8606Spatrickvoid instantiate() { TemplStruct&lt;int&gt; ti; }
355a9ac8606Spatrick</pre>
356a9ac8606Spatrick</td>
357a9ac8606Spatrick<td>
358a9ac8606Spatrick1 match found. Replacement produces correct output:
359a9ac8606Spatrick<pre>
360a9ac8606Spatrickstruct S {
361a9ac8606Spatrick  safe_int m_i;
362a9ac8606Spatrick};
363a9ac8606Spatrick
364a9ac8606Spatricktemplate &lt;typename T&gt; struct TemplStruct {
365a9ac8606Spatrick  TemplStruct() {}
366a9ac8606Spatrick  ~TemplStruct() {}
367a9ac8606Spatrick
368a9ac8606Spatrickprivate:
369a9ac8606Spatrick  T m_t;
370a9ac8606Spatrick};
371a9ac8606Spatrick
372a9ac8606Spatrickvoid instantiate() { TemplStruct&lt;int&gt; ti; }
373a9ac8606Spatrick</pre>
374a9ac8606Spatrick</td>
375a9ac8606Spatrick</tr>
376a9ac8606Spatrick<tr>
377a9ac8606Spatrick  <td>Add prefix to member initializer
378a9ac8606Spatrick<pre>
379a9ac8606SpatrickcxxCtorInitializer(
380a9ac8606Spatrick  forField(fieldDecl())
381a9ac8606Spatrick  ).bind("add_prefix")
382a9ac8606Spatrick</pre>
383a9ac8606Spatrickgiven:
384a9ac8606Spatrick<pre>
385a9ac8606Spatrickstruct Simple {};
386a9ac8606Spatrick
387a9ac8606Spatrickstruct Record {
388a9ac8606Spatrick  Record() : i(42) {}
389a9ac8606Spatrickprivate:
390a9ac8606Spatrick  int i;
391a9ac8606Spatrick  Simple s;
392a9ac8606Spatrick};
393a9ac8606Spatrick</pre>
394a9ac8606Spatrick</td>
395a9ac8606Spatrick<td>
396a9ac8606Spatrick2 matches found. Replacement produces incorrect output:
397a9ac8606Spatrick<pre>
398a9ac8606Spatrickstruct Simple {};
399a9ac8606Spatrick
400a9ac8606Spatrickstruct Record {
401a9ac8606Spatrick  m_Record() : m_i(42) {}
402a9ac8606Spatrickprivate:
403a9ac8606Spatrick  int i;
404a9ac8606Spatrick  Simple s;
405a9ac8606Spatrick};
406a9ac8606Spatrick</pre>
407a9ac8606Spatrick</td>
408a9ac8606Spatrick<td>
409a9ac8606Spatrick1 match found. Replacement produces correct output:
410a9ac8606Spatrick<pre>
411a9ac8606Spatrickstruct Simple {};
412a9ac8606Spatrick
413a9ac8606Spatrickstruct Record {
414a9ac8606Spatrick  Record() : m_i(42) {}
415a9ac8606Spatrickprivate:
416a9ac8606Spatrick  int i;
417a9ac8606Spatrick  Simple s;
418a9ac8606Spatrick};
419a9ac8606Spatrick</pre>
420a9ac8606Spatrick</td>
421a9ac8606Spatrick</tr>
422a9ac8606Spatrick<tr>
423a9ac8606Spatrick  <td>Ignored default arguments
424a9ac8606Spatrick<pre>
425a9ac8606SpatrickcallExpr(
426a9ac8606Spatrick  callee(functionDecl(
427a9ac8606Spatrick    hasName("hasDefaultArg")
428a9ac8606Spatrick    )),
429a9ac8606Spatrick  argumentCountIs(1)
430a9ac8606Spatrick  ).bind("add_prefix")
431a9ac8606Spatrick</pre>
432a9ac8606Spatrickgiven:
433a9ac8606Spatrick<pre>
434a9ac8606Spatrickvoid hasDefaultArg(int i, int j = 0) {}
435a9ac8606Spatrickvoid callDefaultArg() { hasDefaultArg(42); }
436a9ac8606Spatrick</pre>
437a9ac8606Spatrick</td>
438a9ac8606Spatrick<td>
439a9ac8606SpatrickNo match.
440a9ac8606Spatrick</td>
441a9ac8606Spatrick<td>
442a9ac8606Spatrick1 match found.
443a9ac8606Spatrick</td>
444a9ac8606Spatrick</tr>
445a9ac8606Spatrick<tr>
446a9ac8606Spatrick  <td>Lambda fields
447a9ac8606Spatrick<pre>
448a9ac8606SpatrickfieldDecl(
449a9ac8606Spatrick  hasType(asString("int"))
450a9ac8606Spatrick  ).bind("make_safe")
451a9ac8606Spatrick</pre>
452a9ac8606Spatrickgiven:
453a9ac8606Spatrick<pre>
454a9ac8606Spatrickstruct S {
455a9ac8606Spatrick  int m_i;
456a9ac8606Spatrick};
457a9ac8606Spatrick
458a9ac8606Spatrickvoid func() {
459a9ac8606Spatrick  int a = 0;
460a9ac8606Spatrick  int c = 0;
461a9ac8606Spatrick
462a9ac8606Spatrick  auto l = [a, b = c](int d) { int e = d; };
463a9ac8606Spatrick  l(43);
464a9ac8606Spatrick}
465a9ac8606Spatrick</pre>
466a9ac8606Spatrick</td>
467a9ac8606Spatrick<td>
468a9ac8606Spatrick2 matches found. Replacement produces incorrect output:
469a9ac8606Spatrick<pre>
470a9ac8606Spatrickstruct S {
471a9ac8606Spatrick  safe_int m_i;
472a9ac8606Spatrick};
473a9ac8606Spatrick
474a9ac8606Spatrickvoid func() {
475a9ac8606Spatrick  int a = 0;
476a9ac8606Spatrick  int c = 0;
477a9ac8606Spatrick
478a9ac8606Spatrick  auto l = [safe_a, safe_b = c](int d) { int e = d; };
479a9ac8606Spatrick  l(43);
480a9ac8606Spatrick}
481a9ac8606Spatrick</pre>
482a9ac8606Spatrick</td>
483a9ac8606Spatrick<td>
484a9ac8606Spatrick1 match found. Replacement produces correct output:
485a9ac8606Spatrick<pre>
486a9ac8606Spatrickstruct S {
487a9ac8606Spatrick  safe_int m_i;
488a9ac8606Spatrick};
489a9ac8606Spatrick
490a9ac8606Spatrickvoid func() {
491a9ac8606Spatrick  int a = 0;
492a9ac8606Spatrick  int c = 0;
493a9ac8606Spatrick
494a9ac8606Spatrick  auto l = [a, b = c](int d) { int e = d; };
495a9ac8606Spatrick  l(43);
496a9ac8606Spatrick}
497a9ac8606Spatrick</pre>
498a9ac8606Spatrick</td>
499a9ac8606Spatrick
500a9ac8606Spatrick</tr>
501a9ac8606Spatrick
502a9ac8606Spatrick
503a9ac8606Spatrick
504a9ac8606Spatrick
505a9ac8606Spatrick
506a9ac8606Spatrick<tr>
507a9ac8606Spatrick  <td>Rewritten binary operators
508a9ac8606Spatrick<pre>
509a9ac8606SpatrickbinaryOperator(
510a9ac8606Spatrick  hasOperatorName("&lt;"),
511a9ac8606Spatrick  hasRHS(hasDescendant(integerLiteral(equals(0))))
512a9ac8606Spatrick  )
513a9ac8606Spatrick</pre>
514a9ac8606Spatrickgiven:
515a9ac8606Spatrick<pre>
516a9ac8606Spatrick#include &lt;compare&gt;
517a9ac8606Spatrick
518a9ac8606Spatrickclass HasSpaceship {
519a9ac8606Spatrickpublic:
520a9ac8606Spatrick   int x;
521a9ac8606Spatrick   bool operator==(const HasSpaceship&) const = default;
522a9ac8606Spatrick   std::strong_ordering operator<=>(const HasSpaceship&) const = default;
523a9ac8606Spatrick};
524a9ac8606Spatrick
525a9ac8606Spatrickbool isLess(const HasSpaceship& a, const HasSpaceship& b) {
526a9ac8606Spatrick   return a < b;
527a9ac8606Spatrick}
528a9ac8606Spatrick</pre>
529a9ac8606Spatrick</td>
530a9ac8606Spatrick<td>
531a9ac8606Spatrick1 match found.
532a9ac8606Spatrick
533a9ac8606Spatrick<pre>
534a9ac8606Spatrick   return a < b;
535a9ac8606Spatrick          ^~~~~
536a9ac8606Spatrick</pre>
537a9ac8606Spatrick
538a9ac8606Spatrick</td>
539a9ac8606Spatrick<td>
540a9ac8606SpatrickNo match found.
541a9ac8606Spatrick</td>
542a9ac8606Spatrick</tr>
543a9ac8606Spatrick</table>
544a9ac8606Spatrick
545a9ac8606Spatrick<!-- ======================================================================= -->
546e5dd7070Spatrick<h2 id="decl-matchers">Node Matchers</h2>
547e5dd7070Spatrick<!-- ======================================================================= -->
548e5dd7070Spatrick
549e5dd7070Spatrick<p>Node matchers are at the core of matcher expressions - they specify the type
550e5dd7070Spatrickof node that is expected. Every match expression starts with a node matcher,
551e5dd7070Spatrickwhich can then be further refined with a narrowing or traversal matcher. All
552e5dd7070Spatricktraversal matchers take node matchers as their arguments.</p>
553e5dd7070Spatrick
554e5dd7070Spatrick<p>For convenience, all node matchers take an arbitrary number of arguments
555e5dd7070Spatrickand implicitly act as allOf matchers.</p>
556e5dd7070Spatrick
557e5dd7070Spatrick<p>Node matchers are the only matchers that support the bind("id") call to
558e5dd7070Spatrickbind the matched node to the given string, to be later retrieved from the
559e5dd7070Spatrickmatch callback.</p>
560e5dd7070Spatrick
561e5dd7070Spatrick<p>It is important to remember that the arguments to node matchers are
562e5dd7070Spatrickpredicates on the same node, just with additional information about the type.
563e5dd7070SpatrickThis is often useful to make matcher expression more readable by inlining bind
564e5dd7070Spatrickcalls into redundant node matchers inside another node matcher:
565e5dd7070Spatrick<pre>
566e5dd7070Spatrick// This binds the CXXRecordDecl to "id", as the decl() matcher will stay on
567e5dd7070Spatrick// the same node.
568e5dd7070SpatrickrecordDecl(decl().bind("id"), hasName("::MyClass"))
569e5dd7070Spatrick</pre>
570e5dd7070Spatrick</p>
571e5dd7070Spatrick
572e5dd7070Spatrick<table>
573e5dd7070Spatrick<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
574e5dd7070Spatrick<!-- START_DECL_MATCHERS -->
575e5dd7070Spatrick
576*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>&gt;</td><td class="name" onclick="toggle('attr0')"><a name="attr0Anchor">attr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>&gt;...</td></tr>
577*12c85518Srobert<tr><td colspan="4" class="doc" id="attr0"><pre>Matches attributes.
578*12c85518SrobertAttributes may be attached with a variety of different syntaxes (including
579*12c85518Srobertkeywords, C++11 attributes, GNU ``__attribute``` and MSVC `__declspec``,
580*12c85518Srobertand ``#pragma``s). They may also be implicit.
581*12c85518Srobert
582*12c85518SrobertGiven
583*12c85518Srobert  struct [[nodiscard]] Foo{};
584*12c85518Srobert  void bar(int * __attribute__((nonnull)) );
585*12c85518Srobert  __declspec(noinline) void baz();
586*12c85518Srobert
587*12c85518Srobert  #pragma omp declare simd
588*12c85518Srobert  int min();
589*12c85518Srobertattr()
590*12c85518Srobert  matches "nodiscard", "nonnull", "noinline", and the whole "#pragma" line.
591*12c85518Srobert</pre></td></tr>
592*12c85518Srobert
593*12c85518Srobert
594a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;</td><td class="name" onclick="toggle('cxxBaseSpecifier0')"><a name="cxxBaseSpecifier0Anchor">cxxBaseSpecifier</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;...</td></tr>
595a9ac8606Spatrick<tr><td colspan="4" class="doc" id="cxxBaseSpecifier0"><pre>Matches class bases.
596a9ac8606Spatrick
597a9ac8606SpatrickExamples matches public virtual B.
598a9ac8606Spatrick  class B {};
599a9ac8606Spatrick  class C : public virtual B {};
600a9ac8606Spatrick</pre></td></tr>
601a9ac8606Spatrick
602a9ac8606Spatrick
603e5dd7070Spatrick<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>
604e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxCtorInitializer0"><pre>Matches constructor initializers.
605e5dd7070Spatrick
606e5dd7070SpatrickExamples matches i(42).
607e5dd7070Spatrick  class C {
608e5dd7070Spatrick    C() : i(42) {}
609e5dd7070Spatrick    int i;
610e5dd7070Spatrick  };
611e5dd7070Spatrick</pre></td></tr>
612e5dd7070Spatrick
613e5dd7070Spatrick
614e5dd7070Spatrick<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>
615e5dd7070Spatrick<tr><td colspan="4" class="doc" id="accessSpecDecl0"><pre>Matches C++ access specifier declarations.
616e5dd7070Spatrick
617e5dd7070SpatrickGiven
618e5dd7070Spatrick  class C {
619e5dd7070Spatrick  public:
620e5dd7070Spatrick    int a;
621e5dd7070Spatrick  };
622e5dd7070SpatrickaccessSpecDecl()
623e5dd7070Spatrick  matches 'public:'
624e5dd7070Spatrick</pre></td></tr>
625e5dd7070Spatrick
626e5dd7070Spatrick
627a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('bindingDecl0')"><a name="bindingDecl0Anchor">bindingDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BindingDecl.html">BindingDecl</a>&gt;...</td></tr>
628a9ac8606Spatrick<tr><td colspan="4" class="doc" id="bindingDecl0"><pre>Matches binding declarations
629a9ac8606SpatrickExample matches foo and bar
630a9ac8606Spatrick(matcher = bindingDecl()
631a9ac8606Spatrick
632a9ac8606Spatrick  auto [foo, bar] = std::make_pair{42, 42};
633a9ac8606Spatrick</pre></td></tr>
634a9ac8606Spatrick
635a9ac8606Spatrick
636e5dd7070Spatrick<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>
637e5dd7070Spatrick<tr><td colspan="4" class="doc" id="blockDecl0"><pre>Matches block declarations.
638e5dd7070Spatrick
639e5dd7070SpatrickExample matches the declaration of the nameless block printing an input
640e5dd7070Spatrickinteger.
641e5dd7070Spatrick
642e5dd7070Spatrick  myFunc(^(int p) {
643e5dd7070Spatrick    printf("%d", p);
644e5dd7070Spatrick  })
645e5dd7070Spatrick</pre></td></tr>
646e5dd7070Spatrick
647e5dd7070Spatrick
648e5dd7070Spatrick<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>
649e5dd7070Spatrick<tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations.
650e5dd7070Spatrick
651e5dd7070SpatrickExample matches Z
652e5dd7070Spatrick  template&lt;class T&gt; class Z {};
653e5dd7070Spatrick</pre></td></tr>
654e5dd7070Spatrick
655e5dd7070Spatrick
656e5dd7070Spatrick<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>
657e5dd7070Spatrick<tr><td colspan="4" class="doc" id="classTemplatePartialSpecializationDecl0"><pre>Matches C++ class template partial specializations.
658e5dd7070Spatrick
659e5dd7070SpatrickGiven
660e5dd7070Spatrick  template&lt;class T1, class T2, int I&gt;
661e5dd7070Spatrick  class A {};
662e5dd7070Spatrick
663e5dd7070Spatrick  template&lt;class T, int I&gt;
664e5dd7070Spatrick  class A&lt;T, T*, I&gt; {};
665e5dd7070Spatrick
666e5dd7070Spatrick  template&lt;&gt;
667e5dd7070Spatrick  class A&lt;int, int, 1&gt; {};
668e5dd7070SpatrickclassTemplatePartialSpecializationDecl()
669e5dd7070Spatrick  matches the specialization A&lt;T,T*,I&gt; but not A&lt;int,int,1&gt;
670e5dd7070Spatrick</pre></td></tr>
671e5dd7070Spatrick
672e5dd7070Spatrick
673e5dd7070Spatrick<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>
674e5dd7070Spatrick<tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations.
675e5dd7070Spatrick
676e5dd7070SpatrickGiven
677e5dd7070Spatrick  template&lt;typename T&gt; class A {};
678e5dd7070Spatrick  template&lt;&gt; class A&lt;double&gt; {};
679e5dd7070Spatrick  A&lt;int&gt; a;
680e5dd7070SpatrickclassTemplateSpecializationDecl()
681e5dd7070Spatrick  matches the specializations A&lt;int&gt; and A&lt;double&gt;
682e5dd7070Spatrick</pre></td></tr>
683e5dd7070Spatrick
684e5dd7070Spatrick
685e5dd7070Spatrick<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>
686e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxConstructorDecl0"><pre>Matches C++ constructor declarations.
687e5dd7070Spatrick
688e5dd7070SpatrickExample matches Foo::Foo() and Foo::Foo(int)
689e5dd7070Spatrick  class Foo {
690e5dd7070Spatrick   public:
691e5dd7070Spatrick    Foo();
692e5dd7070Spatrick    Foo(int);
693e5dd7070Spatrick    int DoSomething();
694e5dd7070Spatrick  };
695e5dd7070Spatrick</pre></td></tr>
696e5dd7070Spatrick
697e5dd7070Spatrick
698e5dd7070Spatrick<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>
699e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxConversionDecl0"><pre>Matches conversion operator declarations.
700e5dd7070Spatrick
701e5dd7070SpatrickExample matches the operator.
702e5dd7070Spatrick  class X { operator int() const; };
703e5dd7070Spatrick</pre></td></tr>
704e5dd7070Spatrick
705e5dd7070Spatrick
706e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('cxxDeductionGuideDecl0')"><a name="cxxDeductionGuideDecl0Anchor">cxxDeductionGuideDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDeductionGuideDecl.html">CXXDeductionGuideDecl</a>&gt;...</td></tr>
707e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxDeductionGuideDecl0"><pre>Matches user-defined and implicitly generated deduction guide.
708e5dd7070Spatrick
709e5dd7070SpatrickExample matches the deduction guide.
710e5dd7070Spatrick  template&lt;typename T&gt;
711e5dd7070Spatrick  class X { X(int) };
712e5dd7070Spatrick  X(int) -&gt; X&lt;int&gt;;
713e5dd7070Spatrick</pre></td></tr>
714e5dd7070Spatrick
715e5dd7070Spatrick
716e5dd7070Spatrick<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>
717e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations.
718e5dd7070Spatrick
719e5dd7070SpatrickExample matches Foo::~Foo()
720e5dd7070Spatrick  class Foo {
721e5dd7070Spatrick   public:
722e5dd7070Spatrick    virtual ~Foo();
723e5dd7070Spatrick  };
724e5dd7070Spatrick</pre></td></tr>
725e5dd7070Spatrick
726e5dd7070Spatrick
727e5dd7070Spatrick<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>
728e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxMethodDecl0"><pre>Matches method declarations.
729e5dd7070Spatrick
730e5dd7070SpatrickExample matches y
731e5dd7070Spatrick  class X { void y(); };
732e5dd7070Spatrick</pre></td></tr>
733e5dd7070Spatrick
734e5dd7070Spatrick
735e5dd7070Spatrick<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>
736e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxRecordDecl0"><pre>Matches C++ class declarations.
737e5dd7070Spatrick
738e5dd7070SpatrickExample matches X, Z
739e5dd7070Spatrick  class X;
740e5dd7070Spatrick  template&lt;class T&gt; class Z {};
741e5dd7070Spatrick</pre></td></tr>
742e5dd7070Spatrick
743e5dd7070Spatrick
744e5dd7070Spatrick<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>
745e5dd7070Spatrick<tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations.
746e5dd7070Spatrick
747e5dd7070SpatrickExamples matches X, C, and the friend declaration inside C;
748e5dd7070Spatrick  void X();
749e5dd7070Spatrick  class C {
750e5dd7070Spatrick    friend X;
751e5dd7070Spatrick  };
752e5dd7070Spatrick</pre></td></tr>
753e5dd7070Spatrick
754e5dd7070Spatrick
755e5dd7070Spatrick<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>
756e5dd7070Spatrick<tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function
757e5dd7070Spatrickand non-type template parameter declarations).
758e5dd7070Spatrick
759e5dd7070SpatrickGiven
760e5dd7070Spatrick  class X { int y; };
761e5dd7070SpatrickdeclaratorDecl()
762e5dd7070Spatrick  matches int y.
763e5dd7070Spatrick</pre></td></tr>
764e5dd7070Spatrick
765e5dd7070Spatrick
766a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('decompositionDecl0')"><a name="decompositionDecl0Anchor">decompositionDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DecompositionDecl.html">DecompositionDecl</a>&gt;...</td></tr>
767a9ac8606Spatrick<tr><td colspan="4" class="doc" id="decompositionDecl0"><pre>Matches decomposition-declarations.
768a9ac8606Spatrick
769a9ac8606SpatrickExamples matches the declaration node with foo and bar, but not
770a9ac8606Spatricknumber.
771a9ac8606Spatrick(matcher = declStmt(has(decompositionDecl())))
772a9ac8606Spatrick
773a9ac8606Spatrick  int number = 42;
774a9ac8606Spatrick  auto [foo, bar] = std::make_pair{42, 42};
775a9ac8606Spatrick</pre></td></tr>
776a9ac8606Spatrick
777a9ac8606Spatrick
778e5dd7070Spatrick<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>
779e5dd7070Spatrick<tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants.
780e5dd7070Spatrick
781e5dd7070SpatrickExample matches A, B, C
782e5dd7070Spatrick  enum X {
783e5dd7070Spatrick    A, B, C
784e5dd7070Spatrick  };
785e5dd7070Spatrick</pre></td></tr>
786e5dd7070Spatrick
787e5dd7070Spatrick
788e5dd7070Spatrick<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>
789e5dd7070Spatrick<tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations.
790e5dd7070Spatrick
791e5dd7070SpatrickExample matches X
792e5dd7070Spatrick  enum X {
793e5dd7070Spatrick    A, B, C
794e5dd7070Spatrick  };
795e5dd7070Spatrick</pre></td></tr>
796e5dd7070Spatrick
797e5dd7070Spatrick
798e5dd7070Spatrick<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>
799e5dd7070Spatrick<tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations.
800e5dd7070Spatrick
801e5dd7070SpatrickGiven
802e5dd7070Spatrick  class X { int m; };
803e5dd7070SpatrickfieldDecl()
804e5dd7070Spatrick  matches 'm'.
805e5dd7070Spatrick</pre></td></tr>
806e5dd7070Spatrick
807e5dd7070Spatrick
808e5dd7070Spatrick<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>
809e5dd7070Spatrick<tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations.
810e5dd7070Spatrick
811e5dd7070SpatrickGiven
812e5dd7070Spatrick  class X { friend void foo(); };
813e5dd7070SpatrickfriendDecl()
814e5dd7070Spatrick  matches 'friend void foo()'.
815e5dd7070Spatrick</pre></td></tr>
816e5dd7070Spatrick
817e5dd7070Spatrick
818e5dd7070Spatrick<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>
819e5dd7070Spatrick<tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations.
820e5dd7070Spatrick
821e5dd7070SpatrickExample matches f
822e5dd7070Spatrick  void f();
823e5dd7070Spatrick</pre></td></tr>
824e5dd7070Spatrick
825e5dd7070Spatrick
826e5dd7070Spatrick<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>
827e5dd7070Spatrick<tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations.
828e5dd7070Spatrick
829e5dd7070SpatrickExample matches f
830e5dd7070Spatrick  template&lt;class T&gt; void f(T t) {}
831e5dd7070Spatrick</pre></td></tr>
832e5dd7070Spatrick
833e5dd7070Spatrick
834e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('indirectFieldDecl0')"><a name="indirectFieldDecl0Anchor">indirectFieldDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1IndirectFieldDecl.html">IndirectFieldDecl</a>&gt;...</td></tr>
835e5dd7070Spatrick<tr><td colspan="4" class="doc" id="indirectFieldDecl0"><pre>Matches indirect field declarations.
836e5dd7070Spatrick
837e5dd7070SpatrickGiven
838e5dd7070Spatrick  struct X { struct { int a; }; };
839e5dd7070SpatrickindirectFieldDecl()
840e5dd7070Spatrick  matches 'a'.
841e5dd7070Spatrick</pre></td></tr>
842e5dd7070Spatrick
843e5dd7070Spatrick
844e5dd7070Spatrick<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>
845e5dd7070Spatrick<tr><td colspan="4" class="doc" id="labelDecl0"><pre>Matches a declaration of label.
846e5dd7070Spatrick
847e5dd7070SpatrickGiven
848e5dd7070Spatrick  goto FOO;
849e5dd7070Spatrick  FOO: bar();
850e5dd7070SpatricklabelDecl()
851e5dd7070Spatrick  matches 'FOO:'
852e5dd7070Spatrick</pre></td></tr>
853e5dd7070Spatrick
854e5dd7070Spatrick
855e5dd7070Spatrick<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>
856e5dd7070Spatrick<tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification.
857e5dd7070Spatrick
858e5dd7070SpatrickGiven
859e5dd7070Spatrick  extern "C" {}
860e5dd7070SpatricklinkageSpecDecl()
861e5dd7070Spatrick  matches "extern "C" {}"
862e5dd7070Spatrick</pre></td></tr>
863e5dd7070Spatrick
864e5dd7070Spatrick
865e5dd7070Spatrick<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>
866e5dd7070Spatrick<tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name.
867e5dd7070Spatrick
868e5dd7070SpatrickExample matches X, S, the anonymous union type, i, and U;
869e5dd7070Spatrick  typedef int X;
870e5dd7070Spatrick  struct S {
871e5dd7070Spatrick    union {
872e5dd7070Spatrick      int i;
873e5dd7070Spatrick    } U;
874e5dd7070Spatrick  };
875e5dd7070Spatrick</pre></td></tr>
876e5dd7070Spatrick
877e5dd7070Spatrick
878e5dd7070Spatrick<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>
879e5dd7070Spatrick<tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias.
880e5dd7070Spatrick
881e5dd7070SpatrickGiven
882e5dd7070Spatrick  namespace test {}
883e5dd7070Spatrick  namespace alias = ::test;
884e5dd7070SpatricknamespaceAliasDecl()
885e5dd7070Spatrick  matches "namespace alias" but not "namespace test"
886e5dd7070Spatrick</pre></td></tr>
887e5dd7070Spatrick
888e5dd7070Spatrick
889e5dd7070Spatrick<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>
890e5dd7070Spatrick<tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace.
891e5dd7070Spatrick
892e5dd7070SpatrickGiven
893e5dd7070Spatrick  namespace {}
894e5dd7070Spatrick  namespace test {}
895e5dd7070SpatricknamespaceDecl()
896e5dd7070Spatrick  matches "namespace {}" and "namespace test {}"
897e5dd7070Spatrick</pre></td></tr>
898e5dd7070Spatrick
899e5dd7070Spatrick
900e5dd7070Spatrick<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>
901e5dd7070Spatrick<tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations.
902e5dd7070Spatrick
903e5dd7070SpatrickGiven
904e5dd7070Spatrick  template &lt;typename T, int N&gt; struct C {};
905e5dd7070SpatricknonTypeTemplateParmDecl()
906e5dd7070Spatrick  matches 'N', but not 'T'.
907e5dd7070Spatrick</pre></td></tr>
908e5dd7070Spatrick
909e5dd7070Spatrick
910e5dd7070Spatrick<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>
911e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcCategoryDecl0"><pre>Matches Objective-C category declarations.
912e5dd7070Spatrick
913e5dd7070SpatrickExample matches Foo (Additions)
914e5dd7070Spatrick  @interface Foo (Additions)
915e5dd7070Spatrick  @end
916e5dd7070Spatrick</pre></td></tr>
917e5dd7070Spatrick
918e5dd7070Spatrick
919e5dd7070Spatrick<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>
920e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcCategoryImplDecl0"><pre>Matches Objective-C category definitions.
921e5dd7070Spatrick
922e5dd7070SpatrickExample matches Foo (Additions)
923e5dd7070Spatrick  @implementation Foo (Additions)
924e5dd7070Spatrick  @end
925e5dd7070Spatrick</pre></td></tr>
926e5dd7070Spatrick
927e5dd7070Spatrick
928e5dd7070Spatrick<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>
929e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcImplementationDecl0"><pre>Matches Objective-C implementation declarations.
930e5dd7070Spatrick
931e5dd7070SpatrickExample matches Foo
932e5dd7070Spatrick  @implementation Foo
933e5dd7070Spatrick  @end
934e5dd7070Spatrick</pre></td></tr>
935e5dd7070Spatrick
936e5dd7070Spatrick
937e5dd7070Spatrick<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>
938e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations.
939e5dd7070Spatrick
940e5dd7070SpatrickExample matches Foo
941e5dd7070Spatrick  @interface Foo
942e5dd7070Spatrick  @end
943e5dd7070Spatrick</pre></td></tr>
944e5dd7070Spatrick
945e5dd7070Spatrick
946e5dd7070Spatrick<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>
947e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcIvarDecl0"><pre>Matches Objective-C instance variable declarations.
948e5dd7070Spatrick
949e5dd7070SpatrickExample matches _enabled
950e5dd7070Spatrick  @implementation Foo {
951e5dd7070Spatrick    BOOL _enabled;
952e5dd7070Spatrick  }
953e5dd7070Spatrick  @end
954e5dd7070Spatrick</pre></td></tr>
955e5dd7070Spatrick
956e5dd7070Spatrick
957e5dd7070Spatrick<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>
958e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcMethodDecl0"><pre>Matches Objective-C method declarations.
959e5dd7070Spatrick
960e5dd7070SpatrickExample matches both declaration and definition of -[Foo method]
961e5dd7070Spatrick  @interface Foo
962e5dd7070Spatrick  - (void)method;
963e5dd7070Spatrick  @end
964e5dd7070Spatrick
965e5dd7070Spatrick  @implementation Foo
966e5dd7070Spatrick  - (void)method {}
967e5dd7070Spatrick  @end
968e5dd7070Spatrick</pre></td></tr>
969e5dd7070Spatrick
970e5dd7070Spatrick
971e5dd7070Spatrick<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>
972e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcPropertyDecl0"><pre>Matches Objective-C property declarations.
973e5dd7070Spatrick
974e5dd7070SpatrickExample matches enabled
975e5dd7070Spatrick  @interface Foo
976e5dd7070Spatrick  @property BOOL enabled;
977e5dd7070Spatrick  @end
978e5dd7070Spatrick</pre></td></tr>
979e5dd7070Spatrick
980e5dd7070Spatrick
981e5dd7070Spatrick<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>
982e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcProtocolDecl0"><pre>Matches Objective-C protocol declarations.
983e5dd7070Spatrick
984e5dd7070SpatrickExample matches FooDelegate
985e5dd7070Spatrick  @protocol FooDelegate
986e5dd7070Spatrick  @end
987e5dd7070Spatrick</pre></td></tr>
988e5dd7070Spatrick
989e5dd7070Spatrick
990e5dd7070Spatrick<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>
991e5dd7070Spatrick<tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations.
992e5dd7070Spatrick
993e5dd7070SpatrickGiven
994e5dd7070Spatrick  void f(int x);
995e5dd7070SpatrickparmVarDecl()
996e5dd7070Spatrick  matches int x.
997e5dd7070Spatrick</pre></td></tr>
998e5dd7070Spatrick
999e5dd7070Spatrick
1000e5dd7070Spatrick<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>
1001e5dd7070Spatrick<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations.
1002e5dd7070Spatrick
1003e5dd7070SpatrickExample matches X, Z, U, and S
1004e5dd7070Spatrick  class X;
1005e5dd7070Spatrick  template&lt;class T&gt; class Z {};
1006e5dd7070Spatrick  struct S {};
1007e5dd7070Spatrick  union U {};
1008e5dd7070Spatrick</pre></td></tr>
1009e5dd7070Spatrick
1010e5dd7070Spatrick
1011e5dd7070Spatrick<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>
1012e5dd7070Spatrick<tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration.
1013e5dd7070Spatrick
1014e5dd7070SpatrickExample:
1015*12c85518Srobert  staticAssertDecl()
1016e5dd7070Spatrickmatches
1017e5dd7070Spatrick  static_assert(sizeof(S) == sizeof(int))
1018e5dd7070Spatrickin
1019e5dd7070Spatrick  struct S {
1020e5dd7070Spatrick    int x;
1021e5dd7070Spatrick  };
1022e5dd7070Spatrick  static_assert(sizeof(S) == sizeof(int));
1023e5dd7070Spatrick</pre></td></tr>
1024e5dd7070Spatrick
1025e5dd7070Spatrick
1026ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('tagDecl0')"><a name="tagDecl0Anchor">tagDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;...</td></tr>
1027ec727ea7Spatrick<tr><td colspan="4" class="doc" id="tagDecl0"><pre>Matches tag declarations.
1028ec727ea7Spatrick
1029ec727ea7SpatrickExample matches X, Z, U, S, E
1030ec727ea7Spatrick  class X;
1031ec727ea7Spatrick  template&lt;class T&gt; class Z {};
1032ec727ea7Spatrick  struct S {};
1033ec727ea7Spatrick  union U {};
1034ec727ea7Spatrick  enum E {
1035ec727ea7Spatrick    A, B, C
1036ec727ea7Spatrick  };
1037ec727ea7Spatrick</pre></td></tr>
1038ec727ea7Spatrick
1039ec727ea7Spatrick
1040a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('templateTemplateParmDecl0')"><a name="templateTemplateParmDecl0Anchor">templateTemplateParmDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTemplateParmDecl.html">TemplateTemplateParmDecl</a>&gt;...</td></tr>
1041a9ac8606Spatrick<tr><td colspan="4" class="doc" id="templateTemplateParmDecl0"><pre>Matches template template parameter declarations.
1042a9ac8606Spatrick
1043a9ac8606SpatrickGiven
1044a9ac8606Spatrick  template &lt;template &lt;typename&gt; class Z, int N&gt; struct C {};
1045a9ac8606SpatricktemplateTypeParmDecl()
1046a9ac8606Spatrick  matches 'Z', but not 'N'.
1047a9ac8606Spatrick</pre></td></tr>
1048a9ac8606Spatrick
1049a9ac8606Spatrick
1050e5dd7070Spatrick<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>
1051e5dd7070Spatrick<tr><td colspan="4" class="doc" id="templateTypeParmDecl0"><pre>Matches template type parameter declarations.
1052e5dd7070Spatrick
1053e5dd7070SpatrickGiven
1054e5dd7070Spatrick  template &lt;typename T, int N&gt; struct C {};
1055e5dd7070SpatricktemplateTypeParmDecl()
1056e5dd7070Spatrick  matches 'T', but not 'N'.
1057e5dd7070Spatrick</pre></td></tr>
1058e5dd7070Spatrick
1059e5dd7070Spatrick
1060e5dd7070Spatrick<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>
1061e5dd7070Spatrick<tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context.
1062e5dd7070Spatrick
1063e5dd7070SpatrickGiven
1064e5dd7070Spatrick  int X;
1065e5dd7070Spatrick  namespace NS {
1066e5dd7070Spatrick  int Y;
1067e5dd7070Spatrick  }  // namespace NS
1068e5dd7070Spatrickdecl(hasDeclContext(translationUnitDecl()))
1069e5dd7070Spatrick  matches "int X", but not "int Y".
1070e5dd7070Spatrick</pre></td></tr>
1071e5dd7070Spatrick
1072e5dd7070Spatrick
1073e5dd7070Spatrick<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>
1074e5dd7070Spatrick<tr><td colspan="4" class="doc" id="typeAliasDecl0"><pre>Matches type alias declarations.
1075e5dd7070Spatrick
1076e5dd7070SpatrickGiven
1077e5dd7070Spatrick  typedef int X;
1078e5dd7070Spatrick  using Y = int;
1079e5dd7070SpatricktypeAliasDecl()
1080e5dd7070Spatrick  matches "using Y = int", but not "typedef int X"
1081e5dd7070Spatrick</pre></td></tr>
1082e5dd7070Spatrick
1083e5dd7070Spatrick
1084e5dd7070Spatrick<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>
1085e5dd7070Spatrick<tr><td colspan="4" class="doc" id="typeAliasTemplateDecl0"><pre>Matches type alias template declarations.
1086e5dd7070Spatrick
1087e5dd7070SpatricktypeAliasTemplateDecl() matches
1088e5dd7070Spatrick  template &lt;typename T&gt;
1089e5dd7070Spatrick  using Y = X&lt;T&gt;;
1090e5dd7070Spatrick</pre></td></tr>
1091e5dd7070Spatrick
1092e5dd7070Spatrick
1093e5dd7070Spatrick<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>
1094e5dd7070Spatrick<tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations.
1095e5dd7070Spatrick
1096e5dd7070SpatrickGiven
1097e5dd7070Spatrick  typedef int X;
1098e5dd7070Spatrick  using Y = int;
1099e5dd7070SpatricktypedefDecl()
1100e5dd7070Spatrick  matches "typedef int X", but not "using Y = int"
1101e5dd7070Spatrick</pre></td></tr>
1102e5dd7070Spatrick
1103e5dd7070Spatrick
1104e5dd7070Spatrick<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>
1105e5dd7070Spatrick<tr><td colspan="4" class="doc" id="typedefNameDecl0"><pre>Matches typedef name declarations.
1106e5dd7070Spatrick
1107e5dd7070SpatrickGiven
1108e5dd7070Spatrick  typedef int X;
1109e5dd7070Spatrick  using Y = int;
1110e5dd7070SpatricktypedefNameDecl()
1111e5dd7070Spatrick  matches "typedef int X" and "using Y = int"
1112e5dd7070Spatrick</pre></td></tr>
1113e5dd7070Spatrick
1114e5dd7070Spatrick
1115e5dd7070Spatrick<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>
1116e5dd7070Spatrick<tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the
1117e5dd7070Spatricktypename.
1118e5dd7070Spatrick
1119e5dd7070SpatrickGiven
1120e5dd7070Spatrick  template &lt;typename T&gt;
1121e5dd7070Spatrick  struct Base { typedef T Foo; };
1122e5dd7070Spatrick
1123e5dd7070Spatrick  template&lt;typename T&gt;
1124e5dd7070Spatrick  struct S : private Base&lt;T&gt; {
1125e5dd7070Spatrick    using typename Base&lt;T&gt;::Foo;
1126e5dd7070Spatrick  };
1127e5dd7070SpatrickunresolvedUsingTypenameDecl()
1128e5dd7070Spatrick  matches using Base&lt;T&gt;::Foo </pre></td></tr>
1129e5dd7070Spatrick
1130e5dd7070Spatrick
1131e5dd7070Spatrick<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>
1132e5dd7070Spatrick<tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations.
1133e5dd7070Spatrick
1134e5dd7070SpatrickGiven
1135e5dd7070Spatrick  template&lt;typename X&gt;
1136e5dd7070Spatrick  class C : private X {
1137e5dd7070Spatrick    using X::x;
1138e5dd7070Spatrick  };
1139e5dd7070SpatrickunresolvedUsingValueDecl()
1140e5dd7070Spatrick  matches using X::x </pre></td></tr>
1141e5dd7070Spatrick
1142e5dd7070Spatrick
1143e5dd7070Spatrick<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>
1144e5dd7070Spatrick<tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations.
1145e5dd7070Spatrick
1146e5dd7070SpatrickGiven
1147e5dd7070Spatrick  namespace X { int x; }
1148e5dd7070Spatrick  using X::x;
1149e5dd7070SpatrickusingDecl()
1150e5dd7070Spatrick  matches using X::x </pre></td></tr>
1151e5dd7070Spatrick
1152e5dd7070Spatrick
1153e5dd7070Spatrick<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>
1154e5dd7070Spatrick<tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations.
1155e5dd7070Spatrick
1156e5dd7070SpatrickGiven
1157e5dd7070Spatrick  namespace X { int x; }
1158e5dd7070Spatrick  using namespace X;
1159e5dd7070SpatrickusingDirectiveDecl()
1160e5dd7070Spatrick  matches using namespace X </pre></td></tr>
1161e5dd7070Spatrick
1162e5dd7070Spatrick
1163*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('usingEnumDecl0')"><a name="usingEnumDecl0Anchor">usingEnumDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingEnumDecl.html">UsingEnumDecl</a>&gt;...</td></tr>
1164*12c85518Srobert<tr><td colspan="4" class="doc" id="usingEnumDecl0"><pre>Matches using-enum declarations.
1165*12c85518Srobert
1166*12c85518SrobertGiven
1167*12c85518Srobert  namespace X { enum x {...}; }
1168*12c85518Srobert  using enum X::x;
1169*12c85518SrobertusingEnumDecl()
1170*12c85518Srobert  matches using enum X::x </pre></td></tr>
1171*12c85518Srobert
1172*12c85518Srobert
1173e5dd7070Spatrick<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>
1174e5dd7070Spatrick<tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration.
1175e5dd7070Spatrick
1176e5dd7070SpatrickExample matches A, B, C and F
1177e5dd7070Spatrick  enum X { A, B, C };
1178e5dd7070Spatrick  void F();
1179e5dd7070Spatrick</pre></td></tr>
1180e5dd7070Spatrick
1181e5dd7070Spatrick
1182e5dd7070Spatrick<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>
1183e5dd7070Spatrick<tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations.
1184e5dd7070Spatrick
1185e5dd7070SpatrickNote: this does not match declarations of member variables, which are
1186e5dd7070Spatrick"field" declarations in Clang parlance.
1187e5dd7070Spatrick
1188e5dd7070SpatrickExample matches a
1189e5dd7070Spatrick  int a;
1190e5dd7070Spatrick</pre></td></tr>
1191e5dd7070Spatrick
1192e5dd7070Spatrick
1193*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>&gt;</td><td class="name" onclick="toggle('lambdaCapture0')"><a name="lambdaCapture0Anchor">lambdaCapture</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>&gt;...</td></tr>
1194*12c85518Srobert<tr><td colspan="4" class="doc" id="lambdaCapture0"><pre>Matches lambda captures.
1195*12c85518Srobert
1196*12c85518SrobertGiven
1197*12c85518Srobert  int main() {
1198*12c85518Srobert    int x;
1199*12c85518Srobert    auto f = [x](){};
1200*12c85518Srobert    auto g = [x = 1](){};
1201*12c85518Srobert  }
1202*12c85518SrobertIn the matcher `lambdaExpr(hasAnyCapture(lambdaCapture()))`,
1203*12c85518Srobert`lambdaCapture()` matches `x` and `x=1`.
1204*12c85518Srobert</pre></td></tr>
1205*12c85518Srobert
1206*12c85518Srobert
1207e5dd7070Spatrick<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>
1208e5dd7070Spatrick<tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
1209e5dd7070Spatrick</pre></td></tr>
1210e5dd7070Spatrick
1211e5dd7070Spatrick
1212e5dd7070Spatrick<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>
1213e5dd7070Spatrick<tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers.
1214e5dd7070Spatrick
1215e5dd7070SpatrickGiven
1216e5dd7070Spatrick  namespace ns {
1217e5dd7070Spatrick    struct A { static void f(); };
1218e5dd7070Spatrick    void A::f() {}
1219e5dd7070Spatrick    void g() { A::f(); }
1220e5dd7070Spatrick  }
1221e5dd7070Spatrick  ns::A a;
1222e5dd7070SpatricknestedNameSpecifier()
1223e5dd7070Spatrick  matches "ns::" and both "A::"
1224e5dd7070Spatrick</pre></td></tr>
1225e5dd7070Spatrick
1226e5dd7070Spatrick
1227e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPClause.html">OMPClause</a>&gt;</td><td class="name" onclick="toggle('ompDefaultClause0')"><a name="ompDefaultClause0Anchor">ompDefaultClause</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause</a>&gt;...</td></tr>
1228e5dd7070Spatrick<tr><td colspan="4" class="doc" id="ompDefaultClause0"><pre>Matches OpenMP ``default`` clause.
1229e5dd7070Spatrick
1230e5dd7070SpatrickGiven
1231e5dd7070Spatrick
1232e5dd7070Spatrick  #pragma omp parallel default(none)
1233e5dd7070Spatrick  #pragma omp parallel default(shared)
1234*12c85518Srobert  #pragma omp parallel default(private)
1235ec727ea7Spatrick  #pragma omp parallel default(firstprivate)
1236e5dd7070Spatrick  #pragma omp parallel
1237e5dd7070Spatrick
1238*12c85518Srobert``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``,
1239*12c85518Srobert`` default(private)`` and ``default(firstprivate)``
1240e5dd7070Spatrick</pre></td></tr>
1241e5dd7070Spatrick
1242e5dd7070Spatrick
1243e5dd7070Spatrick<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>
1244e5dd7070Spatrick<tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST.
1245e5dd7070Spatrick</pre></td></tr>
1246e5dd7070Spatrick
1247e5dd7070Spatrick
1248e5dd7070Spatrick<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>
1249e5dd7070Spatrick<tr><td colspan="4" class="doc" id="addrLabelExpr0"><pre>Matches address of label statements (GNU extension).
1250e5dd7070Spatrick
1251e5dd7070SpatrickGiven
1252e5dd7070Spatrick  FOO: bar();
1253e5dd7070Spatrick  void *ptr = &amp;&amp;FOO;
1254e5dd7070Spatrick  goto *bar;
1255e5dd7070SpatrickaddrLabelExpr()
1256e5dd7070Spatrick  matches '&amp;&amp;FOO'
1257e5dd7070Spatrick</pre></td></tr>
1258e5dd7070Spatrick
1259e5dd7070Spatrick
1260e5dd7070Spatrick<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>
1261e5dd7070Spatrick<tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions.
1262e5dd7070Spatrick
1263e5dd7070SpatrickGiven
1264e5dd7070Spatrick  int i = a[1];
1265e5dd7070SpatrickarraySubscriptExpr()
1266e5dd7070Spatrick  matches "a[1]"
1267e5dd7070Spatrick</pre></td></tr>
1268e5dd7070Spatrick
1269e5dd7070Spatrick
1270e5dd7070Spatrick<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>
1271e5dd7070Spatrick<tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements.
1272e5dd7070Spatrick
1273e5dd7070Spatrick int i = 100;
1274e5dd7070Spatrick  __asm("mov al, 2");
1275e5dd7070SpatrickasmStmt()
1276e5dd7070Spatrick  matches '__asm("mov al, 2")'
1277e5dd7070Spatrick</pre></td></tr>
1278e5dd7070Spatrick
1279e5dd7070Spatrick
1280e5dd7070Spatrick<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>
1281e5dd7070Spatrick<tr><td colspan="4" class="doc" id="atomicExpr0"><pre>Matches atomic builtins.
1282e5dd7070SpatrickExample matches __atomic_load_n(ptr, 1)
1283e5dd7070Spatrick  void foo() { int *ptr; __atomic_load_n(ptr, 1); }
1284e5dd7070Spatrick</pre></td></tr>
1285e5dd7070Spatrick
1286e5dd7070Spatrick
1287e5dd7070Spatrick<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>
1288e5dd7070Spatrick<tr><td colspan="4" class="doc" id="autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement.
1289e5dd7070Spatrick
1290e5dd7070SpatrickGiven
1291e5dd7070Spatrick  @autoreleasepool {
1292e5dd7070Spatrick    int x = 0;
1293e5dd7070Spatrick  }
1294e5dd7070SpatrickautoreleasePoolStmt(stmt()) matches the declaration of "x"
1295e5dd7070Spatrickinside the autorelease pool.
1296e5dd7070Spatrick</pre></td></tr>
1297e5dd7070Spatrick
1298e5dd7070Spatrick
1299e5dd7070Spatrick<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>
1300e5dd7070Spatrick<tr><td colspan="4" class="doc" id="binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension).
1301e5dd7070Spatrick
1302e5dd7070SpatrickExample matches a ?: b
1303e5dd7070Spatrick  (a ?: b) + 42;
1304e5dd7070Spatrick</pre></td></tr>
1305e5dd7070Spatrick
1306e5dd7070Spatrick
1307e5dd7070Spatrick<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>
1308e5dd7070Spatrick<tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions.
1309e5dd7070Spatrick
1310e5dd7070SpatrickExample matches a || b
1311e5dd7070Spatrick  !(a || b)
1312a9ac8606SpatrickSee also the binaryOperation() matcher for more-general matching.
1313e5dd7070Spatrick</pre></td></tr>
1314e5dd7070Spatrick
1315e5dd7070Spatrick
1316e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('blockExpr0')"><a name="blockExpr0Anchor">blockExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockExpr.html">BlockExpr</a>&gt;...</td></tr>
1317e5dd7070Spatrick<tr><td colspan="4" class="doc" id="blockExpr0"><pre>Matches a reference to a block.
1318e5dd7070Spatrick
1319e5dd7070SpatrickExample: matches "^{}":
1320e5dd7070Spatrick  void f() { ^{}(); }
1321e5dd7070Spatrick</pre></td></tr>
1322e5dd7070Spatrick
1323e5dd7070Spatrick
1324e5dd7070Spatrick<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>
1325e5dd7070Spatrick<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements.
1326e5dd7070Spatrick
1327e5dd7070SpatrickGiven
1328e5dd7070Spatrick  while (true) { break; }
1329e5dd7070SpatrickbreakStmt()
1330e5dd7070Spatrick  matches 'break'
1331e5dd7070Spatrick</pre></td></tr>
1332e5dd7070Spatrick
1333e5dd7070Spatrick
1334e5dd7070Spatrick<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>
1335e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression.
1336e5dd7070Spatrick
1337e5dd7070SpatrickExample: Matches (int) 2.2f in
1338e5dd7070Spatrick  int i = (int) 2.2f;
1339e5dd7070Spatrick</pre></td></tr>
1340e5dd7070Spatrick
1341e5dd7070Spatrick
1342e5dd7070Spatrick<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>
1343e5dd7070Spatrick<tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions.
1344e5dd7070Spatrick
1345e5dd7070SpatrickExample matches x.y() and y()
1346e5dd7070Spatrick  X x;
1347e5dd7070Spatrick  x.y();
1348e5dd7070Spatrick  y();
1349e5dd7070Spatrick</pre></td></tr>
1350e5dd7070Spatrick
1351e5dd7070Spatrick
1352e5dd7070Spatrick<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>
1353e5dd7070Spatrick<tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements.
1354e5dd7070Spatrick
1355e5dd7070SpatrickGiven
1356e5dd7070Spatrick  switch(a) { case 42: break; default: break; }
1357e5dd7070SpatrickcaseStmt()
1358e5dd7070Spatrick  matches 'case 42:'.
1359e5dd7070Spatrick</pre></td></tr>
1360e5dd7070Spatrick
1361e5dd7070Spatrick
1362e5dd7070Spatrick<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>
1363e5dd7070Spatrick<tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST.
1364e5dd7070Spatrick
1365e5dd7070SpatrickExample: castExpr() matches each of the following:
1366e5dd7070Spatrick  (int) 3;
1367e5dd7070Spatrick  const_cast&lt;Expr *&gt;(SubExpr);
1368e5dd7070Spatrick  char c = 0;
1369e5dd7070Spatrickbut does not match
1370e5dd7070Spatrick  int i = (0);
1371e5dd7070Spatrick  int k = 0;
1372e5dd7070Spatrick</pre></td></tr>
1373e5dd7070Spatrick
1374e5dd7070Spatrick
1375e5dd7070Spatrick<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>
1376e5dd7070Spatrick<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t).
1377e5dd7070Spatrick
1378e5dd7070SpatrickNot matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
1379e5dd7070Spatrickthough.
1380e5dd7070Spatrick
1381e5dd7070SpatrickExample matches 'a', L'a'
1382e5dd7070Spatrick  char ch = 'a';
1383e5dd7070Spatrick  wchar_t chw = L'a';
1384e5dd7070Spatrick</pre></td></tr>
1385e5dd7070Spatrick
1386e5dd7070Spatrick
1387e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('chooseExpr0')"><a name="chooseExpr0Anchor">chooseExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ChooseExpr.html">ChooseExpr</a>&gt;...</td></tr>
1388e5dd7070Spatrick<tr><td colspan="4" class="doc" id="chooseExpr0"><pre>Matches GNU __builtin_choose_expr.
1389e5dd7070Spatrick</pre></td></tr>
1390e5dd7070Spatrick
1391e5dd7070Spatrick
1392a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('coawaitExpr0')"><a name="coawaitExpr0Anchor">coawaitExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CoawaitExpr.html">CoawaitExpr</a>&gt;...</td></tr>
1393a9ac8606Spatrick<tr><td colspan="4" class="doc" id="coawaitExpr0"><pre>Matches co_await expressions.
1394a9ac8606Spatrick
1395a9ac8606SpatrickGiven
1396a9ac8606Spatrick  co_await 1;
1397a9ac8606SpatrickcoawaitExpr()
1398a9ac8606Spatrick  matches 'co_await 1'
1399a9ac8606Spatrick</pre></td></tr>
1400a9ac8606Spatrick
1401a9ac8606Spatrick
1402e5dd7070Spatrick<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>
1403e5dd7070Spatrick<tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals
1404e5dd7070Spatrick
1405e5dd7070SpatrickExample match: {1}, (1, 2)
1406e5dd7070Spatrick  int array[4] = {1};
1407e5dd7070Spatrick  vector int myvec = (vector int)(1, 2);
1408e5dd7070Spatrick</pre></td></tr>
1409e5dd7070Spatrick
1410e5dd7070Spatrick
1411e5dd7070Spatrick<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>
1412e5dd7070Spatrick<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements.
1413e5dd7070Spatrick
1414e5dd7070SpatrickExample matches '{}' and '{{}}' in 'for (;;) {{}}'
1415e5dd7070Spatrick  for (;;) {{}}
1416e5dd7070Spatrick</pre></td></tr>
1417e5dd7070Spatrick
1418e5dd7070Spatrick
1419e5dd7070Spatrick<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>
1420e5dd7070Spatrick<tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions.
1421e5dd7070Spatrick
1422e5dd7070SpatrickExample matches a ? b : c
1423e5dd7070Spatrick  (a ? b : c) + 42
1424e5dd7070Spatrick</pre></td></tr>
1425e5dd7070Spatrick
1426e5dd7070Spatrick
1427e5dd7070Spatrick<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>
1428e5dd7070Spatrick<tr><td colspan="4" class="doc" id="constantExpr0"><pre>Matches a constant expression wrapper.
1429e5dd7070Spatrick
1430e5dd7070SpatrickExample matches the constant in the case statement:
1431e5dd7070Spatrick    (matcher = constantExpr())
1432e5dd7070Spatrick  switch (a) {
1433e5dd7070Spatrick  case 37: break;
1434e5dd7070Spatrick  }
1435e5dd7070Spatrick</pre></td></tr>
1436e5dd7070Spatrick
1437e5dd7070Spatrick
1438e5dd7070Spatrick<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>
1439e5dd7070Spatrick<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements.
1440e5dd7070Spatrick
1441e5dd7070SpatrickGiven
1442e5dd7070Spatrick  while (true) { continue; }
1443e5dd7070SpatrickcontinueStmt()
1444e5dd7070Spatrick  matches 'continue'
1445e5dd7070Spatrick</pre></td></tr>
1446e5dd7070Spatrick
1447e5dd7070Spatrick
1448a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('coreturnStmt0')"><a name="coreturnStmt0Anchor">coreturnStmt</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CoreturnStmt.html">CoreturnStmt</a>&gt;...</td></tr>
1449a9ac8606Spatrick<tr><td colspan="4" class="doc" id="coreturnStmt0"><pre>Matches co_return statements.
1450a9ac8606Spatrick
1451a9ac8606SpatrickGiven
1452a9ac8606Spatrick  while (true) { co_return; }
1453a9ac8606SpatrickcoreturnStmt()
1454a9ac8606Spatrick  matches 'co_return'
1455a9ac8606Spatrick</pre></td></tr>
1456a9ac8606Spatrick
1457a9ac8606Spatrick
1458a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('coyieldExpr0')"><a name="coyieldExpr0Anchor">coyieldExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CoyieldExpr.html">CoyieldExpr</a>&gt;...</td></tr>
1459a9ac8606Spatrick<tr><td colspan="4" class="doc" id="coyieldExpr0"><pre>Matches co_yield expressions.
1460a9ac8606Spatrick
1461a9ac8606SpatrickGiven
1462a9ac8606Spatrick  co_yield 1;
1463a9ac8606SpatrickcoyieldExpr()
1464a9ac8606Spatrick  matches 'co_yield 1'
1465a9ac8606Spatrick</pre></td></tr>
1466a9ac8606Spatrick
1467a9ac8606Spatrick
1468e5dd7070Spatrick<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>
1469e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression.
1470e5dd7070Spatrick
1471e5dd7070SpatrickExample matches,
1472e5dd7070Spatrick  kernel&lt;&lt;&lt;i,j&gt;&gt;&gt;();
1473e5dd7070Spatrick</pre></td></tr>
1474e5dd7070Spatrick
1475e5dd7070Spatrick
1476e5dd7070Spatrick<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>
1477e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created.
1478e5dd7070Spatrick
1479e5dd7070SpatrickExample matches FunctionTakesString(GetStringByValue())
1480e5dd7070Spatrick    (matcher = cxxBindTemporaryExpr())
1481e5dd7070Spatrick  FunctionTakesString(GetStringByValue());
1482e5dd7070Spatrick  FunctionTakesStringByPointer(GetStringPointer());
1483e5dd7070Spatrick</pre></td></tr>
1484e5dd7070Spatrick
1485e5dd7070Spatrick
1486e5dd7070Spatrick<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>
1487e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals.
1488e5dd7070Spatrick
1489e5dd7070SpatrickExample matches true
1490e5dd7070Spatrick  true
1491e5dd7070Spatrick</pre></td></tr>
1492e5dd7070Spatrick
1493e5dd7070Spatrick
1494e5dd7070Spatrick<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>
1495e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements.
1496e5dd7070Spatrick
1497e5dd7070Spatrick  try {} catch(int i) {}
1498e5dd7070SpatrickcxxCatchStmt()
1499e5dd7070Spatrick  matches 'catch(int i)'
1500e5dd7070Spatrick</pre></td></tr>
1501e5dd7070Spatrick
1502e5dd7070Spatrick
1503e5dd7070Spatrick<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>
1504e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression.
1505e5dd7070Spatrick
1506e5dd7070SpatrickExample: Matches const_cast&lt;int*&gt;(&amp;r) in
1507e5dd7070Spatrick  int n = 42;
1508e5dd7070Spatrick  const int &amp;r(n);
1509e5dd7070Spatrick  int* p = const_cast&lt;int*&gt;(&amp;r);
1510e5dd7070Spatrick</pre></td></tr>
1511e5dd7070Spatrick
1512e5dd7070Spatrick
1513e5dd7070Spatrick<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>
1514e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones).
1515e5dd7070Spatrick
1516e5dd7070SpatrickExample matches string(ptr, n) and ptr within arguments of f
1517e5dd7070Spatrick    (matcher = cxxConstructExpr())
1518e5dd7070Spatrick  void f(const string &amp;a, const string &amp;b);
1519e5dd7070Spatrick  char *ptr;
1520e5dd7070Spatrick  int n;
1521e5dd7070Spatrick  f(string(ptr, n), ptr);
1522e5dd7070Spatrick</pre></td></tr>
1523e5dd7070Spatrick
1524e5dd7070Spatrick
1525e5dd7070Spatrick<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>
1526e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site.
1527e5dd7070Spatrick
1528e5dd7070SpatrickExample matches the CXXDefaultArgExpr placeholder inserted for the
1529e5dd7070Spatrick    default value of the second parameter in the call expression f(42)
1530e5dd7070Spatrick    (matcher = cxxDefaultArgExpr())
1531e5dd7070Spatrick  void f(int x, int y = 0);
1532e5dd7070Spatrick  f(42);
1533e5dd7070Spatrick</pre></td></tr>
1534e5dd7070Spatrick
1535e5dd7070Spatrick
1536e5dd7070Spatrick<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>
1537e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions.
1538e5dd7070Spatrick
1539e5dd7070SpatrickGiven
1540e5dd7070Spatrick  delete X;
1541e5dd7070SpatrickcxxDeleteExpr()
1542e5dd7070Spatrick  matches 'delete X'.
1543e5dd7070Spatrick</pre></td></tr>
1544e5dd7070Spatrick
1545e5dd7070Spatrick
1546e5dd7070Spatrick<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>
1547e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be
1548e5dd7070Spatrickresolved because the base expression or the member name was dependent.
1549e5dd7070Spatrick
1550e5dd7070SpatrickGiven
1551e5dd7070Spatrick  template &lt;class T&gt; void f() { T t; t.g(); }
1552e5dd7070SpatrickcxxDependentScopeMemberExpr()
1553e5dd7070Spatrick  matches t.g
1554e5dd7070Spatrick</pre></td></tr>
1555e5dd7070Spatrick
1556e5dd7070Spatrick
1557e5dd7070Spatrick<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>
1558e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression.
1559e5dd7070Spatrick
1560e5dd7070SpatrickExample:
1561e5dd7070Spatrick  cxxDynamicCastExpr()
1562e5dd7070Spatrickmatches
1563e5dd7070Spatrick  dynamic_cast&lt;D*&gt;(&amp;b);
1564e5dd7070Spatrickin
1565e5dd7070Spatrick  struct B { virtual ~B() {} }; struct D : B {};
1566e5dd7070Spatrick  B b;
1567e5dd7070Spatrick  D* p = dynamic_cast&lt;D*&gt;(&amp;b);
1568e5dd7070Spatrick</pre></td></tr>
1569e5dd7070Spatrick
1570e5dd7070Spatrick
1571e5dd7070Spatrick<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>
1572e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements.
1573e5dd7070Spatrick
1574e5dd7070SpatrickcxxForRangeStmt() matches 'for (auto a : i)'
1575e5dd7070Spatrick  int i[] =  {1, 2, 3}; for (auto a : i);
1576e5dd7070Spatrick  for(int j = 0; j &lt; 5; ++j);
1577e5dd7070Spatrick</pre></td></tr>
1578e5dd7070Spatrick
1579e5dd7070Spatrick
1580e5dd7070Spatrick<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>
1581e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions
1582e5dd7070Spatrick
1583e5dd7070SpatrickExample: Matches Foo(bar);
1584e5dd7070Spatrick  Foo f = bar;
1585e5dd7070Spatrick  Foo g = (Foo) bar;
1586e5dd7070Spatrick  Foo h = Foo(bar);
1587e5dd7070Spatrick</pre></td></tr>
1588e5dd7070Spatrick
1589e5dd7070Spatrick
1590e5dd7070Spatrick<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>
1591e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions.
1592e5dd7070Spatrick
1593e5dd7070SpatrickExample matches x.y()
1594e5dd7070Spatrick  X x;
1595e5dd7070Spatrick  x.y();
1596e5dd7070Spatrick</pre></td></tr>
1597e5dd7070Spatrick
1598e5dd7070Spatrick
1599e5dd7070Spatrick<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>
1600e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions.
1601e5dd7070Spatrick
1602e5dd7070SpatrickGiven
1603e5dd7070Spatrick  new X;
1604e5dd7070SpatrickcxxNewExpr()
1605e5dd7070Spatrick  matches 'new X'.
1606e5dd7070Spatrick</pre></td></tr>
1607e5dd7070Spatrick
1608e5dd7070Spatrick
1609ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxNoexceptExpr0')"><a name="cxxNoexceptExpr0Anchor">cxxNoexceptExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNoexceptExpr.html">CXXNoexceptExpr</a>&gt;...</td></tr>
1610ec727ea7Spatrick<tr><td colspan="4" class="doc" id="cxxNoexceptExpr0"><pre>Matches noexcept expressions.
1611ec727ea7Spatrick
1612ec727ea7SpatrickGiven
1613ec727ea7Spatrick  bool a() noexcept;
1614ec727ea7Spatrick  bool b() noexcept(true);
1615ec727ea7Spatrick  bool c() noexcept(false);
1616ec727ea7Spatrick  bool d() noexcept(noexcept(a()));
1617ec727ea7Spatrick  bool e = noexcept(b()) || noexcept(c());
1618ec727ea7SpatrickcxxNoexceptExpr()
1619ec727ea7Spatrick  matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`.
1620ec727ea7Spatrick  doesn't match the noexcept specifier in the declarations a, b, c or d.
1621ec727ea7Spatrick</pre></td></tr>
1622ec727ea7Spatrick
1623ec727ea7Spatrick
1624e5dd7070Spatrick<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>
1625e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal.
1626e5dd7070Spatrick</pre></td></tr>
1627e5dd7070Spatrick
1628e5dd7070Spatrick
1629e5dd7070Spatrick<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>
1630e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls.
1631e5dd7070Spatrick
1632e5dd7070SpatrickNote that if an operator isn't overloaded, it won't match. Instead, use
1633e5dd7070SpatrickbinaryOperator matcher.
1634e5dd7070SpatrickCurrently it does not match operators such as new delete.
1635e5dd7070SpatrickFIXME: figure out why these do not match?
1636e5dd7070Spatrick
1637e5dd7070SpatrickExample matches both operator&lt;&lt;((o &lt;&lt; b), c) and operator&lt;&lt;(o, b)
1638e5dd7070Spatrick    (matcher = cxxOperatorCallExpr())
1639e5dd7070Spatrick  ostream &amp;operator&lt;&lt; (ostream &amp;out, int i) { };
1640e5dd7070Spatrick  ostream &amp;o; int b = 1, c = 1;
1641e5dd7070Spatrick  o &lt;&lt; b &lt;&lt; c;
1642a9ac8606SpatrickSee also the binaryOperation() matcher for more-general matching of binary
1643a9ac8606Spatrickuses of this AST node.
1644e5dd7070Spatrick</pre></td></tr>
1645e5dd7070Spatrick
1646e5dd7070Spatrick
1647e5dd7070Spatrick<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>
1648e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression.
1649e5dd7070Spatrick
1650e5dd7070SpatrickEither the source expression or the destination type can be matched
1651e5dd7070Spatrickusing has(), but hasDestinationType() is more specific and can be
1652e5dd7070Spatrickmore readable.
1653e5dd7070Spatrick
1654e5dd7070SpatrickExample matches reinterpret_cast&lt;char*&gt;(&amp;p) in
1655e5dd7070Spatrick  void* p = reinterpret_cast&lt;char*&gt;(&amp;p);
1656e5dd7070Spatrick</pre></td></tr>
1657e5dd7070Spatrick
1658e5dd7070Spatrick
1659a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxRewrittenBinaryOperator0')"><a name="cxxRewrittenBinaryOperator0Anchor">cxxRewrittenBinaryOperator</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>&gt;...</td></tr>
1660a9ac8606Spatrick<tr><td colspan="4" class="doc" id="cxxRewrittenBinaryOperator0"><pre>Matches rewritten binary operators
1661a9ac8606Spatrick
1662a9ac8606SpatrickExample matches use of "&lt;":
1663a9ac8606Spatrick  #include &lt;compare&gt;
1664a9ac8606Spatrick  struct HasSpaceshipMem {
1665a9ac8606Spatrick    int a;
1666a9ac8606Spatrick    constexpr auto operator&lt;=&gt;(const HasSpaceshipMem&amp;) const = default;
1667a9ac8606Spatrick  };
1668a9ac8606Spatrick  void compare() {
1669a9ac8606Spatrick    HasSpaceshipMem hs1, hs2;
1670a9ac8606Spatrick    if (hs1 &lt; hs2)
1671a9ac8606Spatrick        return;
1672a9ac8606Spatrick  }
1673a9ac8606SpatrickSee also the binaryOperation() matcher for more-general matching
1674a9ac8606Spatrickof this AST node.
1675a9ac8606Spatrick</pre></td></tr>
1676a9ac8606Spatrick
1677a9ac8606Spatrick
1678e5dd7070Spatrick<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>
1679e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression.
1680e5dd7070Spatrick
1681e5dd7070SpatrickSee also: hasDestinationType
1682e5dd7070SpatrickSee also: reinterpretCast
1683e5dd7070Spatrick
1684e5dd7070SpatrickExample:
1685e5dd7070Spatrick  cxxStaticCastExpr()
1686e5dd7070Spatrickmatches
1687e5dd7070Spatrick  static_cast&lt;long&gt;(8)
1688e5dd7070Spatrickin
1689e5dd7070Spatrick  long eight(static_cast&lt;long&gt;(8));
1690e5dd7070Spatrick</pre></td></tr>
1691e5dd7070Spatrick
1692e5dd7070Spatrick
1693e5dd7070Spatrick<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>
1694e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions.
1695e5dd7070Spatrick
1696e5dd7070SpatrickGiven
1697e5dd7070Spatrick  std::vector&lt;int&gt; a({ 1, 2, 3 });
1698e5dd7070Spatrick  std::vector&lt;int&gt; b = { 4, 5 };
1699e5dd7070Spatrick  int c[] = { 6, 7 };
1700e5dd7070Spatrick  std::pair&lt;int, int&gt; d = { 8, 9 };
1701e5dd7070SpatrickcxxStdInitializerListExpr()
1702e5dd7070Spatrick  matches "{ 1, 2, 3 }" and "{ 4, 5 }"
1703e5dd7070Spatrick</pre></td></tr>
1704e5dd7070Spatrick
1705e5dd7070Spatrick
1706e5dd7070Spatrick<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>
1707e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments
1708e5dd7070Spatrick
1709e5dd7070SpatrickExample: Matches Foo(bar, bar)
1710e5dd7070Spatrick  Foo h = Foo(bar, bar);
1711e5dd7070Spatrick</pre></td></tr>
1712e5dd7070Spatrick
1713e5dd7070Spatrick
1714e5dd7070Spatrick<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>
1715e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions.
1716e5dd7070Spatrick
1717e5dd7070SpatrickExample matches the implicit this expression in "return i".
1718e5dd7070Spatrick    (matcher = cxxThisExpr())
1719e5dd7070Spatrickstruct foo {
1720e5dd7070Spatrick  int i;
1721e5dd7070Spatrick  int f() { return i; }
1722e5dd7070Spatrick};
1723e5dd7070Spatrick</pre></td></tr>
1724e5dd7070Spatrick
1725e5dd7070Spatrick
1726e5dd7070Spatrick<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>
1727e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions.
1728e5dd7070Spatrick
1729e5dd7070Spatrick  try { throw 5; } catch(int i) {}
1730e5dd7070SpatrickcxxThrowExpr()
1731e5dd7070Spatrick  matches 'throw 5'
1732e5dd7070Spatrick</pre></td></tr>
1733e5dd7070Spatrick
1734e5dd7070Spatrick
1735e5dd7070Spatrick<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>
1736e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements.
1737e5dd7070Spatrick
1738e5dd7070Spatrick  try {} catch(int i) {}
1739e5dd7070SpatrickcxxTryStmt()
1740e5dd7070Spatrick  matches 'try {}'
1741e5dd7070Spatrick</pre></td></tr>
1742e5dd7070Spatrick
1743e5dd7070Spatrick
1744e5dd7070Spatrick<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>
1745e5dd7070Spatrick<tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions.
1746e5dd7070Spatrick
1747e5dd7070SpatrickExample matches T(t) in return statement of f
1748e5dd7070Spatrick    (matcher = cxxUnresolvedConstructExpr())
1749e5dd7070Spatrick  template &lt;typename T&gt;
1750e5dd7070Spatrick  void f(const T&amp; t) { return T(t); }
1751e5dd7070Spatrick</pre></td></tr>
1752e5dd7070Spatrick
1753e5dd7070Spatrick
1754e5dd7070Spatrick<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>
1755e5dd7070Spatrick<tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations.
1756e5dd7070Spatrick
1757e5dd7070SpatrickExample matches x in if (x)
1758e5dd7070Spatrick  bool x;
1759e5dd7070Spatrick  if (x) {}
1760e5dd7070Spatrick</pre></td></tr>
1761e5dd7070Spatrick
1762e5dd7070Spatrick
1763e5dd7070Spatrick<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>
1764e5dd7070Spatrick<tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements.
1765e5dd7070Spatrick
1766e5dd7070SpatrickGiven
1767e5dd7070Spatrick  int a;
1768e5dd7070SpatrickdeclStmt()
1769e5dd7070Spatrick  matches 'int a'.
1770e5dd7070Spatrick</pre></td></tr>
1771e5dd7070Spatrick
1772e5dd7070Spatrick
1773e5dd7070Spatrick<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>
1774e5dd7070Spatrick<tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements.
1775e5dd7070Spatrick
1776e5dd7070SpatrickGiven
1777e5dd7070Spatrick  switch(a) { case 42: break; default: break; }
1778e5dd7070SpatrickdefaultStmt()
1779e5dd7070Spatrick  matches 'default:'.
1780e5dd7070Spatrick</pre></td></tr>
1781e5dd7070Spatrick
1782e5dd7070Spatrick
1783a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('dependentCoawaitExpr0')"><a name="dependentCoawaitExpr0Anchor">dependentCoawaitExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentCoawaitExpr.html">DependentCoawaitExpr</a>&gt;...</td></tr>
1784a9ac8606Spatrick<tr><td colspan="4" class="doc" id="dependentCoawaitExpr0"><pre>Matches co_await expressions where the type of the promise is dependent
1785a9ac8606Spatrick</pre></td></tr>
1786a9ac8606Spatrick
1787a9ac8606Spatrick
1788e5dd7070Spatrick<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>
1789e5dd7070Spatrick<tr><td colspan="4" class="doc" id="designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99 6.7.8].
1790e5dd7070Spatrick
1791e5dd7070SpatrickExample: Matches { [2].y = 1.0, [0].x = 1.0 }
1792e5dd7070Spatrick  point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
1793e5dd7070Spatrick</pre></td></tr>
1794e5dd7070Spatrick
1795e5dd7070Spatrick
1796e5dd7070Spatrick<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>
1797e5dd7070Spatrick<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements.
1798e5dd7070Spatrick
1799e5dd7070SpatrickGiven
1800e5dd7070Spatrick  do {} while (true);
1801e5dd7070SpatrickdoStmt()
1802e5dd7070Spatrick  matches 'do {} while(true)'
1803e5dd7070Spatrick</pre></td></tr>
1804e5dd7070Spatrick
1805e5dd7070Spatrick
1806e5dd7070Spatrick<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>
1807e5dd7070Spatrick<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions.
1808e5dd7070Spatrick
1809e5dd7070SpatrickMatches any cast expression written in user code, whether it be a
1810e5dd7070SpatrickC-style cast, a functional-style cast, or a keyword cast.
1811e5dd7070Spatrick
1812e5dd7070SpatrickDoes not match implicit conversions.
1813e5dd7070Spatrick
1814e5dd7070SpatrickNote: the name "explicitCast" is chosen to match Clang's terminology, as
1815e5dd7070SpatrickClang uses the term "cast" to apply to implicit conversions as well as to
1816e5dd7070Spatrickactual cast expressions.
1817e5dd7070Spatrick
1818e5dd7070SpatrickSee also: hasDestinationType.
1819e5dd7070Spatrick
1820e5dd7070SpatrickExample: matches all five of the casts in
1821e5dd7070Spatrick  int((int)(reinterpret_cast&lt;int&gt;(static_cast&lt;int&gt;(const_cast&lt;int&gt;(42)))))
1822e5dd7070Spatrickbut does not match the implicit conversion in
1823e5dd7070Spatrick  long ell = 42;
1824e5dd7070Spatrick</pre></td></tr>
1825e5dd7070Spatrick
1826e5dd7070Spatrick
1827e5dd7070Spatrick<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>
1828e5dd7070Spatrick<tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions.
1829e5dd7070Spatrick
1830e5dd7070SpatrickExample matches x()
1831e5dd7070Spatrick  void f() { x(); }
1832e5dd7070Spatrick</pre></td></tr>
1833e5dd7070Spatrick
1834e5dd7070Spatrick
1835e5dd7070Spatrick<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>
1836e5dd7070Spatrick<tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end
1837e5dd7070Spatrickof the sub-expression's evaluation.
1838e5dd7070Spatrick
1839e5dd7070SpatrickExample matches std::string()
1840e5dd7070Spatrick  const std::string str = std::string();
1841e5dd7070Spatrick</pre></td></tr>
1842e5dd7070Spatrick
1843e5dd7070Spatrick
1844ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('fixedPointLiteral0')"><a name="fixedPointLiteral0Anchor">fixedPointLiteral</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FixedPointLiteral.html">FixedPointLiteral</a>&gt;...</td></tr>
1845ec727ea7Spatrick<tr><td colspan="4" class="doc" id="fixedPointLiteral0"><pre>Matches fixed point literals
1846ec727ea7Spatrick</pre></td></tr>
1847ec727ea7Spatrick
1848ec727ea7Spatrick
1849e5dd7070Spatrick<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>
1850e5dd7070Spatrick<tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes / encodings, e.g.
1851e5dd7070Spatrick1.0, 1.0f, 1.0L and 1e10.
1852e5dd7070Spatrick
1853e5dd7070SpatrickDoes not match implicit conversions such as
1854e5dd7070Spatrick  float a = 10;
1855e5dd7070Spatrick</pre></td></tr>
1856e5dd7070Spatrick
1857e5dd7070Spatrick
1858e5dd7070Spatrick<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>
1859e5dd7070Spatrick<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements.
1860e5dd7070Spatrick
1861e5dd7070SpatrickExample matches 'for (;;) {}'
1862e5dd7070Spatrick  for (;;) {}
1863e5dd7070Spatrick  int i[] =  {1, 2, 3}; for (auto a : i);
1864e5dd7070Spatrick</pre></td></tr>
1865e5dd7070Spatrick
1866e5dd7070Spatrick
1867a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('genericSelectionExpr0')"><a name="genericSelectionExpr0Anchor">genericSelectionExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1GenericSelectionExpr.html">GenericSelectionExpr</a>&gt;...</td></tr>
1868a9ac8606Spatrick<tr><td colspan="4" class="doc" id="genericSelectionExpr0"><pre>Matches C11 _Generic expression.
1869a9ac8606Spatrick</pre></td></tr>
1870a9ac8606Spatrick
1871a9ac8606Spatrick
1872e5dd7070Spatrick<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>
1873e5dd7070Spatrick<tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression.
1874e5dd7070Spatrick</pre></td></tr>
1875e5dd7070Spatrick
1876e5dd7070Spatrick
1877e5dd7070Spatrick<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>
1878e5dd7070Spatrick<tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements.
1879e5dd7070Spatrick
1880e5dd7070SpatrickGiven
1881e5dd7070Spatrick  goto FOO;
1882e5dd7070Spatrick  FOO: bar();
1883e5dd7070SpatrickgotoStmt()
1884e5dd7070Spatrick  matches 'goto FOO'
1885e5dd7070Spatrick</pre></td></tr>
1886e5dd7070Spatrick
1887e5dd7070Spatrick
1888e5dd7070Spatrick<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>
1889e5dd7070Spatrick<tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements.
1890e5dd7070Spatrick
1891e5dd7070SpatrickExample matches 'if (x) {}'
1892e5dd7070Spatrick  if (x) {}
1893e5dd7070Spatrick</pre></td></tr>
1894e5dd7070Spatrick
1895e5dd7070Spatrick
1896e5dd7070Spatrick<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>
1897e5dd7070Spatrick<tr><td colspan="4" class="doc" id="imaginaryLiteral0"><pre>Matches imaginary literals, which are based on integer and floating
1898e5dd7070Spatrickpoint literals e.g.: 1i, 1.0i
1899e5dd7070Spatrick</pre></td></tr>
1900e5dd7070Spatrick
1901e5dd7070Spatrick
1902e5dd7070Spatrick<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>
1903e5dd7070Spatrick<tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST.
1904e5dd7070Spatrick
1905e5dd7070SpatrickThis matches many different places, including function call return value
1906e5dd7070Spatrickeliding, as well as any type conversions.
1907e5dd7070Spatrick</pre></td></tr>
1908e5dd7070Spatrick
1909e5dd7070Spatrick
1910e5dd7070Spatrick<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>
1911e5dd7070Spatrick<tr><td colspan="4" class="doc" id="implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions.
1912e5dd7070Spatrick
1913e5dd7070SpatrickGiven
1914e5dd7070Spatrick  point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 };
1915e5dd7070SpatrickimplicitValueInitExpr()
1916e5dd7070Spatrick  matches "[0].y" (implicitly)
1917e5dd7070Spatrick</pre></td></tr>
1918e5dd7070Spatrick
1919e5dd7070Spatrick
1920e5dd7070Spatrick<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>
1921e5dd7070Spatrick<tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions.
1922e5dd7070Spatrick
1923e5dd7070SpatrickGiven
1924e5dd7070Spatrick  int a[] = { 1, 2 };
1925e5dd7070Spatrick  struct B { int x, y; };
1926e5dd7070Spatrick  B b = { 5, 6 };
1927e5dd7070SpatrickinitListExpr()
1928e5dd7070Spatrick  matches "{ 1, 2 }" and "{ 5, 6 }"
1929e5dd7070Spatrick</pre></td></tr>
1930e5dd7070Spatrick
1931e5dd7070Spatrick
1932e5dd7070Spatrick<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>
1933e5dd7070Spatrick<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes / encodings, e.g.
1934e5dd7070Spatrick1, 1L, 0x1 and 1U.
1935e5dd7070Spatrick
1936e5dd7070SpatrickDoes not match character-encoded integers such as L'a'.
1937e5dd7070Spatrick</pre></td></tr>
1938e5dd7070Spatrick
1939e5dd7070Spatrick
1940e5dd7070Spatrick<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>
1941e5dd7070Spatrick<tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements.
1942e5dd7070Spatrick
1943e5dd7070SpatrickGiven
1944e5dd7070Spatrick  goto FOO;
1945e5dd7070Spatrick  FOO: bar();
1946e5dd7070SpatricklabelStmt()
1947e5dd7070Spatrick  matches 'FOO:'
1948e5dd7070Spatrick</pre></td></tr>
1949e5dd7070Spatrick
1950e5dd7070Spatrick
1951e5dd7070Spatrick<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>
1952e5dd7070Spatrick<tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions.
1953e5dd7070Spatrick
1954e5dd7070SpatrickExample matches [&amp;](){return 5;}
1955e5dd7070Spatrick  [&amp;](){return 5;}
1956e5dd7070Spatrick</pre></td></tr>
1957e5dd7070Spatrick
1958e5dd7070Spatrick
1959e5dd7070Spatrick<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>
1960e5dd7070Spatrick<tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized.
1961e5dd7070Spatrick
1962e5dd7070SpatrickExample: Given
1963e5dd7070Spatrick  struct T {void func();};
1964e5dd7070Spatrick  T f();
1965e5dd7070Spatrick  void g(T);
1966e5dd7070SpatrickmaterializeTemporaryExpr() matches 'f()' in these statements
1967e5dd7070Spatrick  T u(f());
1968e5dd7070Spatrick  g(f());
1969e5dd7070Spatrick  f().func();
1970e5dd7070Spatrickbut does not match
1971e5dd7070Spatrick  f();
1972e5dd7070Spatrick</pre></td></tr>
1973e5dd7070Spatrick
1974e5dd7070Spatrick
1975e5dd7070Spatrick<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>
1976e5dd7070Spatrick<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions.
1977e5dd7070Spatrick
1978e5dd7070SpatrickGiven
1979e5dd7070Spatrick  class Y {
1980e5dd7070Spatrick    void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
1981e5dd7070Spatrick    int a; static int b;
1982e5dd7070Spatrick  };
1983e5dd7070SpatrickmemberExpr()
1984e5dd7070Spatrick  matches this-&gt;x, x, y.x, a, this-&gt;b
1985e5dd7070Spatrick</pre></td></tr>
1986e5dd7070Spatrick
1987e5dd7070Spatrick
1988e5dd7070Spatrick<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>
1989e5dd7070Spatrick<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements.
1990e5dd7070Spatrick
1991e5dd7070Spatrick  foo();;
1992e5dd7070SpatricknullStmt()
1993e5dd7070Spatrick  matches the second ';'
1994e5dd7070Spatrick</pre></td></tr>
1995e5dd7070Spatrick
1996e5dd7070Spatrick
1997e5dd7070Spatrick<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>
1998e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcCatchStmt0"><pre>Matches Objective-C @catch statements.
1999e5dd7070Spatrick
2000e5dd7070SpatrickExample matches @catch
2001e5dd7070Spatrick  @try {}
2002e5dd7070Spatrick  @catch (...) {}
2003e5dd7070Spatrick</pre></td></tr>
2004e5dd7070Spatrick
2005e5dd7070Spatrick
2006e5dd7070Spatrick<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>
2007e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcFinallyStmt0"><pre>Matches Objective-C @finally statements.
2008e5dd7070Spatrick
2009e5dd7070SpatrickExample matches @finally
2010e5dd7070Spatrick  @try {}
2011e5dd7070Spatrick  @finally {}
2012e5dd7070Spatrick</pre></td></tr>
2013e5dd7070Spatrick
2014e5dd7070Spatrick
2015e5dd7070Spatrick<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>
2016e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar.
2017e5dd7070Spatrick
2018e5dd7070SpatrickExample: matches "a" in "init" method:
2019e5dd7070Spatrick@implementation A {
2020e5dd7070Spatrick  NSString *a;
2021e5dd7070Spatrick}
2022e5dd7070Spatrick- (void) init {
2023e5dd7070Spatrick  a = @"hello";
2024e5dd7070Spatrick}
2025e5dd7070Spatrick</pre></td></tr>
2026e5dd7070Spatrick
2027e5dd7070Spatrick
2028e5dd7070Spatrick<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>
2029e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions.
2030e5dd7070Spatrick
2031e5dd7070SpatrickThe innermost message send invokes the "alloc" class method on the
2032e5dd7070SpatrickNSString class, while the outermost message send invokes the
2033e5dd7070Spatrick"initWithString" instance method on the object returned from
2034e5dd7070SpatrickNSString's "alloc". This matcher should match both message sends.
2035e5dd7070Spatrick  [[NSString alloc] initWithString:@"Hello"]
2036e5dd7070Spatrick</pre></td></tr>
2037e5dd7070Spatrick
2038e5dd7070Spatrick
2039*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('objcStringLiteral0')"><a name="objcStringLiteral0Anchor">objcStringLiteral</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCStringLiteral.html">ObjCStringLiteral</a>&gt;...</td></tr>
2040*12c85518Srobert<tr><td colspan="4" class="doc" id="objcStringLiteral0"><pre>Matches ObjectiveC String literal expressions.
2041*12c85518Srobert
2042*12c85518SrobertExample matches @"abcd"
2043*12c85518Srobert  NSString *s = @"abcd";
2044*12c85518Srobert</pre></td></tr>
2045*12c85518Srobert
2046*12c85518Srobert
2047e5dd7070Spatrick<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>
2048e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcThrowStmt0"><pre>Matches Objective-C statements.
2049e5dd7070Spatrick
2050e5dd7070SpatrickExample matches @throw obj;
2051e5dd7070Spatrick</pre></td></tr>
2052e5dd7070Spatrick
2053e5dd7070Spatrick
2054e5dd7070Spatrick<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>
2055e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcTryStmt0"><pre>Matches Objective-C @try statements.
2056e5dd7070Spatrick
2057e5dd7070SpatrickExample matches @try
2058e5dd7070Spatrick  @try {}
2059e5dd7070Spatrick  @catch (...) {}
2060e5dd7070Spatrick</pre></td></tr>
2061e5dd7070Spatrick
2062e5dd7070Spatrick
2063e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('ompExecutableDirective0')"><a name="ompExecutableDirective0Anchor">ompExecutableDirective</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html">OMPExecutableDirective</a>&gt;...</td></tr>
2064e5dd7070Spatrick<tr><td colspan="4" class="doc" id="ompExecutableDirective0"><pre>Matches any ``#pragma omp`` executable directive.
2065e5dd7070Spatrick
2066e5dd7070SpatrickGiven
2067e5dd7070Spatrick
2068e5dd7070Spatrick  #pragma omp parallel
2069e5dd7070Spatrick  #pragma omp parallel default(none)
2070e5dd7070Spatrick  #pragma omp taskyield
2071e5dd7070Spatrick
2072e5dd7070Spatrick``ompExecutableDirective()`` matches ``omp parallel``,
2073e5dd7070Spatrick``omp parallel default(none)`` and ``omp taskyield``.
2074e5dd7070Spatrick</pre></td></tr>
2075e5dd7070Spatrick
2076e5dd7070Spatrick
2077e5dd7070Spatrick<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>
2078e5dd7070Spatrick<tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers
2079e5dd7070Spatrickto reference another expressions and can be met
2080e5dd7070Spatrickin BinaryConditionalOperators, for example.
2081e5dd7070Spatrick
2082e5dd7070SpatrickExample matches 'a'
2083e5dd7070Spatrick  (a ?: c) + 42;
2084e5dd7070Spatrick</pre></td></tr>
2085e5dd7070Spatrick
2086e5dd7070Spatrick
2087e5dd7070Spatrick<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>
2088e5dd7070Spatrick<tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions.
2089e5dd7070Spatrick
2090e5dd7070SpatrickExample matches (foo() + 1)
2091e5dd7070Spatrick  int foo() { return 1; }
2092e5dd7070Spatrick  int a = (foo() + 1);
2093e5dd7070Spatrick</pre></td></tr>
2094e5dd7070Spatrick
2095e5dd7070Spatrick
2096e5dd7070Spatrick<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>
2097e5dd7070Spatrick<tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions.
2098e5dd7070SpatrickParenListExprs don't have a predefined type and are used for late parsing.
2099e5dd7070SpatrickIn the final AST, they can be met in template declarations.
2100e5dd7070Spatrick
2101e5dd7070SpatrickGiven
2102e5dd7070Spatrick  template&lt;typename T&gt; class X {
2103e5dd7070Spatrick    void f() {
2104e5dd7070Spatrick      X x(*this);
2105e5dd7070Spatrick      int a = 0, b = 1; int i = (a, b);
2106e5dd7070Spatrick    }
2107e5dd7070Spatrick  };
2108e5dd7070SpatrickparenListExpr() matches "*this" but NOT matches (a, b) because (a, b)
2109e5dd7070Spatrickhas a predefined type and is a ParenExpr, not a ParenListExpr.
2110e5dd7070Spatrick</pre></td></tr>
2111e5dd7070Spatrick
2112e5dd7070Spatrick
2113e5dd7070Spatrick<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>
2114e5dd7070Spatrick<tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2].
2115e5dd7070Spatrick
2116e5dd7070SpatrickExample: Matches __func__
2117e5dd7070Spatrick  printf("%s", __func__);
2118e5dd7070Spatrick</pre></td></tr>
2119e5dd7070Spatrick
2120e5dd7070Spatrick
2121e5dd7070Spatrick<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>
2122e5dd7070Spatrick<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements.
2123e5dd7070Spatrick
2124e5dd7070SpatrickGiven
2125e5dd7070Spatrick  return 1;
2126e5dd7070SpatrickreturnStmt()
2127e5dd7070Spatrick  matches 'return 1'
2128e5dd7070Spatrick</pre></td></tr>
2129e5dd7070Spatrick
2130e5dd7070Spatrick
2131e5dd7070Spatrick<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>
2132e5dd7070Spatrick<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements.
2133e5dd7070Spatrick
2134e5dd7070SpatrickGiven
2135e5dd7070Spatrick  { ++a; }
2136e5dd7070Spatrickstmt()
2137e5dd7070Spatrick  matches both the compound statement '{ ++a; }' and '++a'.
2138e5dd7070Spatrick</pre></td></tr>
2139e5dd7070Spatrick
2140e5dd7070Spatrick
2141e5dd7070Spatrick<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>
2142e5dd7070Spatrick<tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension).
2143e5dd7070Spatrick
2144e5dd7070SpatrickExample match: ({ int X = 4; X; })
2145e5dd7070Spatrick  int C = ({ int X = 4; X; });
2146e5dd7070Spatrick</pre></td></tr>
2147e5dd7070Spatrick
2148e5dd7070Spatrick
2149e5dd7070Spatrick<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>
2150e5dd7070Spatrick<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals).
2151e5dd7070Spatrick
2152e5dd7070SpatrickExample matches "abcd", L"abcd"
2153e5dd7070Spatrick  char *s = "abcd";
2154e5dd7070Spatrick  wchar_t *ws = L"abcd";
2155e5dd7070Spatrick</pre></td></tr>
2156e5dd7070Spatrick
2157e5dd7070Spatrick
2158e5dd7070Spatrick<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>
2159e5dd7070Spatrick<tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters.
2160e5dd7070Spatrick
2161e5dd7070SpatrickGiven
2162e5dd7070Spatrick  template &lt;int N&gt;
2163e5dd7070Spatrick  struct A { static const int n = N; };
2164e5dd7070Spatrick  struct B : public A&lt;42&gt; {};
2165e5dd7070SpatricksubstNonTypeTemplateParmExpr()
2166e5dd7070Spatrick  matches "N" in the right-hand side of "static const int n = N;"
2167e5dd7070Spatrick</pre></td></tr>
2168e5dd7070Spatrick
2169e5dd7070Spatrick
2170e5dd7070Spatrick<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>
2171e5dd7070Spatrick<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements.
2172e5dd7070Spatrick
2173e5dd7070SpatrickGiven
2174e5dd7070Spatrick  switch(a) { case 42: break; default: break; }
2175e5dd7070SpatrickswitchCase()
2176e5dd7070Spatrick  matches 'case 42:' and 'default:'.
2177e5dd7070Spatrick</pre></td></tr>
2178e5dd7070Spatrick
2179e5dd7070Spatrick
2180e5dd7070Spatrick<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>
2181e5dd7070Spatrick<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements.
2182e5dd7070Spatrick
2183e5dd7070SpatrickGiven
2184e5dd7070Spatrick  switch(a) { case 42: break; default: break; }
2185e5dd7070SpatrickswitchStmt()
2186e5dd7070Spatrick  matches 'switch(a)'.
2187e5dd7070Spatrick</pre></td></tr>
2188e5dd7070Spatrick
2189e5dd7070Spatrick
2190e5dd7070Spatrick<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>
2191e5dd7070Spatrick<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
2192e5dd7070Spatrick
2193e5dd7070SpatrickGiven
2194e5dd7070Spatrick  Foo x = bar;
2195e5dd7070Spatrick  int y = sizeof(x) + alignof(x);
2196e5dd7070SpatrickunaryExprOrTypeTraitExpr()
2197e5dd7070Spatrick  matches sizeof(x) and alignof(x)
2198e5dd7070Spatrick</pre></td></tr>
2199e5dd7070Spatrick
2200e5dd7070Spatrick
2201e5dd7070Spatrick<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>
2202e5dd7070Spatrick<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions.
2203e5dd7070Spatrick
2204e5dd7070SpatrickExample matches !a
2205e5dd7070Spatrick  !a || b
2206e5dd7070Spatrick</pre></td></tr>
2207e5dd7070Spatrick
2208e5dd7070Spatrick
2209e5dd7070Spatrick<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>
2210e5dd7070Spatrick<tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing
2211e5dd7070Spatrickbut could not be resolved to a specific declaration.
2212e5dd7070Spatrick
2213e5dd7070SpatrickGiven
2214e5dd7070Spatrick  template&lt;typename T&gt;
2215e5dd7070Spatrick  T foo() { T a; return a; }
2216e5dd7070Spatrick  template&lt;typename T&gt;
2217e5dd7070Spatrick  void bar() {
2218e5dd7070Spatrick    foo&lt;T&gt;();
2219e5dd7070Spatrick  }
2220e5dd7070SpatrickunresolvedLookupExpr()
2221e5dd7070Spatrick  matches foo&lt;T&gt;() </pre></td></tr>
2222e5dd7070Spatrick
2223e5dd7070Spatrick
2224e5dd7070Spatrick<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>
2225e5dd7070Spatrick<tr><td colspan="4" class="doc" id="unresolvedMemberExpr0"><pre>Matches unresolved member expressions.
2226e5dd7070Spatrick
2227e5dd7070SpatrickGiven
2228e5dd7070Spatrick  struct X {
2229e5dd7070Spatrick    template &lt;class T&gt; void f();
2230e5dd7070Spatrick    void g();
2231e5dd7070Spatrick  };
2232e5dd7070Spatrick  template &lt;class T&gt; void h() { X x; x.f&lt;T&gt;(); x.g(); }
2233e5dd7070SpatrickunresolvedMemberExpr()
2234e5dd7070Spatrick  matches x.f&lt;T&gt;
2235e5dd7070Spatrick</pre></td></tr>
2236e5dd7070Spatrick
2237e5dd7070Spatrick
2238e5dd7070Spatrick<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>
2239e5dd7070Spatrick<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call.
2240e5dd7070Spatrick
2241e5dd7070SpatrickExample match: "foo"_suffix
2242e5dd7070Spatrick</pre></td></tr>
2243e5dd7070Spatrick
2244e5dd7070Spatrick
2245e5dd7070Spatrick<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>
2246e5dd7070Spatrick<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements.
2247e5dd7070Spatrick
2248e5dd7070SpatrickGiven
2249e5dd7070Spatrick  while (true) {}
2250e5dd7070SpatrickwhileStmt()
2251e5dd7070Spatrick  matches 'while (true) {}'.
2252e5dd7070Spatrick</pre></td></tr>
2253e5dd7070Spatrick
2254e5dd7070Spatrick
2255a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;</td><td class="name" onclick="toggle('templateArgumentLoc0')"><a name="templateArgumentLoc0Anchor">templateArgumentLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;...</td></tr>
2256a9ac8606Spatrick<tr><td colspan="4" class="doc" id="templateArgumentLoc0"><pre>Matches template arguments (with location info).
2257a9ac8606Spatrick
2258a9ac8606SpatrickGiven
2259a9ac8606Spatrick  template &lt;typename T&gt; struct C {};
2260a9ac8606Spatrick  C&lt;int&gt; c;
2261a9ac8606SpatricktemplateArgumentLoc()
2262a9ac8606Spatrick  matches 'int' in C&lt;int&gt;.
2263a9ac8606Spatrick</pre></td></tr>
2264a9ac8606Spatrick
2265a9ac8606Spatrick
2266e5dd7070Spatrick<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>
2267e5dd7070Spatrick<tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments.
2268e5dd7070Spatrick
2269e5dd7070SpatrickGiven
2270e5dd7070Spatrick  template &lt;typename T&gt; struct C {};
2271e5dd7070Spatrick  C&lt;int&gt; c;
2272e5dd7070SpatricktemplateArgument()
2273e5dd7070Spatrick  matches 'int' in C&lt;int&gt;.
2274e5dd7070Spatrick</pre></td></tr>
2275e5dd7070Spatrick
2276e5dd7070Spatrick
2277e5dd7070Spatrick<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>
2278e5dd7070Spatrick<tr><td colspan="4" class="doc" id="templateName0"><pre>Matches template name.
2279e5dd7070Spatrick
2280e5dd7070SpatrickGiven
2281e5dd7070Spatrick  template &lt;typename T&gt; class X { };
2282e5dd7070Spatrick  X&lt;int&gt; xi;
2283e5dd7070SpatricktemplateName()
2284e5dd7070Spatrick  matches 'X' in X&lt;int&gt;.
2285e5dd7070Spatrick</pre></td></tr>
2286e5dd7070Spatrick
2287e5dd7070Spatrick
2288*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('elaboratedTypeLoc0')"><a name="elaboratedTypeLoc0Anchor">elaboratedTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ElaboratedTypeLoc.html">ElaboratedTypeLoc</a>&gt;...</td></tr>
2289*12c85518Srobert<tr><td colspan="4" class="doc" id="elaboratedTypeLoc0"><pre>Matches C or C++ elaborated `TypeLoc`s.
2290*12c85518Srobert
2291*12c85518SrobertGiven
2292*12c85518Srobert  struct s {};
2293*12c85518Srobert  struct s ss;
2294*12c85518SrobertelaboratedTypeLoc()
2295*12c85518Srobert  matches the `TypeLoc` of the variable declaration of `ss`.
2296*12c85518Srobert</pre></td></tr>
2297*12c85518Srobert
2298*12c85518Srobert
2299*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('pointerTypeLoc0')"><a name="pointerTypeLoc0Anchor">pointerTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>&gt;...</td></tr>
2300*12c85518Srobert<tr><td colspan="4" class="doc" id="pointerTypeLoc0"><pre>Matches pointer `TypeLoc`s.
2301*12c85518Srobert
2302*12c85518SrobertGiven
2303*12c85518Srobert  int* x;
2304*12c85518SrobertpointerTypeLoc()
2305*12c85518Srobert  matches `int*`.
2306*12c85518Srobert</pre></td></tr>
2307*12c85518Srobert
2308*12c85518Srobert
2309*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('qualifiedTypeLoc0')"><a name="qualifiedTypeLoc0Anchor">qualifiedTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualifiedTypeLoc.html">QualifiedTypeLoc</a>&gt;...</td></tr>
2310*12c85518Srobert<tr><td colspan="4" class="doc" id="qualifiedTypeLoc0"><pre>Matches `QualifiedTypeLoc`s in the clang AST.
2311*12c85518Srobert
2312*12c85518SrobertGiven
2313*12c85518Srobert  const int x = 0;
2314*12c85518SrobertqualifiedTypeLoc()
2315*12c85518Srobert  matches `const int`.
2316*12c85518Srobert</pre></td></tr>
2317*12c85518Srobert
2318*12c85518Srobert
2319*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('referenceTypeLoc0')"><a name="referenceTypeLoc0Anchor">referenceTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>&gt;...</td></tr>
2320*12c85518Srobert<tr><td colspan="4" class="doc" id="referenceTypeLoc0"><pre>Matches reference `TypeLoc`s.
2321*12c85518Srobert
2322*12c85518SrobertGiven
2323*12c85518Srobert  int x = 3;
2324*12c85518Srobert  int&amp; l = x;
2325*12c85518Srobert  int&amp;&amp; r = 3;
2326*12c85518SrobertreferenceTypeLoc()
2327*12c85518Srobert  matches `int&amp;` and `int&amp;&amp;`.
2328*12c85518Srobert</pre></td></tr>
2329*12c85518Srobert
2330*12c85518Srobert
2331*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('templateSpecializationTypeLoc0')"><a name="templateSpecializationTypeLoc0Anchor">templateSpecializationTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>&gt;...</td></tr>
2332*12c85518Srobert<tr><td colspan="4" class="doc" id="templateSpecializationTypeLoc0"><pre>Matches template specialization `TypeLoc`s.
2333*12c85518Srobert
2334*12c85518SrobertGiven
2335*12c85518Srobert  template &lt;typename T&gt; class C {};
2336*12c85518Srobert  C&lt;char&gt; var;
2337*12c85518SrobertvarDecl(hasTypeLoc(templateSpecializationTypeLoc(typeLoc())))
2338*12c85518Srobert  matches `C&lt;char&gt; var`.
2339*12c85518Srobert</pre></td></tr>
2340*12c85518Srobert
2341*12c85518Srobert
2342e5dd7070Spatrick<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>
2343e5dd7070Spatrick<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST.
2344e5dd7070Spatrick</pre></td></tr>
2345e5dd7070Spatrick
2346e5dd7070Spatrick
2347e5dd7070Spatrick<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>
2348e5dd7070Spatrick<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays.
2349e5dd7070Spatrick
2350e5dd7070SpatrickGiven
2351e5dd7070Spatrick  int a[] = { 2, 3 };
2352e5dd7070Spatrick  int b[4];
2353e5dd7070Spatrick  void f() { int c[a[0]]; }
2354e5dd7070SpatrickarrayType()
2355e5dd7070Spatrick  matches "int a[]", "int b[4]" and "int c[a[0]]";
2356e5dd7070Spatrick</pre></td></tr>
2357e5dd7070Spatrick
2358e5dd7070Spatrick
2359e5dd7070Spatrick<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>
2360e5dd7070Spatrick<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types.
2361e5dd7070Spatrick
2362e5dd7070SpatrickGiven
2363e5dd7070Spatrick  _Atomic(int) i;
2364e5dd7070SpatrickatomicType()
2365e5dd7070Spatrick  matches "_Atomic(int) i"
2366e5dd7070Spatrick</pre></td></tr>
2367e5dd7070Spatrick
2368e5dd7070Spatrick
2369e5dd7070Spatrick<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>
2370e5dd7070Spatrick<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types.
2371e5dd7070Spatrick
2372e5dd7070SpatrickGiven:
2373e5dd7070Spatrick  auto n = 4;
2374e5dd7070Spatrick  int v[] = { 2, 3 }
2375e5dd7070Spatrick  for (auto i : v) { }
2376e5dd7070SpatrickautoType()
2377e5dd7070Spatrick  matches "auto n" and "auto i"
2378e5dd7070Spatrick</pre></td></tr>
2379e5dd7070Spatrick
2380e5dd7070Spatrick
2381e5dd7070Spatrick<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>
2382e5dd7070Spatrick<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as
2383e5dd7070Spatrick"void (^)(int)".
2384e5dd7070Spatrick
2385e5dd7070SpatrickThe pointee is always required to be a FunctionType.
2386e5dd7070Spatrick</pre></td></tr>
2387e5dd7070Spatrick
2388e5dd7070Spatrick
2389e5dd7070Spatrick<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>
2390e5dd7070Spatrick<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types.
2391e5dd7070Spatrick
2392e5dd7070SpatrickGiven
2393e5dd7070Spatrick  struct A {};
2394e5dd7070Spatrick  A a;
2395e5dd7070Spatrick  int b;
2396e5dd7070Spatrick  float c;
2397e5dd7070Spatrick  bool d;
2398e5dd7070SpatrickbuiltinType()
2399e5dd7070Spatrick  matches "int b", "float c" and "bool d"
2400e5dd7070Spatrick</pre></td></tr>
2401e5dd7070Spatrick
2402e5dd7070Spatrick
2403e5dd7070Spatrick<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>
2404e5dd7070Spatrick<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types.
2405e5dd7070Spatrick
2406e5dd7070SpatrickGiven
2407e5dd7070Spatrick  _Complex float f;
2408e5dd7070SpatrickcomplexType()
2409e5dd7070Spatrick  matches "_Complex float f"
2410e5dd7070Spatrick</pre></td></tr>
2411e5dd7070Spatrick
2412e5dd7070Spatrick
2413e5dd7070Spatrick<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>
2414e5dd7070Spatrick<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size.
2415e5dd7070Spatrick
2416e5dd7070SpatrickGiven
2417e5dd7070Spatrick  void() {
2418e5dd7070Spatrick    int a[2];
2419e5dd7070Spatrick    int b[] = { 2, 3 };
2420e5dd7070Spatrick    int c[b[0]];
2421e5dd7070Spatrick  }
2422e5dd7070SpatrickconstantArrayType()
2423e5dd7070Spatrick  matches "int a[2]"
2424e5dd7070Spatrick</pre></td></tr>
2425e5dd7070Spatrick
2426e5dd7070Spatrick
2427e5dd7070Spatrick<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>
2428e5dd7070Spatrick<tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type
2429e5dd7070SpatrickExample matches i[] in declaration of f.
2430e5dd7070Spatrick    (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
2431e5dd7070SpatrickExample matches i[1].
2432e5dd7070Spatrick    (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())))))
2433e5dd7070Spatrick  void f(int i[]) {
2434e5dd7070Spatrick    i[1] = 0;
2435e5dd7070Spatrick  }
2436e5dd7070Spatrick</pre></td></tr>
2437e5dd7070Spatrick
2438e5dd7070Spatrick
2439e5dd7070Spatrick<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>
2440e5dd7070Spatrick<tr><td colspan="4" class="doc" id="decltypeType0"><pre>Matches types nodes representing C++11 decltype(&lt;expr&gt;) types.
2441e5dd7070Spatrick
2442e5dd7070SpatrickGiven:
2443e5dd7070Spatrick  short i = 1;
2444e5dd7070Spatrick  int j = 42;
2445e5dd7070Spatrick  decltype(i + j) result = i + j;
2446e5dd7070SpatrickdecltypeType()
2447e5dd7070Spatrick  matches "decltype(i + j)"
2448e5dd7070Spatrick</pre></td></tr>
2449e5dd7070Spatrick
2450e5dd7070Spatrick
2451ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('deducedTemplateSpecializationType0')"><a name="deducedTemplateSpecializationType0Anchor">deducedTemplateSpecializationType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeducedTemplateSpecializationType.html">DeducedTemplateSpecializationType</a>&gt;...</td></tr>
2452ec727ea7Spatrick<tr><td colspan="4" class="doc" id="deducedTemplateSpecializationType0"><pre>Matches C++17 deduced template specialization types, e.g. deduced class
2453ec727ea7Spatricktemplate types.
2454ec727ea7Spatrick
2455ec727ea7SpatrickGiven
2456ec727ea7Spatrick  template &lt;typename T&gt;
2457ec727ea7Spatrick  class C { public: C(T); };
2458ec727ea7Spatrick
2459ec727ea7Spatrick  C c(123);
2460ec727ea7SpatrickdeducedTemplateSpecializationType() matches the type in the declaration
2461ec727ea7Spatrickof the variable c.
2462ec727ea7Spatrick</pre></td></tr>
2463ec727ea7Spatrick
2464ec727ea7Spatrick
2465e5dd7070Spatrick<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>
2466e5dd7070Spatrick<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression.
2467e5dd7070Spatrick
2468e5dd7070SpatrickGiven
2469e5dd7070Spatrick  template&lt;typename T, int Size&gt;
2470e5dd7070Spatrick  class array {
2471e5dd7070Spatrick    T data[Size];
2472e5dd7070Spatrick  };
2473e5dd7070SpatrickdependentSizedArrayType
2474e5dd7070Spatrick  matches "T data[Size]"
2475e5dd7070Spatrick</pre></td></tr>
2476e5dd7070Spatrick
2477e5dd7070Spatrick
2478e5dd7070Spatrick<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>
2479e5dd7070Spatrick<tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a
2480e5dd7070Spatrickqualified name.
2481e5dd7070Spatrick
2482e5dd7070SpatrickGiven
2483e5dd7070Spatrick  namespace N {
2484e5dd7070Spatrick    namespace M {
2485e5dd7070Spatrick      class D {};
2486e5dd7070Spatrick    }
2487e5dd7070Spatrick  }
2488e5dd7070Spatrick  class C {};
2489e5dd7070Spatrick
2490e5dd7070Spatrick  class C c;
2491e5dd7070Spatrick  N::M::D d;
2492e5dd7070Spatrick
2493e5dd7070SpatrickelaboratedType() matches the type of the variable declarations of both
2494e5dd7070Spatrickc and d.
2495e5dd7070Spatrick</pre></td></tr>
2496e5dd7070Spatrick
2497e5dd7070Spatrick
2498e5dd7070Spatrick<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>
2499e5dd7070Spatrick<tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types.
2500e5dd7070Spatrick
2501e5dd7070SpatrickGiven
2502e5dd7070Spatrick  enum C { Green };
2503e5dd7070Spatrick  enum class S { Red };
2504e5dd7070Spatrick
2505e5dd7070Spatrick  C c;
2506e5dd7070Spatrick  S s;
2507e5dd7070Spatrick
2508e5dd7070SpatrickenumType() matches the type of the variable declarations of both c and
2509e5dd7070Spatricks.
2510e5dd7070Spatrick</pre></td></tr>
2511e5dd7070Spatrick
2512e5dd7070Spatrick
2513e5dd7070Spatrick<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>
2514e5dd7070Spatrick<tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes.
2515e5dd7070Spatrick
2516e5dd7070SpatrickGiven
2517e5dd7070Spatrick  int (*f)(int);
2518e5dd7070Spatrick  void g();
2519e5dd7070SpatrickfunctionProtoType()
2520e5dd7070Spatrick  matches "int (*f)(int)" and the type of "g" in C++ mode.
2521e5dd7070Spatrick  In C mode, "g" is not matched because it does not contain a prototype.
2522e5dd7070Spatrick</pre></td></tr>
2523e5dd7070Spatrick
2524e5dd7070Spatrick
2525e5dd7070Spatrick<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>
2526e5dd7070Spatrick<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes.
2527e5dd7070Spatrick
2528e5dd7070SpatrickGiven
2529e5dd7070Spatrick  int (*f)(int);
2530e5dd7070Spatrick  void g();
2531e5dd7070SpatrickfunctionType()
2532e5dd7070Spatrick  matches "int (*f)(int)" and the type of "g".
2533e5dd7070Spatrick</pre></td></tr>
2534e5dd7070Spatrick
2535e5dd7070Spatrick
2536e5dd7070Spatrick<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>
2537e5dd7070Spatrick<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size.
2538e5dd7070Spatrick
2539e5dd7070SpatrickGiven
2540e5dd7070Spatrick  int a[] = { 2, 3 };
2541e5dd7070Spatrick  int b[42];
2542e5dd7070Spatrick  void f(int c[]) { int d[a[0]]; };
2543e5dd7070SpatrickincompleteArrayType()
2544e5dd7070Spatrick  matches "int a[]" and "int c[]"
2545e5dd7070Spatrick</pre></td></tr>
2546e5dd7070Spatrick
2547e5dd7070Spatrick
2548e5dd7070Spatrick<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>
2549e5dd7070Spatrick<tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types.
2550e5dd7070Spatrick
2551e5dd7070SpatrickExample matches S s, but not S&lt;T&gt; s.
2552e5dd7070Spatrick    (matcher = parmVarDecl(hasType(injectedClassNameType())))
2553e5dd7070Spatrick  template &lt;typename T&gt; struct S {
2554e5dd7070Spatrick    void f(S s);
2555e5dd7070Spatrick    void g(S&lt;T&gt; s);
2556e5dd7070Spatrick  };
2557e5dd7070Spatrick</pre></td></tr>
2558e5dd7070Spatrick
2559e5dd7070Spatrick
2560e5dd7070Spatrick<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>
2561e5dd7070Spatrick<tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types.
2562e5dd7070Spatrick
2563e5dd7070SpatrickGiven:
2564e5dd7070Spatrick  int *a;
2565e5dd7070Spatrick  int &amp;b = *a;
2566e5dd7070Spatrick  int &amp;&amp;c = 1;
2567e5dd7070Spatrick  auto &amp;d = b;
2568e5dd7070Spatrick  auto &amp;&amp;e = c;
2569e5dd7070Spatrick  auto &amp;&amp;f = 2;
2570e5dd7070Spatrick  int g = 5;
2571e5dd7070Spatrick
2572e5dd7070SpatricklValueReferenceType() matches the types of b, d, and e. e is
2573e5dd7070Spatrickmatched since the type is deduced as int&amp; by reference collapsing rules.
2574e5dd7070Spatrick</pre></td></tr>
2575e5dd7070Spatrick
2576e5dd7070Spatrick
2577e5dd7070Spatrick<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>
2578e5dd7070Spatrick<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types.
2579e5dd7070SpatrickGiven
2580e5dd7070Spatrick  struct A { int i; }
2581e5dd7070Spatrick  A::* ptr = A::i;
2582e5dd7070SpatrickmemberPointerType()
2583e5dd7070Spatrick  matches "A::* ptr"
2584e5dd7070Spatrick</pre></td></tr>
2585e5dd7070Spatrick
2586e5dd7070Spatrick
2587e5dd7070Spatrick<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>
2588e5dd7070Spatrick<tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from
2589e5dd7070Spatricka pointer type, despite being syntactically similar.
2590e5dd7070Spatrick
2591e5dd7070SpatrickGiven
2592e5dd7070Spatrick  int *a;
2593e5dd7070Spatrick
2594e5dd7070Spatrick  @interface Foo
2595e5dd7070Spatrick  @end
2596e5dd7070Spatrick  Foo *f;
2597e5dd7070SpatrickpointerType()
2598e5dd7070Spatrick  matches "Foo *f", but does not match "int *a".
2599e5dd7070Spatrick</pre></td></tr>
2600e5dd7070Spatrick
2601e5dd7070Spatrick
2602e5dd7070Spatrick<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>
2603e5dd7070Spatrick<tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes.
2604e5dd7070Spatrick
2605e5dd7070SpatrickGiven
2606e5dd7070Spatrick  int (*ptr_to_array)[4];
2607e5dd7070Spatrick  int *array_of_ptrs[4];
2608e5dd7070Spatrick
2609e5dd7070SpatrickvarDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not
2610e5dd7070Spatrickarray_of_ptrs.
2611e5dd7070Spatrick</pre></td></tr>
2612e5dd7070Spatrick
2613e5dd7070Spatrick
2614e5dd7070Spatrick<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>
2615e5dd7070Spatrick<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer
2616e5dd7070Spatricktypes.
2617e5dd7070Spatrick
2618e5dd7070SpatrickGiven
2619e5dd7070Spatrick  int *a;
2620e5dd7070Spatrick  int &amp;b = *a;
2621e5dd7070Spatrick  int c = 5;
2622e5dd7070Spatrick
2623e5dd7070Spatrick  @interface Foo
2624e5dd7070Spatrick  @end
2625e5dd7070Spatrick  Foo *f;
2626e5dd7070SpatrickpointerType()
2627e5dd7070Spatrick  matches "int *a", but does not match "Foo *f".
2628e5dd7070Spatrick</pre></td></tr>
2629e5dd7070Spatrick
2630e5dd7070Spatrick
2631e5dd7070Spatrick<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>
2632e5dd7070Spatrick<tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types.
2633e5dd7070Spatrick
2634e5dd7070SpatrickGiven:
2635e5dd7070Spatrick  int *a;
2636e5dd7070Spatrick  int &amp;b = *a;
2637e5dd7070Spatrick  int &amp;&amp;c = 1;
2638e5dd7070Spatrick  auto &amp;d = b;
2639e5dd7070Spatrick  auto &amp;&amp;e = c;
2640e5dd7070Spatrick  auto &amp;&amp;f = 2;
2641e5dd7070Spatrick  int g = 5;
2642e5dd7070Spatrick
2643e5dd7070SpatrickrValueReferenceType() matches the types of c and f. e is not
2644e5dd7070Spatrickmatched as it is deduced to int&amp; by reference collapsing rules.
2645e5dd7070Spatrick</pre></td></tr>
2646e5dd7070Spatrick
2647e5dd7070Spatrick
2648e5dd7070Spatrick<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>
2649e5dd7070Spatrick<tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes).
2650e5dd7070Spatrick
2651e5dd7070SpatrickGiven
2652e5dd7070Spatrick  class C {};
2653e5dd7070Spatrick  struct S {};
2654e5dd7070Spatrick
2655e5dd7070Spatrick  C c;
2656e5dd7070Spatrick  S s;
2657e5dd7070Spatrick
2658e5dd7070SpatrickrecordType() matches the type of the variable declarations of both c
2659e5dd7070Spatrickand s.
2660e5dd7070Spatrick</pre></td></tr>
2661e5dd7070Spatrick
2662e5dd7070Spatrick
2663e5dd7070Spatrick<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>
2664e5dd7070Spatrick<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types.
2665e5dd7070Spatrick
2666e5dd7070SpatrickGiven
2667e5dd7070Spatrick  int *a;
2668e5dd7070Spatrick  int &amp;b = *a;
2669e5dd7070Spatrick  int &amp;&amp;c = 1;
2670e5dd7070Spatrick  auto &amp;d = b;
2671e5dd7070Spatrick  auto &amp;&amp;e = c;
2672e5dd7070Spatrick  auto &amp;&amp;f = 2;
2673e5dd7070Spatrick  int g = 5;
2674e5dd7070Spatrick
2675e5dd7070SpatrickreferenceType() matches the types of b, c, d, e, and f.
2676e5dd7070Spatrick</pre></td></tr>
2677e5dd7070Spatrick
2678e5dd7070Spatrick
2679e5dd7070Spatrick<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>
2680e5dd7070Spatrick<tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a
2681e5dd7070Spatricktemplate type parameter.
2682e5dd7070Spatrick
2683e5dd7070SpatrickGiven
2684e5dd7070Spatrick  template &lt;typename T&gt;
2685e5dd7070Spatrick  void F(T t) {
2686e5dd7070Spatrick    int i = 1 + t;
2687e5dd7070Spatrick  }
2688e5dd7070Spatrick
2689e5dd7070SpatricksubstTemplateTypeParmType() matches the type of 't' but not '1'
2690e5dd7070Spatrick</pre></td></tr>
2691e5dd7070Spatrick
2692e5dd7070Spatrick
2693e5dd7070Spatrick<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>
2694e5dd7070Spatrick<tr><td colspan="4" class="doc" id="tagType0"><pre>Matches tag types (record and enum types).
2695e5dd7070Spatrick
2696e5dd7070SpatrickGiven
2697e5dd7070Spatrick  enum E {};
2698e5dd7070Spatrick  class C {};
2699e5dd7070Spatrick
2700e5dd7070Spatrick  E e;
2701e5dd7070Spatrick  C c;
2702e5dd7070Spatrick
2703e5dd7070SpatricktagType() matches the type of the variable declarations of both e
2704e5dd7070Spatrickand c.
2705e5dd7070Spatrick</pre></td></tr>
2706e5dd7070Spatrick
2707e5dd7070Spatrick
2708e5dd7070Spatrick<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>
2709e5dd7070Spatrick<tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types.
2710e5dd7070Spatrick
2711e5dd7070SpatrickGiven
2712e5dd7070Spatrick  template &lt;typename T&gt;
2713e5dd7070Spatrick  class C { };
2714e5dd7070Spatrick
2715e5dd7070Spatrick  template class C&lt;int&gt;;  // A
2716e5dd7070Spatrick  C&lt;char&gt; var;            // B
2717e5dd7070Spatrick
2718e5dd7070SpatricktemplateSpecializationType() matches the type of the explicit
2719e5dd7070Spatrickinstantiation in A and the type of the variable declaration in B.
2720e5dd7070Spatrick</pre></td></tr>
2721e5dd7070Spatrick
2722e5dd7070Spatrick
2723e5dd7070Spatrick<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>
2724e5dd7070Spatrick<tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types.
2725e5dd7070Spatrick
2726e5dd7070SpatrickExample matches T, but not int.
2727e5dd7070Spatrick    (matcher = templateTypeParmType())
2728e5dd7070Spatrick  template &lt;typename T&gt; void f(int i);
2729e5dd7070Spatrick</pre></td></tr>
2730e5dd7070Spatrick
2731e5dd7070Spatrick
2732e5dd7070Spatrick<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>
2733e5dd7070Spatrick<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST.
2734e5dd7070Spatrick</pre></td></tr>
2735e5dd7070Spatrick
2736e5dd7070Spatrick
2737e5dd7070Spatrick<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>
2738e5dd7070Spatrick<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types.
2739e5dd7070Spatrick
2740e5dd7070SpatrickGiven
2741e5dd7070Spatrick  typedef int X;
2742e5dd7070SpatricktypedefType()
2743e5dd7070Spatrick  matches "typedef int X"
2744e5dd7070Spatrick</pre></td></tr>
2745e5dd7070Spatrick
2746e5dd7070Spatrick
2747e5dd7070Spatrick<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>
2748e5dd7070Spatrick<tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations.
2749e5dd7070Spatrick
2750e5dd7070SpatrickGiven:
2751e5dd7070Spatrick  typedef __underlying_type(T) type;
2752e5dd7070SpatrickunaryTransformType()
2753e5dd7070Spatrick  matches "__underlying_type(T)"
2754e5dd7070Spatrick</pre></td></tr>
2755e5dd7070Spatrick
2756e5dd7070Spatrick
2757*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('usingType0')"><a name="usingType0Anchor">usingType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>&gt;...</td></tr>
2758*12c85518Srobert<tr><td colspan="4" class="doc" id="usingType0"><pre>Matches types specified through a using declaration.
2759*12c85518Srobert
2760*12c85518SrobertGiven
2761*12c85518Srobert  namespace a { struct S {}; }
2762*12c85518Srobert  using a::S;
2763*12c85518Srobert  S s;
2764*12c85518Srobert
2765*12c85518SrobertusingType() matches the type of the variable declaration of s.
2766*12c85518Srobert</pre></td></tr>
2767*12c85518Srobert
2768*12c85518Srobert
2769e5dd7070Spatrick<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>
2770e5dd7070Spatrick<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an
2771e5dd7070Spatrickinteger-constant-expression.
2772e5dd7070Spatrick
2773e5dd7070SpatrickGiven
2774e5dd7070Spatrick  void f() {
2775e5dd7070Spatrick    int a[] = { 2, 3 }
2776e5dd7070Spatrick    int b[42];
2777e5dd7070Spatrick    int c[a[0]];
2778e5dd7070Spatrick  }
2779e5dd7070SpatrickvariableArrayType()
2780e5dd7070Spatrick  matches "int c[a[0]]"
2781e5dd7070Spatrick</pre></td></tr>
2782e5dd7070Spatrick
2783e5dd7070Spatrick<!--END_DECL_MATCHERS -->
2784e5dd7070Spatrick</table>
2785e5dd7070Spatrick
2786e5dd7070Spatrick<!-- ======================================================================= -->
2787e5dd7070Spatrick<h2 id="narrowing-matchers">Narrowing Matchers</h2>
2788e5dd7070Spatrick<!-- ======================================================================= -->
2789e5dd7070Spatrick
2790e5dd7070Spatrick<p>Narrowing matchers match certain attributes on the current node, thus
2791e5dd7070Spatricknarrowing down the set of nodes of the current type to match on.</p>
2792e5dd7070Spatrick
2793e5dd7070Spatrick<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless)
2794e5dd7070Spatrickwhich allow users to create more powerful match expressions.</p>
2795e5dd7070Spatrick
2796e5dd7070Spatrick<table>
2797e5dd7070Spatrick<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
2798e5dd7070Spatrick<!-- START_NARROWING_MATCHERS -->
2799e5dd7070Spatrick
2800e5dd7070Spatrick<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>
2801e5dd7070Spatrick<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match.
2802e5dd7070Spatrick
2803e5dd7070SpatrickUsable as: Any Matcher
2804e5dd7070Spatrick</pre></td></tr>
2805e5dd7070Spatrick
2806e5dd7070Spatrick
2807e5dd7070Spatrick<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>
2808e5dd7070Spatrick<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches.
2809e5dd7070Spatrick
2810e5dd7070SpatrickUsable as: Any Matcher
2811e5dd7070Spatrick</pre></td></tr>
2812e5dd7070Spatrick
2813e5dd7070Spatrick
2814e5dd7070Spatrick<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr>
2815e5dd7070Spatrick<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node.
2816e5dd7070Spatrick
2817e5dd7070SpatrickUseful when another matcher requires a child matcher, but there's no
2818e5dd7070Spatrickadditional constraint. This will often be used with an explicit conversion
2819e5dd7070Spatrickto an internal::Matcher&lt;&gt; type such as TypeMatcher.
2820e5dd7070Spatrick
2821e5dd7070SpatrickExample: DeclarationMatcher(anything()) matches all declarations, e.g.,
2822e5dd7070Spatrick"int* p" and "void f()" in
2823e5dd7070Spatrick  int* p;
2824e5dd7070Spatrick  void f();
2825e5dd7070Spatrick
2826e5dd7070SpatrickUsable as: Any Matcher
2827e5dd7070Spatrick</pre></td></tr>
2828e5dd7070Spatrick
2829e5dd7070Spatrick
2830a9ac8606Spatrick<tr><td><em>unspecified</em></td><td class="name" onclick="toggle('mapAnyOf0')"><a name="mapAnyOf0Anchor">mapAnyOf</a></td><td>nodeMatcherFunction...</td></tr>
2831a9ac8606Spatrick<tr><td colspan="4" class="doc" id="mapAnyOf0"><pre>Matches any of the NodeMatchers with InnerMatchers nested within
2832a9ac8606Spatrick
2833a9ac8606SpatrickGiven
2834a9ac8606Spatrick  if (true);
2835a9ac8606Spatrick  for (; true; );
2836a9ac8606Spatrickwith the matcher
2837a9ac8606Spatrick  mapAnyOf(ifStmt, forStmt).with(
2838a9ac8606Spatrick    hasCondition(cxxBoolLiteralExpr(equals(true)))
2839a9ac8606Spatrick    ).bind("trueCond")
2840a9ac8606Spatrickmatches the if and the for. It is equivalent to:
2841a9ac8606Spatrick  auto trueCond = hasCondition(cxxBoolLiteralExpr(equals(true)));
2842a9ac8606Spatrick  anyOf(
2843a9ac8606Spatrick    ifStmt(trueCond).bind("trueCond"),
2844a9ac8606Spatrick    forStmt(trueCond).bind("trueCond")
2845a9ac8606Spatrick    );
2846a9ac8606Spatrick
2847a9ac8606SpatrickThe with() chain-call accepts zero or more matchers which are combined
2848a9ac8606Spatrickas-if with allOf() in each of the node matchers.
2849a9ac8606SpatrickUsable as: Any Matcher
2850a9ac8606Spatrick</pre></td></tr>
2851a9ac8606Spatrick
2852a9ac8606Spatrick
2853e5dd7070Spatrick<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher&lt;*&gt;</td></tr>
2854e5dd7070Spatrick<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match.
2855e5dd7070Spatrick
2856e5dd7070SpatrickExample matches Y (matcher = cxxRecordDecl(unless(hasName("X"))))
2857e5dd7070Spatrick  class X {};
2858e5dd7070Spatrick  class Y {};
2859e5dd7070Spatrick
2860e5dd7070SpatrickUsable as: Any Matcher
2861e5dd7070Spatrick</pre></td></tr>
2862e5dd7070Spatrick
2863e5dd7070Spatrick
2864*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>&gt;</td><td class="name" onclick="toggle('isImplicit1')"><a name="isImplicit1Anchor">isImplicit</a></td><td></td></tr>
2865*12c85518Srobert<tr><td colspan="4" class="doc" id="isImplicit1"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
2866*12c85518Srobertimplicit default/copy constructors).
2867*12c85518Srobert</pre></td></tr>
2868*12c85518Srobert
2869*12c85518Srobert
2870ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasAnyOperatorName0')"><a name="hasAnyOperatorName0Anchor">hasAnyOperatorName</a></td><td>StringRef, ..., StringRef</td></tr>
2871ec727ea7Spatrick<tr><td colspan="4" class="doc" id="hasAnyOperatorName0"><pre>Matches operator expressions (binary or unary) that have any of the
2872ec727ea7Spatrickspecified names.
2873ec727ea7Spatrick
2874ec727ea7Spatrick   hasAnyOperatorName("+", "-")
2875ec727ea7Spatrick Is equivalent to
2876ec727ea7Spatrick   anyOf(hasOperatorName("+"), hasOperatorName("-"))
2877ec727ea7Spatrick</pre></td></tr>
2878ec727ea7Spatrick
2879ec727ea7Spatrick
2880e5dd7070Spatrick<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>
2881e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or
2882e5dd7070Spatrickunary).
2883e5dd7070Spatrick
2884e5dd7070SpatrickExample matches a || b (matcher = binaryOperator(hasOperatorName("||")))
2885e5dd7070Spatrick  !(a || b)
2886e5dd7070Spatrick</pre></td></tr>
2887e5dd7070Spatrick
2888e5dd7070Spatrick
2889e5dd7070Spatrick<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>
2890e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isAssignmentOperator0"><pre>Matches all kinds of assignment operators.
2891e5dd7070Spatrick
2892e5dd7070SpatrickExample 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
2893e5dd7070Spatrick  if (a == b)
2894e5dd7070Spatrick    a += b;
2895e5dd7070Spatrick
2896e5dd7070SpatrickExample 2: matches s1 = s2
2897e5dd7070Spatrick           (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
2898e5dd7070Spatrick  struct S { S&amp; operator=(const S&amp;); };
2899ec727ea7Spatrick  void x() { S s1, s2; s1 = s2; }
2900ec727ea7Spatrick</pre></td></tr>
2901ec727ea7Spatrick
2902ec727ea7Spatrick
2903ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;</td><td class="name" onclick="toggle('isComparisonOperator0')"><a name="isComparisonOperator0Anchor">isComparisonOperator</a></td><td></td></tr>
2904ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isComparisonOperator0"><pre>Matches comparison operators.
2905ec727ea7Spatrick
2906ec727ea7SpatrickExample 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
2907ec727ea7Spatrick  if (a == b)
2908ec727ea7Spatrick    a += b;
2909ec727ea7Spatrick
2910ec727ea7SpatrickExample 2: matches s1 &lt; s2
2911ec727ea7Spatrick           (matcher = cxxOperatorCallExpr(isComparisonOperator()))
2912ec727ea7Spatrick  struct S { bool operator&lt;(const S&amp; other); };
2913ec727ea7Spatrick  void x(S s1, S s2) { bool b1 = s1 &lt; s2; }
2914ec727ea7Spatrick</pre></td></tr>
2915ec727ea7Spatrick
2916ec727ea7Spatrick
2917ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;</td><td class="name" onclick="toggle('isPrivate1')"><a name="isPrivate1Anchor">isPrivate</a></td><td></td></tr>
2918ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isPrivate1"><pre>Matches private C++ declarations and C++ base specifers that specify private
2919ec727ea7Spatrickinheritance.
2920ec727ea7Spatrick
2921ec727ea7SpatrickExamples:
2922ec727ea7Spatrick  class C {
2923ec727ea7Spatrick  public:    int a;
2924ec727ea7Spatrick  protected: int b;
2925ec727ea7Spatrick  private:   int c; // fieldDecl(isPrivate()) matches 'c'
2926ec727ea7Spatrick  };
2927ec727ea7Spatrick
2928ec727ea7Spatrick  struct Base {};
2929ec727ea7Spatrick  struct Derived1 : private Base {}; // matches 'Base'
2930ec727ea7Spatrick  class Derived2 : Base {}; // matches 'Base'
2931ec727ea7Spatrick</pre></td></tr>
2932ec727ea7Spatrick
2933ec727ea7Spatrick
2934ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;</td><td class="name" onclick="toggle('isProtected1')"><a name="isProtected1Anchor">isProtected</a></td><td></td></tr>
2935ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isProtected1"><pre>Matches protected C++ declarations and C++ base specifers that specify
2936ec727ea7Spatrickprotected inheritance.
2937ec727ea7Spatrick
2938ec727ea7SpatrickExamples:
2939ec727ea7Spatrick  class C {
2940ec727ea7Spatrick  public:    int a;
2941ec727ea7Spatrick  protected: int b; // fieldDecl(isProtected()) matches 'b'
2942ec727ea7Spatrick  private:   int c;
2943ec727ea7Spatrick  };
2944ec727ea7Spatrick
2945ec727ea7Spatrick  class Base {};
2946ec727ea7Spatrick  class Derived : protected Base {}; // matches 'Base'
2947ec727ea7Spatrick</pre></td></tr>
2948ec727ea7Spatrick
2949ec727ea7Spatrick
2950ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;</td><td class="name" onclick="toggle('isPublic1')"><a name="isPublic1Anchor">isPublic</a></td><td></td></tr>
2951ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isPublic1"><pre>Matches public C++ declarations and C++ base specifers that specify public
2952ec727ea7Spatrickinheritance.
2953ec727ea7Spatrick
2954ec727ea7SpatrickExamples:
2955ec727ea7Spatrick  class C {
2956ec727ea7Spatrick  public:    int a; // fieldDecl(isPublic()) matches 'a'
2957ec727ea7Spatrick  protected: int b;
2958ec727ea7Spatrick  private:   int c;
2959ec727ea7Spatrick  };
2960ec727ea7Spatrick
2961ec727ea7Spatrick  class Base {};
2962ec727ea7Spatrick  class Derived1 : public Base {}; // matches 'Base'
2963ec727ea7Spatrick  struct Derived2 : Base {}; // matches 'Base'
2964ec727ea7Spatrick</pre></td></tr>
2965ec727ea7Spatrick
2966ec727ea7Spatrick
2967ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;</td><td class="name" onclick="toggle('isVirtual1')"><a name="isVirtual1Anchor">isVirtual</a></td><td></td></tr>
2968ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isVirtual1"><pre>Matches declarations of virtual methods and C++ base specifers that specify
2969ec727ea7Spatrickvirtual inheritance.
2970ec727ea7Spatrick
2971ec727ea7SpatrickExample:
2972ec727ea7Spatrick  class A {
2973ec727ea7Spatrick   public:
2974ec727ea7Spatrick    virtual void x(); // matches x
2975ec727ea7Spatrick  };
2976ec727ea7Spatrick
2977ec727ea7SpatrickExample:
2978ec727ea7Spatrick  class Base {};
2979ec727ea7Spatrick  class DirectlyDerived : virtual Base {}; // matches Base
2980ec727ea7Spatrick  class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
2981ec727ea7Spatrick
2982ec727ea7SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
2983e5dd7070Spatrick</pre></td></tr>
2984e5dd7070Spatrick
2985e5dd7070Spatrick
2986e5dd7070Spatrick<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>
2987e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equals5"><pre></pre></td></tr>
2988e5dd7070Spatrick
2989e5dd7070Spatrick
2990e5dd7070Spatrick<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>
2991e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value of type ValueT.
2992e5dd7070Spatrick
2993e5dd7070SpatrickGiven
2994e5dd7070Spatrick  f('false, 3.14, 42);
2995e5dd7070SpatrickcharacterLiteral(equals(0))
2996e5dd7070Spatrick  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
2997e5dd7070Spatrick  match false
2998e5dd7070SpatrickfloatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
2999e5dd7070Spatrick  match 3.14
3000e5dd7070SpatrickintegerLiteral(equals(42))
3001e5dd7070Spatrick  matches 42
3002e5dd7070Spatrick
3003e5dd7070SpatrickNote that you cannot directly match a negative numeric literal because the
3004e5dd7070Spatrickminus sign is not part of the literal: It is a unary operator whose operand
3005e5dd7070Spatrickis the positive numeric literal. Instead, you must use a unaryOperator()
3006e5dd7070Spatrickmatcher to match the minus sign:
3007e5dd7070Spatrick
3008e5dd7070SpatrickunaryOperator(hasOperatorName("-"),
3009e5dd7070Spatrick              hasUnaryOperand(integerLiteral(equals(13))))
3010e5dd7070Spatrick
3011e5dd7070SpatrickUsable 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;,
3012e5dd7070Spatrick           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;
3013e5dd7070Spatrick</pre></td></tr>
3014e5dd7070Spatrick
3015e5dd7070Spatrick
3016e5dd7070Spatrick<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>
3017e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equals11"><pre></pre></td></tr>
3018e5dd7070Spatrick
3019e5dd7070Spatrick
3020e5dd7070Spatrick<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>
3021e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equals8"><pre></pre></td></tr>
3022e5dd7070Spatrick
3023e5dd7070Spatrick
3024e5dd7070Spatrick<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>
3025e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler.
3026e5dd7070Spatrick
3027e5dd7070SpatrickGiven
3028e5dd7070Spatrick  try {
3029e5dd7070Spatrick    // ...
3030e5dd7070Spatrick  } catch (int) {
3031e5dd7070Spatrick    // ...
3032e5dd7070Spatrick  } catch (...) {
3033e5dd7070Spatrick    // ...
3034e5dd7070Spatrick  }
3035e5dd7070SpatrickcxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
3036e5dd7070Spatrick</pre></td></tr>
3037e5dd7070Spatrick
3038e5dd7070Spatrick
3039e5dd7070Spatrick<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>
3040e5dd7070Spatrick<tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has
3041e5dd7070Spatricka specific number of arguments (including absent default arguments).
3042e5dd7070Spatrick
3043e5dd7070SpatrickExample matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
3044e5dd7070Spatrick  void f(int x, int y);
3045e5dd7070Spatrick  f(0, 0);
3046e5dd7070Spatrick</pre></td></tr>
3047e5dd7070Spatrick
3048e5dd7070Spatrick
3049e5dd7070Spatrick<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>
3050e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization.
3051e5dd7070Spatrick</pre></td></tr>
3052e5dd7070Spatrick
3053e5dd7070Spatrick
3054e5dd7070Spatrick<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>
3055e5dd7070Spatrick<tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires
3056e5dd7070Spatrickzero initialization.
3057e5dd7070Spatrick
3058e5dd7070SpatrickGiven
3059e5dd7070Spatrickvoid foo() {
3060e5dd7070Spatrick  struct point { double x; double y; };
3061e5dd7070Spatrick  point pt[2] = { { 1.0, 2.0 } };
3062e5dd7070Spatrick}
3063e5dd7070SpatrickinitListExpr(has(cxxConstructExpr(requiresZeroInitialization()))
3064e5dd7070Spatrickwill match the implicit array filler for pt[1].
3065e5dd7070Spatrick</pre></td></tr>
3066e5dd7070Spatrick
3067e5dd7070Spatrick
3068e5dd7070Spatrick<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>
3069e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors.
3070e5dd7070Spatrick
3071e5dd7070SpatrickGiven
3072e5dd7070Spatrick  struct S {
3073e5dd7070Spatrick    S(); // #1
3074e5dd7070Spatrick    S(const S &amp;); // #2
3075e5dd7070Spatrick    S(S &amp;&amp;); // #3
3076e5dd7070Spatrick  };
3077e5dd7070SpatrickcxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
3078e5dd7070Spatrick</pre></td></tr>
3079e5dd7070Spatrick
3080e5dd7070Spatrick
3081e5dd7070Spatrick<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>
3082e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors.
3083e5dd7070Spatrick
3084e5dd7070SpatrickGiven
3085e5dd7070Spatrick  struct S {
3086e5dd7070Spatrick    S(); // #1
3087e5dd7070Spatrick    S(const S &amp;); // #2
3088e5dd7070Spatrick    S(S &amp;&amp;); // #3
3089e5dd7070Spatrick  };
3090e5dd7070SpatrickcxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
3091e5dd7070Spatrick</pre></td></tr>
3092e5dd7070Spatrick
3093e5dd7070Spatrick
3094e5dd7070Spatrick<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>
3095e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor.
3096e5dd7070Spatrick
3097e5dd7070SpatrickGiven
3098e5dd7070Spatrick  struct S {
3099e5dd7070Spatrick    S(); // #1
3100e5dd7070Spatrick    S(int) {} // #2
3101e5dd7070Spatrick    S(S &amp;&amp;) : S() {} // #3
3102e5dd7070Spatrick  };
3103e5dd7070Spatrick  S::S() : S(0) {} // #4
3104e5dd7070SpatrickcxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not
3105e5dd7070Spatrick#1 or #2.
3106e5dd7070Spatrick</pre></td></tr>
3107e5dd7070Spatrick
3108e5dd7070Spatrick
3109e5dd7070Spatrick<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>
3110e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor, conversion function, and deduction guide declarations
3111e5dd7070Spatrickthat have an explicit specifier if this explicit specifier is resolved to
3112e5dd7070Spatricktrue.
3113e5dd7070Spatrick
3114e5dd7070SpatrickGiven
3115e5dd7070Spatrick  template&lt;bool b&gt;
3116e5dd7070Spatrick  struct S {
3117e5dd7070Spatrick    S(int); // #1
3118e5dd7070Spatrick    explicit S(double); // #2
3119e5dd7070Spatrick    operator int(); // #3
3120e5dd7070Spatrick    explicit operator bool(); // #4
3121e5dd7070Spatrick    explicit(false) S(bool) // # 7
3122e5dd7070Spatrick    explicit(true) S(char) // # 8
3123e5dd7070Spatrick    explicit(b) S(S) // # 9
3124e5dd7070Spatrick  };
3125e5dd7070Spatrick  S(int) -&gt; S&lt;true&gt; // #5
3126e5dd7070Spatrick  explicit S(double) -&gt; S&lt;false&gt; // #6
3127e5dd7070SpatrickcxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
3128e5dd7070SpatrickcxxConversionDecl(isExplicit()) will match #4, but not #3.
3129e5dd7070SpatrickcxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
3130e5dd7070Spatrick</pre></td></tr>
3131e5dd7070Spatrick
3132e5dd7070Spatrick
3133*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('isInheritingConstructor0')"><a name="isInheritingConstructor0Anchor">isInheritingConstructor</a></td><td></td></tr>
3134*12c85518Srobert<tr><td colspan="4" class="doc" id="isInheritingConstructor0"><pre></pre></td></tr>
3135*12c85518Srobert
3136*12c85518Srobert
3137e5dd7070Spatrick<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>
3138e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors.
3139e5dd7070Spatrick
3140e5dd7070SpatrickGiven
3141e5dd7070Spatrick  struct S {
3142e5dd7070Spatrick    S(); // #1
3143e5dd7070Spatrick    S(const S &amp;); // #2
3144e5dd7070Spatrick    S(S &amp;&amp;); // #3
3145e5dd7070Spatrick  };
3146e5dd7070SpatrickcxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
3147e5dd7070Spatrick</pre></td></tr>
3148e5dd7070Spatrick
3149e5dd7070Spatrick
3150e5dd7070Spatrick<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>
3151e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor, conversion function, and deduction guide declarations
3152e5dd7070Spatrickthat have an explicit specifier if this explicit specifier is resolved to
3153e5dd7070Spatricktrue.
3154e5dd7070Spatrick
3155e5dd7070SpatrickGiven
3156e5dd7070Spatrick  template&lt;bool b&gt;
3157e5dd7070Spatrick  struct S {
3158e5dd7070Spatrick    S(int); // #1
3159e5dd7070Spatrick    explicit S(double); // #2
3160e5dd7070Spatrick    operator int(); // #3
3161e5dd7070Spatrick    explicit operator bool(); // #4
3162e5dd7070Spatrick    explicit(false) S(bool) // # 7
3163e5dd7070Spatrick    explicit(true) S(char) // # 8
3164e5dd7070Spatrick    explicit(b) S(S) // # 9
3165e5dd7070Spatrick  };
3166e5dd7070Spatrick  S(int) -&gt; S&lt;true&gt; // #5
3167e5dd7070Spatrick  explicit S(double) -&gt; S&lt;false&gt; // #6
3168e5dd7070SpatrickcxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
3169e5dd7070SpatrickcxxConversionDecl(isExplicit()) will match #4, but not #3.
3170e5dd7070SpatrickcxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
3171e5dd7070Spatrick</pre></td></tr>
3172e5dd7070Spatrick
3173e5dd7070Spatrick
3174e5dd7070Spatrick<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>
3175e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as
3176e5dd7070Spatrickopposed to a member.
3177e5dd7070Spatrick
3178e5dd7070SpatrickGiven
3179e5dd7070Spatrick  struct B {};
3180e5dd7070Spatrick  struct D : B {
3181e5dd7070Spatrick    int I;
3182e5dd7070Spatrick    D(int i) : I(i) {}
3183e5dd7070Spatrick  };
3184e5dd7070Spatrick  struct E : B {
3185e5dd7070Spatrick    E() : B() {}
3186e5dd7070Spatrick  };
3187e5dd7070SpatrickcxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
3188e5dd7070Spatrick  will match E(), but not match D(int).
3189e5dd7070Spatrick</pre></td></tr>
3190e5dd7070Spatrick
3191e5dd7070Spatrick
3192e5dd7070Spatrick<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>
3193e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as
3194e5dd7070Spatrickopposed to a base.
3195e5dd7070Spatrick
3196e5dd7070SpatrickGiven
3197e5dd7070Spatrick  struct B {};
3198e5dd7070Spatrick  struct D : B {
3199e5dd7070Spatrick    int I;
3200e5dd7070Spatrick    D(int i) : I(i) {}
3201e5dd7070Spatrick  };
3202e5dd7070Spatrick  struct E : B {
3203e5dd7070Spatrick    E() : B() {}
3204e5dd7070Spatrick  };
3205e5dd7070SpatrickcxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
3206e5dd7070Spatrick  will match D(int), but not match E().
3207e5dd7070Spatrick</pre></td></tr>
3208e5dd7070Spatrick
3209e5dd7070Spatrick
3210e5dd7070Spatrick<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>
3211e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in
3212e5dd7070Spatrickcode (as opposed to implicitly added by the compiler).
3213e5dd7070Spatrick
3214e5dd7070SpatrickGiven
3215e5dd7070Spatrick  struct Foo {
3216e5dd7070Spatrick    Foo() { }
3217e5dd7070Spatrick    Foo(int) : foo_("A") { }
3218e5dd7070Spatrick    string foo_;
3219e5dd7070Spatrick  };
3220e5dd7070SpatrickcxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
3221e5dd7070Spatrick  will match Foo(int), but not Foo()
3222e5dd7070Spatrick</pre></td></tr>
3223e5dd7070Spatrick
3224e5dd7070Spatrick
3225e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDeductionGuideDecl.html">CXXDeductionGuideDecl</a>&gt;</td><td class="name" onclick="toggle('isExplicit2')"><a name="isExplicit2Anchor">isExplicit</a></td><td></td></tr>
3226e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExplicit2"><pre>Matches constructor, conversion function, and deduction guide declarations
3227e5dd7070Spatrickthat have an explicit specifier if this explicit specifier is resolved to
3228e5dd7070Spatricktrue.
3229e5dd7070Spatrick
3230e5dd7070SpatrickGiven
3231e5dd7070Spatrick  template&lt;bool b&gt;
3232e5dd7070Spatrick  struct S {
3233e5dd7070Spatrick    S(int); // #1
3234e5dd7070Spatrick    explicit S(double); // #2
3235e5dd7070Spatrick    operator int(); // #3
3236e5dd7070Spatrick    explicit operator bool(); // #4
3237e5dd7070Spatrick    explicit(false) S(bool) // # 7
3238e5dd7070Spatrick    explicit(true) S(char) // # 8
3239e5dd7070Spatrick    explicit(b) S(S) // # 9
3240e5dd7070Spatrick  };
3241e5dd7070Spatrick  S(int) -&gt; S&lt;true&gt; // #5
3242e5dd7070Spatrick  explicit S(double) -&gt; S&lt;false&gt; // #6
3243e5dd7070SpatrickcxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
3244e5dd7070SpatrickcxxConversionDecl(isExplicit()) will match #4, but not #3.
3245e5dd7070SpatrickcxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
3246e5dd7070Spatrick</pre></td></tr>
3247e5dd7070Spatrick
3248e5dd7070Spatrick
3249a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>&gt;</td><td class="name" onclick="toggle('hasMemberName0')"><a name="hasMemberName0Anchor">hasMemberName</a></td><td>std::string N</td></tr>
3250a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasMemberName0"><pre>Matches template-dependent, but known, member names.
3251a9ac8606Spatrick
3252a9ac8606SpatrickIn template declarations, dependent members are not resolved and so can
3253a9ac8606Spatricknot be matched to particular named declarations.
3254a9ac8606Spatrick
3255a9ac8606SpatrickThis matcher allows to match on the known name of members.
3256a9ac8606Spatrick
3257a9ac8606SpatrickGiven
3258a9ac8606Spatrick  template &lt;typename T&gt;
3259a9ac8606Spatrick  struct S {
3260a9ac8606Spatrick      void mem();
3261a9ac8606Spatrick  };
3262a9ac8606Spatrick  template &lt;typename T&gt;
3263a9ac8606Spatrick  void x() {
3264a9ac8606Spatrick      S&lt;T&gt; s;
3265a9ac8606Spatrick      s.mem();
3266a9ac8606Spatrick  }
3267a9ac8606SpatrickcxxDependentScopeMemberExpr(hasMemberName("mem")) matches `s.mem()`
3268a9ac8606Spatrick</pre></td></tr>
3269a9ac8606Spatrick
3270a9ac8606Spatrick
3271e5dd7070Spatrick<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>
3272e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isArrow2"><pre>Matches member expressions that are called with '-&gt;' as opposed
3273e5dd7070Spatrickto '.'.
3274e5dd7070Spatrick
3275e5dd7070SpatrickMember calls on the implicit this pointer match as called with '-&gt;'.
3276e5dd7070Spatrick
3277e5dd7070SpatrickGiven
3278e5dd7070Spatrick  class Y {
3279e5dd7070Spatrick    void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
3280e5dd7070Spatrick    template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
3281e5dd7070Spatrick    int a;
3282e5dd7070Spatrick    static int b;
3283e5dd7070Spatrick  };
3284e5dd7070Spatrick  template &lt;class T&gt;
3285e5dd7070Spatrick  class Z {
3286e5dd7070Spatrick    void x() { this-&gt;m; }
3287e5dd7070Spatrick  };
3288e5dd7070SpatrickmemberExpr(isArrow())
3289e5dd7070Spatrick  matches this-&gt;x, x, y.x, a, this-&gt;b
3290e5dd7070SpatrickcxxDependentScopeMemberExpr(isArrow())
3291e5dd7070Spatrick  matches this-&gt;m
3292e5dd7070SpatrickunresolvedMemberExpr(isArrow())
3293e5dd7070Spatrick  matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
3294e5dd7070Spatrick</pre></td></tr>
3295e5dd7070Spatrick
3296e5dd7070Spatrick
3297a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr</a>&gt;</td><td class="name" onclick="toggle('memberHasSameNameAsBoundNode0')"><a name="memberHasSameNameAsBoundNode0Anchor">memberHasSameNameAsBoundNode</a></td><td>std::string BindingID</td></tr>
3298a9ac8606Spatrick<tr><td colspan="4" class="doc" id="memberHasSameNameAsBoundNode0"><pre>Matches template-dependent, but known, member names against an already-bound
3299a9ac8606Spatricknode
3300a9ac8606Spatrick
3301a9ac8606SpatrickIn template declarations, dependent members are not resolved and so can
3302a9ac8606Spatricknot be matched to particular named declarations.
3303a9ac8606Spatrick
3304a9ac8606SpatrickThis matcher allows to match on the name of already-bound VarDecl, FieldDecl
3305a9ac8606Spatrickand CXXMethodDecl nodes.
3306a9ac8606Spatrick
3307a9ac8606SpatrickGiven
3308a9ac8606Spatrick  template &lt;typename T&gt;
3309a9ac8606Spatrick  struct S {
3310a9ac8606Spatrick      void mem();
3311a9ac8606Spatrick  };
3312a9ac8606Spatrick  template &lt;typename T&gt;
3313a9ac8606Spatrick  void x() {
3314a9ac8606Spatrick      S&lt;T&gt; s;
3315a9ac8606Spatrick      s.mem();
3316a9ac8606Spatrick  }
3317a9ac8606SpatrickThe matcher
3318a9ac8606Spatrick@code
3319a9ac8606SpatrickcxxDependentScopeMemberExpr(
3320a9ac8606Spatrick  hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
3321a9ac8606Spatrick      hasDeclaration(classTemplateDecl(has(cxxRecordDecl(has(
3322a9ac8606Spatrick          cxxMethodDecl(hasName("mem")).bind("templMem")
3323a9ac8606Spatrick          )))))
3324a9ac8606Spatrick      )))),
3325a9ac8606Spatrick  memberHasSameNameAsBoundNode("templMem")
3326a9ac8606Spatrick  )
3327a9ac8606Spatrick@endcode
3328a9ac8606Spatrickfirst matches and binds the @c mem member of the @c S template, then
3329a9ac8606Spatrickcompares its name to the usage in @c s.mem() in the @c x function template
3330a9ac8606Spatrick</pre></td></tr>
3331a9ac8606Spatrick
3332a9ac8606Spatrick
3333e5dd7070Spatrick<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>
3334e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const.
3335e5dd7070Spatrick
3336e5dd7070SpatrickGiven
3337e5dd7070Spatrickstruct A {
3338e5dd7070Spatrick  void foo() const;
3339e5dd7070Spatrick  void bar();
3340e5dd7070Spatrick};
3341e5dd7070Spatrick
3342e5dd7070SpatrickcxxMethodDecl(isConst()) matches A::foo() but not A::bar()
3343e5dd7070Spatrick</pre></td></tr>
3344e5dd7070Spatrick
3345e5dd7070Spatrick
3346e5dd7070Spatrick<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>
3347e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment
3348e5dd7070Spatrickoperator.
3349e5dd7070Spatrick
3350e5dd7070SpatrickGiven
3351e5dd7070Spatrickstruct A {
3352e5dd7070Spatrick  A &amp;operator=(const A &amp;);
3353e5dd7070Spatrick  A &amp;operator=(A &amp;&amp;);
3354e5dd7070Spatrick};
3355e5dd7070Spatrick
3356e5dd7070SpatrickcxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not
3357e5dd7070Spatrickthe second one.
3358e5dd7070Spatrick</pre></td></tr>
3359e5dd7070Spatrick
3360e5dd7070Spatrick
3361e5dd7070Spatrick<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>
3362e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final.
3363e5dd7070Spatrick
3364e5dd7070SpatrickGiven:
3365e5dd7070Spatrick  class A final {};
3366e5dd7070Spatrick
3367e5dd7070Spatrick  struct B {
3368e5dd7070Spatrick    virtual void f();
3369e5dd7070Spatrick  };
3370e5dd7070Spatrick
3371e5dd7070Spatrick  struct C : B {
3372e5dd7070Spatrick    void f() final;
3373e5dd7070Spatrick  };
3374e5dd7070Spatrickmatches A and C::f, but not B, C, or B::f
3375e5dd7070Spatrick</pre></td></tr>
3376e5dd7070Spatrick
3377e5dd7070Spatrick
3378e5dd7070Spatrick<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>
3379e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment
3380e5dd7070Spatrickoperator.
3381e5dd7070Spatrick
3382e5dd7070SpatrickGiven
3383e5dd7070Spatrickstruct A {
3384e5dd7070Spatrick  A &amp;operator=(const A &amp;);
3385e5dd7070Spatrick  A &amp;operator=(A &amp;&amp;);
3386e5dd7070Spatrick};
3387e5dd7070Spatrick
3388e5dd7070SpatrickcxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not
3389e5dd7070Spatrickthe first one.
3390e5dd7070Spatrick</pre></td></tr>
3391e5dd7070Spatrick
3392e5dd7070Spatrick
3393e5dd7070Spatrick<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>
3394e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method.
3395e5dd7070Spatrick
3396e5dd7070SpatrickGiven
3397e5dd7070Spatrick  class A {
3398e5dd7070Spatrick   public:
3399e5dd7070Spatrick    virtual void x();
3400e5dd7070Spatrick  };
3401e5dd7070Spatrick  class B : public A {
3402e5dd7070Spatrick   public:
3403e5dd7070Spatrick    virtual void x();
3404e5dd7070Spatrick  };
3405e5dd7070Spatrick  matches B::x
3406e5dd7070Spatrick</pre></td></tr>
3407e5dd7070Spatrick
3408e5dd7070Spatrick
3409e5dd7070Spatrick<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>
3410e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure.
3411e5dd7070Spatrick
3412e5dd7070SpatrickGiven
3413e5dd7070Spatrick  class A {
3414e5dd7070Spatrick   public:
3415e5dd7070Spatrick    virtual void x() = 0;
3416e5dd7070Spatrick  };
3417e5dd7070Spatrick  matches A::x
3418e5dd7070Spatrick</pre></td></tr>
3419e5dd7070Spatrick
3420e5dd7070Spatrick
3421e5dd7070Spatrick<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>
3422e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isUserProvided0"><pre>Matches method declarations that are user-provided.
3423e5dd7070Spatrick
3424e5dd7070SpatrickGiven
3425e5dd7070Spatrick  struct S {
3426e5dd7070Spatrick    S(); // #1
3427e5dd7070Spatrick    S(const S &amp;) = default; // #2
3428e5dd7070Spatrick    S(S &amp;&amp;) = delete; // #3
3429e5dd7070Spatrick  };
3430e5dd7070SpatrickcxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
3431e5dd7070Spatrick</pre></td></tr>
3432e5dd7070Spatrick
3433e5dd7070Spatrick
3434e5dd7070Spatrick<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>
3435ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches declarations of virtual methods and C++ base specifers that specify
3436ec727ea7Spatrickvirtual inheritance.
3437e5dd7070Spatrick
3438ec727ea7SpatrickExample:
3439e5dd7070Spatrick  class A {
3440e5dd7070Spatrick   public:
3441ec727ea7Spatrick    virtual void x(); // matches x
3442e5dd7070Spatrick  };
3443ec727ea7Spatrick
3444ec727ea7SpatrickExample:
3445ec727ea7Spatrick  class Base {};
3446ec727ea7Spatrick  class DirectlyDerived : virtual Base {}; // matches Base
3447ec727ea7Spatrick  class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
3448ec727ea7Spatrick
3449ec727ea7SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
3450e5dd7070Spatrick</pre></td></tr>
3451e5dd7070Spatrick
3452e5dd7070Spatrick
3453e5dd7070Spatrick<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>
3454e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual".
3455e5dd7070Spatrick
3456e5dd7070SpatrickGiven
3457e5dd7070Spatrick  class A {
3458e5dd7070Spatrick   public:
3459e5dd7070Spatrick    virtual void x();
3460e5dd7070Spatrick  };
3461e5dd7070Spatrick  class B : public A {
3462e5dd7070Spatrick   public:
3463e5dd7070Spatrick    void x();
3464e5dd7070Spatrick  };
3465e5dd7070Spatrick  matches A::x but not B::x
3466e5dd7070Spatrick</pre></td></tr>
3467e5dd7070Spatrick
3468e5dd7070Spatrick
3469e5dd7070Spatrick<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>
3470e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isArray0"><pre>Matches array new expressions.
3471e5dd7070Spatrick
3472e5dd7070SpatrickGiven:
3473e5dd7070Spatrick  MyClass *p1 = new MyClass[10];
3474e5dd7070SpatrickcxxNewExpr(isArray())
3475e5dd7070Spatrick  matches the expression 'new MyClass[10]'.
3476e5dd7070Spatrick</pre></td></tr>
3477e5dd7070Spatrick
3478e5dd7070Spatrick
3479a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnyOperatorName1')"><a name="hasAnyOperatorName1Anchor">hasAnyOperatorName</a></td><td>StringRef, ..., StringRef</td></tr>
3480a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasAnyOperatorName1"><pre>Matches operator expressions (binary or unary) that have any of the
3481a9ac8606Spatrickspecified names.
3482a9ac8606Spatrick
3483a9ac8606Spatrick   hasAnyOperatorName("+", "-")
3484a9ac8606Spatrick Is equivalent to
3485a9ac8606Spatrick   anyOf(hasOperatorName("+"), hasOperatorName("-"))
3486a9ac8606Spatrick</pre></td></tr>
3487a9ac8606Spatrick
3488a9ac8606Spatrick
3489ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnyOverloadedOperatorName0')"><a name="hasAnyOverloadedOperatorName0Anchor">hasAnyOverloadedOperatorName</a></td><td>StringRef, ..., StringRef</td></tr>
3490ec727ea7Spatrick<tr><td colspan="4" class="doc" id="hasAnyOverloadedOperatorName0"><pre>Matches overloaded operator names.
3491ec727ea7Spatrick
3492ec727ea7SpatrickMatches overloaded operator names specified in strings without the
3493ec727ea7Spatrick"operator" prefix: e.g. "&lt;&lt;".
3494ec727ea7Spatrick
3495a9ac8606Spatrick  hasAnyOverloadedOperatorName("+", "-")
3496ec727ea7SpatrickIs equivalent to
3497ec727ea7Spatrick  anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
3498ec727ea7Spatrick</pre></td></tr>
3499ec727ea7Spatrick
3500ec727ea7Spatrick
3501a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;</td><td class="name" onclick="toggle('hasOperatorName1')"><a name="hasOperatorName1Anchor">hasOperatorName</a></td><td>std::string Name</td></tr>
3502a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or
3503a9ac8606Spatrickunary).
3504a9ac8606Spatrick
3505a9ac8606SpatrickExample matches a || b (matcher = binaryOperator(hasOperatorName("||")))
3506a9ac8606Spatrick  !(a || b)
3507a9ac8606Spatrick</pre></td></tr>
3508a9ac8606Spatrick
3509a9ac8606Spatrick
3510e5dd7070Spatrick<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>
3511e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names.
3512e5dd7070Spatrick
3513e5dd7070SpatrickMatches overloaded operator names specified in strings without the
3514e5dd7070Spatrick"operator" prefix: e.g. "&lt;&lt;".
3515e5dd7070Spatrick
3516e5dd7070SpatrickGiven:
3517e5dd7070Spatrick  class A { int operator*(); };
3518e5dd7070Spatrick  const A &amp;operator&lt;&lt;(const A &amp;a, const A &amp;b);
3519e5dd7070Spatrick  A a;
3520e5dd7070Spatrick  a &lt;&lt; a;   // &lt;-- This matches
3521e5dd7070Spatrick
3522e5dd7070SpatrickcxxOperatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the
3523e5dd7070Spatrickspecified line and
3524e5dd7070SpatrickcxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
3525e5dd7070Spatrickmatches the declaration of A.
3526e5dd7070Spatrick
3527e5dd7070SpatrickUsable 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;
3528e5dd7070Spatrick</pre></td></tr>
3529e5dd7070Spatrick
3530e5dd7070Spatrick
3531e5dd7070Spatrick<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>
3532e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isAssignmentOperator1"><pre>Matches all kinds of assignment operators.
3533e5dd7070Spatrick
3534e5dd7070SpatrickExample 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3535e5dd7070Spatrick  if (a == b)
3536e5dd7070Spatrick    a += b;
3537e5dd7070Spatrick
3538e5dd7070SpatrickExample 2: matches s1 = s2
3539e5dd7070Spatrick           (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3540e5dd7070Spatrick  struct S { S&amp; operator=(const S&amp;); };
3541ec727ea7Spatrick  void x() { S s1, s2; s1 = s2; }
3542ec727ea7Spatrick</pre></td></tr>
3543ec727ea7Spatrick
3544ec727ea7Spatrick
3545ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;</td><td class="name" onclick="toggle('isComparisonOperator1')"><a name="isComparisonOperator1Anchor">isComparisonOperator</a></td><td></td></tr>
3546ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isComparisonOperator1"><pre>Matches comparison operators.
3547ec727ea7Spatrick
3548ec727ea7SpatrickExample 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3549ec727ea7Spatrick  if (a == b)
3550ec727ea7Spatrick    a += b;
3551ec727ea7Spatrick
3552ec727ea7SpatrickExample 2: matches s1 &lt; s2
3553ec727ea7Spatrick           (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3554ec727ea7Spatrick  struct S { bool operator&lt;(const S&amp; other); };
3555ec727ea7Spatrick  void x(S s1, S s2) { bool b1 = s1 &lt; s2; }
3556e5dd7070Spatrick</pre></td></tr>
3557e5dd7070Spatrick
3558e5dd7070Spatrick
3559e5dd7070Spatrick<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>
3560e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined.
3561e5dd7070Spatrick
3562e5dd7070SpatrickExample matches x (matcher = cxxRecordDecl(hasDefinition()))
3563e5dd7070Spatrickclass x {};
3564e5dd7070Spatrickclass y;
3565e5dd7070Spatrick</pre></td></tr>
3566e5dd7070Spatrick
3567e5dd7070Spatrick
3568e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isDerivedFrom2')"><a name="isDerivedFrom2Anchor">isDerivedFrom</a></td><td>std::string BaseName</td></tr>
3569e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDerivedFrom2"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
3570e5dd7070Spatrick</pre></td></tr>
3571e5dd7070Spatrick
3572e5dd7070Spatrick
3573e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isDirectlyDerivedFrom2')"><a name="isDirectlyDerivedFrom2Anchor">isDirectlyDerivedFrom</a></td><td>std::string BaseName</td></tr>
3574e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom2"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
3575e5dd7070Spatrick</pre></td></tr>
3576e5dd7070Spatrick
3577e5dd7070Spatrick
3578e5dd7070Spatrick<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>
3579e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or
3580e5dd7070Spatrickstatic member variable template instantiations.
3581e5dd7070Spatrick
3582e5dd7070SpatrickGiven
3583e5dd7070Spatrick  template&lt;typename T&gt; void A(T t) { }
3584e5dd7070Spatrick  template&lt;&gt; void A(int N) { }
3585e5dd7070SpatrickfunctionDecl(isExplicitTemplateSpecialization())
3586e5dd7070Spatrick  matches the specialization A&lt;int&gt;().
3587e5dd7070Spatrick
3588e5dd7070SpatrickUsable 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;
3589e5dd7070Spatrick</pre></td></tr>
3590e5dd7070Spatrick
3591e5dd7070Spatrick
3592e5dd7070Spatrick<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>
3593e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final.
3594e5dd7070Spatrick
3595e5dd7070SpatrickGiven:
3596e5dd7070Spatrick  class A final {};
3597e5dd7070Spatrick
3598e5dd7070Spatrick  struct B {
3599e5dd7070Spatrick    virtual void f();
3600e5dd7070Spatrick  };
3601e5dd7070Spatrick
3602e5dd7070Spatrick  struct C : B {
3603e5dd7070Spatrick    void f() final;
3604e5dd7070Spatrick  };
3605e5dd7070Spatrickmatches A and C::f, but not B, C, or B::f
3606e5dd7070Spatrick</pre></td></tr>
3607e5dd7070Spatrick
3608e5dd7070Spatrick
3609e5dd7070Spatrick<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>
3610e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isLambda0"><pre>Matches the generated class of lambda expressions.
3611e5dd7070Spatrick
3612e5dd7070SpatrickGiven:
3613e5dd7070Spatrick  auto x = []{};
3614e5dd7070Spatrick
3615e5dd7070SpatrickcxxRecordDecl(isLambda()) matches the implicit class declaration of
3616e5dd7070Spatrickdecltype(x)
3617e5dd7070Spatrick</pre></td></tr>
3618e5dd7070Spatrick
3619e5dd7070Spatrick
3620e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isSameOrDerivedFrom2')"><a name="isSameOrDerivedFrom2Anchor">isSameOrDerivedFrom</a></td><td>std::string BaseName</td></tr>
3621e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom2"><pre>Overloaded method as shortcut for
3622e5dd7070SpatrickisSameOrDerivedFrom(hasName(...)).
3623e5dd7070Spatrick</pre></td></tr>
3624e5dd7070Spatrick
3625e5dd7070Spatrick
3626e5dd7070Spatrick<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>
3627e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static
3628e5dd7070Spatrickmember variable template instantiations.
3629e5dd7070Spatrick
3630e5dd7070SpatrickGiven
3631e5dd7070Spatrick  template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
3632e5dd7070Spatrickor
3633e5dd7070Spatrick  template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
3634e5dd7070Spatrickor
3635e5dd7070Spatrick  template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
3636e5dd7070SpatrickcxxRecordDecl(hasName("::X"), isTemplateInstantiation())
3637e5dd7070Spatrick  matches the template instantiation of X&lt;A&gt;.
3638e5dd7070Spatrick
3639e5dd7070SpatrickBut given
3640e5dd7070Spatrick  template &lt;typename T&gt;  class X {}; class A {};
3641e5dd7070Spatrick  template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
3642e5dd7070SpatrickcxxRecordDecl(hasName("::X"), isTemplateInstantiation())
3643e5dd7070Spatrick  does not match, as X&lt;A&gt; is an explicit template specialization.
3644e5dd7070Spatrick
3645e5dd7070SpatrickUsable 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;
3646e5dd7070Spatrick</pre></td></tr>
3647e5dd7070Spatrick
3648e5dd7070Spatrick
3649a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasAnyOperatorName2')"><a name="hasAnyOperatorName2Anchor">hasAnyOperatorName</a></td><td>StringRef, ..., StringRef</td></tr>
3650a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasAnyOperatorName2"><pre>Matches operator expressions (binary or unary) that have any of the
3651a9ac8606Spatrickspecified names.
3652a9ac8606Spatrick
3653a9ac8606Spatrick   hasAnyOperatorName("+", "-")
3654a9ac8606Spatrick Is equivalent to
3655a9ac8606Spatrick   anyOf(hasOperatorName("+"), hasOperatorName("-"))
3656a9ac8606Spatrick</pre></td></tr>
3657a9ac8606Spatrick
3658a9ac8606Spatrick
3659a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasOperatorName2')"><a name="hasOperatorName2Anchor">hasOperatorName</a></td><td>std::string Name</td></tr>
3660a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasOperatorName2"><pre>Matches the operator Name of operator expressions (binary or
3661a9ac8606Spatrickunary).
3662a9ac8606Spatrick
3663a9ac8606SpatrickExample matches a || b (matcher = binaryOperator(hasOperatorName("||")))
3664a9ac8606Spatrick  !(a || b)
3665a9ac8606Spatrick</pre></td></tr>
3666a9ac8606Spatrick
3667a9ac8606Spatrick
3668a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>&gt;</td><td class="name" onclick="toggle('isAssignmentOperator2')"><a name="isAssignmentOperator2Anchor">isAssignmentOperator</a></td><td></td></tr>
3669a9ac8606Spatrick<tr><td colspan="4" class="doc" id="isAssignmentOperator2"><pre>Matches all kinds of assignment operators.
3670a9ac8606Spatrick
3671a9ac8606SpatrickExample 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3672a9ac8606Spatrick  if (a == b)
3673a9ac8606Spatrick    a += b;
3674a9ac8606Spatrick
3675a9ac8606SpatrickExample 2: matches s1 = s2
3676a9ac8606Spatrick           (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3677a9ac8606Spatrick  struct S { S&amp; operator=(const S&amp;); };
3678a9ac8606Spatrick  void x() { S s1, s2; s1 = s2; }
3679a9ac8606Spatrick</pre></td></tr>
3680a9ac8606Spatrick
3681a9ac8606Spatrick
3682a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>&gt;</td><td class="name" onclick="toggle('isComparisonOperator2')"><a name="isComparisonOperator2Anchor">isComparisonOperator</a></td><td></td></tr>
3683a9ac8606Spatrick<tr><td colspan="4" class="doc" id="isComparisonOperator2"><pre>Matches comparison operators.
3684a9ac8606Spatrick
3685a9ac8606SpatrickExample 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3686a9ac8606Spatrick  if (a == b)
3687a9ac8606Spatrick    a += b;
3688a9ac8606Spatrick
3689a9ac8606SpatrickExample 2: matches s1 &lt; s2
3690a9ac8606Spatrick           (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3691a9ac8606Spatrick  struct S { bool operator&lt;(const S&amp; other); };
3692a9ac8606Spatrick  void x(S s1, S s2) { bool b1 = s1 &lt; s2; }
3693a9ac8606Spatrick</pre></td></tr>
3694a9ac8606Spatrick
3695a9ac8606Spatrick
3696a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;</td><td class="name" onclick="toggle('argumentCountIs2')"><a name="argumentCountIs2Anchor">argumentCountIs</a></td><td>unsigned N</td></tr>
3697a9ac8606Spatrick<tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has
3698a9ac8606Spatricka specific number of arguments (including absent default arguments).
3699a9ac8606Spatrick
3700a9ac8606SpatrickExample matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
3701a9ac8606Spatrick  void f(int x, int y);
3702a9ac8606Spatrick  f(0, 0);
3703a9ac8606Spatrick</pre></td></tr>
3704a9ac8606Spatrick
3705a9ac8606Spatrick
3706e5dd7070Spatrick<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>
3707e5dd7070Spatrick<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has
3708e5dd7070Spatricka specific number of arguments (including absent default arguments).
3709e5dd7070Spatrick
3710e5dd7070SpatrickExample matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
3711e5dd7070Spatrick  void f(int x, int y);
3712e5dd7070Spatrick  f(0, 0);
3713e5dd7070Spatrick</pre></td></tr>
3714e5dd7070Spatrick
3715e5dd7070Spatrick
3716e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('usesADL0')"><a name="usesADL0Anchor">usesADL</a></td><td></td></tr>
3717e5dd7070Spatrick<tr><td colspan="4" class="doc" id="usesADL0"><pre>Matches call expressions which were resolved using ADL.
3718e5dd7070Spatrick
3719e5dd7070SpatrickExample matches y(x) but not y(42) or NS::y(x).
3720e5dd7070Spatrick  namespace NS {
3721e5dd7070Spatrick    struct X {};
3722e5dd7070Spatrick    void y(X);
3723e5dd7070Spatrick  }
3724e5dd7070Spatrick
3725e5dd7070Spatrick  void y(...);
3726e5dd7070Spatrick
3727e5dd7070Spatrick  void test() {
3728e5dd7070Spatrick    NS::X x;
3729e5dd7070Spatrick    y(x); // Matches
3730e5dd7070Spatrick    NS::y(x); // Doesn't match
3731e5dd7070Spatrick    y(42); // Doesn't match
3732e5dd7070Spatrick    using NS::y;
3733e5dd7070Spatrick    y(x); // Found by both unqualified lookup and ADL, doesn't match
3734e5dd7070Spatrick   }
3735e5dd7070Spatrick</pre></td></tr>
3736e5dd7070Spatrick
3737e5dd7070Spatrick
3738e5dd7070Spatrick<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>
3739e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasCastKind0"><pre>Matches casts that has a given cast kind.
3740e5dd7070Spatrick
3741e5dd7070SpatrickExample: matches the implicit cast around 0
3742e5dd7070Spatrick(matcher = castExpr(hasCastKind(CK_NullToPointer)))
3743e5dd7070Spatrick  int *p = 0;
3744e5dd7070Spatrick
3745e5dd7070SpatrickIf the matcher is use from clang-query, CastKind parameter
3746ec727ea7Spatrickshould be passed as a quoted string. e.g., hasCastKind("CK_NullToPointer").
3747e5dd7070Spatrick</pre></td></tr>
3748e5dd7070Spatrick
3749e5dd7070Spatrick
3750e5dd7070Spatrick<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>
3751e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equals4"><pre></pre></td></tr>
3752e5dd7070Spatrick
3753e5dd7070Spatrick
3754e5dd7070Spatrick<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>
3755e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value of type ValueT.
3756e5dd7070Spatrick
3757e5dd7070SpatrickGiven
3758e5dd7070Spatrick  f('false, 3.14, 42);
3759e5dd7070SpatrickcharacterLiteral(equals(0))
3760e5dd7070Spatrick  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
3761e5dd7070Spatrick  match false
3762e5dd7070SpatrickfloatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
3763e5dd7070Spatrick  match 3.14
3764e5dd7070SpatrickintegerLiteral(equals(42))
3765e5dd7070Spatrick  matches 42
3766e5dd7070Spatrick
3767e5dd7070SpatrickNote that you cannot directly match a negative numeric literal because the
3768e5dd7070Spatrickminus sign is not part of the literal: It is a unary operator whose operand
3769e5dd7070Spatrickis the positive numeric literal. Instead, you must use a unaryOperator()
3770e5dd7070Spatrickmatcher to match the minus sign:
3771e5dd7070Spatrick
3772e5dd7070SpatrickunaryOperator(hasOperatorName("-"),
3773e5dd7070Spatrick              hasUnaryOperand(integerLiteral(equals(13))))
3774e5dd7070Spatrick
3775e5dd7070SpatrickUsable 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;,
3776e5dd7070Spatrick           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;
3777e5dd7070Spatrick</pre></td></tr>
3778e5dd7070Spatrick
3779e5dd7070Spatrick
3780e5dd7070Spatrick<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>
3781e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equals10"><pre></pre></td></tr>
3782e5dd7070Spatrick
3783e5dd7070Spatrick
3784e5dd7070Spatrick<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>
3785e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equals7"><pre></pre></td></tr>
3786e5dd7070Spatrick
3787e5dd7070Spatrick
3788e5dd7070Spatrick<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>
3789e5dd7070Spatrick<tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N.
3790e5dd7070Spatrick
3791e5dd7070SpatrickGiven
3792e5dd7070Spatrick  template&lt;typename T&gt; struct C {};
3793e5dd7070Spatrick  C&lt;int&gt; c;
3794e5dd7070SpatrickclassTemplateSpecializationDecl(templateArgumentCountIs(1))
3795e5dd7070Spatrick  matches C&lt;int&gt;.
3796e5dd7070Spatrick</pre></td></tr>
3797e5dd7070Spatrick
3798e5dd7070Spatrick
3799e5dd7070Spatrick<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>
3800e5dd7070Spatrick<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of
3801e5dd7070Spatrickchild statements.
3802e5dd7070Spatrick
3803e5dd7070SpatrickExample: Given
3804e5dd7070Spatrick  { for (;;) {} }
3805e5dd7070SpatrickcompoundStmt(statementCountIs(0)))
3806e5dd7070Spatrick  matches '{}'
3807e5dd7070Spatrick  but does not match the outer compound statement.
3808e5dd7070Spatrick</pre></td></tr>
3809e5dd7070Spatrick
3810e5dd7070Spatrick
3811e5dd7070Spatrick<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>
3812e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches nodes that have the specified size.
3813e5dd7070Spatrick
3814e5dd7070SpatrickGiven
3815e5dd7070Spatrick  int a[42];
3816e5dd7070Spatrick  int b[2 * 21];
3817e5dd7070Spatrick  int c[41], d[43];
3818e5dd7070Spatrick  char *s = "abcd";
3819e5dd7070Spatrick  wchar_t *ws = L"abcd";
3820e5dd7070Spatrick  char *w = "a";
3821e5dd7070SpatrickconstantArrayType(hasSize(42))
3822e5dd7070Spatrick  matches "int a[42]" and "int b[2 * 21]"
3823e5dd7070SpatrickstringLiteral(hasSize(4))
3824e5dd7070Spatrick  matches "abcd", L"abcd"
3825e5dd7070Spatrick</pre></td></tr>
3826e5dd7070Spatrick
3827e5dd7070Spatrick
3828e5dd7070Spatrick<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>
3829e5dd7070Spatrick<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of
3830e5dd7070Spatrickdeclarations.
3831e5dd7070Spatrick
3832e5dd7070SpatrickExample: Given
3833e5dd7070Spatrick  int a, b;
3834e5dd7070Spatrick  int c;
3835e5dd7070Spatrick  int d = 2, e;
3836e5dd7070SpatrickdeclCountIs(2)
3837e5dd7070Spatrick  matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.
3838e5dd7070Spatrick</pre></td></tr>
3839e5dd7070Spatrick
3840e5dd7070Spatrick
3841e5dd7070Spatrick<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>
3842e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node.
3843e5dd7070Spatrick
3844e5dd7070SpatrickMatches a node if it equals the node previously bound to ID.
3845e5dd7070Spatrick
3846e5dd7070SpatrickGiven
3847e5dd7070Spatrick  class X { int a; int b; };
3848e5dd7070SpatrickcxxRecordDecl(
3849e5dd7070Spatrick    has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
3850e5dd7070Spatrick    has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
3851e5dd7070Spatrick  matches the class X, as a and b have the same type.
3852e5dd7070Spatrick
3853e5dd7070SpatrickNote that when multiple matches are involved via forEach* matchers,
3854e5dd7070SpatrickequalsBoundNodes acts as a filter.
3855e5dd7070SpatrickFor example:
3856e5dd7070SpatrickcompoundStmt(
3857e5dd7070Spatrick    forEachDescendant(varDecl().bind("d")),
3858e5dd7070Spatrick    forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
3859e5dd7070Spatrickwill trigger a match for each combination of variable declaration
3860e5dd7070Spatrickand reference to that variable declaration within a compound statement.
3861e5dd7070Spatrick</pre></td></tr>
3862e5dd7070Spatrick
3863e5dd7070Spatrick
3864e5dd7070Spatrick<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>
3865e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node.
3866e5dd7070Spatrick
3867e5dd7070SpatrickDecl has pointer identity in the AST.
3868e5dd7070Spatrick</pre></td></tr>
3869e5dd7070Spatrick
3870e5dd7070Spatrick
3871e5dd7070Spatrick<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>
3872e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute.
3873e5dd7070Spatrick
3874e5dd7070SpatrickGiven
3875e5dd7070Spatrick  __attribute__((device)) void f() { ... }
3876e5dd7070Spatrickdecl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
3877e5dd7070Spatrickf. If the matcher is used from clang-query, attr::Kind parameter should be
3878e5dd7070Spatrickpassed as a quoted string. e.g., hasAttr("attr::CUDADevice").
3879e5dd7070Spatrick</pre></td></tr>
3880e5dd7070Spatrick
3881e5dd7070Spatrick
3882a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isExpandedFromMacro0')"><a name="isExpandedFromMacro0Anchor">isExpandedFromMacro</a></td><td>std::string MacroName</td></tr>
3883a9ac8606Spatrick<tr><td colspan="4" class="doc" id="isExpandedFromMacro0"><pre>Matches statements that are (transitively) expanded from the named macro.
3884a9ac8606SpatrickDoes not match if only part of the statement is expanded from that macro or
3885*12c85518Srobertif different parts of the statement are expanded from different
3886a9ac8606Spatrickappearances of the macro.
3887a9ac8606Spatrick</pre></td></tr>
3888a9ac8606Spatrick
3889a9ac8606Spatrick
3890ec727ea7Spatrick<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>StringRef RegExp, Regex::RegexFlags Flags = NoFlags</td></tr>
3891e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is
3892e5dd7070Spatrickpartially matching a given regex.
3893e5dd7070Spatrick
3894e5dd7070SpatrickExample matches Y but not X
3895e5dd7070Spatrick    (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
3896e5dd7070Spatrick  #include "ASTMatcher.h"
3897e5dd7070Spatrick  class X {};
3898e5dd7070SpatrickASTMatcher.h:
3899e5dd7070Spatrick  class Y {};
3900e5dd7070Spatrick
3901e5dd7070SpatrickUsable 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;
3902ec727ea7Spatrick
3903ec727ea7SpatrickIf the matcher is used in clang-query, RegexFlags parameter
3904ec727ea7Spatrickshould be passed as a quoted string. e.g: "NoFlags".
3905ec727ea7SpatrickFlags can be combined with '|' example "IgnoreCase | BasicRegex"
3906e5dd7070Spatrick</pre></td></tr>
3907e5dd7070Spatrick
3908e5dd7070Spatrick
3909e5dd7070Spatrick<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>
3910e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file.
3911e5dd7070Spatrick
3912e5dd7070SpatrickExample matches X but not Y
3913e5dd7070Spatrick  (matcher = cxxRecordDecl(isExpansionInMainFile())
3914e5dd7070Spatrick  #include &lt;Y.h&gt;
3915e5dd7070Spatrick  class X {};
3916e5dd7070SpatrickY.h:
3917e5dd7070Spatrick  class Y {};
3918e5dd7070Spatrick
3919e5dd7070SpatrickUsable 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;
3920e5dd7070Spatrick</pre></td></tr>
3921e5dd7070Spatrick
3922e5dd7070Spatrick
3923e5dd7070Spatrick<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>
3924e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files.
3925e5dd7070Spatrick
3926e5dd7070SpatrickExample matches Y but not X
3927e5dd7070Spatrick    (matcher = cxxRecordDecl(isExpansionInSystemHeader())
3928e5dd7070Spatrick  #include &lt;SystemHeader.h&gt;
3929e5dd7070Spatrick  class X {};
3930e5dd7070SpatrickSystemHeader.h:
3931e5dd7070Spatrick  class Y {};
3932e5dd7070Spatrick
3933e5dd7070SpatrickUsable 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;
3934e5dd7070Spatrick</pre></td></tr>
3935e5dd7070Spatrick
3936e5dd7070Spatrick
3937e5dd7070Spatrick<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>
3938*12c85518Srobert<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
3939*12c85518Srobertimplicit default/copy constructors).
3940*12c85518Srobert</pre></td></tr>
3941*12c85518Srobert
3942*12c85518Srobert
3943*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isInAnonymousNamespace0')"><a name="isInAnonymousNamespace0Anchor">isInAnonymousNamespace</a></td><td></td></tr>
3944*12c85518Srobert<tr><td colspan="4" class="doc" id="isInAnonymousNamespace0"><pre>Matches declarations in an anonymous namespace.
3945*12c85518Srobert
3946*12c85518SrobertGiven
3947*12c85518Srobert  class vector {};
3948*12c85518Srobert  namespace foo {
3949*12c85518Srobert    class vector {};
3950*12c85518Srobert    namespace {
3951*12c85518Srobert      class vector {}; // #1
3952*12c85518Srobert    }
3953*12c85518Srobert  }
3954*12c85518Srobert  namespace {
3955*12c85518Srobert    class vector {}; // #2
3956*12c85518Srobert    namespace foo {
3957*12c85518Srobert      class vector{}; // #3
3958*12c85518Srobert    }
3959*12c85518Srobert  }
3960*12c85518SrobertcxxRecordDecl(hasName("vector"), isInAnonymousNamespace()) will match
3961*12c85518Srobert#1, #2 and #3.
3962e5dd7070Spatrick</pre></td></tr>
3963e5dd7070Spatrick
3964e5dd7070Spatrick
3965e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isInStdNamespace0')"><a name="isInStdNamespace0Anchor">isInStdNamespace</a></td><td></td></tr>
3966e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isInStdNamespace0"><pre>Matches declarations in the namespace `std`, but not in nested namespaces.
3967e5dd7070Spatrick
3968e5dd7070SpatrickGiven
3969e5dd7070Spatrick  class vector {};
3970e5dd7070Spatrick  namespace foo {
3971e5dd7070Spatrick    class vector {};
3972e5dd7070Spatrick    namespace std {
3973e5dd7070Spatrick      class vector {};
3974e5dd7070Spatrick    }
3975e5dd7070Spatrick  }
3976e5dd7070Spatrick  namespace std {
3977e5dd7070Spatrick    inline namespace __1 {
3978e5dd7070Spatrick      class vector {}; // #1
3979e5dd7070Spatrick      namespace experimental {
3980e5dd7070Spatrick        class vector {};
3981e5dd7070Spatrick      }
3982e5dd7070Spatrick    }
3983e5dd7070Spatrick  }
3984e5dd7070SpatrickcxxRecordDecl(hasName("vector"), isInStdNamespace()) will match only #1.
3985e5dd7070Spatrick</pre></td></tr>
3986e5dd7070Spatrick
3987e5dd7070Spatrick
3988ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isInstantiated0')"><a name="isInstantiated0Anchor">isInstantiated</a></td><td></td></tr>
3989ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside
3990ec727ea7Spatricktemplate instantiations.
3991e5dd7070Spatrick
3992e5dd7070SpatrickGiven
3993ec727ea7Spatrick  template&lt;typename T&gt; void A(T t) { T i; }
3994ec727ea7Spatrick  A(0);
3995ec727ea7Spatrick  A(0U);
3996ec727ea7SpatrickfunctionDecl(isInstantiated())
3997ec727ea7Spatrick  matches 'A(int) {...};' and 'A(unsigned) {...}'.
3998ec727ea7Spatrick</pre></td></tr>
3999ec727ea7Spatrick
4000ec727ea7Spatrick
4001ec727ea7Spatrick<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>
4002ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations and C++ base specifers that specify private
4003ec727ea7Spatrickinheritance.
4004ec727ea7Spatrick
4005ec727ea7SpatrickExamples:
4006e5dd7070Spatrick  class C {
4007e5dd7070Spatrick  public:    int a;
4008e5dd7070Spatrick  protected: int b;
4009ec727ea7Spatrick  private:   int c; // fieldDecl(isPrivate()) matches 'c'
4010e5dd7070Spatrick  };
4011ec727ea7Spatrick
4012ec727ea7Spatrick  struct Base {};
4013ec727ea7Spatrick  struct Derived1 : private Base {}; // matches 'Base'
4014ec727ea7Spatrick  class Derived2 : Base {}; // matches 'Base'
4015e5dd7070Spatrick</pre></td></tr>
4016e5dd7070Spatrick
4017e5dd7070Spatrick
4018e5dd7070Spatrick<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>
4019ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations and C++ base specifers that specify
4020ec727ea7Spatrickprotected inheritance.
4021e5dd7070Spatrick
4022ec727ea7SpatrickExamples:
4023e5dd7070Spatrick  class C {
4024e5dd7070Spatrick  public:    int a;
4025ec727ea7Spatrick  protected: int b; // fieldDecl(isProtected()) matches 'b'
4026e5dd7070Spatrick  private:   int c;
4027e5dd7070Spatrick  };
4028ec727ea7Spatrick
4029ec727ea7Spatrick  class Base {};
4030ec727ea7Spatrick  class Derived : protected Base {}; // matches 'Base'
4031e5dd7070Spatrick</pre></td></tr>
4032e5dd7070Spatrick
4033e5dd7070Spatrick
4034e5dd7070Spatrick<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>
4035ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations and C++ base specifers that specify public
4036ec727ea7Spatrickinheritance.
4037e5dd7070Spatrick
4038ec727ea7SpatrickExamples:
4039e5dd7070Spatrick  class C {
4040ec727ea7Spatrick  public:    int a; // fieldDecl(isPublic()) matches 'a'
4041e5dd7070Spatrick  protected: int b;
4042e5dd7070Spatrick  private:   int c;
4043e5dd7070Spatrick  };
4044ec727ea7Spatrick
4045ec727ea7Spatrick  class Base {};
4046ec727ea7Spatrick  class Derived1 : public Base {}; // matches 'Base'
4047ec727ea7Spatrick  struct Derived2 : Base {}; // matches 'Base'
4048e5dd7070Spatrick</pre></td></tr>
4049e5dd7070Spatrick
4050e5dd7070Spatrick
4051e5dd7070Spatrick<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>
4052e5dd7070Spatrick<tr><td colspan="4" class="doc" id="designatorCountIs0"><pre>Matches designated initializer expressions that contain
4053e5dd7070Spatricka specific number of designators.
4054e5dd7070Spatrick
4055e5dd7070SpatrickExample: Given
4056e5dd7070Spatrick  point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
4057e5dd7070Spatrick  point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 };
4058e5dd7070SpatrickdesignatorCountIs(2)
4059e5dd7070Spatrick  matches '{ [2].y = 1.0, [0].x = 1.0 }',
4060e5dd7070Spatrick  but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'.
4061e5dd7070Spatrick</pre></td></tr>
4062e5dd7070Spatrick
4063e5dd7070Spatrick
4064e5dd7070Spatrick<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>
4065e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isScoped0"><pre>Matches C++11 scoped enum declaration.
4066e5dd7070Spatrick
4067e5dd7070SpatrickExample matches Y (matcher = enumDecl(isScoped()))
4068e5dd7070Spatrickenum X {};
4069e5dd7070Spatrickenum class Y {};
4070e5dd7070Spatrick</pre></td></tr>
4071e5dd7070Spatrick
4072e5dd7070Spatrick
4073e5dd7070Spatrick<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>
4074e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isInstantiationDependent0"><pre>Matches expressions that are instantiation-dependent even if it is
4075e5dd7070Spatrickneither type- nor value-dependent.
4076e5dd7070Spatrick
4077e5dd7070SpatrickIn the following example, the expression sizeof(sizeof(T() + T()))
4078e5dd7070Spatrickis instantiation-dependent (since it involves a template parameter T),
4079e5dd7070Spatrickbut is neither type- nor value-dependent, since the type of the inner
4080e5dd7070Spatricksizeof is known (std::size_t) and therefore the size of the outer
4081e5dd7070Spatricksizeof is known.
4082e5dd7070Spatrick  template&lt;typename T&gt;
4083e5dd7070Spatrick  void f(T x, T y) { sizeof(sizeof(T() + T()); }
4084e5dd7070Spatrickexpr(isInstantiationDependent()) matches sizeof(sizeof(T() + T())
4085e5dd7070Spatrick</pre></td></tr>
4086e5dd7070Spatrick
4087e5dd7070Spatrick
4088e5dd7070Spatrick<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>
4089e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isTypeDependent0"><pre>Matches expressions that are type-dependent because the template type
4090e5dd7070Spatrickis not yet instantiated.
4091e5dd7070Spatrick
4092e5dd7070SpatrickFor example, the expressions "x" and "x + y" are type-dependent in
4093e5dd7070Spatrickthe following code, but "y" is not type-dependent:
4094e5dd7070Spatrick  template&lt;typename T&gt;
4095e5dd7070Spatrick  void add(T x, int y) {
4096e5dd7070Spatrick    x + y;
4097e5dd7070Spatrick  }
4098e5dd7070Spatrickexpr(isTypeDependent()) matches x + y
4099e5dd7070Spatrick</pre></td></tr>
4100e5dd7070Spatrick
4101e5dd7070Spatrick
4102e5dd7070Spatrick<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>
4103e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isValueDependent0"><pre>Matches expression that are value-dependent because they contain a
4104e5dd7070Spatricknon-type template parameter.
4105e5dd7070Spatrick
4106e5dd7070SpatrickFor example, the array bound of "Chars" in the following example is
4107e5dd7070Spatrickvalue-dependent.
4108e5dd7070Spatrick  template&lt;int Size&gt; int f() { return Size; }
4109e5dd7070Spatrickexpr(isValueDependent()) matches return Size
4110e5dd7070Spatrick</pre></td></tr>
4111e5dd7070Spatrick
4112e5dd7070Spatrick
4113e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('nullPointerConstant0')"><a name="nullPointerConstant0Anchor">nullPointerConstant</a></td><td></td></tr>
4114e5dd7070Spatrick<tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as
4115e5dd7070SpatrickGNU's __null, C++11's nullptr, or C's NULL macro.
4116e5dd7070Spatrick
4117e5dd7070SpatrickGiven:
4118e5dd7070Spatrick  void *v1 = NULL;
4119e5dd7070Spatrick  void *v2 = nullptr;
4120e5dd7070Spatrick  void *v3 = __null; // GNU extension
4121e5dd7070Spatrick  char *cp = (char *)0;
4122e5dd7070Spatrick  int *ip = 0;
4123e5dd7070Spatrick  int i = 0;
4124e5dd7070Spatrickexpr(nullPointerConstant())
4125e5dd7070Spatrick  matches the initializer for v1, v2, v3, cp, and ip. Does not match the
4126e5dd7070Spatrick  initializer for i.
4127e5dd7070Spatrick</pre></td></tr>
4128e5dd7070Spatrick
4129e5dd7070Spatrick
4130e5dd7070Spatrick<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>
4131e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified
4132e5dd7070Spatrickbit width.
4133e5dd7070Spatrick
4134e5dd7070SpatrickGiven
4135e5dd7070Spatrick  class C {
4136e5dd7070Spatrick    int a : 2;
4137e5dd7070Spatrick    int b : 4;
4138e5dd7070Spatrick    int c : 2;
4139e5dd7070Spatrick  };
4140e5dd7070SpatrickfieldDecl(hasBitWidth(2))
4141e5dd7070Spatrick  matches 'int a;' and 'int c;' but not 'int b;'.
4142e5dd7070Spatrick</pre></td></tr>
4143e5dd7070Spatrick
4144e5dd7070Spatrick
4145e5dd7070Spatrick<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>
4146e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isBitField0"><pre>Matches non-static data members that are bit-fields.
4147e5dd7070Spatrick
4148e5dd7070SpatrickGiven
4149e5dd7070Spatrick  class C {
4150e5dd7070Spatrick    int a : 2;
4151e5dd7070Spatrick    int b;
4152e5dd7070Spatrick  };
4153e5dd7070SpatrickfieldDecl(isBitField())
4154e5dd7070Spatrick  matches 'int a;' but not 'int b;'.
4155e5dd7070Spatrick</pre></td></tr>
4156e5dd7070Spatrick
4157e5dd7070Spatrick
4158e5dd7070Spatrick<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>
4159e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value of type ValueT.
4160e5dd7070Spatrick
4161e5dd7070SpatrickGiven
4162e5dd7070Spatrick  f('false, 3.14, 42);
4163e5dd7070SpatrickcharacterLiteral(equals(0))
4164e5dd7070Spatrick  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
4165e5dd7070Spatrick  match false
4166e5dd7070SpatrickfloatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
4167e5dd7070Spatrick  match 3.14
4168e5dd7070SpatrickintegerLiteral(equals(42))
4169e5dd7070Spatrick  matches 42
4170e5dd7070Spatrick
4171e5dd7070SpatrickNote that you cannot directly match a negative numeric literal because the
4172e5dd7070Spatrickminus sign is not part of the literal: It is a unary operator whose operand
4173e5dd7070Spatrickis the positive numeric literal. Instead, you must use a unaryOperator()
4174e5dd7070Spatrickmatcher to match the minus sign:
4175e5dd7070Spatrick
4176e5dd7070SpatrickunaryOperator(hasOperatorName("-"),
4177e5dd7070Spatrick              hasUnaryOperand(integerLiteral(equals(13))))
4178e5dd7070Spatrick
4179e5dd7070SpatrickUsable 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;,
4180e5dd7070Spatrick           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;
4181e5dd7070Spatrick</pre></td></tr>
4182e5dd7070Spatrick
4183e5dd7070Spatrick
4184e5dd7070Spatrick<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>
4185e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equals12"><pre></pre></td></tr>
4186e5dd7070Spatrick
4187e5dd7070Spatrick
4188ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyOverloadedOperatorName1')"><a name="hasAnyOverloadedOperatorName1Anchor">hasAnyOverloadedOperatorName</a></td><td>StringRef, ..., StringRef</td></tr>
4189ec727ea7Spatrick<tr><td colspan="4" class="doc" id="hasAnyOverloadedOperatorName1"><pre>Matches overloaded operator names.
4190ec727ea7Spatrick
4191ec727ea7SpatrickMatches overloaded operator names specified in strings without the
4192ec727ea7Spatrick"operator" prefix: e.g. "&lt;&lt;".
4193ec727ea7Spatrick
4194a9ac8606Spatrick  hasAnyOverloadedOperatorName("+", "-")
4195ec727ea7SpatrickIs equivalent to
4196ec727ea7Spatrick  anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
4197ec727ea7Spatrick</pre></td></tr>
4198ec727ea7Spatrick
4199ec727ea7Spatrick
4200e5dd7070Spatrick<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>
4201e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification.
4202e5dd7070Spatrick
4203e5dd7070SpatrickGiven:
4204e5dd7070Spatrick  void f();
4205e5dd7070Spatrick  void g() noexcept;
4206e5dd7070Spatrick  void h() noexcept(true);
4207e5dd7070Spatrick  void i() noexcept(false);
4208e5dd7070Spatrick  void j() throw();
4209e5dd7070Spatrick  void k() throw(int);
4210e5dd7070Spatrick  void l() throw(...);
4211e5dd7070SpatrickfunctionDecl(hasDynamicExceptionSpec()) and
4212e5dd7070Spatrick  functionProtoType(hasDynamicExceptionSpec())
4213e5dd7070Spatrick  match the declarations of j, k, and l, but not f, g, h, or i.
4214e5dd7070Spatrick</pre></td></tr>
4215e5dd7070Spatrick
4216e5dd7070Spatrick
4217e5dd7070Spatrick<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>
4218e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names.
4219e5dd7070Spatrick
4220e5dd7070SpatrickMatches overloaded operator names specified in strings without the
4221e5dd7070Spatrick"operator" prefix: e.g. "&lt;&lt;".
4222e5dd7070Spatrick
4223e5dd7070SpatrickGiven:
4224e5dd7070Spatrick  class A { int operator*(); };
4225e5dd7070Spatrick  const A &amp;operator&lt;&lt;(const A &amp;a, const A &amp;b);
4226e5dd7070Spatrick  A a;
4227e5dd7070Spatrick  a &lt;&lt; a;   // &lt;-- This matches
4228e5dd7070Spatrick
4229e5dd7070SpatrickcxxOperatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the
4230e5dd7070Spatrickspecified line and
4231e5dd7070SpatrickcxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
4232e5dd7070Spatrickmatches the declaration of A.
4233e5dd7070Spatrick
4234e5dd7070SpatrickUsable 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;
4235e5dd7070Spatrick</pre></td></tr>
4236e5dd7070Spatrick
4237e5dd7070Spatrick
4238e5dd7070Spatrick<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>
4239e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasTrailingReturn0"><pre>Matches a function declared with a trailing return type.
4240e5dd7070Spatrick
4241e5dd7070SpatrickExample matches Y (matcher = functionDecl(hasTrailingReturn()))
4242e5dd7070Spatrickint X() {}
4243e5dd7070Spatrickauto Y() -&gt; int {}
4244e5dd7070Spatrick</pre></td></tr>
4245e5dd7070Spatrick
4246e5dd7070Spatrick
4247*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isConsteval0')"><a name="isConsteval0Anchor">isConsteval</a></td><td></td></tr>
4248*12c85518Srobert<tr><td colspan="4" class="doc" id="isConsteval0"><pre>Matches consteval function declarations and if consteval/if ! consteval
4249*12c85518Srobertstatements.
4250*12c85518Srobert
4251*12c85518SrobertGiven:
4252*12c85518Srobert  consteval int a();
4253*12c85518Srobert  void b() { if consteval {} }
4254*12c85518Srobert  void c() { if ! consteval {} }
4255*12c85518Srobert  void d() { if ! consteval {} else {} }
4256*12c85518SrobertfunctionDecl(isConsteval())
4257*12c85518Srobert  matches the declaration of "int a()".
4258*12c85518SrobertifStmt(isConsteval())
4259*12c85518Srobert  matches the if statement in "void b()", "void c()", "void d()".
4260*12c85518Srobert</pre></td></tr>
4261*12c85518Srobert
4262*12c85518Srobert
4263e5dd7070Spatrick<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>
4264e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations,
4265e5dd7070Spatrick       and if constexpr.
4266e5dd7070Spatrick
4267e5dd7070SpatrickGiven:
4268e5dd7070Spatrick  constexpr int foo = 42;
4269e5dd7070Spatrick  constexpr int bar();
4270e5dd7070Spatrick  void baz() { if constexpr(1 &gt; 0) {} }
4271e5dd7070SpatrickvarDecl(isConstexpr())
4272e5dd7070Spatrick  matches the declaration of foo.
4273e5dd7070SpatrickfunctionDecl(isConstexpr())
4274e5dd7070Spatrick  matches the declaration of bar.
4275e5dd7070SpatrickifStmt(isConstexpr())
4276e5dd7070Spatrick  matches the if statement in baz.
4277e5dd7070Spatrick</pre></td></tr>
4278e5dd7070Spatrick
4279e5dd7070Spatrick
4280e5dd7070Spatrick<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>
4281e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations.
4282e5dd7070Spatrick
4283e5dd7070SpatrickGiven:
4284e5dd7070Spatrick  class A { ~A(); };
4285e5dd7070Spatrick  class B { ~B() = default; };
4286e5dd7070SpatrickfunctionDecl(isDefaulted())
4287e5dd7070Spatrick  matches the declaration of ~B, but not ~A.
4288e5dd7070Spatrick</pre></td></tr>
4289e5dd7070Spatrick
4290e5dd7070Spatrick
4291e5dd7070Spatrick<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>
4292e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDefinition3"><pre>Matches if a declaration has a body attached.
4293e5dd7070Spatrick
4294e5dd7070SpatrickExample matches A, va, fa
4295e5dd7070Spatrick  class A {};
4296e5dd7070Spatrick  class B;  // Doesn't match, as it has no body.
4297e5dd7070Spatrick  int va;
4298e5dd7070Spatrick  extern int vb;  // Doesn't match, as it doesn't define the variable.
4299e5dd7070Spatrick  void fa() {}
4300e5dd7070Spatrick  void fb();  // Doesn't match, as it has no body.
4301e5dd7070Spatrick  @interface X
4302e5dd7070Spatrick  - (void)ma; // Doesn't match, interface is declaration.
4303e5dd7070Spatrick  @end
4304e5dd7070Spatrick  @implementation X
4305e5dd7070Spatrick  - (void)ma {}
4306e5dd7070Spatrick  @end
4307e5dd7070Spatrick
4308e5dd7070SpatrickUsable 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;,
4309e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
4310e5dd7070Spatrick</pre></td></tr>
4311e5dd7070Spatrick
4312e5dd7070Spatrick
4313e5dd7070Spatrick<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>
4314e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations.
4315e5dd7070Spatrick
4316e5dd7070SpatrickGiven:
4317e5dd7070Spatrick  void Func();
4318e5dd7070Spatrick  void DeletedFunc() = delete;
4319e5dd7070SpatrickfunctionDecl(isDeleted())
4320e5dd7070Spatrick  matches the declaration of DeletedFunc, but not Func.
4321e5dd7070Spatrick</pre></td></tr>
4322e5dd7070Spatrick
4323e5dd7070Spatrick
4324e5dd7070Spatrick<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>
4325e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or
4326e5dd7070Spatrickstatic member variable template instantiations.
4327e5dd7070Spatrick
4328e5dd7070SpatrickGiven
4329e5dd7070Spatrick  template&lt;typename T&gt; void A(T t) { }
4330e5dd7070Spatrick  template&lt;&gt; void A(int N) { }
4331e5dd7070SpatrickfunctionDecl(isExplicitTemplateSpecialization())
4332e5dd7070Spatrick  matches the specialization A&lt;int&gt;().
4333e5dd7070Spatrick
4334e5dd7070SpatrickUsable 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;
4335e5dd7070Spatrick</pre></td></tr>
4336e5dd7070Spatrick
4337e5dd7070Spatrick
4338e5dd7070Spatrick<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>
4339e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function or variable declarations.
4340e5dd7070Spatrick
4341e5dd7070SpatrickGiven:
4342e5dd7070Spatrick  extern "C" void f() {}
4343e5dd7070Spatrick  extern "C" { void g() {} }
4344e5dd7070Spatrick  void h() {}
4345e5dd7070Spatrick  extern "C" int x = 1;
4346e5dd7070Spatrick  extern "C" int y = 2;
4347e5dd7070Spatrick  int z = 3;
4348e5dd7070SpatrickfunctionDecl(isExternC())
4349e5dd7070Spatrick  matches the declaration of f and g, but not the declaration of h.
4350e5dd7070SpatrickvarDecl(isExternC())
4351e5dd7070Spatrick  matches the declaration of x and y, but not the declaration of z.
4352e5dd7070Spatrick</pre></td></tr>
4353e5dd7070Spatrick
4354e5dd7070Spatrick
4355e5dd7070Spatrick<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>
4356*12c85518Srobert<tr><td colspan="4" class="doc" id="isInline1"><pre>Matches functions, variables and namespace declarations that are marked with
4357e5dd7070Spatrickthe inline keyword.
4358e5dd7070Spatrick
4359e5dd7070SpatrickGiven
4360e5dd7070Spatrick  inline void f();
4361e5dd7070Spatrick  void g();
4362e5dd7070Spatrick  namespace n {
4363e5dd7070Spatrick  inline namespace m {}
4364e5dd7070Spatrick  }
4365*12c85518Srobert  inline int Foo = 5;
4366e5dd7070SpatrickfunctionDecl(isInline()) will match ::f().
4367e5dd7070SpatricknamespaceDecl(isInline()) will match n::m.
4368*12c85518SrobertvarDecl(isInline()) will match Foo;
4369e5dd7070Spatrick</pre></td></tr>
4370e5dd7070Spatrick
4371e5dd7070Spatrick
4372e5dd7070Spatrick<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>
4373e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isMain0"><pre>Determines whether the function is "main", which is the entry point
4374e5dd7070Spatrickinto an executable program.
4375e5dd7070Spatrick</pre></td></tr>
4376e5dd7070Spatrick
4377e5dd7070Spatrick
4378e5dd7070Spatrick<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>
4379e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute.
4380e5dd7070Spatrick
4381e5dd7070SpatrickGiven
4382e5dd7070Spatrick  void nope();
4383e5dd7070Spatrick  [[noreturn]] void a();
4384e5dd7070Spatrick  __attribute__((noreturn)) void b();
4385e5dd7070Spatrick  struct c { [[noreturn]] c(); };
4386e5dd7070SpatrickfunctionDecl(isNoReturn())
4387e5dd7070Spatrick  matches all of those except
4388e5dd7070Spatrick  void nope();
4389e5dd7070Spatrick</pre></td></tr>
4390e5dd7070Spatrick
4391e5dd7070Spatrick
4392e5dd7070Spatrick<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>
4393e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification.
4394e5dd7070Spatrick
4395e5dd7070SpatrickGiven:
4396e5dd7070Spatrick  void f();
4397e5dd7070Spatrick  void g() noexcept;
4398e5dd7070Spatrick  void h() throw();
4399e5dd7070Spatrick  void i() throw(int);
4400e5dd7070Spatrick  void j() noexcept(false);
4401e5dd7070SpatrickfunctionDecl(isNoThrow()) and functionProtoType(isNoThrow())
4402e5dd7070Spatrick  match the declarations of g, and h, but not f, i or j.
4403e5dd7070Spatrick</pre></td></tr>
4404e5dd7070Spatrick
4405e5dd7070Spatrick
4406e5dd7070Spatrick<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>
4407e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variable/function declarations that have "static" storage
4408e5dd7070Spatrickclass specifier ("static" keyword) written in the source.
4409e5dd7070Spatrick
4410e5dd7070SpatrickGiven:
4411e5dd7070Spatrick  static void f() {}
4412e5dd7070Spatrick  static int i = 0;
4413e5dd7070Spatrick  extern int j;
4414e5dd7070Spatrick  int k;
4415e5dd7070SpatrickfunctionDecl(isStaticStorageClass())
4416e5dd7070Spatrick  matches the function declaration f.
4417e5dd7070SpatrickvarDecl(isStaticStorageClass())
4418e5dd7070Spatrick  matches the variable declaration i.
4419e5dd7070Spatrick</pre></td></tr>
4420e5dd7070Spatrick
4421e5dd7070Spatrick
4422e5dd7070Spatrick<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>
4423e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static
4424e5dd7070Spatrickmember variable template instantiations.
4425e5dd7070Spatrick
4426e5dd7070SpatrickGiven
4427e5dd7070Spatrick  template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
4428e5dd7070Spatrickor
4429e5dd7070Spatrick  template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
4430e5dd7070Spatrickor
4431e5dd7070Spatrick  template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
4432e5dd7070SpatrickcxxRecordDecl(hasName("::X"), isTemplateInstantiation())
4433e5dd7070Spatrick  matches the template instantiation of X&lt;A&gt;.
4434e5dd7070Spatrick
4435e5dd7070SpatrickBut given
4436e5dd7070Spatrick  template &lt;typename T&gt;  class X {}; class A {};
4437e5dd7070Spatrick  template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
4438e5dd7070SpatrickcxxRecordDecl(hasName("::X"), isTemplateInstantiation())
4439e5dd7070Spatrick  does not match, as X&lt;A&gt; is an explicit template specialization.
4440e5dd7070Spatrick
4441e5dd7070SpatrickUsable 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;
4442e5dd7070Spatrick</pre></td></tr>
4443e5dd7070Spatrick
4444e5dd7070Spatrick
4445e5dd7070Spatrick<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>
4446e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic.
4447e5dd7070Spatrick
4448e5dd7070SpatrickExample matches f, but not g or h. The function i will not match, even when
4449e5dd7070Spatrickcompiled in C mode.
4450e5dd7070Spatrick  void f(...);
4451e5dd7070Spatrick  void g(int);
4452e5dd7070Spatrick  template &lt;typename... Ts&gt; void h(Ts...);
4453e5dd7070Spatrick  void i();
4454e5dd7070Spatrick</pre></td></tr>
4455e5dd7070Spatrick
4456e5dd7070Spatrick
4457a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('isWeak0')"><a name="isWeak0Anchor">isWeak</a></td><td></td></tr>
4458a9ac8606Spatrick<tr><td colspan="4" class="doc" id="isWeak0"><pre>Matches weak function declarations.
4459a9ac8606Spatrick
4460a9ac8606SpatrickGiven:
4461a9ac8606Spatrick  void foo() __attribute__((__weakref__("__foo")));
4462a9ac8606Spatrick  void bar();
4463a9ac8606SpatrickfunctionDecl(isWeak())
4464a9ac8606Spatrick  matches the weak declaration "foo", but not "bar".
4465a9ac8606Spatrick</pre></td></tr>
4466a9ac8606Spatrick
4467a9ac8606Spatrick
4468e5dd7070Spatrick<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>
4469e5dd7070Spatrick<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
4470e5dd7070Spatrickspecific parameter count.
4471e5dd7070Spatrick
4472e5dd7070SpatrickGiven
4473e5dd7070Spatrick  void f(int i) {}
4474e5dd7070Spatrick  void g(int i, int j) {}
4475e5dd7070Spatrick  void h(int i, int j);
4476e5dd7070Spatrick  void j(int i);
4477e5dd7070Spatrick  void k(int x, int y, int z, ...);
4478e5dd7070SpatrickfunctionDecl(parameterCountIs(2))
4479e5dd7070Spatrick  matches g and h
4480e5dd7070SpatrickfunctionProtoType(parameterCountIs(2))
4481e5dd7070Spatrick  matches g and h
4482e5dd7070SpatrickfunctionProtoType(parameterCountIs(3))
4483e5dd7070Spatrick  matches k
4484e5dd7070Spatrick</pre></td></tr>
4485e5dd7070Spatrick
4486e5dd7070Spatrick
4487e5dd7070Spatrick<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>
4488e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification.
4489e5dd7070Spatrick
4490e5dd7070SpatrickGiven:
4491e5dd7070Spatrick  void f();
4492e5dd7070Spatrick  void g() noexcept;
4493e5dd7070Spatrick  void h() noexcept(true);
4494e5dd7070Spatrick  void i() noexcept(false);
4495e5dd7070Spatrick  void j() throw();
4496e5dd7070Spatrick  void k() throw(int);
4497e5dd7070Spatrick  void l() throw(...);
4498e5dd7070SpatrickfunctionDecl(hasDynamicExceptionSpec()) and
4499e5dd7070Spatrick  functionProtoType(hasDynamicExceptionSpec())
4500e5dd7070Spatrick  match the declarations of j, k, and l, but not f, g, h, or i.
4501e5dd7070Spatrick</pre></td></tr>
4502e5dd7070Spatrick
4503e5dd7070Spatrick
4504e5dd7070Spatrick<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>
4505e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isNoThrow1"><pre>Matches functions that have a non-throwing exception specification.
4506e5dd7070Spatrick
4507e5dd7070SpatrickGiven:
4508e5dd7070Spatrick  void f();
4509e5dd7070Spatrick  void g() noexcept;
4510e5dd7070Spatrick  void h() throw();
4511e5dd7070Spatrick  void i() throw(int);
4512e5dd7070Spatrick  void j() noexcept(false);
4513e5dd7070SpatrickfunctionDecl(isNoThrow()) and functionProtoType(isNoThrow())
4514e5dd7070Spatrick  match the declarations of g, and h, but not f, i or j.
4515e5dd7070Spatrick</pre></td></tr>
4516e5dd7070Spatrick
4517e5dd7070Spatrick
4518e5dd7070Spatrick<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>
4519e5dd7070Spatrick<tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
4520e5dd7070Spatrickspecific parameter count.
4521e5dd7070Spatrick
4522e5dd7070SpatrickGiven
4523e5dd7070Spatrick  void f(int i) {}
4524e5dd7070Spatrick  void g(int i, int j) {}
4525e5dd7070Spatrick  void h(int i, int j);
4526e5dd7070Spatrick  void j(int i);
4527e5dd7070Spatrick  void k(int x, int y, int z, ...);
4528e5dd7070SpatrickfunctionDecl(parameterCountIs(2))
4529e5dd7070Spatrick  matches g and h
4530e5dd7070SpatrickfunctionProtoType(parameterCountIs(2))
4531e5dd7070Spatrick  matches g and h
4532e5dd7070SpatrickfunctionProtoType(parameterCountIs(3))
4533e5dd7070Spatrick  matches k
4534e5dd7070Spatrick</pre></td></tr>
4535e5dd7070Spatrick
4536e5dd7070Spatrick
4537*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>&gt;</td><td class="name" onclick="toggle('isConsteval1')"><a name="isConsteval1Anchor">isConsteval</a></td><td></td></tr>
4538*12c85518Srobert<tr><td colspan="4" class="doc" id="isConsteval1"><pre>Matches consteval function declarations and if consteval/if ! consteval
4539*12c85518Srobertstatements.
4540*12c85518Srobert
4541*12c85518SrobertGiven:
4542*12c85518Srobert  consteval int a();
4543*12c85518Srobert  void b() { if consteval {} }
4544*12c85518Srobert  void c() { if ! consteval {} }
4545*12c85518Srobert  void d() { if ! consteval {} else {} }
4546*12c85518SrobertfunctionDecl(isConsteval())
4547*12c85518Srobert  matches the declaration of "int a()".
4548*12c85518SrobertifStmt(isConsteval())
4549*12c85518Srobert  matches the if statement in "void b()", "void c()", "void d()".
4550*12c85518Srobert</pre></td></tr>
4551*12c85518Srobert
4552*12c85518Srobert
4553e5dd7070Spatrick<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>
4554e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isConstexpr2"><pre>Matches constexpr variable and function declarations,
4555e5dd7070Spatrick       and if constexpr.
4556e5dd7070Spatrick
4557e5dd7070SpatrickGiven:
4558e5dd7070Spatrick  constexpr int foo = 42;
4559e5dd7070Spatrick  constexpr int bar();
4560e5dd7070Spatrick  void baz() { if constexpr(1 &gt; 0) {} }
4561e5dd7070SpatrickvarDecl(isConstexpr())
4562e5dd7070Spatrick  matches the declaration of foo.
4563e5dd7070SpatrickfunctionDecl(isConstexpr())
4564e5dd7070Spatrick  matches the declaration of bar.
4565e5dd7070SpatrickifStmt(isConstexpr())
4566e5dd7070Spatrick  matches the if statement in baz.
4567e5dd7070Spatrick</pre></td></tr>
4568e5dd7070Spatrick
4569e5dd7070Spatrick
4570e5dd7070Spatrick<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>
4571e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equals6"><pre></pre></td></tr>
4572e5dd7070Spatrick
4573e5dd7070Spatrick
4574e5dd7070Spatrick<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>
4575e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value of type ValueT.
4576e5dd7070Spatrick
4577e5dd7070SpatrickGiven
4578e5dd7070Spatrick  f('false, 3.14, 42);
4579e5dd7070SpatrickcharacterLiteral(equals(0))
4580e5dd7070Spatrick  matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
4581e5dd7070Spatrick  match false
4582e5dd7070SpatrickfloatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
4583e5dd7070Spatrick  match 3.14
4584e5dd7070SpatrickintegerLiteral(equals(42))
4585e5dd7070Spatrick  matches 42
4586e5dd7070Spatrick
4587e5dd7070SpatrickNote that you cannot directly match a negative numeric literal because the
4588e5dd7070Spatrickminus sign is not part of the literal: It is a unary operator whose operand
4589e5dd7070Spatrickis the positive numeric literal. Instead, you must use a unaryOperator()
4590e5dd7070Spatrickmatcher to match the minus sign:
4591e5dd7070Spatrick
4592e5dd7070SpatrickunaryOperator(hasOperatorName("-"),
4593e5dd7070Spatrick              hasUnaryOperand(integerLiteral(equals(13))))
4594e5dd7070Spatrick
4595e5dd7070SpatrickUsable 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;,
4596e5dd7070Spatrick           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;
4597e5dd7070Spatrick</pre></td></tr>
4598e5dd7070Spatrick
4599e5dd7070Spatrick
4600e5dd7070Spatrick<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>
4601e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equals13"><pre></pre></td></tr>
4602e5dd7070Spatrick
4603e5dd7070Spatrick
4604e5dd7070Spatrick<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>
4605e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equals9"><pre></pre></td></tr>
4606e5dd7070Spatrick
4607e5dd7070Spatrick
4608*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>&gt;</td><td class="name" onclick="toggle('capturesThis0')"><a name="capturesThis0Anchor">capturesThis</a></td><td></td></tr>
4609*12c85518Srobert<tr><td colspan="4" class="doc" id="capturesThis0"><pre>Matches a `LambdaCapture` that refers to 'this'.
4610*12c85518Srobert
4611*12c85518SrobertGiven
4612*12c85518Srobertclass C {
4613*12c85518Srobert  int cc;
4614*12c85518Srobert  int f() {
4615*12c85518Srobert    auto l = [this]() { return cc; };
4616*12c85518Srobert    return l();
4617*12c85518Srobert  }
4618*12c85518Srobert};
4619*12c85518SrobertlambdaExpr(hasAnyCapture(lambdaCapture(capturesThis())))
4620*12c85518Srobert  matches `[this]() { return cc; }`.
4621*12c85518Srobert</pre></td></tr>
4622*12c85518Srobert
4623*12c85518Srobert
4624*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>&gt;</td><td class="name" onclick="toggle('isImplicit2')"><a name="isImplicit2Anchor">isImplicit</a></td><td></td></tr>
4625*12c85518Srobert<tr><td colspan="4" class="doc" id="isImplicit2"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
4626*12c85518Srobertimplicit default/copy constructors).
4627*12c85518Srobert</pre></td></tr>
4628*12c85518Srobert
4629*12c85518Srobert
4630e5dd7070Spatrick<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>
4631e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '-&gt;' as opposed
4632e5dd7070Spatrickto '.'.
4633e5dd7070Spatrick
4634e5dd7070SpatrickMember calls on the implicit this pointer match as called with '-&gt;'.
4635e5dd7070Spatrick
4636e5dd7070SpatrickGiven
4637e5dd7070Spatrick  class Y {
4638e5dd7070Spatrick    void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
4639e5dd7070Spatrick    template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
4640e5dd7070Spatrick    int a;
4641e5dd7070Spatrick    static int b;
4642e5dd7070Spatrick  };
4643e5dd7070Spatrick  template &lt;class T&gt;
4644e5dd7070Spatrick  class Z {
4645e5dd7070Spatrick    void x() { this-&gt;m; }
4646e5dd7070Spatrick  };
4647e5dd7070SpatrickmemberExpr(isArrow())
4648e5dd7070Spatrick  matches this-&gt;x, x, y.x, a, this-&gt;b
4649e5dd7070SpatrickcxxDependentScopeMemberExpr(isArrow())
4650e5dd7070Spatrick  matches this-&gt;m
4651e5dd7070SpatrickunresolvedMemberExpr(isArrow())
4652e5dd7070Spatrick  matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
4653e5dd7070Spatrick</pre></td></tr>
4654e5dd7070Spatrick
4655e5dd7070Spatrick
4656ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyName0')"><a name="hasAnyName0Anchor">hasAnyName</a></td><td>StringRef, ..., StringRef</td></tr>
4657ec727ea7Spatrick<tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names.
4658ec727ea7Spatrick
4659ec727ea7SpatrickThis matcher is only provided as a performance optimization of hasName.
4660ec727ea7Spatrick    hasAnyName(a, b, c)
4661ec727ea7Spatrick is equivalent to, but faster than
4662ec727ea7Spatrick    anyOf(hasName(a), hasName(b), hasName(c))
4663ec727ea7Spatrick</pre></td></tr>
4664ec727ea7Spatrick
4665ec727ea7Spatrick
4666e5dd7070Spatrick<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>
4667e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage.
4668e5dd7070Spatrick
4669e5dd7070SpatrickExample matches only z (matcher = varDecl(hasExternalFormalLinkage()))
4670e5dd7070Spatrickvoid f() {
4671e5dd7070Spatrick  int x;
4672e5dd7070Spatrick  static int y;
4673e5dd7070Spatrick}
4674e5dd7070Spatrickint z;
4675e5dd7070Spatrick
4676e5dd7070SpatrickExample matches f() because it has external formal linkage despite being
4677e5dd7070Spatrickunique to the translation unit as though it has internal likage
4678e5dd7070Spatrick(matcher = functionDecl(hasExternalFormalLinkage()))
4679e5dd7070Spatrick
4680e5dd7070Spatricknamespace {
4681e5dd7070Spatrickvoid f() {}
4682e5dd7070Spatrick}
4683e5dd7070Spatrick</pre></td></tr>
4684e5dd7070Spatrick
4685e5dd7070Spatrick
4686ec727ea7Spatrick<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>StringRef Name</td></tr>
4687e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name.
4688e5dd7070Spatrick
4689e5dd7070SpatrickSupports specifying enclosing namespaces or classes by prefixing the name
4690e5dd7070Spatrickwith '&lt;enclosing&gt;::'.
4691e5dd7070SpatrickDoes not match typedefs of an underlying type with the given name.
4692e5dd7070Spatrick
4693e5dd7070SpatrickExample matches X (Name == "X")
4694e5dd7070Spatrick  class X;
4695e5dd7070Spatrick
4696e5dd7070SpatrickExample matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
4697e5dd7070Spatrick  namespace a { namespace b { class X; } }
4698e5dd7070Spatrick</pre></td></tr>
4699e5dd7070Spatrick
4700e5dd7070Spatrick
4701ec727ea7Spatrick<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>StringRef RegExp, Regex::RegexFlags Flags = NoFlags</td></tr>
4702e5dd7070Spatrick<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain
4703e5dd7070Spatricka substring matched by the given RegExp.
4704e5dd7070Spatrick
4705e5dd7070SpatrickSupports specifying enclosing namespaces or classes by
4706e5dd7070Spatrickprefixing the name with '&lt;enclosing&gt;::'.  Does not match typedefs
4707e5dd7070Spatrickof an underlying type with the given name.
4708e5dd7070Spatrick
4709e5dd7070SpatrickExample matches X (regexp == "::X")
4710e5dd7070Spatrick  class X;
4711e5dd7070Spatrick
4712e5dd7070SpatrickExample matches X (regexp is one of "::X", "^foo::.*X", among others)
4713e5dd7070Spatrick  namespace foo { namespace bar { class X; } }
4714ec727ea7Spatrick
4715ec727ea7SpatrickIf the matcher is used in clang-query, RegexFlags parameter
4716ec727ea7Spatrickshould be passed as a quoted string. e.g: "NoFlags".
4717ec727ea7SpatrickFlags can be combined with '|' example "IgnoreCase | BasicRegex"
4718e5dd7070Spatrick</pre></td></tr>
4719e5dd7070Spatrick
4720e5dd7070Spatrick
4721e5dd7070Spatrick<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>
4722e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations.
4723e5dd7070Spatrick
4724e5dd7070SpatrickGiven
4725e5dd7070Spatrick  namespace n {
4726e5dd7070Spatrick  namespace {} // #1
4727e5dd7070Spatrick  }
4728e5dd7070SpatricknamespaceDecl(isAnonymous()) will match #1 but not ::n.
4729e5dd7070Spatrick</pre></td></tr>
4730e5dd7070Spatrick
4731e5dd7070Spatrick
4732e5dd7070Spatrick<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>
4733*12c85518Srobert<tr><td colspan="4" class="doc" id="isInline0"><pre>Matches functions, variables and namespace declarations that are marked with
4734e5dd7070Spatrickthe inline keyword.
4735e5dd7070Spatrick
4736e5dd7070SpatrickGiven
4737e5dd7070Spatrick  inline void f();
4738e5dd7070Spatrick  void g();
4739e5dd7070Spatrick  namespace n {
4740e5dd7070Spatrick  inline namespace m {}
4741e5dd7070Spatrick  }
4742*12c85518Srobert  inline int Foo = 5;
4743e5dd7070SpatrickfunctionDecl(isInline()) will match ::f().
4744e5dd7070SpatricknamespaceDecl(isInline()) will match n::m.
4745*12c85518SrobertvarDecl(isInline()) will match Foo;
4746e5dd7070Spatrick</pre></td></tr>
4747e5dd7070Spatrick
4748e5dd7070Spatrick
4749a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause</a>&gt;</td><td class="name" onclick="toggle('isFirstPrivateKind0')"><a name="isFirstPrivateKind0Anchor">isFirstPrivateKind</a></td><td></td></tr>
4750a9ac8606Spatrick<tr><td colspan="4" class="doc" id="isFirstPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``firstprivate`` kind
4751a9ac8606Spatrickspecified.
4752a9ac8606Spatrick
4753a9ac8606SpatrickGiven
4754a9ac8606Spatrick
4755a9ac8606Spatrick  #pragma omp parallel
4756a9ac8606Spatrick  #pragma omp parallel default(none)
4757a9ac8606Spatrick  #pragma omp parallel default(shared)
4758*12c85518Srobert  #pragma omp parallel default(private)
4759a9ac8606Spatrick  #pragma omp parallel default(firstprivate)
4760a9ac8606Spatrick
4761a9ac8606Spatrick``ompDefaultClause(isFirstPrivateKind())`` matches only
4762a9ac8606Spatrick``default(firstprivate)``.
4763a9ac8606Spatrick</pre></td></tr>
4764a9ac8606Spatrick
4765a9ac8606Spatrick
4766e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause</a>&gt;</td><td class="name" onclick="toggle('isNoneKind0')"><a name="isNoneKind0Anchor">isNoneKind</a></td><td></td></tr>
4767e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isNoneKind0"><pre>Matches if the OpenMP ``default`` clause has ``none`` kind specified.
4768e5dd7070Spatrick
4769e5dd7070SpatrickGiven
4770e5dd7070Spatrick
4771e5dd7070Spatrick  #pragma omp parallel
4772e5dd7070Spatrick  #pragma omp parallel default(none)
4773e5dd7070Spatrick  #pragma omp parallel default(shared)
4774*12c85518Srobert  #pragma omp parallel default(private)
4775ec727ea7Spatrick  #pragma omp parallel default(firstprivate)
4776e5dd7070Spatrick
4777e5dd7070Spatrick``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
4778e5dd7070Spatrick</pre></td></tr>
4779e5dd7070Spatrick
4780e5dd7070Spatrick
4781*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause</a>&gt;</td><td class="name" onclick="toggle('isPrivateKind0')"><a name="isPrivateKind0Anchor">isPrivateKind</a></td><td></td></tr>
4782*12c85518Srobert<tr><td colspan="4" class="doc" id="isPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``private`` kind
4783*12c85518Srobertspecified.
4784*12c85518Srobert
4785*12c85518SrobertGiven
4786*12c85518Srobert
4787*12c85518Srobert  #pragma omp parallel
4788*12c85518Srobert  #pragma omp parallel default(none)
4789*12c85518Srobert  #pragma omp parallel default(shared)
4790*12c85518Srobert  #pragma omp parallel default(private)
4791*12c85518Srobert  #pragma omp parallel default(firstprivate)
4792*12c85518Srobert
4793*12c85518Srobert``ompDefaultClause(isPrivateKind())`` matches only
4794*12c85518Srobert``default(private)``.
4795*12c85518Srobert</pre></td></tr>
4796*12c85518Srobert
4797*12c85518Srobert
4798e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause</a>&gt;</td><td class="name" onclick="toggle('isSharedKind0')"><a name="isSharedKind0Anchor">isSharedKind</a></td><td></td></tr>
4799e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isSharedKind0"><pre>Matches if the OpenMP ``default`` clause has ``shared`` kind specified.
4800e5dd7070Spatrick
4801e5dd7070SpatrickGiven
4802e5dd7070Spatrick
4803e5dd7070Spatrick  #pragma omp parallel
4804e5dd7070Spatrick  #pragma omp parallel default(none)
4805e5dd7070Spatrick  #pragma omp parallel default(shared)
4806*12c85518Srobert  #pragma omp parallel default(private)
4807ec727ea7Spatrick  #pragma omp parallel default(firstprivate)
4808e5dd7070Spatrick
4809e5dd7070Spatrick``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``.
4810e5dd7070Spatrick</pre></td></tr>
4811e5dd7070Spatrick
4812e5dd7070Spatrick
4813e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html">OMPExecutableDirective</a>&gt;</td><td class="name" onclick="toggle('isAllowedToContainClauseKind0')"><a name="isAllowedToContainClauseKind0Anchor">isAllowedToContainClauseKind</a></td><td>OpenMPClauseKind CKind</td></tr>
4814e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isAllowedToContainClauseKind0"><pre>Matches if the OpenMP directive is allowed to contain the specified OpenMP
4815e5dd7070Spatrickclause kind.
4816e5dd7070Spatrick
4817e5dd7070SpatrickGiven
4818e5dd7070Spatrick
4819e5dd7070Spatrick  #pragma omp parallel
4820e5dd7070Spatrick  #pragma omp parallel for
4821e5dd7070Spatrick  #pragma omp          for
4822e5dd7070Spatrick
4823e5dd7070Spatrick`ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches
4824e5dd7070Spatrick``omp parallel`` and ``omp parallel for``.
4825e5dd7070Spatrick
4826e5dd7070SpatrickIf the matcher is use from clang-query, ``OpenMPClauseKind`` parameter
4827e5dd7070Spatrickshould be passed as a quoted string. e.g.,
4828e5dd7070Spatrick``isAllowedToContainClauseKind("OMPC_default").``
4829e5dd7070Spatrick</pre></td></tr>
4830e5dd7070Spatrick
4831e5dd7070Spatrick
4832e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html">OMPExecutableDirective</a>&gt;</td><td class="name" onclick="toggle('isStandaloneDirective0')"><a name="isStandaloneDirective0Anchor">isStandaloneDirective</a></td><td></td></tr>
4833e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isStandaloneDirective0"><pre>Matches standalone OpenMP directives,
4834e5dd7070Spatricki.e., directives that can't have a structured block.
4835e5dd7070Spatrick
4836e5dd7070SpatrickGiven
4837e5dd7070Spatrick
4838e5dd7070Spatrick  #pragma omp parallel
4839e5dd7070Spatrick  {}
4840e5dd7070Spatrick  #pragma omp taskyield
4841e5dd7070Spatrick
4842e5dd7070Spatrick``ompExecutableDirective(isStandaloneDirective()))`` matches
4843e5dd7070Spatrick``omp taskyield``.
4844e5dd7070Spatrick</pre></td></tr>
4845e5dd7070Spatrick
4846e5dd7070Spatrick
4847e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>&gt;</td><td class="name" onclick="toggle('isDerivedFrom3')"><a name="isDerivedFrom3Anchor">isDerivedFrom</a></td><td>std::string BaseName</td></tr>
4848e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDerivedFrom3"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
4849e5dd7070Spatrick</pre></td></tr>
4850e5dd7070Spatrick
4851e5dd7070Spatrick
4852e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>&gt;</td><td class="name" onclick="toggle('isDirectlyDerivedFrom3')"><a name="isDirectlyDerivedFrom3Anchor">isDirectlyDerivedFrom</a></td><td>std::string BaseName</td></tr>
4853e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom3"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
4854e5dd7070Spatrick</pre></td></tr>
4855e5dd7070Spatrick
4856e5dd7070Spatrick
4857e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>&gt;</td><td class="name" onclick="toggle('isSameOrDerivedFrom3')"><a name="isSameOrDerivedFrom3Anchor">isSameOrDerivedFrom</a></td><td>std::string BaseName</td></tr>
4858e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom3"><pre>Overloaded method as shortcut for
4859e5dd7070SpatrickisSameOrDerivedFrom(hasName(...)).
4860e5dd7070Spatrick</pre></td></tr>
4861e5dd7070Spatrick
4862e5dd7070Spatrick
4863a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('argumentCountIs3')"><a name="argumentCountIs3Anchor">argumentCountIs</a></td><td>unsigned N</td></tr>
4864a9ac8606Spatrick<tr><td colspan="4" class="doc" id="argumentCountIs3"><pre>Checks that a call expression or a constructor call expression has
4865e5dd7070Spatricka specific number of arguments (including absent default arguments).
4866e5dd7070Spatrick
4867e5dd7070SpatrickExample matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
4868e5dd7070Spatrick  void f(int x, int y);
4869e5dd7070Spatrick  f(0, 0);
4870e5dd7070Spatrick</pre></td></tr>
4871e5dd7070Spatrick
4872e5dd7070Spatrick
4873ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnySelector0')"><a name="hasAnySelector0Anchor">hasAnySelector</a></td><td>StringRef, ..., StringRef</td></tr>
4874ec727ea7Spatrick<tr><td colspan="4" class="doc" id="hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the
4875ec727ea7SpatrickSelector.getAsString()
4876ec727ea7Spatrick
4877ec727ea7Spatrick matcher = objCMessageExpr(hasSelector("methodA:", "methodB:"));
4878ec727ea7Spatrick matches both of the expressions below:
4879ec727ea7Spatrick    [myObj methodA:argA];
4880ec727ea7Spatrick    [myObj methodB:argB];
4881ec727ea7Spatrick</pre></td></tr>
4882ec727ea7Spatrick
4883ec727ea7Spatrick
4884e5dd7070Spatrick<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>
4885e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector
4886e5dd7070Spatrick
4887e5dd7070SpatrickobjCMessageExpr(hasKeywordSelector()) matches the generated setFrame
4888e5dd7070Spatrickmessage expression in
4889e5dd7070Spatrick
4890e5dd7070Spatrick  UIWebView *webView = ...;
4891e5dd7070Spatrick  CGRect bodyFrame = webView.frame;
4892e5dd7070Spatrick  bodyFrame.size.height = self.bodyContentHeight;
4893e5dd7070Spatrick  webView.frame = bodyFrame;
4894e5dd7070Spatrick  //     ^---- matches here
4895e5dd7070Spatrick</pre></td></tr>
4896e5dd7070Spatrick
4897e5dd7070Spatrick
4898e5dd7070Spatrick<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>
4899e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector
4900e5dd7070Spatrick
4901e5dd7070SpatrickMatches only when the selector of the objCMessageExpr is NULL. This may
4902e5dd7070Spatrickrepresent an error condition in the tree!
4903e5dd7070Spatrick</pre></td></tr>
4904e5dd7070Spatrick
4905e5dd7070Spatrick
4906e5dd7070Spatrick<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>
4907e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString()
4908e5dd7070Spatrick
4909e5dd7070Spatrick matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:"));
4910e5dd7070Spatrick matches the outer message expr in the code below, but NOT the message
4911e5dd7070Spatrick invocation for self.bodyView.
4912e5dd7070Spatrick    [self.bodyView loadHTMLString:html baseURL:NULL];
4913e5dd7070Spatrick</pre></td></tr>
4914e5dd7070Spatrick
4915e5dd7070Spatrick
4916e5dd7070Spatrick<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>
4917e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector
4918e5dd7070Spatrick
4919e5dd7070Spatrick matcher = objCMessageExpr(matchesSelector(hasUnarySelector());
4920e5dd7070Spatrick matches self.bodyView in the code below, but NOT the outer message
4921e5dd7070Spatrick invocation of "loadHTMLString:baseURL:".
4922e5dd7070Spatrick    [self.bodyView loadHTMLString:html baseURL:NULL];
4923e5dd7070Spatrick</pre></td></tr>
4924e5dd7070Spatrick
4925e5dd7070Spatrick
4926e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('isClassMessage0')"><a name="isClassMessage0Anchor">isClassMessage</a></td><td></td></tr>
4927e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isClassMessage0"><pre>Returns true when the Objective-C message is sent to a class.
4928e5dd7070Spatrick
4929e5dd7070SpatrickExample
4930e5dd7070Spatrickmatcher = objcMessageExpr(isClassMessage())
4931e5dd7070Spatrickmatches
4932e5dd7070Spatrick  [NSString stringWithFormat:@"format"];
4933e5dd7070Spatrickbut not
4934e5dd7070Spatrick  NSString *x = @"hello";
4935e5dd7070Spatrick  [x containsString:@"h"];
4936e5dd7070Spatrick</pre></td></tr>
4937e5dd7070Spatrick
4938e5dd7070Spatrick
4939e5dd7070Spatrick<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>
4940e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance.
4941e5dd7070Spatrick
4942e5dd7070SpatrickExample
4943e5dd7070Spatrickmatcher = objcMessageExpr(isInstanceMessage())
4944e5dd7070Spatrickmatches
4945e5dd7070Spatrick  NSString *x = @"hello";
4946e5dd7070Spatrick  [x containsString:@"h"];
4947e5dd7070Spatrickbut not
4948e5dd7070Spatrick  [NSString stringWithFormat:@"format"];
4949e5dd7070Spatrick</pre></td></tr>
4950e5dd7070Spatrick
4951e5dd7070Spatrick
4952ec727ea7Spatrick<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>StringRef RegExp, Regex::RegexFlags Flags = NoFlags</td></tr>
4953e5dd7070Spatrick<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains
4954e5dd7070Spatricka substring matched by the given RegExp.
4955e5dd7070Spatrick matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message
4956e5dd7070Spatrick invocation for self.bodyView.
4957e5dd7070Spatrick    [self.bodyView loadHTMLString:html baseURL:NULL];
4958ec727ea7Spatrick
4959ec727ea7SpatrickIf the matcher is used in clang-query, RegexFlags parameter
4960ec727ea7Spatrickshould be passed as a quoted string. e.g: "NoFlags".
4961ec727ea7SpatrickFlags can be combined with '|' example "IgnoreCase | BasicRegex"
4962e5dd7070Spatrick</pre></td></tr>
4963e5dd7070Spatrick
4964e5dd7070Spatrick
4965e5dd7070Spatrick<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>
4966e5dd7070Spatrick<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments
4967e5dd7070Spatrick
4968e5dd7070Spatrick matcher = objCMessageExpr(numSelectorArgs(0));
4969e5dd7070Spatrick matches self.bodyView in the code below
4970e5dd7070Spatrick
4971e5dd7070Spatrick matcher = objCMessageExpr(numSelectorArgs(2));
4972e5dd7070Spatrick matches the invocation of "loadHTMLString:baseURL:" but not that
4973e5dd7070Spatrick of self.bodyView
4974e5dd7070Spatrick    [self.bodyView loadHTMLString:html baseURL:NULL];
4975e5dd7070Spatrick</pre></td></tr>
4976e5dd7070Spatrick
4977e5dd7070Spatrick
4978e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isClassMethod0')"><a name="isClassMethod0Anchor">isClassMethod</a></td><td></td></tr>
4979e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isClassMethod0"><pre>Returns true when the Objective-C method declaration is a class method.
4980e5dd7070Spatrick
4981e5dd7070SpatrickExample
4982e5dd7070Spatrickmatcher = objcMethodDecl(isClassMethod())
4983e5dd7070Spatrickmatches
4984e5dd7070Spatrick@interface I + (void)foo; @end
4985e5dd7070Spatrickbut not
4986e5dd7070Spatrick@interface I - (void)bar; @end
4987e5dd7070Spatrick</pre></td></tr>
4988e5dd7070Spatrick
4989e5dd7070Spatrick
4990e5dd7070Spatrick<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>
4991e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached.
4992e5dd7070Spatrick
4993e5dd7070SpatrickExample matches A, va, fa
4994e5dd7070Spatrick  class A {};
4995e5dd7070Spatrick  class B;  // Doesn't match, as it has no body.
4996e5dd7070Spatrick  int va;
4997e5dd7070Spatrick  extern int vb;  // Doesn't match, as it doesn't define the variable.
4998e5dd7070Spatrick  void fa() {}
4999e5dd7070Spatrick  void fb();  // Doesn't match, as it has no body.
5000e5dd7070Spatrick  @interface X
5001e5dd7070Spatrick  - (void)ma; // Doesn't match, interface is declaration.
5002e5dd7070Spatrick  @end
5003e5dd7070Spatrick  @implementation X
5004e5dd7070Spatrick  - (void)ma {}
5005e5dd7070Spatrick  @end
5006e5dd7070Spatrick
5007e5dd7070SpatrickUsable 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;,
5008e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
5009e5dd7070Spatrick</pre></td></tr>
5010e5dd7070Spatrick
5011e5dd7070Spatrick
5012e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isInstanceMethod0')"><a name="isInstanceMethod0Anchor">isInstanceMethod</a></td><td></td></tr>
5013e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isInstanceMethod0"><pre>Returns true when the Objective-C method declaration is an instance method.
5014e5dd7070Spatrick
5015e5dd7070SpatrickExample
5016e5dd7070Spatrickmatcher = objcMethodDecl(isInstanceMethod())
5017e5dd7070Spatrickmatches
5018e5dd7070Spatrick@interface I - (void)bar; @end
5019e5dd7070Spatrickbut not
5020e5dd7070Spatrick@interface I + (void)foo; @end
5021e5dd7070Spatrick</pre></td></tr>
5022e5dd7070Spatrick
5023e5dd7070Spatrick
5024e5dd7070Spatrick<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>
5025e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDefaultArgument0"><pre>Matches a declaration that has default arguments.
5026e5dd7070Spatrick
5027e5dd7070SpatrickExample matches y (matcher = parmVarDecl(hasDefaultArgument()))
5028e5dd7070Spatrickvoid x(int val) {}
5029e5dd7070Spatrickvoid y(int val = 0) {}
5030e5dd7070Spatrick
5031e5dd7070SpatrickDeprecated. Use hasInitializer() instead to be able to
5032e5dd7070Spatrickmatch on the contents of the default argument.  For example:
5033e5dd7070Spatrick
5034e5dd7070Spatrickvoid x(int val = 7) {}
5035e5dd7070Spatrickvoid y(int val = 42) {}
5036e5dd7070SpatrickparmVarDecl(hasInitializer(integerLiteral(equals(42))))
5037e5dd7070Spatrick  matches the parameter of y
5038e5dd7070Spatrick
5039e5dd7070SpatrickA matcher such as
5040e5dd7070Spatrick  parmVarDecl(hasInitializer(anything()))
5041e5dd7070Spatrickis equivalent to parmVarDecl(hasDefaultArgument()).
5042e5dd7070Spatrick</pre></td></tr>
5043e5dd7070Spatrick
5044e5dd7070Spatrick
5045ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>&gt;</td><td class="name" onclick="toggle('isAtPosition0')"><a name="isAtPosition0Anchor">isAtPosition</a></td><td>unsigned N</td></tr>
5046ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isAtPosition0"><pre>Matches the ParmVarDecl nodes that are at the N'th position in the parameter
5047ec727ea7Spatricklist. The parameter list could be that of either a block, function, or
5048ec727ea7Spatrickobjc-method.
5049ec727ea7Spatrick
5050ec727ea7Spatrick
5051ec727ea7SpatrickGiven
5052ec727ea7Spatrick
5053ec727ea7Spatrickvoid f(int a, int b, int c) {
5054ec727ea7Spatrick}
5055ec727ea7Spatrick
5056ec727ea7Spatrick``parmVarDecl(isAtPosition(0))`` matches ``int a``.
5057ec727ea7Spatrick
5058ec727ea7Spatrick``parmVarDecl(isAtPosition(1))`` matches ``int b``.
5059ec727ea7Spatrick</pre></td></tr>
5060ec727ea7Spatrick
5061ec727ea7Spatrick
5062e5dd7070Spatrick<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>
5063e5dd7070Spatrick<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string.
5064e5dd7070Spatrick
5065e5dd7070SpatrickGiven
5066e5dd7070Spatrick  class Y { public: void x(); };
5067e5dd7070Spatrick  void z() { Y* y; y-&gt;x(); }
5068e5dd7070SpatrickcxxMemberCallExpr(on(hasType(asString("class Y *"))))
5069e5dd7070Spatrick  matches y-&gt;x()
5070e5dd7070Spatrick</pre></td></tr>
5071e5dd7070Spatrick
5072e5dd7070Spatrick
5073e5dd7070Spatrick<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>
5074e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node.
5075e5dd7070Spatrick
5076e5dd7070SpatrickMatches a node if it equals the node previously bound to ID.
5077e5dd7070Spatrick
5078e5dd7070SpatrickGiven
5079e5dd7070Spatrick  class X { int a; int b; };
5080e5dd7070SpatrickcxxRecordDecl(
5081e5dd7070Spatrick    has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
5082e5dd7070Spatrick    has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
5083e5dd7070Spatrick  matches the class X, as a and b have the same type.
5084e5dd7070Spatrick
5085e5dd7070SpatrickNote that when multiple matches are involved via forEach* matchers,
5086e5dd7070SpatrickequalsBoundNodes acts as a filter.
5087e5dd7070SpatrickFor example:
5088e5dd7070SpatrickcompoundStmt(
5089e5dd7070Spatrick    forEachDescendant(varDecl().bind("d")),
5090e5dd7070Spatrick    forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
5091e5dd7070Spatrickwill trigger a match for each combination of variable declaration
5092e5dd7070Spatrickand reference to that variable declaration within a compound statement.
5093e5dd7070Spatrick</pre></td></tr>
5094e5dd7070Spatrick
5095e5dd7070Spatrick
5096e5dd7070Spatrick<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>
5097e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to
5098e5dd7070Spatrickthe node, not hidden within a typedef.
5099e5dd7070Spatrick
5100e5dd7070SpatrickGiven
5101e5dd7070Spatrick  typedef const int const_int;
5102e5dd7070Spatrick  const_int i;
5103e5dd7070Spatrick  int *const j;
5104e5dd7070Spatrick  int *volatile k;
5105e5dd7070Spatrick  int m;
5106e5dd7070SpatrickvarDecl(hasType(hasLocalQualifiers())) matches only j and k.
5107e5dd7070Spatricki is const-qualified but the qualifier is not local.
5108e5dd7070Spatrick</pre></td></tr>
5109e5dd7070Spatrick
5110e5dd7070Spatrick
5111e5dd7070Spatrick<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>
5112e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type.
5113e5dd7070Spatrick
5114e5dd7070SpatrickGiven
5115e5dd7070Spatrick  void a(char);
5116e5dd7070Spatrick  void b(wchar_t);
5117e5dd7070Spatrick  void c(double);
5118e5dd7070SpatrickfunctionDecl(hasAnyParameter(hasType(isAnyCharacter())))
5119e5dd7070Spatrickmatches "a(char)", "b(wchar_t)", but not "c(double)".
5120e5dd7070Spatrick</pre></td></tr>
5121e5dd7070Spatrick
5122e5dd7070Spatrick
5123e5dd7070Spatrick<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>
5124e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type; this includes
5125e5dd7070Spatrickthe Objective-C object pointer type, which is different despite being
5126e5dd7070Spatricksyntactically similar.
5127e5dd7070Spatrick
5128e5dd7070SpatrickGiven
5129e5dd7070Spatrick  int *i = nullptr;
5130e5dd7070Spatrick
5131e5dd7070Spatrick  @interface Foo
5132e5dd7070Spatrick  @end
5133e5dd7070Spatrick  Foo *f;
5134e5dd7070Spatrick
5135e5dd7070Spatrick  int j;
5136e5dd7070SpatrickvarDecl(hasType(isAnyPointer()))
5137e5dd7070Spatrick  matches "int *i" and "Foo *f", but not "int j".
5138e5dd7070Spatrick</pre></td></tr>
5139e5dd7070Spatrick
5140e5dd7070Spatrick
5141e5dd7070Spatrick<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>
5142e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that
5143e5dd7070Spatrickinclude "top-level" const.
5144e5dd7070Spatrick
5145e5dd7070SpatrickGiven
5146e5dd7070Spatrick  void a(int);
5147e5dd7070Spatrick  void b(int const);
5148e5dd7070Spatrick  void c(const int);
5149e5dd7070Spatrick  void d(const int*);
5150e5dd7070Spatrick  void e(int const) {};
5151e5dd7070SpatrickfunctionDecl(hasAnyParameter(hasType(isConstQualified())))
5152e5dd7070Spatrick  matches "void b(int const)", "void c(const int)" and
5153e5dd7070Spatrick  "void e(int const) {}". It does not match d as there
5154e5dd7070Spatrick  is no top-level const on the parameter type "const int *".
5155e5dd7070Spatrick</pre></td></tr>
5156e5dd7070Spatrick
5157e5dd7070Spatrick
5158e5dd7070Spatrick<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>
5159e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type.
5160e5dd7070Spatrick
5161e5dd7070SpatrickGiven
5162e5dd7070Spatrick  void a(int);
5163e5dd7070Spatrick  void b(long);
5164e5dd7070Spatrick  void c(double);
5165e5dd7070SpatrickfunctionDecl(hasAnyParameter(hasType(isInteger())))
5166e5dd7070Spatrickmatches "a(int)", "b(long)", but not "c(double)".
5167e5dd7070Spatrick</pre></td></tr>
5168e5dd7070Spatrick
5169e5dd7070Spatrick
5170e5dd7070Spatrick<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>
5171e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isSignedInteger0"><pre>Matches QualType nodes that are of signed integer type.
5172e5dd7070Spatrick
5173e5dd7070SpatrickGiven
5174e5dd7070Spatrick  void a(int);
5175e5dd7070Spatrick  void b(unsigned long);
5176e5dd7070Spatrick  void c(double);
5177e5dd7070SpatrickfunctionDecl(hasAnyParameter(hasType(isSignedInteger())))
5178e5dd7070Spatrickmatches "a(int)", but not "b(unsigned long)" and "c(double)".
5179e5dd7070Spatrick</pre></td></tr>
5180e5dd7070Spatrick
5181e5dd7070Spatrick
5182e5dd7070Spatrick<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>
5183e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isUnsignedInteger0"><pre>Matches QualType nodes that are of unsigned integer type.
5184e5dd7070Spatrick
5185e5dd7070SpatrickGiven
5186e5dd7070Spatrick  void a(int);
5187e5dd7070Spatrick  void b(unsigned long);
5188e5dd7070Spatrick  void c(double);
5189e5dd7070SpatrickfunctionDecl(hasAnyParameter(hasType(isUnsignedInteger())))
5190e5dd7070Spatrickmatches "b(unsigned long)", but not "a(int)" and "c(double)".
5191e5dd7070Spatrick</pre></td></tr>
5192e5dd7070Spatrick
5193e5dd7070Spatrick
5194e5dd7070Spatrick<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>
5195e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that
5196e5dd7070Spatrickinclude "top-level" volatile.
5197e5dd7070Spatrick
5198e5dd7070SpatrickGiven
5199e5dd7070Spatrick  void a(int);
5200e5dd7070Spatrick  void b(int volatile);
5201e5dd7070Spatrick  void c(volatile int);
5202e5dd7070Spatrick  void d(volatile int*);
5203e5dd7070Spatrick  void e(int volatile) {};
5204e5dd7070SpatrickfunctionDecl(hasAnyParameter(hasType(isVolatileQualified())))
5205e5dd7070Spatrick  matches "void b(int volatile)", "void c(volatile int)" and
5206e5dd7070Spatrick  "void e(int volatile) {}". It does not match d as there
5207e5dd7070Spatrick  is no top-level volatile on the parameter type "volatile int *".
5208e5dd7070Spatrick</pre></td></tr>
5209e5dd7070Spatrick
5210e5dd7070Spatrick
5211e5dd7070Spatrick<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>
5212e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node.
5213e5dd7070Spatrick
5214e5dd7070SpatrickMatches a node if it equals the node previously bound to ID.
5215e5dd7070Spatrick
5216e5dd7070SpatrickGiven
5217e5dd7070Spatrick  class X { int a; int b; };
5218e5dd7070SpatrickcxxRecordDecl(
5219e5dd7070Spatrick    has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
5220e5dd7070Spatrick    has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
5221e5dd7070Spatrick  matches the class X, as a and b have the same type.
5222e5dd7070Spatrick
5223e5dd7070SpatrickNote that when multiple matches are involved via forEach* matchers,
5224e5dd7070SpatrickequalsBoundNodes acts as a filter.
5225e5dd7070SpatrickFor example:
5226e5dd7070SpatrickcompoundStmt(
5227e5dd7070Spatrick    forEachDescendant(varDecl().bind("d")),
5228e5dd7070Spatrick    forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
5229e5dd7070Spatrickwill trigger a match for each combination of variable declaration
5230e5dd7070Spatrickand reference to that variable declaration within a compound statement.
5231e5dd7070Spatrick</pre></td></tr>
5232e5dd7070Spatrick
5233e5dd7070Spatrick
5234e5dd7070Spatrick<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>
5235e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node.
5236e5dd7070Spatrick
5237e5dd7070SpatrickStmt has pointer identity in the AST.
5238e5dd7070Spatrick</pre></td></tr>
5239e5dd7070Spatrick
5240e5dd7070Spatrick
5241a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('isExpandedFromMacro1')"><a name="isExpandedFromMacro1Anchor">isExpandedFromMacro</a></td><td>std::string MacroName</td></tr>
5242a9ac8606Spatrick<tr><td colspan="4" class="doc" id="isExpandedFromMacro1"><pre>Matches statements that are (transitively) expanded from the named macro.
5243ec727ea7SpatrickDoes not match if only part of the statement is expanded from that macro or
5244*12c85518Srobertif different parts of the statement are expanded from different
5245ec727ea7Spatrickappearances of the macro.
5246ec727ea7Spatrick</pre></td></tr>
5247ec727ea7Spatrick
5248ec727ea7Spatrick
5249ec727ea7Spatrick<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>StringRef RegExp, Regex::RegexFlags Flags = NoFlags</td></tr>
5250e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is
5251e5dd7070Spatrickpartially matching a given regex.
5252e5dd7070Spatrick
5253e5dd7070SpatrickExample matches Y but not X
5254e5dd7070Spatrick    (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
5255e5dd7070Spatrick  #include "ASTMatcher.h"
5256e5dd7070Spatrick  class X {};
5257e5dd7070SpatrickASTMatcher.h:
5258e5dd7070Spatrick  class Y {};
5259e5dd7070Spatrick
5260e5dd7070SpatrickUsable 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;
5261ec727ea7Spatrick
5262ec727ea7SpatrickIf the matcher is used in clang-query, RegexFlags parameter
5263ec727ea7Spatrickshould be passed as a quoted string. e.g: "NoFlags".
5264ec727ea7SpatrickFlags can be combined with '|' example "IgnoreCase | BasicRegex"
5265e5dd7070Spatrick</pre></td></tr>
5266e5dd7070Spatrick
5267e5dd7070Spatrick
5268e5dd7070Spatrick<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>
5269e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file.
5270e5dd7070Spatrick
5271e5dd7070SpatrickExample matches X but not Y
5272e5dd7070Spatrick  (matcher = cxxRecordDecl(isExpansionInMainFile())
5273e5dd7070Spatrick  #include &lt;Y.h&gt;
5274e5dd7070Spatrick  class X {};
5275e5dd7070SpatrickY.h:
5276e5dd7070Spatrick  class Y {};
5277e5dd7070Spatrick
5278e5dd7070SpatrickUsable 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;
5279e5dd7070Spatrick</pre></td></tr>
5280e5dd7070Spatrick
5281e5dd7070Spatrick
5282e5dd7070Spatrick<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>
5283e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files.
5284e5dd7070Spatrick
5285e5dd7070SpatrickExample matches Y but not X
5286e5dd7070Spatrick    (matcher = cxxRecordDecl(isExpansionInSystemHeader())
5287e5dd7070Spatrick  #include &lt;SystemHeader.h&gt;
5288e5dd7070Spatrick  class X {};
5289e5dd7070SpatrickSystemHeader.h:
5290e5dd7070Spatrick  class Y {};
5291e5dd7070Spatrick
5292e5dd7070SpatrickUsable 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;
5293e5dd7070Spatrick</pre></td></tr>
5294e5dd7070Spatrick
5295e5dd7070Spatrick
5296ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('isInTemplateInstantiation0')"><a name="isInTemplateInstantiation0Anchor">isInTemplateInstantiation</a></td><td></td></tr>
5297ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation.
5298e5dd7070Spatrick
5299e5dd7070SpatrickGiven
5300ec727ea7Spatrick  int j;
5301ec727ea7Spatrick  template&lt;typename T&gt; void A(T t) { T i; j += 42;}
5302ec727ea7Spatrick  A(0);
5303ec727ea7Spatrick  A(0U);
5304ec727ea7SpatrickdeclStmt(isInTemplateInstantiation())
5305ec727ea7Spatrick  matches 'int i;' and 'unsigned i'.
5306ec727ea7Spatrickunless(stmt(isInTemplateInstantiation()))
5307ec727ea7Spatrick  will NOT match j += 42; as it's shared between the template definition and
5308ec727ea7Spatrick  instantiation.
5309e5dd7070Spatrick</pre></td></tr>
5310e5dd7070Spatrick
5311e5dd7070Spatrick
5312e5dd7070Spatrick<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>
5313e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size.
5314e5dd7070Spatrick
5315e5dd7070SpatrickGiven
5316e5dd7070Spatrick  int a[42];
5317e5dd7070Spatrick  int b[2 * 21];
5318e5dd7070Spatrick  int c[41], d[43];
5319e5dd7070Spatrick  char *s = "abcd";
5320e5dd7070Spatrick  wchar_t *ws = L"abcd";
5321e5dd7070Spatrick  char *w = "a";
5322e5dd7070SpatrickconstantArrayType(hasSize(42))
5323e5dd7070Spatrick  matches "int a[42]" and "int b[2 * 21]"
5324e5dd7070SpatrickstringLiteral(hasSize(4))
5325e5dd7070Spatrick  matches "abcd", L"abcd"
5326e5dd7070Spatrick</pre></td></tr>
5327e5dd7070Spatrick
5328e5dd7070Spatrick
5329ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;</td><td class="name" onclick="toggle('isClass0')"><a name="isClass0Anchor">isClass</a></td><td></td></tr>
5330ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isClass0"><pre>Matches TagDecl object that are spelled with "class."
5331ec727ea7Spatrick
5332ec727ea7SpatrickExample matches C, but not S, U or E.
5333ec727ea7Spatrick  struct S {};
5334ec727ea7Spatrick  class C {};
5335ec727ea7Spatrick  union U {};
5336ec727ea7Spatrick  enum E {};
5337ec727ea7Spatrick</pre></td></tr>
5338ec727ea7Spatrick
5339ec727ea7Spatrick
5340e5dd7070Spatrick<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>
5341e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached.
5342e5dd7070Spatrick
5343e5dd7070SpatrickExample matches A, va, fa
5344e5dd7070Spatrick  class A {};
5345e5dd7070Spatrick  class B;  // Doesn't match, as it has no body.
5346e5dd7070Spatrick  int va;
5347e5dd7070Spatrick  extern int vb;  // Doesn't match, as it doesn't define the variable.
5348e5dd7070Spatrick  void fa() {}
5349e5dd7070Spatrick  void fb();  // Doesn't match, as it has no body.
5350e5dd7070Spatrick  @interface X
5351e5dd7070Spatrick  - (void)ma; // Doesn't match, interface is declaration.
5352e5dd7070Spatrick  @end
5353e5dd7070Spatrick  @implementation X
5354e5dd7070Spatrick  - (void)ma {}
5355e5dd7070Spatrick  @end
5356e5dd7070Spatrick
5357e5dd7070SpatrickUsable 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;,
5358e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
5359e5dd7070Spatrick</pre></td></tr>
5360e5dd7070Spatrick
5361e5dd7070Spatrick
5362ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;</td><td class="name" onclick="toggle('isEnum0')"><a name="isEnum0Anchor">isEnum</a></td><td></td></tr>
5363ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isEnum0"><pre>Matches TagDecl object that are spelled with "enum."
5364ec727ea7Spatrick
5365ec727ea7SpatrickExample matches E, but not C, S or U.
5366ec727ea7Spatrick  struct S {};
5367ec727ea7Spatrick  class C {};
5368ec727ea7Spatrick  union U {};
5369ec727ea7Spatrick  enum E {};
5370ec727ea7Spatrick</pre></td></tr>
5371ec727ea7Spatrick
5372ec727ea7Spatrick
5373ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;</td><td class="name" onclick="toggle('isStruct0')"><a name="isStruct0Anchor">isStruct</a></td><td></td></tr>
5374ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches TagDecl object that are spelled with "struct."
5375ec727ea7Spatrick
5376ec727ea7SpatrickExample matches S, but not C, U or E.
5377ec727ea7Spatrick  struct S {};
5378ec727ea7Spatrick  class C {};
5379ec727ea7Spatrick  union U {};
5380ec727ea7Spatrick  enum E {};
5381ec727ea7Spatrick</pre></td></tr>
5382ec727ea7Spatrick
5383ec727ea7Spatrick
5384ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>&gt;</td><td class="name" onclick="toggle('isUnion0')"><a name="isUnion0Anchor">isUnion</a></td><td></td></tr>
5385ec727ea7Spatrick<tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches TagDecl object that are spelled with "union."
5386ec727ea7Spatrick
5387ec727ea7SpatrickExample matches U, but not C, S or E.
5388ec727ea7Spatrick  struct S {};
5389ec727ea7Spatrick  class C {};
5390ec727ea7Spatrick  union U {};
5391ec727ea7Spatrick  enum E {};
5392ec727ea7Spatrick</pre></td></tr>
5393ec727ea7Spatrick
5394ec727ea7Spatrick
5395e5dd7070Spatrick<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>
5396e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value.
5397e5dd7070Spatrick
5398e5dd7070SpatrickNote that 'Value' is a string as the template argument's value is
5399e5dd7070Spatrickan arbitrary precision integer. 'Value' must be euqal to the canonical
5400e5dd7070Spatrickrepresentation of that integral value in base 10.
5401e5dd7070Spatrick
5402e5dd7070SpatrickGiven
5403e5dd7070Spatrick  template&lt;int T&gt; struct C {};
5404e5dd7070Spatrick  C&lt;42&gt; c;
5405e5dd7070SpatrickclassTemplateSpecializationDecl(
5406e5dd7070Spatrick  hasAnyTemplateArgument(equalsIntegralValue("42")))
5407e5dd7070Spatrick  matches the implicit instantiation of C in C&lt;42&gt;.
5408e5dd7070Spatrick</pre></td></tr>
5409e5dd7070Spatrick
5410e5dd7070Spatrick
5411e5dd7070Spatrick<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>
5412e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value.
5413e5dd7070Spatrick
5414e5dd7070SpatrickGiven
5415e5dd7070Spatrick  template&lt;int T&gt; struct C {};
5416e5dd7070Spatrick  C&lt;42&gt; c;
5417e5dd7070SpatrickclassTemplateSpecializationDecl(
5418e5dd7070Spatrick  hasAnyTemplateArgument(isIntegral()))
5419e5dd7070Spatrick  matches the implicit instantiation of C in C&lt;42&gt;
5420e5dd7070Spatrick  with isIntegral() matching 42.
5421e5dd7070Spatrick</pre></td></tr>
5422e5dd7070Spatrick
5423e5dd7070Spatrick
5424e5dd7070Spatrick<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>
5425e5dd7070Spatrick<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N.
5426e5dd7070Spatrick
5427e5dd7070SpatrickGiven
5428e5dd7070Spatrick  template&lt;typename T&gt; struct C {};
5429e5dd7070Spatrick  C&lt;int&gt; c;
5430e5dd7070SpatrickclassTemplateSpecializationDecl(templateArgumentCountIs(1))
5431e5dd7070Spatrick  matches C&lt;int&gt;.
5432e5dd7070Spatrick</pre></td></tr>
5433e5dd7070Spatrick
5434e5dd7070Spatrick
5435a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('isExpandedFromMacro2')"><a name="isExpandedFromMacro2Anchor">isExpandedFromMacro</a></td><td>std::string MacroName</td></tr>
5436a9ac8606Spatrick<tr><td colspan="4" class="doc" id="isExpandedFromMacro2"><pre>Matches statements that are (transitively) expanded from the named macro.
5437a9ac8606SpatrickDoes not match if only part of the statement is expanded from that macro or
5438*12c85518Srobertif different parts of the statement are expanded from different
5439a9ac8606Spatrickappearances of the macro.
5440a9ac8606Spatrick</pre></td></tr>
5441a9ac8606Spatrick
5442a9ac8606Spatrick
5443ec727ea7Spatrick<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>StringRef RegExp, Regex::RegexFlags Flags = NoFlags</td></tr>
5444e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is
5445e5dd7070Spatrickpartially matching a given regex.
5446e5dd7070Spatrick
5447e5dd7070SpatrickExample matches Y but not X
5448e5dd7070Spatrick    (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
5449e5dd7070Spatrick  #include "ASTMatcher.h"
5450e5dd7070Spatrick  class X {};
5451e5dd7070SpatrickASTMatcher.h:
5452e5dd7070Spatrick  class Y {};
5453e5dd7070Spatrick
5454e5dd7070SpatrickUsable 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;
5455ec727ea7Spatrick
5456ec727ea7SpatrickIf the matcher is used in clang-query, RegexFlags parameter
5457ec727ea7Spatrickshould be passed as a quoted string. e.g: "NoFlags".
5458ec727ea7SpatrickFlags can be combined with '|' example "IgnoreCase | BasicRegex"
5459e5dd7070Spatrick</pre></td></tr>
5460e5dd7070Spatrick
5461e5dd7070Spatrick
5462e5dd7070Spatrick<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>
5463e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file.
5464e5dd7070Spatrick
5465e5dd7070SpatrickExample matches X but not Y
5466e5dd7070Spatrick  (matcher = cxxRecordDecl(isExpansionInMainFile())
5467e5dd7070Spatrick  #include &lt;Y.h&gt;
5468e5dd7070Spatrick  class X {};
5469e5dd7070SpatrickY.h:
5470e5dd7070Spatrick  class Y {};
5471e5dd7070Spatrick
5472e5dd7070SpatrickUsable 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;
5473e5dd7070Spatrick</pre></td></tr>
5474e5dd7070Spatrick
5475e5dd7070Spatrick
5476e5dd7070Spatrick<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>
5477e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files.
5478e5dd7070Spatrick
5479e5dd7070SpatrickExample matches Y but not X
5480e5dd7070Spatrick    (matcher = cxxRecordDecl(isExpansionInSystemHeader())
5481e5dd7070Spatrick  #include &lt;SystemHeader.h&gt;
5482e5dd7070Spatrick  class X {};
5483e5dd7070SpatrickSystemHeader.h:
5484e5dd7070Spatrick  class Y {};
5485e5dd7070Spatrick
5486e5dd7070SpatrickUsable 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;
5487e5dd7070Spatrick</pre></td></tr>
5488e5dd7070Spatrick
5489e5dd7070Spatrick
5490e5dd7070Spatrick<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>
5491e5dd7070Spatrick<tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool.
5492e5dd7070Spatrick
5493e5dd7070SpatrickGiven
5494e5dd7070Spatrick struct S { bool func(); };
5495e5dd7070SpatrickfunctionDecl(returns(booleanType()))
5496e5dd7070Spatrick  matches "bool func();"
5497e5dd7070Spatrick</pre></td></tr>
5498e5dd7070Spatrick
5499e5dd7070Spatrick
5500e5dd7070Spatrick<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>
5501e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node.
5502e5dd7070Spatrick
5503e5dd7070SpatrickMatches a node if it equals the node previously bound to ID.
5504e5dd7070Spatrick
5505e5dd7070SpatrickGiven
5506e5dd7070Spatrick  class X { int a; int b; };
5507e5dd7070SpatrickcxxRecordDecl(
5508e5dd7070Spatrick    has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
5509e5dd7070Spatrick    has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
5510e5dd7070Spatrick  matches the class X, as a and b have the same type.
5511e5dd7070Spatrick
5512e5dd7070SpatrickNote that when multiple matches are involved via forEach* matchers,
5513e5dd7070SpatrickequalsBoundNodes acts as a filter.
5514e5dd7070SpatrickFor example:
5515e5dd7070SpatrickcompoundStmt(
5516e5dd7070Spatrick    forEachDescendant(varDecl().bind("d")),
5517e5dd7070Spatrick    forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
5518e5dd7070Spatrickwill trigger a match for each combination of variable declaration
5519e5dd7070Spatrickand reference to that variable declaration within a compound statement.
5520e5dd7070Spatrick</pre></td></tr>
5521e5dd7070Spatrick
5522e5dd7070Spatrick
5523e5dd7070Spatrick<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>
5524e5dd7070Spatrick<tr><td colspan="4" class="doc" id="equalsNode2"><pre>Matches if a node equals another node.
5525e5dd7070Spatrick
5526e5dd7070SpatrickType has pointer identity in the AST.
5527e5dd7070Spatrick</pre></td></tr>
5528e5dd7070Spatrick
5529e5dd7070Spatrick
5530e5dd7070Spatrick<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>
5531e5dd7070Spatrick<tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double).
5532e5dd7070Spatrick
5533e5dd7070SpatrickGiven
5534e5dd7070Spatrick  int i;
5535e5dd7070Spatrick  float f;
5536e5dd7070SpatrickrealFloatingPointType()
5537e5dd7070Spatrick  matches "float f" but not "int i"
5538e5dd7070Spatrick</pre></td></tr>
5539e5dd7070Spatrick
5540e5dd7070Spatrick
5541e5dd7070Spatrick<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>
5542e5dd7070Spatrick<tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void.
5543e5dd7070Spatrick
5544e5dd7070SpatrickGiven
5545e5dd7070Spatrick struct S { void func(); };
5546e5dd7070SpatrickfunctionDecl(returns(voidType()))
5547e5dd7070Spatrick  matches "void func();"
5548e5dd7070Spatrick</pre></td></tr>
5549e5dd7070Spatrick
5550e5dd7070Spatrick
5551e5dd7070Spatrick<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>
5552e5dd7070Spatrick<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind.
5553e5dd7070Spatrick
5554e5dd7070SpatrickGiven
5555e5dd7070Spatrick  int x;
5556e5dd7070Spatrick  int s = sizeof(x) + alignof(x)
5557e5dd7070SpatrickunaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
5558e5dd7070Spatrick  matches sizeof(x)
5559e5dd7070Spatrick
5560e5dd7070SpatrickIf the matcher is use from clang-query, UnaryExprOrTypeTrait parameter
5561e5dd7070Spatrickshould be passed as a quoted string. e.g., ofKind("UETT_SizeOf").
5562e5dd7070Spatrick</pre></td></tr>
5563e5dd7070Spatrick
5564e5dd7070Spatrick
5565a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasAnyOperatorName3')"><a name="hasAnyOperatorName3Anchor">hasAnyOperatorName</a></td><td>StringRef, ..., StringRef</td></tr>
5566a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasAnyOperatorName3"><pre>Matches operator expressions (binary or unary) that have any of the
5567ec727ea7Spatrickspecified names.
5568ec727ea7Spatrick
5569ec727ea7Spatrick   hasAnyOperatorName("+", "-")
5570ec727ea7Spatrick Is equivalent to
5571ec727ea7Spatrick   anyOf(hasOperatorName("+"), hasOperatorName("-"))
5572ec727ea7Spatrick</pre></td></tr>
5573ec727ea7Spatrick
5574ec727ea7Spatrick
5575a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasOperatorName3')"><a name="hasOperatorName3Anchor">hasOperatorName</a></td><td>std::string Name</td></tr>
5576a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasOperatorName3"><pre>Matches the operator Name of operator expressions (binary or
5577e5dd7070Spatrickunary).
5578e5dd7070Spatrick
5579e5dd7070SpatrickExample matches a || b (matcher = binaryOperator(hasOperatorName("||")))
5580e5dd7070Spatrick  !(a || b)
5581e5dd7070Spatrick</pre></td></tr>
5582e5dd7070Spatrick
5583e5dd7070Spatrick
5584e5dd7070Spatrick<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>
5585e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isArrow1"><pre>Matches member expressions that are called with '-&gt;' as opposed
5586e5dd7070Spatrickto '.'.
5587e5dd7070Spatrick
5588e5dd7070SpatrickMember calls on the implicit this pointer match as called with '-&gt;'.
5589e5dd7070Spatrick
5590e5dd7070SpatrickGiven
5591e5dd7070Spatrick  class Y {
5592e5dd7070Spatrick    void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
5593e5dd7070Spatrick    template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
5594e5dd7070Spatrick    int a;
5595e5dd7070Spatrick    static int b;
5596e5dd7070Spatrick  };
5597e5dd7070Spatrick  template &lt;class T&gt;
5598e5dd7070Spatrick  class Z {
5599e5dd7070Spatrick    void x() { this-&gt;m; }
5600e5dd7070Spatrick  };
5601e5dd7070SpatrickmemberExpr(isArrow())
5602e5dd7070Spatrick  matches this-&gt;x, x, y.x, a, this-&gt;b
5603e5dd7070SpatrickcxxDependentScopeMemberExpr(isArrow())
5604e5dd7070Spatrick  matches this-&gt;m
5605e5dd7070SpatrickunresolvedMemberExpr(isArrow())
5606e5dd7070Spatrick  matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
5607e5dd7070Spatrick</pre></td></tr>
5608e5dd7070Spatrick
5609e5dd7070Spatrick
5610e5dd7070Spatrick<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>
5611e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration.
5612e5dd7070Spatrick
5613e5dd7070SpatrickExample matches x, but not y, z, or a.
5614e5dd7070Spatrick(matcher = varDecl(hasAutomaticStorageDuration())
5615e5dd7070Spatrickvoid f() {
5616e5dd7070Spatrick  int x;
5617e5dd7070Spatrick  static int y;
5618e5dd7070Spatrick  thread_local int z;
5619e5dd7070Spatrick}
5620e5dd7070Spatrickint a;
5621e5dd7070Spatrick</pre></td></tr>
5622e5dd7070Spatrick
5623e5dd7070Spatrick
5624e5dd7070Spatrick<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>
5625e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage.
5626e5dd7070Spatrick
5627e5dd7070SpatrickExample matches y and z (matcher = varDecl(hasGlobalStorage())
5628e5dd7070Spatrickvoid f() {
5629e5dd7070Spatrick  int x;
5630e5dd7070Spatrick  static int y;
5631e5dd7070Spatrick}
5632e5dd7070Spatrickint z;
5633e5dd7070Spatrick</pre></td></tr>
5634e5dd7070Spatrick
5635e5dd7070Spatrick
5636e5dd7070Spatrick<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>
5637e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a
5638e5dd7070Spatricknon-static local variable.
5639e5dd7070Spatrick
5640e5dd7070SpatrickExample matches x (matcher = varDecl(hasLocalStorage())
5641e5dd7070Spatrickvoid f() {
5642e5dd7070Spatrick  int x;
5643e5dd7070Spatrick  static int y;
5644e5dd7070Spatrick}
5645e5dd7070Spatrickint z;
5646e5dd7070Spatrick</pre></td></tr>
5647e5dd7070Spatrick
5648e5dd7070Spatrick
5649e5dd7070Spatrick<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>
5650e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration.
5651e5dd7070SpatrickIt includes the variable declared at namespace scope and those declared
5652e5dd7070Spatrickwith "static" and "extern" storage class specifiers.
5653e5dd7070Spatrick
5654e5dd7070Spatrickvoid f() {
5655e5dd7070Spatrick  int x;
5656e5dd7070Spatrick  static int y;
5657e5dd7070Spatrick  thread_local int z;
5658e5dd7070Spatrick}
5659e5dd7070Spatrickint a;
5660e5dd7070Spatrickstatic int b;
5661e5dd7070Spatrickextern int c;
5662e5dd7070SpatrickvarDecl(hasStaticStorageDuration())
5663e5dd7070Spatrick  matches the function declaration y, a, b and c.
5664e5dd7070Spatrick</pre></td></tr>
5665e5dd7070Spatrick
5666e5dd7070Spatrick
5667e5dd7070Spatrick<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>
5668e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration.
5669e5dd7070Spatrick
5670e5dd7070SpatrickExample matches z, but not x, z, or a.
5671e5dd7070Spatrick(matcher = varDecl(hasThreadStorageDuration())
5672e5dd7070Spatrickvoid f() {
5673e5dd7070Spatrick  int x;
5674e5dd7070Spatrick  static int y;
5675e5dd7070Spatrick  thread_local int z;
5676e5dd7070Spatrick}
5677e5dd7070Spatrickint a;
5678e5dd7070Spatrick</pre></td></tr>
5679e5dd7070Spatrick
5680e5dd7070Spatrick
5681e5dd7070Spatrick<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>
5682e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations,
5683e5dd7070Spatrick       and if constexpr.
5684e5dd7070Spatrick
5685e5dd7070SpatrickGiven:
5686e5dd7070Spatrick  constexpr int foo = 42;
5687e5dd7070Spatrick  constexpr int bar();
5688e5dd7070Spatrick  void baz() { if constexpr(1 &gt; 0) {} }
5689e5dd7070SpatrickvarDecl(isConstexpr())
5690e5dd7070Spatrick  matches the declaration of foo.
5691e5dd7070SpatrickfunctionDecl(isConstexpr())
5692e5dd7070Spatrick  matches the declaration of bar.
5693e5dd7070SpatrickifStmt(isConstexpr())
5694e5dd7070Spatrick  matches the if statement in baz.
5695e5dd7070Spatrick</pre></td></tr>
5696e5dd7070Spatrick
5697e5dd7070Spatrick
5698*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isConstinit0')"><a name="isConstinit0Anchor">isConstinit</a></td><td></td></tr>
5699*12c85518Srobert<tr><td colspan="4" class="doc" id="isConstinit0"><pre>Matches constinit variable declarations.
5700*12c85518Srobert
5701*12c85518SrobertGiven:
5702*12c85518Srobert  constinit int foo = 42;
5703*12c85518Srobert  constinit const char* bar = "bar";
5704*12c85518Srobert  int baz = 42;
5705*12c85518Srobert  [[clang::require_constant_initialization]] int xyz = 42;
5706*12c85518SrobertvarDecl(isConstinit())
5707*12c85518Srobert  matches the declaration of `foo` and `bar`, but not `baz` and `xyz`.
5708*12c85518Srobert</pre></td></tr>
5709*12c85518Srobert
5710*12c85518Srobert
5711e5dd7070Spatrick<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>
5712e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached.
5713e5dd7070Spatrick
5714e5dd7070SpatrickExample matches A, va, fa
5715e5dd7070Spatrick  class A {};
5716e5dd7070Spatrick  class B;  // Doesn't match, as it has no body.
5717e5dd7070Spatrick  int va;
5718e5dd7070Spatrick  extern int vb;  // Doesn't match, as it doesn't define the variable.
5719e5dd7070Spatrick  void fa() {}
5720e5dd7070Spatrick  void fb();  // Doesn't match, as it has no body.
5721e5dd7070Spatrick  @interface X
5722e5dd7070Spatrick  - (void)ma; // Doesn't match, interface is declaration.
5723e5dd7070Spatrick  @end
5724e5dd7070Spatrick  @implementation X
5725e5dd7070Spatrick  - (void)ma {}
5726e5dd7070Spatrick  @end
5727e5dd7070Spatrick
5728e5dd7070SpatrickUsable 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;,
5729e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
5730e5dd7070Spatrick</pre></td></tr>
5731e5dd7070Spatrick
5732e5dd7070Spatrick
5733e5dd7070Spatrick<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>
5734e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from
5735e5dd7070Spatricka C++ catch block, or an Objective-C statement.
5736e5dd7070Spatrick
5737e5dd7070SpatrickExample matches x (matcher = varDecl(isExceptionVariable())
5738e5dd7070Spatrickvoid f(int y) {
5739e5dd7070Spatrick  try {
5740e5dd7070Spatrick  } catch (int x) {
5741e5dd7070Spatrick  }
5742e5dd7070Spatrick}
5743e5dd7070Spatrick</pre></td></tr>
5744e5dd7070Spatrick
5745e5dd7070Spatrick
5746e5dd7070Spatrick<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>
5747e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or
5748e5dd7070Spatrickstatic member variable template instantiations.
5749e5dd7070Spatrick
5750e5dd7070SpatrickGiven
5751e5dd7070Spatrick  template&lt;typename T&gt; void A(T t) { }
5752e5dd7070Spatrick  template&lt;&gt; void A(int N) { }
5753e5dd7070SpatrickfunctionDecl(isExplicitTemplateSpecialization())
5754e5dd7070Spatrick  matches the specialization A&lt;int&gt;().
5755e5dd7070Spatrick
5756e5dd7070SpatrickUsable 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;
5757e5dd7070Spatrick</pre></td></tr>
5758e5dd7070Spatrick
5759e5dd7070Spatrick
5760e5dd7070Spatrick<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>
5761e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function or variable declarations.
5762e5dd7070Spatrick
5763e5dd7070SpatrickGiven:
5764e5dd7070Spatrick  extern "C" void f() {}
5765e5dd7070Spatrick  extern "C" { void g() {} }
5766e5dd7070Spatrick  void h() {}
5767e5dd7070Spatrick  extern "C" int x = 1;
5768e5dd7070Spatrick  extern "C" int y = 2;
5769e5dd7070Spatrick  int z = 3;
5770e5dd7070SpatrickfunctionDecl(isExternC())
5771e5dd7070Spatrick  matches the declaration of f and g, but not the declaration of h.
5772e5dd7070SpatrickvarDecl(isExternC())
5773e5dd7070Spatrick  matches the declaration of x and y, but not the declaration of z.
5774e5dd7070Spatrick</pre></td></tr>
5775e5dd7070Spatrick
5776e5dd7070Spatrick
5777*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isInitCapture0')"><a name="isInitCapture0Anchor">isInitCapture</a></td><td></td></tr>
5778*12c85518Srobert<tr><td colspan="4" class="doc" id="isInitCapture0"><pre>Matches a variable serving as the implicit variable for a lambda init-
5779*12c85518Srobertcapture.
5780*12c85518Srobert
5781*12c85518SrobertExample matches x (matcher = varDecl(isInitCapture()))
5782*12c85518Srobertauto f = [x=3]() { return x; };
5783*12c85518Srobert</pre></td></tr>
5784*12c85518Srobert
5785*12c85518Srobert
5786*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>&gt;</td><td class="name" onclick="toggle('isInline2')"><a name="isInline2Anchor">isInline</a></td><td></td></tr>
5787*12c85518Srobert<tr><td colspan="4" class="doc" id="isInline2"><pre>Matches functions, variables and namespace declarations that are marked with
5788*12c85518Srobertthe inline keyword.
5789*12c85518Srobert
5790*12c85518SrobertGiven
5791*12c85518Srobert  inline void f();
5792*12c85518Srobert  void g();
5793*12c85518Srobert  namespace n {
5794*12c85518Srobert  inline namespace m {}
5795*12c85518Srobert  }
5796*12c85518Srobert  inline int Foo = 5;
5797*12c85518SrobertfunctionDecl(isInline()) will match ::f().
5798*12c85518SrobertnamespaceDecl(isInline()) will match n::m.
5799*12c85518SrobertvarDecl(isInline()) will match Foo;
5800*12c85518Srobert</pre></td></tr>
5801*12c85518Srobert
5802*12c85518Srobert
5803e5dd7070Spatrick<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>
5804e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isStaticLocal0"><pre>Matches a static variable with local scope.
5805e5dd7070Spatrick
5806e5dd7070SpatrickExample matches y (matcher = varDecl(isStaticLocal()))
5807e5dd7070Spatrickvoid f() {
5808e5dd7070Spatrick  int x;
5809e5dd7070Spatrick  static int y;
5810e5dd7070Spatrick}
5811e5dd7070Spatrickstatic int z;
5812e5dd7070Spatrick</pre></td></tr>
5813e5dd7070Spatrick
5814e5dd7070Spatrick
5815e5dd7070Spatrick<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>
5816e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variable/function declarations that have "static" storage
5817e5dd7070Spatrickclass specifier ("static" keyword) written in the source.
5818e5dd7070Spatrick
5819e5dd7070SpatrickGiven:
5820e5dd7070Spatrick  static void f() {}
5821e5dd7070Spatrick  static int i = 0;
5822e5dd7070Spatrick  extern int j;
5823e5dd7070Spatrick  int k;
5824e5dd7070SpatrickfunctionDecl(isStaticStorageClass())
5825e5dd7070Spatrick  matches the function declaration f.
5826e5dd7070SpatrickvarDecl(isStaticStorageClass())
5827e5dd7070Spatrick  matches the variable declaration i.
5828e5dd7070Spatrick</pre></td></tr>
5829e5dd7070Spatrick
5830e5dd7070Spatrick
5831e5dd7070Spatrick<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>
5832e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static
5833e5dd7070Spatrickmember variable template instantiations.
5834e5dd7070Spatrick
5835e5dd7070SpatrickGiven
5836e5dd7070Spatrick  template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
5837e5dd7070Spatrickor
5838e5dd7070Spatrick  template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
5839e5dd7070Spatrickor
5840e5dd7070Spatrick  template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
5841e5dd7070SpatrickcxxRecordDecl(hasName("::X"), isTemplateInstantiation())
5842e5dd7070Spatrick  matches the template instantiation of X&lt;A&gt;.
5843e5dd7070Spatrick
5844e5dd7070SpatrickBut given
5845e5dd7070Spatrick  template &lt;typename T&gt;  class X {}; class A {};
5846e5dd7070Spatrick  template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
5847e5dd7070SpatrickcxxRecordDecl(hasName("::X"), isTemplateInstantiation())
5848e5dd7070Spatrick  does not match, as X&lt;A&gt; is an explicit template specialization.
5849e5dd7070Spatrick
5850e5dd7070SpatrickUsable 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;
5851e5dd7070Spatrick</pre></td></tr>
5852e5dd7070Spatrick
5853e5dd7070Spatrick<!--END_NARROWING_MATCHERS -->
5854e5dd7070Spatrick</table>
5855e5dd7070Spatrick
5856e5dd7070Spatrick<!-- ======================================================================= -->
5857e5dd7070Spatrick<h2 id="traversal-matchers">AST Traversal Matchers</h2>
5858e5dd7070Spatrick<!-- ======================================================================= -->
5859e5dd7070Spatrick
5860e5dd7070Spatrick<p>Traversal matchers specify the relationship to other nodes that are
5861e5dd7070Spatrickreachable from the current node.</p>
5862e5dd7070Spatrick
5863e5dd7070Spatrick<p>Note that there are special traversal matchers (has, hasDescendant, forEach and
5864e5dd7070SpatrickforEachDescendant) which work on all nodes and allow users to write more generic
5865e5dd7070Spatrickmatch expressions.</p>
5866e5dd7070Spatrick
5867e5dd7070Spatrick<table>
5868e5dd7070Spatrick<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
5869e5dd7070Spatrick<!-- START_TRAVERSAL_MATCHERS -->
5870e5dd7070Spatrick
5871a9ac8606Spatrick<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('binaryOperation0')"><a name="binaryOperation0Anchor">binaryOperation</a></td><td>Matcher&lt;*&gt;...Matcher&lt;*&gt;</td></tr>
5872a9ac8606Spatrick<tr><td colspan="4" class="doc" id="binaryOperation0"><pre>Matches nodes which can be used with binary operators.
5873a9ac8606Spatrick
5874a9ac8606SpatrickThe code
5875a9ac8606Spatrick  var1 != var2;
5876a9ac8606Spatrickmight be represented in the clang AST as a binaryOperator, a
5877a9ac8606SpatrickcxxOperatorCallExpr or a cxxRewrittenBinaryOperator, depending on
5878a9ac8606Spatrick
5879a9ac8606Spatrick* whether the types of var1 and var2 are fundamental (binaryOperator) or at
5880a9ac8606Spatrick  least one is a class type (cxxOperatorCallExpr)
5881a9ac8606Spatrick* whether the code appears in a template declaration, if at least one of the
5882a9ac8606Spatrick  vars is a dependent-type (binaryOperator)
5883a9ac8606Spatrick* whether the code relies on a rewritten binary operator, such as a
5884a9ac8606Spatrickspaceship operator or an inverted equality operator
5885a9ac8606Spatrick(cxxRewrittenBinaryOperator)
5886a9ac8606Spatrick
5887a9ac8606SpatrickThis matcher elides details in places where the matchers for the nodes are
5888a9ac8606Spatrickcompatible.
5889a9ac8606Spatrick
5890a9ac8606SpatrickGiven
5891a9ac8606Spatrick  binaryOperation(
5892a9ac8606Spatrick    hasOperatorName("!="),
5893a9ac8606Spatrick    hasLHS(expr().bind("lhs")),
5894a9ac8606Spatrick    hasRHS(expr().bind("rhs"))
5895a9ac8606Spatrick  )
5896a9ac8606Spatrickmatches each use of "!=" in:
5897a9ac8606Spatrick  struct S{
5898a9ac8606Spatrick      bool operator!=(const S&amp;) const;
5899a9ac8606Spatrick  };
5900a9ac8606Spatrick
5901a9ac8606Spatrick  void foo()
5902a9ac8606Spatrick  {
5903a9ac8606Spatrick     1 != 2;
5904a9ac8606Spatrick     S() != S();
5905a9ac8606Spatrick  }
5906a9ac8606Spatrick
5907a9ac8606Spatrick  template&lt;typename T&gt;
5908a9ac8606Spatrick  void templ()
5909a9ac8606Spatrick  {
5910a9ac8606Spatrick     1 != 2;
5911a9ac8606Spatrick     T() != S();
5912a9ac8606Spatrick  }
5913a9ac8606Spatrick  struct HasOpEq
5914a9ac8606Spatrick  {
5915a9ac8606Spatrick      bool operator==(const HasOpEq &amp;) const;
5916a9ac8606Spatrick  };
5917a9ac8606Spatrick
5918a9ac8606Spatrick  void inverse()
5919a9ac8606Spatrick  {
5920a9ac8606Spatrick      HasOpEq s1;
5921a9ac8606Spatrick      HasOpEq s2;
5922a9ac8606Spatrick      if (s1 != s2)
5923a9ac8606Spatrick          return;
5924a9ac8606Spatrick  }
5925a9ac8606Spatrick
5926a9ac8606Spatrick  struct HasSpaceship
5927a9ac8606Spatrick  {
5928a9ac8606Spatrick      bool operator&lt;=&gt;(const HasOpEq &amp;) const;
5929a9ac8606Spatrick  };
5930a9ac8606Spatrick
5931a9ac8606Spatrick  void use_spaceship()
5932a9ac8606Spatrick  {
5933a9ac8606Spatrick      HasSpaceship s1;
5934a9ac8606Spatrick      HasSpaceship s2;
5935a9ac8606Spatrick      if (s1 != s2)
5936a9ac8606Spatrick          return;
5937a9ac8606Spatrick  }
5938a9ac8606Spatrick</pre></td></tr>
5939a9ac8606Spatrick
5940a9ac8606Spatrick
5941e5dd7070Spatrick<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>
5942e5dd7070Spatrick<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches.
5943e5dd7070Spatrick
5944e5dd7070SpatrickUnlike anyOf, eachOf will generate a match result for each
5945e5dd7070Spatrickmatching submatcher.
5946e5dd7070Spatrick
5947e5dd7070SpatrickFor example, in:
5948e5dd7070Spatrick  class A { int a; int b; };
5949e5dd7070SpatrickThe matcher:
5950e5dd7070Spatrick  cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
5951e5dd7070Spatrick                       has(fieldDecl(hasName("b")).bind("v"))))
5952e5dd7070Spatrickwill generate two results binding "v", the first of which binds
5953e5dd7070Spatrickthe field declaration of a, the second the field declaration of
5954e5dd7070Spatrickb.
5955e5dd7070Spatrick
5956e5dd7070SpatrickUsable as: Any Matcher
5957e5dd7070Spatrick</pre></td></tr>
5958e5dd7070Spatrick
5959e5dd7070Spatrick
5960ec727ea7Spatrick<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher&lt;*&gt;  Matcher</td></tr>
5961ec727ea7Spatrick<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches.
5962ec727ea7Spatrick
5963ec727ea7SpatrickGenerates results for each match.
5964ec727ea7Spatrick
5965ec727ea7SpatrickFor example, in:
5966ec727ea7Spatrick  class A { class B {}; class C {}; };
5967ec727ea7SpatrickThe matcher:
5968ec727ea7Spatrick  cxxRecordDecl(hasName("::A"),
5969ec727ea7Spatrick                findAll(cxxRecordDecl(isDefinition()).bind("m")))
5970ec727ea7Spatrickwill generate results for A, B and C.
5971ec727ea7Spatrick
5972ec727ea7SpatrickUsable as: Any Matcher
5973ec727ea7Spatrick</pre></td></tr>
5974ec727ea7Spatrick
5975ec727ea7Spatrick
5976e5dd7070Spatrick<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher&lt;*&gt;</td></tr>
5977e5dd7070Spatrick<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
5978e5dd7070Spatrickprovided matcher.
5979e5dd7070Spatrick
5980e5dd7070SpatrickExample matches X, A, A::X, B, B::C, B::C::X
5981e5dd7070Spatrick  (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))
5982e5dd7070Spatrick  class X {};
5983e5dd7070Spatrick  class A { class X {}; };  // Matches A, because A::X is a class of name
5984e5dd7070Spatrick                            // X inside A.
5985e5dd7070Spatrick  class B { class C { class X {}; }; };
5986e5dd7070Spatrick
5987e5dd7070SpatrickDescendantT must be an AST base type.
5988e5dd7070Spatrick
5989e5dd7070SpatrickAs opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
5990e5dd7070Spatrickeach result that matches instead of only on the first one.
5991e5dd7070Spatrick
5992e5dd7070SpatrickNote: Recursively combined ForEachDescendant can cause many matches:
5993e5dd7070Spatrick  cxxRecordDecl(forEachDescendant(cxxRecordDecl(
5994e5dd7070Spatrick    forEachDescendant(cxxRecordDecl())
5995e5dd7070Spatrick  )))
5996e5dd7070Spatrickwill match 10 times (plus injected class name matches) on:
5997e5dd7070Spatrick  class A { class B { class C { class D { class E {}; }; }; }; };
5998e5dd7070Spatrick
5999e5dd7070SpatrickUsable as: Any Matcher
6000e5dd7070Spatrick</pre></td></tr>
6001e5dd7070Spatrick
6002e5dd7070Spatrick
6003e5dd7070Spatrick<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher&lt;*&gt;</td></tr>
6004e5dd7070Spatrick<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the
6005e5dd7070Spatrickprovided matcher.
6006e5dd7070Spatrick
6007e5dd7070SpatrickExample matches X, Y, Y::X, Z::Y, Z::Y::X
6008e5dd7070Spatrick  (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
6009e5dd7070Spatrick  class X {};
6010e5dd7070Spatrick  class Y { class X {}; };  // Matches Y, because Y::X is a class of name X
6011e5dd7070Spatrick                            // inside Y.
6012e5dd7070Spatrick  class Z { class Y { class X {}; }; };  // Does not match Z.
6013e5dd7070Spatrick
6014e5dd7070SpatrickChildT must be an AST base type.
6015e5dd7070Spatrick
6016e5dd7070SpatrickAs opposed to 'has', 'forEach' will cause a match for each result that
6017e5dd7070Spatrickmatches instead of only on the first one.
6018e5dd7070Spatrick
6019e5dd7070SpatrickUsable as: Any Matcher
6020e5dd7070Spatrick</pre></td></tr>
6021e5dd7070Spatrick
6022e5dd7070Spatrick
6023e5dd7070Spatrick<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher&lt;*&gt;</td></tr>
6024e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided
6025e5dd7070Spatrickmatcher.
6026e5dd7070Spatrick
6027e5dd7070SpatrickGiven
6028e5dd7070Spatrickvoid f() { if (true) { int x = 42; } }
6029e5dd7070Spatrickvoid g() { for (;;) { int x = 43; } }
6030e5dd7070Spatrickexpr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.
6031e5dd7070Spatrick
6032e5dd7070SpatrickUsable as: Any Matcher
6033e5dd7070Spatrick</pre></td></tr>
6034e5dd7070Spatrick
6035e5dd7070Spatrick
6036e5dd7070Spatrick<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher&lt;*&gt;</td></tr>
6037e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
6038e5dd7070Spatrickprovided matcher.
6039e5dd7070Spatrick
6040e5dd7070SpatrickExample matches X, Y, Z
6041e5dd7070Spatrick    (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X")))))
6042e5dd7070Spatrick  class X {};  // Matches X, because X::X is a class of name X inside X.
6043e5dd7070Spatrick  class Y { class X {}; };
6044e5dd7070Spatrick  class Z { class Y { class X {}; }; };
6045e5dd7070Spatrick
6046e5dd7070SpatrickDescendantT must be an AST base type.
6047e5dd7070Spatrick
6048e5dd7070SpatrickUsable as: Any Matcher
6049e5dd7070Spatrick</pre></td></tr>
6050e5dd7070Spatrick
6051e5dd7070Spatrick
6052e5dd7070Spatrick<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher&lt;*&gt;</td></tr>
6053e5dd7070Spatrick<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the
6054e5dd7070Spatrickprovided matcher.
6055e5dd7070Spatrick
6056e5dd7070SpatrickExample matches X, Y
6057e5dd7070Spatrick  (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X")))
6058e5dd7070Spatrick  class X {};  // Matches X, because X::X is a class of name X inside X.
6059e5dd7070Spatrick  class Y { class X {}; };
6060e5dd7070Spatrick  class Z { class Y { class X {}; }; };  // Does not match Z.
6061e5dd7070Spatrick
6062e5dd7070SpatrickChildT must be an AST base type.
6063e5dd7070Spatrick
6064e5dd7070SpatrickUsable as: Any Matcher
6065e5dd7070SpatrickNote that has is direct matcher, so it also matches things like implicit
6066e5dd7070Spatrickcasts and paren casts. If you are matching with expr then you should
6067e5dd7070Spatrickprobably consider using ignoringParenImpCasts like:
6068e5dd7070Spatrickhas(ignoringParenImpCasts(expr())).
6069e5dd7070Spatrick</pre></td></tr>
6070e5dd7070Spatrick
6071e5dd7070Spatrick
6072e5dd7070Spatrick<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher&lt;*&gt;</td></tr>
6073e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided
6074e5dd7070Spatrickmatcher.
6075e5dd7070Spatrick
6076e5dd7070SpatrickGiven
6077e5dd7070Spatrickvoid f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
6078e5dd7070SpatrickcompoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".
6079e5dd7070Spatrick
6080e5dd7070SpatrickUsable as: Any Matcher
6081e5dd7070Spatrick</pre></td></tr>
6082e5dd7070Spatrick
6083e5dd7070Spatrick
6084a9ac8606Spatrick<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('invocation0')"><a name="invocation0Anchor">invocation</a></td><td>Matcher&lt;*&gt;...Matcher&lt;*&gt;</td></tr>
6085a9ac8606Spatrick<tr><td colspan="4" class="doc" id="invocation0"><pre>Matches function calls and constructor calls
6086a9ac8606Spatrick
6087a9ac8606SpatrickBecause CallExpr and CXXConstructExpr do not share a common
6088a9ac8606Spatrickbase class with API accessing arguments etc, AST Matchers for code
6089a9ac8606Spatrickwhich should match both are typically duplicated. This matcher
6090a9ac8606Spatrickremoves the need for duplication.
6091a9ac8606Spatrick
6092a9ac8606SpatrickGiven code
6093a9ac8606Spatrickstruct ConstructorTakesInt
6094a9ac8606Spatrick{
6095a9ac8606Spatrick  ConstructorTakesInt(int i) {}
6096a9ac8606Spatrick};
6097a9ac8606Spatrick
6098a9ac8606Spatrickvoid callTakesInt(int i)
6099a9ac8606Spatrick{
6100a9ac8606Spatrick}
6101a9ac8606Spatrick
6102a9ac8606Spatrickvoid doCall()
6103a9ac8606Spatrick{
6104a9ac8606Spatrick  callTakesInt(42);
6105a9ac8606Spatrick}
6106a9ac8606Spatrick
6107a9ac8606Spatrickvoid doConstruct()
6108a9ac8606Spatrick{
6109a9ac8606Spatrick  ConstructorTakesInt cti(42);
6110a9ac8606Spatrick}
6111a9ac8606Spatrick
6112a9ac8606SpatrickThe matcher
6113a9ac8606Spatrickinvocation(hasArgument(0, integerLiteral(equals(42))))
6114a9ac8606Spatrickmatches the expression in both doCall and doConstruct
6115a9ac8606Spatrick</pre></td></tr>
6116a9ac8606Spatrick
6117a9ac8606Spatrick
6118ec727ea7Spatrick<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('optionally0')"><a name="optionally0Anchor">optionally</a></td><td>Matcher&lt;*&gt;</td></tr>
6119ec727ea7Spatrick<tr><td colspan="4" class="doc" id="optionally0"><pre>Matches any node regardless of the submatcher.
6120e5dd7070Spatrick
6121ec727ea7SpatrickHowever, optionally will retain any bindings generated by the submatcher.
6122ec727ea7SpatrickUseful when additional information which may or may not present about a main
6123ec727ea7Spatrickmatching node is desired.
6124e5dd7070Spatrick
6125e5dd7070SpatrickFor example, in:
6126e5dd7070Spatrick  class Foo {
6127e5dd7070Spatrick    int bar;
6128e5dd7070Spatrick  }
6129e5dd7070SpatrickThe matcher:
6130e5dd7070Spatrick  cxxRecordDecl(
6131e5dd7070Spatrick    optionally(has(
6132e5dd7070Spatrick      fieldDecl(hasName("bar")).bind("var")
6133e5dd7070Spatrick  ))).bind("record")
6134e5dd7070Spatrickwill produce a result binding for both "record" and "var".
6135e5dd7070SpatrickThe matcher will produce a "record" binding for even if there is no data
6136e5dd7070Spatrickmember named "bar" in that class.
6137e5dd7070Spatrick
6138e5dd7070SpatrickUsable as: Any Matcher
6139e5dd7070Spatrick</pre></td></tr>
6140e5dd7070Spatrick
6141e5dd7070Spatrick
6142ec727ea7Spatrick<tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('traverse0')"><a name="traverse0Anchor">traverse</a></td><td>TraversalKind TK, Matcher&lt;*&gt;  InnerMatcher</td></tr>
6143ec727ea7Spatrick<tr><td colspan="4" class="doc" id="traverse0"><pre>Causes all nested matchers to be matched with the specified traversal kind.
6144ec727ea7Spatrick
6145ec727ea7SpatrickGiven
6146ec727ea7Spatrick  void foo()
6147ec727ea7Spatrick  {
6148ec727ea7Spatrick      int i = 3.0;
6149ec727ea7Spatrick  }
6150ec727ea7SpatrickThe matcher
6151a9ac8606Spatrick  traverse(TK_IgnoreUnlessSpelledInSource,
6152ec727ea7Spatrick    varDecl(hasInitializer(floatLiteral().bind("init")))
6153ec727ea7Spatrick  )
6154ec727ea7Spatrickmatches the variable declaration with "init" bound to the "3.0".
6155ec727ea7Spatrick</pre></td></tr>
6156ec727ea7Spatrick
6157ec727ea7Spatrick
6158e5dd7070Spatrick<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>
6159e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasCondition5"><pre>Matches the condition expression of an if statement, for loop,
6160e5dd7070Spatrickswitch statement or conditional operator.
6161e5dd7070Spatrick
6162e5dd7070SpatrickExample matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
6163e5dd7070Spatrick  if (true) {}
6164e5dd7070Spatrick</pre></td></tr>
6165e5dd7070Spatrick
6166e5dd7070Spatrick
6167e5dd7070Spatrick<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>
6168e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator
6169e5dd7070Spatrick(binary or ternary).
6170e5dd7070Spatrick
6171e5dd7070SpatrickExample matches b
6172e5dd7070Spatrick  condition ? a : b
6173e5dd7070Spatrick  condition ?: b
6174e5dd7070Spatrick</pre></td></tr>
6175e5dd7070Spatrick
6176e5dd7070Spatrick
6177e5dd7070Spatrick<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>
6178e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator.
6179e5dd7070Spatrick
6180e5dd7070SpatrickExample 1 (conditional ternary operator): matches a
6181e5dd7070Spatrick  condition ? a : b
6182e5dd7070Spatrick
6183e5dd7070SpatrickExample 2 (conditional binary operator): matches opaqueValueExpr(condition)
6184e5dd7070Spatrick  condition ?: b
6185e5dd7070Spatrick</pre></td></tr>
6186e5dd7070Spatrick
6187e5dd7070Spatrick
6188ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
6189e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration15"><pre>Matches a node if the declaration associated with that node
6190e5dd7070Spatrickmatches the given matcher.
6191e5dd7070Spatrick
6192e5dd7070SpatrickThe associated declaration is:
6193e5dd7070Spatrick- for type nodes, the declaration of the underlying type
6194e5dd7070Spatrick- for CallExpr, the declaration of the callee
6195e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
6196e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
6197e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
6198e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
6199e5dd7070Spatrick
6200e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
6201e5dd7070Spatricksugared type. Given
6202e5dd7070Spatrick  class X {};
6203e5dd7070Spatrick  typedef X Y;
6204e5dd7070Spatrick  Y y;
6205e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6206e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
6207e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
6208e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
6209e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
6210e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
6211e5dd7070Spatrick
6212e5dd7070SpatrickUsable 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;,
6213e5dd7070Spatrick  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;,
6214e5dd7070Spatrick  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;,
6215e5dd7070Spatrick  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;,
6216e5dd7070Spatrick  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;,
6217e5dd7070Spatrick  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;,
6218e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6219e5dd7070Spatrick</pre></td></tr>
6220e5dd7070Spatrick
6221e5dd7070Spatrick
6222e5dd7070Spatrick<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>
6223e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression.
6224e5dd7070Spatrick
6225e5dd7070SpatrickGiven
6226e5dd7070Spatrick  int i[5];
6227e5dd7070Spatrick  void f() { i[1] = 42; }
6228e5dd7070SpatrickarraySubscriptExpression(hasBase(implicitCastExpr(
6229e5dd7070Spatrick    hasSourceExpression(declRefExpr()))))
6230e5dd7070Spatrick  matches i[1] with the declRefExpr() matching i
6231e5dd7070Spatrick</pre></td></tr>
6232e5dd7070Spatrick
6233e5dd7070Spatrick
6234e5dd7070Spatrick<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>
6235e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression.
6236e5dd7070Spatrick
6237e5dd7070SpatrickGiven
6238e5dd7070Spatrick  int i[5];
6239e5dd7070Spatrick  void f() { i[1] = 42; }
6240e5dd7070SpatrickarraySubscriptExpression(hasIndex(integerLiteral()))
6241e5dd7070Spatrick  matches i[1] with the integerLiteral() matching 1
6242e5dd7070Spatrick</pre></td></tr>
6243e5dd7070Spatrick
6244e5dd7070Spatrick
6245a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>&gt;</td><td class="name" onclick="toggle('hasLHS3')"><a name="hasLHS3Anchor">hasLHS</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6246a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasLHS3"><pre>Matches the left hand side of binary operator expressions.
6247e5dd7070Spatrick
6248e5dd7070SpatrickExample matches a (matcher = binaryOperator(hasLHS()))
6249e5dd7070Spatrick  a || b
6250e5dd7070Spatrick</pre></td></tr>
6251e5dd7070Spatrick
6252e5dd7070Spatrick
6253a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>&gt;</td><td class="name" onclick="toggle('hasRHS3')"><a name="hasRHS3Anchor">hasRHS</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6254a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasRHS3"><pre>Matches the right hand side of binary operator expressions.
6255e5dd7070Spatrick
6256e5dd7070SpatrickExample matches b (matcher = binaryOperator(hasRHS()))
6257e5dd7070Spatrick  a || b
6258e5dd7070Spatrick</pre></td></tr>
6259e5dd7070Spatrick
6260e5dd7070Spatrick
6261e5dd7070Spatrick<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>
6262e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element
6263e5dd7070Spatricktype.
6264e5dd7070Spatrick
6265e5dd7070SpatrickGiven
6266e5dd7070Spatrick  struct A {};
6267e5dd7070Spatrick  A a[7];
6268e5dd7070Spatrick  int b[7];
6269e5dd7070SpatrickarrayType(hasElementType(builtinType()))
6270e5dd7070Spatrick  matches "int b[7]"
6271e5dd7070Spatrick
6272e5dd7070SpatrickUsable 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;
6273e5dd7070Spatrick</pre></td></tr>
6274e5dd7070Spatrick
6275e5dd7070Spatrick
6276e5dd7070Spatrick<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>
6277e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type.
6278e5dd7070Spatrick
6279e5dd7070SpatrickGiven
6280e5dd7070Spatrick  _Atomic(int) i;
6281e5dd7070Spatrick  _Atomic(float) f;
6282e5dd7070SpatrickatomicType(hasValueType(isInteger()))
6283e5dd7070Spatrick matches "_Atomic(int) i"
6284e5dd7070Spatrick
6285e5dd7070SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
6286e5dd7070Spatrick</pre></td></tr>
6287e5dd7070Spatrick
6288e5dd7070Spatrick
6289e5dd7070Spatrick<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>
6290e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type.
6291e5dd7070Spatrick
6292e5dd7070SpatrickNote: There is no TypeLoc for the deduced type and thus no
6293e5dd7070SpatrickgetDeducedLoc() matcher.
6294e5dd7070Spatrick
6295e5dd7070SpatrickGiven
6296e5dd7070Spatrick  auto a = 1;
6297e5dd7070Spatrick  auto b = 2.0;
6298e5dd7070SpatrickautoType(hasDeducedType(isInteger()))
6299e5dd7070Spatrick  matches "auto a"
6300e5dd7070Spatrick
6301e5dd7070SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>&gt;
6302e5dd7070Spatrick</pre></td></tr>
6303e5dd7070Spatrick
6304e5dd7070Spatrick
6305*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BaseUsingDecl.html">BaseUsingDecl</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>
6306*12c85518Srobert<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration.
6307*12c85518Srobert
6308*12c85518SrobertGiven
6309*12c85518Srobert  namespace X { void b(); }
6310*12c85518Srobert  using X::b;
6311*12c85518SrobertusingDecl(hasAnyUsingShadowDecl(hasName("b"))))
6312*12c85518Srobert  matches using X::b </pre></td></tr>
6313*12c85518Srobert
6314*12c85518Srobert
6315ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6316e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a
6317e5dd7070Spatrickbinary operator matches.
6318e5dd7070Spatrick</pre></td></tr>
6319e5dd7070Spatrick
6320e5dd7070Spatrick
6321e5dd7070Spatrick<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>
6322e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions.
6323e5dd7070Spatrick
6324e5dd7070SpatrickExample matches a (matcher = binaryOperator(hasLHS()))
6325e5dd7070Spatrick  a || b
6326e5dd7070Spatrick</pre></td></tr>
6327e5dd7070Spatrick
6328e5dd7070Spatrick
6329ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasOperands0')"><a name="hasOperands0Anchor">hasOperands</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; Matcher1, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; Matcher2</td></tr>
6330ec727ea7Spatrick<tr><td colspan="4" class="doc" id="hasOperands0"><pre>Matches if both matchers match with opposite sides of the binary operator.
6331ec727ea7Spatrick
6332ec727ea7SpatrickExample matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
6333ec727ea7Spatrick                                             integerLiteral(equals(2)))
6334ec727ea7Spatrick  1 + 2 // Match
6335ec727ea7Spatrick  2 + 1 // Match
6336ec727ea7Spatrick  1 + 1 // No match
6337ec727ea7Spatrick  2 + 2 // No match
6338ec727ea7Spatrick</pre></td></tr>
6339ec727ea7Spatrick
6340ec727ea7Spatrick
6341e5dd7070Spatrick<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>
6342e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions.
6343e5dd7070Spatrick
6344e5dd7070SpatrickExample matches b (matcher = binaryOperator(hasRHS()))
6345e5dd7070Spatrick  a || b
6346e5dd7070Spatrick</pre></td></tr>
6347e5dd7070Spatrick
6348e5dd7070Spatrick
6349a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BindingDecl.html">BindingDecl</a>&gt;</td><td class="name" onclick="toggle('forDecomposition0')"><a name="forDecomposition0Anchor">forDecomposition</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt; InnerMatcher</td></tr>
6350a9ac8606Spatrick<tr><td colspan="4" class="doc" id="forDecomposition0"><pre>Matches the DecompositionDecl the binding belongs to.
6351a9ac8606Spatrick
6352a9ac8606SpatrickFor example, in:
6353a9ac8606Spatrickvoid foo()
6354a9ac8606Spatrick{
6355a9ac8606Spatrick    int arr[3];
6356a9ac8606Spatrick    auto &amp;[f, s, t] = arr;
6357a9ac8606Spatrick
6358a9ac8606Spatrick    f = 42;
6359a9ac8606Spatrick}
6360a9ac8606SpatrickThe matcher:
6361a9ac8606Spatrick  bindingDecl(hasName("f"),
6362a9ac8606Spatrick                forDecomposition(decompositionDecl())
6363a9ac8606Spatrickmatches 'f' in 'auto &amp;[f, s, t]'.
6364a9ac8606Spatrick</pre></td></tr>
6365a9ac8606Spatrick
6366a9ac8606Spatrick
6367e5dd7070Spatrick<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>
6368e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnyParameter2"><pre>Matches any parameter of a function or an ObjC method declaration or a
6369e5dd7070Spatrickblock.
6370e5dd7070Spatrick
6371e5dd7070SpatrickDoes not match the 'this' parameter of a method.
6372e5dd7070Spatrick
6373e5dd7070SpatrickGiven
6374e5dd7070Spatrick  class X { void f(int x, int y, int z) {} };
6375e5dd7070SpatrickcxxMethodDecl(hasAnyParameter(hasName("y")))
6376e5dd7070Spatrick  matches f(int x, int y, int z) {}
6377e5dd7070Spatrickwith hasAnyParameter(...)
6378e5dd7070Spatrick  matching int y
6379e5dd7070Spatrick
6380e5dd7070SpatrickFor ObjectiveC, given
6381e5dd7070Spatrick  @interface I - (void) f:(int) y; @end
6382e5dd7070Spatrick
6383e5dd7070Spatrickthe matcher objcMethodDecl(hasAnyParameter(hasName("y")))
6384e5dd7070Spatrickmatches the declaration of method f with hasParameter
6385e5dd7070Spatrickmatching y.
6386e5dd7070Spatrick
6387e5dd7070SpatrickFor blocks, given
6388e5dd7070Spatrick  b = ^(int y) { printf("%d", y) };
6389e5dd7070Spatrick
6390e5dd7070Spatrickthe matcher blockDecl(hasAnyParameter(hasName("y")))
6391e5dd7070Spatrickmatches the declaration of the block b with hasParameter
6392e5dd7070Spatrickmatching y.
6393e5dd7070Spatrick</pre></td></tr>
6394e5dd7070Spatrick
6395e5dd7070Spatrick
6396e5dd7070Spatrick<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>
6397e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasParameter2"><pre>Matches the n'th parameter of a function or an ObjC method
6398e5dd7070Spatrickdeclaration or a block.
6399e5dd7070Spatrick
6400e5dd7070SpatrickGiven
6401e5dd7070Spatrick  class X { void f(int x) {} };
6402e5dd7070SpatrickcxxMethodDecl(hasParameter(0, hasType(varDecl())))
6403e5dd7070Spatrick  matches f(int x) {}
6404e5dd7070Spatrickwith hasParameter(...)
6405e5dd7070Spatrick  matching int x
6406e5dd7070Spatrick
6407e5dd7070SpatrickFor ObjectiveC, given
6408e5dd7070Spatrick  @interface I - (void) f:(int) y; @end
6409e5dd7070Spatrick
6410e5dd7070Spatrickthe matcher objcMethodDecl(hasParameter(0, hasName("y")))
6411e5dd7070Spatrickmatches the declaration of method f with hasParameter
6412e5dd7070Spatrickmatching y.
6413e5dd7070Spatrick</pre></td></tr>
6414e5dd7070Spatrick
6415e5dd7070Spatrick
6416a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</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>
6417a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of a node matches the inner matcher.
6418a9ac8606Spatrick
6419a9ac8606SpatrickExamples:
6420a9ac8606Spatrick  int x;
6421a9ac8606SpatrickdeclaratorDecl(hasTypeLoc(loc(asString("int"))))
6422a9ac8606Spatrick  matches int x
6423a9ac8606Spatrick
6424a9ac8606Spatrickauto x = int(3);
6425a9ac8606SpatrickcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6426a9ac8606Spatrick  matches int(3)
6427a9ac8606Spatrick
6428a9ac8606Spatrickstruct Foo { Foo(int, int); };
6429a9ac8606Spatrickauto x = Foo(1, 2);
6430a9ac8606SpatrickcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6431a9ac8606Spatrick  matches Foo(1, 2)
6432a9ac8606Spatrick
6433a9ac8606SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
6434a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
6435a9ac8606Spatrick  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_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
6436a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6437a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
6438a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
6439a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
6440a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6441a9ac8606Spatrick</pre></td></tr>
6442a9ac8606Spatrick
6443a9ac8606Spatrick
6444e5dd7070Spatrick<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>
6445e5dd7070Spatrick<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the
6446e5dd7070Spatrickpointee matches a given matcher.
6447e5dd7070Spatrick
6448e5dd7070SpatrickGiven
6449e5dd7070Spatrick  int *a;
6450e5dd7070Spatrick  int const *b;
6451e5dd7070Spatrick  float const *f;
6452e5dd7070SpatrickpointerType(pointee(isConstQualified(), isInteger()))
6453e5dd7070Spatrick  matches "int const *b"
6454e5dd7070Spatrick
6455e5dd7070SpatrickUsable 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;,
6456e5dd7070Spatrick  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;
6457e5dd7070Spatrick</pre></td></tr>
6458e5dd7070Spatrick
6459e5dd7070Spatrick
6460a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc1')"><a name="hasTypeLoc1Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
6461a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasTypeLoc1"><pre>Matches if the type location of a node matches the inner matcher.
6462a9ac8606Spatrick
6463a9ac8606SpatrickExamples:
6464a9ac8606Spatrick  int x;
6465a9ac8606SpatrickdeclaratorDecl(hasTypeLoc(loc(asString("int"))))
6466a9ac8606Spatrick  matches int x
6467a9ac8606Spatrick
6468a9ac8606Spatrickauto x = int(3);
6469a9ac8606SpatrickcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6470a9ac8606Spatrick  matches int(3)
6471a9ac8606Spatrick
6472a9ac8606Spatrickstruct Foo { Foo(int, int); };
6473a9ac8606Spatrickauto x = Foo(1, 2);
6474a9ac8606SpatrickcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6475a9ac8606Spatrick  matches Foo(1, 2)
6476a9ac8606Spatrick
6477a9ac8606SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
6478a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
6479a9ac8606Spatrick  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_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
6480a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6481a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
6482a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
6483a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
6484a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6485a9ac8606Spatrick</pre></td></tr>
6486a9ac8606Spatrick
6487a9ac8606Spatrick
6488a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;</td><td class="name" onclick="toggle('hasType8')"><a name="hasType8Anchor">hasType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
6489a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasType8"><pre>Overloaded to match the declaration of the expression's or value
6490ec727ea7Spatrickdeclaration's type.
6491ec727ea7Spatrick
6492ec727ea7SpatrickIn case of a value declaration (for example a variable declaration),
6493ec727ea7Spatrickthis resolves one layer of indirection. For example, in the value
6494ec727ea7Spatrickdeclaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
6495ec727ea7SpatrickX, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
6496ec727ea7Spatrickdeclaration of x.
6497ec727ea7Spatrick
6498ec727ea7SpatrickExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
6499ec727ea7Spatrick            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
6500ec727ea7Spatrick            and friend class X (matcher = friendDecl(hasType("X"))
6501a9ac8606Spatrick            and public virtual X (matcher = cxxBaseSpecifier(hasType(
6502a9ac8606Spatrick                                              cxxRecordDecl(hasName("X"))))
6503ec727ea7Spatrick class X {};
6504ec727ea7Spatrick void y(X &amp;x) { x; X z; }
6505ec727ea7Spatrick class Y { friend class X; };
6506a9ac8606Spatrick class Z : public virtual X {};
6507ec727ea7Spatrick
6508ec727ea7SpatrickExample matches class Derived
6509ec727ea7Spatrick(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
6510ec727ea7Spatrickclass Base {};
6511ec727ea7Spatrickclass Derived : Base {};
6512ec727ea7Spatrick
6513ec727ea7SpatrickUsable 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_1FriendDecl.html">FriendDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;,
6514ec727ea7SpatrickMatcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
6515ec727ea7Spatrick</pre></td></tr>
6516ec727ea7Spatrick
6517ec727ea7Spatrick
6518a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</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_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
6519a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasType4"><pre>Matches if the expression's or declaration's type matches a type
6520a9ac8606Spatrickmatcher.
6521a9ac8606Spatrick
6522a9ac8606SpatrickExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
6523a9ac8606Spatrick            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
6524a9ac8606Spatrick            and U (matcher = typedefDecl(hasType(asString("int")))
6525a9ac8606Spatrick            and friend class X (matcher = friendDecl(hasType("X"))
6526a9ac8606Spatrick            and public virtual X (matcher = cxxBaseSpecifier(hasType(
6527a9ac8606Spatrick                                              asString("class X")))
6528a9ac8606Spatrick class X {};
6529a9ac8606Spatrick void y(X &amp;x) { x; X z; }
6530a9ac8606Spatrick typedef int U;
6531a9ac8606Spatrick class Y { friend class X; };
6532a9ac8606Spatrick class Z : public virtual X {};
6533a9ac8606Spatrick</pre></td></tr>
6534a9ac8606Spatrick
6535a9ac8606Spatrick
6536e5dd7070Spatrick<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>
6537e5dd7070Spatrick<tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl.
6538e5dd7070Spatrick
6539e5dd7070SpatrickGiven
6540e5dd7070Spatrick  void f(int i);
6541e5dd7070Spatrick  int y;
6542e5dd7070Spatrick  f(y);
6543e5dd7070SpatrickcallExpr(
6544e5dd7070Spatrick  forEachArgumentWithParam(
6545e5dd7070Spatrick    declRefExpr(to(varDecl(hasName("y")))),
6546e5dd7070Spatrick    parmVarDecl(hasType(isInteger()))
6547e5dd7070Spatrick))
6548e5dd7070Spatrick  matches f(y);
6549e5dd7070Spatrickwith declRefExpr(...)
6550e5dd7070Spatrick  matching int y
6551e5dd7070Spatrickand parmVarDecl(...)
6552e5dd7070Spatrick  matching int i
6553e5dd7070Spatrick</pre></td></tr>
6554e5dd7070Spatrick
6555e5dd7070Spatrick
6556a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('forEachArgumentWithParamType1')"><a name="forEachArgumentWithParamType1Anchor">forEachArgumentWithParamType</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_1QualType.html">QualType</a>&gt; ParamMatcher</td></tr>
6557a9ac8606Spatrick<tr><td colspan="4" class="doc" id="forEachArgumentWithParamType1"><pre>Matches all arguments and their respective types for a CallExpr or
6558a9ac8606SpatrickCXXConstructExpr. It is very similar to forEachArgumentWithParam but
6559a9ac8606Spatrickit works on calls through function pointers as well.
6560a9ac8606Spatrick
6561a9ac8606SpatrickThe difference is, that function pointers do not provide access to a
6562a9ac8606SpatrickParmVarDecl, but only the QualType for each argument.
6563a9ac8606Spatrick
6564a9ac8606SpatrickGiven
6565a9ac8606Spatrick  void f(int i);
6566a9ac8606Spatrick  int y;
6567a9ac8606Spatrick  f(y);
6568a9ac8606Spatrick  void (*f_ptr)(int) = f;
6569a9ac8606Spatrick  f_ptr(y);
6570a9ac8606SpatrickcallExpr(
6571a9ac8606Spatrick  forEachArgumentWithParamType(
6572a9ac8606Spatrick    declRefExpr(to(varDecl(hasName("y")))),
6573a9ac8606Spatrick    qualType(isInteger()).bind("type)
6574a9ac8606Spatrick))
6575a9ac8606Spatrick  matches f(y) and f_ptr(y)
6576a9ac8606Spatrickwith declRefExpr(...)
6577a9ac8606Spatrick  matching int y
6578a9ac8606Spatrickand qualType(...)
6579a9ac8606Spatrick  matching int
6580a9ac8606Spatrick</pre></td></tr>
6581a9ac8606Spatrick
6582a9ac8606Spatrick
6583e5dd7070Spatrick<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>
6584e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call
6585e5dd7070Spatrickexpression, or an ObjC-message-send expression.
6586e5dd7070Spatrick
6587e5dd7070SpatrickGiven
6588e5dd7070Spatrick  void x(int, int, int) { int y; x(1, y, 42); }
6589e5dd7070SpatrickcallExpr(hasAnyArgument(declRefExpr()))
6590e5dd7070Spatrick  matches x(1, y, 42)
6591e5dd7070Spatrickwith hasAnyArgument(...)
6592e5dd7070Spatrick  matching y
6593e5dd7070Spatrick
6594e5dd7070SpatrickFor ObjectiveC, given
6595e5dd7070Spatrick  @interface I - (void) f:(int) y; @end
6596e5dd7070Spatrick  void foo(I *i) { [i f:12]; }
6597e5dd7070SpatrickobjcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
6598e5dd7070Spatrick  matches [i f:12]
6599e5dd7070Spatrick</pre></td></tr>
6600e5dd7070Spatrick
6601e5dd7070Spatrick
6602e5dd7070Spatrick<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>
6603e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor
6604e5dd7070Spatrickcall expression.
6605e5dd7070Spatrick
6606e5dd7070SpatrickExample matches y in x(y)
6607e5dd7070Spatrick    (matcher = callExpr(hasArgument(0, declRefExpr())))
6608e5dd7070Spatrick  void x(int) { int y; x(y); }
6609e5dd7070Spatrick</pre></td></tr>
6610e5dd7070Spatrick
6611e5dd7070Spatrick
6612ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
6613e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node
6614e5dd7070Spatrickmatches the given matcher.
6615e5dd7070Spatrick
6616e5dd7070SpatrickThe associated declaration is:
6617e5dd7070Spatrick- for type nodes, the declaration of the underlying type
6618e5dd7070Spatrick- for CallExpr, the declaration of the callee
6619e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
6620e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
6621e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
6622e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
6623e5dd7070Spatrick
6624e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
6625e5dd7070Spatricksugared type. Given
6626e5dd7070Spatrick  class X {};
6627e5dd7070Spatrick  typedef X Y;
6628e5dd7070Spatrick  Y y;
6629e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6630e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
6631e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
6632e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
6633e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
6634e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
6635e5dd7070Spatrick
6636e5dd7070SpatrickUsable 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;,
6637e5dd7070Spatrick  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;,
6638e5dd7070Spatrick  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;,
6639e5dd7070Spatrick  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;,
6640e5dd7070Spatrick  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;,
6641e5dd7070Spatrick  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;,
6642e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6643e5dd7070Spatrick</pre></td></tr>
6644e5dd7070Spatrick
6645e5dd7070Spatrick
6646e5dd7070Spatrick<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>
6647e5dd7070Spatrick<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition.
6648e5dd7070Spatrick
6649e5dd7070SpatrickGiven
6650e5dd7070Spatrick  class A { A() : i(42), j(42) {} int i; int j; };
6651e5dd7070SpatrickcxxConstructorDecl(forEachConstructorInitializer(
6652e5dd7070Spatrick  forField(decl().bind("x"))
6653e5dd7070Spatrick))
6654e5dd7070Spatrick  will trigger two matches, binding for 'i' and 'j' respectively.
6655e5dd7070Spatrick</pre></td></tr>
6656e5dd7070Spatrick
6657e5dd7070Spatrick
6658e5dd7070Spatrick<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>
6659e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer.
6660e5dd7070Spatrick
6661e5dd7070SpatrickGiven
6662e5dd7070Spatrick  struct Foo {
6663e5dd7070Spatrick    Foo() : foo_(1) { }
6664e5dd7070Spatrick    int foo_;
6665e5dd7070Spatrick  };
6666e5dd7070SpatrickcxxRecordDecl(has(cxxConstructorDecl(
6667e5dd7070Spatrick  hasAnyConstructorInitializer(anything())
6668e5dd7070Spatrick)))
6669e5dd7070Spatrick  record matches Foo, hasAnyConstructorInitializer matches foo_(1)
6670e5dd7070Spatrick</pre></td></tr>
6671e5dd7070Spatrick
6672e5dd7070Spatrick
6673e5dd7070Spatrick<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>
6674e5dd7070Spatrick<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer.
6675e5dd7070Spatrick
6676e5dd7070SpatrickGiven
6677e5dd7070Spatrick  struct Foo {
6678e5dd7070Spatrick    Foo() : foo_(1) { }
6679e5dd7070Spatrick    int foo_;
6680e5dd7070Spatrick  };
6681e5dd7070SpatrickcxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
6682e5dd7070Spatrick    forField(hasName("foo_"))))))
6683e5dd7070Spatrick  matches Foo
6684e5dd7070Spatrickwith forField matching foo_
6685e5dd7070Spatrick</pre></td></tr>
6686e5dd7070Spatrick
6687e5dd7070Spatrick
6688a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc2')"><a name="hasTypeLoc2Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
6689a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasTypeLoc2"><pre>Matches if the type location of a node matches the inner matcher.
6690a9ac8606Spatrick
6691a9ac8606SpatrickExamples:
6692a9ac8606Spatrick  int x;
6693a9ac8606SpatrickdeclaratorDecl(hasTypeLoc(loc(asString("int"))))
6694a9ac8606Spatrick  matches int x
6695a9ac8606Spatrick
6696a9ac8606Spatrickauto x = int(3);
6697a9ac8606SpatrickcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6698a9ac8606Spatrick  matches int(3)
6699a9ac8606Spatrick
6700a9ac8606Spatrickstruct Foo { Foo(int, int); };
6701a9ac8606Spatrickauto x = Foo(1, 2);
6702a9ac8606SpatrickcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6703a9ac8606Spatrick  matches Foo(1, 2)
6704a9ac8606Spatrick
6705a9ac8606SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
6706a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
6707a9ac8606Spatrick  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_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
6708a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6709a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
6710a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
6711a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
6712a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6713a9ac8606Spatrick</pre></td></tr>
6714a9ac8606Spatrick
6715a9ac8606Spatrick
6716e5dd7070Spatrick<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>
6717e5dd7070Spatrick<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer.
6718e5dd7070Spatrick
6719e5dd7070SpatrickGiven
6720e5dd7070Spatrick  struct Foo {
6721e5dd7070Spatrick    Foo() : foo_(1) { }
6722e5dd7070Spatrick    int foo_;
6723e5dd7070Spatrick  };
6724e5dd7070SpatrickcxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
6725e5dd7070Spatrick    withInitializer(integerLiteral(equals(1)))))))
6726e5dd7070Spatrick  matches Foo
6727e5dd7070Spatrickwith withInitializer matching (1)
6728e5dd7070Spatrick</pre></td></tr>
6729e5dd7070Spatrick
6730e5dd7070Spatrick
6731e5dd7070Spatrick<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>
6732e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasObjectExpression2"><pre>Matches a member expression where the object expression is matched by a
6733e5dd7070Spatrickgiven matcher. Implicit object expressions are included; that is, it matches
6734e5dd7070Spatrickuse of implicit `this`.
6735e5dd7070Spatrick
6736e5dd7070SpatrickGiven
6737e5dd7070Spatrick  struct X {
6738e5dd7070Spatrick    int m;
6739e5dd7070Spatrick    int f(X x) { x.m; return m; }
6740e5dd7070Spatrick  };
6741e5dd7070SpatrickmemberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))
6742e5dd7070Spatrick  matches `x.m`, but not `m`; however,
6743e5dd7070SpatrickmemberExpr(hasObjectExpression(hasType(pointsTo(
6744e5dd7070Spatrick     cxxRecordDecl(hasName("X"))))))
6745e5dd7070Spatrick  matches `m` (aka. `this-&gt;m`), but not `x.m`.
6746e5dd7070Spatrick</pre></td></tr>
6747e5dd7070Spatrick
6748e5dd7070Spatrick
6749e5dd7070Spatrick<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>
6750*12c85518Srobert<tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', 'do' statement or a function definition that has
6751*12c85518Sroberta given body. Note that in case of functions this matcher only matches the
6752*12c85518Srobertdefinition itself and not the other declarations of the same function.
6753*12c85518Srobert
6754*12c85518SrobertGiven
6755*12c85518Srobert  for (;;) {}
6756*12c85518SrobertforStmt(hasBody(compoundStmt()))
6757*12c85518Srobert  matches 'for (;;) {}'
6758*12c85518Srobertwith compoundStmt()
6759*12c85518Srobert  matching '{}'
6760*12c85518Srobert
6761*12c85518SrobertGiven
6762*12c85518Srobert  void f();
6763*12c85518Srobert  void f() {}
6764*12c85518SrobertfunctionDecl(hasBody(compoundStmt()))
6765*12c85518Srobert  matches 'void f() {}'
6766*12c85518Srobertwith compoundStmt()
6767*12c85518Srobert  matching '{}'
6768*12c85518Srobert  but does not match 'void f();'
6769*12c85518Srobert</pre></td></tr>
6770e5dd7070Spatrick
6771e5dd7070Spatrick
6772e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>&gt;</td><td class="name" onclick="toggle('hasInitStatement2')"><a name="hasInitStatement2Anchor">hasInitStatement</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
6773e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasInitStatement2"><pre>Matches selection statements with initializer.
6774e5dd7070Spatrick
6775e5dd7070SpatrickGiven:
6776e5dd7070Spatrick void foo() {
6777e5dd7070Spatrick   if (int i = foobar(); i &gt; 0) {}
6778e5dd7070Spatrick   switch (int i = foobar(); i) {}
6779e5dd7070Spatrick   for (auto&amp; a = get_range(); auto&amp; x : a) {}
6780e5dd7070Spatrick }
6781e5dd7070Spatrick void bar() {
6782e5dd7070Spatrick   if (foobar() &gt; 0) {}
6783e5dd7070Spatrick   switch (foobar()) {}
6784e5dd7070Spatrick   for (auto&amp; x : get_range()) {}
6785e5dd7070Spatrick }
6786e5dd7070SpatrickifStmt(hasInitStatement(anything()))
6787e5dd7070Spatrick  matches the if statement in foo but not in bar.
6788e5dd7070SpatrickswitchStmt(hasInitStatement(anything()))
6789e5dd7070Spatrick  matches the switch statement in foo but not in bar.
6790e5dd7070SpatrickcxxForRangeStmt(hasInitStatement(anything()))
6791e5dd7070Spatrick  matches the range for statement in foo but not in bar.
6792e5dd7070Spatrick</pre></td></tr>
6793e5dd7070Spatrick
6794e5dd7070Spatrick
6795e5dd7070Spatrick<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>
6796e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop.
6797e5dd7070Spatrick
6798e5dd7070SpatrickExample:
6799e5dd7070Spatrick    forStmt(hasLoopVariable(anything()))
6800e5dd7070Spatrickmatches 'int x' in
6801e5dd7070Spatrick    for (int x : a) { }
6802e5dd7070Spatrick</pre></td></tr>
6803e5dd7070Spatrick
6804e5dd7070Spatrick
6805e5dd7070Spatrick<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>
6806e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop.
6807e5dd7070Spatrick
6808e5dd7070SpatrickExample:
6809e5dd7070Spatrick    forStmt(hasRangeInit(anything()))
6810e5dd7070Spatrickmatches 'a' in
6811e5dd7070Spatrick    for (int x : a) { }
6812e5dd7070Spatrick</pre></td></tr>
6813e5dd7070Spatrick
6814e5dd7070Spatrick
6815a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc3')"><a name="hasTypeLoc3Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
6816a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasTypeLoc3"><pre>Matches if the type location of a node matches the inner matcher.
6817a9ac8606Spatrick
6818a9ac8606SpatrickExamples:
6819a9ac8606Spatrick  int x;
6820a9ac8606SpatrickdeclaratorDecl(hasTypeLoc(loc(asString("int"))))
6821a9ac8606Spatrick  matches int x
6822a9ac8606Spatrick
6823a9ac8606Spatrickauto x = int(3);
6824a9ac8606SpatrickcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6825a9ac8606Spatrick  matches int(3)
6826a9ac8606Spatrick
6827a9ac8606Spatrickstruct Foo { Foo(int, int); };
6828a9ac8606Spatrickauto x = Foo(1, 2);
6829a9ac8606SpatrickcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6830a9ac8606Spatrick  matches Foo(1, 2)
6831a9ac8606Spatrick
6832a9ac8606SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
6833a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
6834a9ac8606Spatrick  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_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
6835a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6836a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
6837a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
6838a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
6839a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6840a9ac8606Spatrick</pre></td></tr>
6841a9ac8606Spatrick
6842a9ac8606Spatrick
6843e5dd7070Spatrick<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>
6844e5dd7070Spatrick<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre>Matches on the implicit object argument of a member call expression. Unlike
6845e5dd7070Spatrick`on`, matches the argument directly without stripping away anything.
6846e5dd7070Spatrick
6847e5dd7070SpatrickGiven
6848e5dd7070Spatrick  class Y { public: void m(); };
6849e5dd7070Spatrick  Y g();
6850e5dd7070Spatrick  class X : public Y { void g(); };
6851e5dd7070Spatrick  void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); }
6852e5dd7070SpatrickcxxMemberCallExpr(onImplicitObjectArgument(hasType(
6853e5dd7070Spatrick    cxxRecordDecl(hasName("Y")))))
6854e5dd7070Spatrick  matches `y.m()`, `x.m()` and (g()).m(), but not `x.g()`.
6855e5dd7070SpatrickcxxMemberCallExpr(on(callExpr()))
6856e5dd7070Spatrick  does not match `(g()).m()`, because the parens are not ignored.
6857e5dd7070Spatrick
6858e5dd7070SpatrickFIXME: Overload to allow directly matching types?
6859e5dd7070Spatrick</pre></td></tr>
6860e5dd7070Spatrick
6861e5dd7070Spatrick
6862e5dd7070Spatrick<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>
6863e5dd7070Spatrick<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression, after
6864e5dd7070Spatrickstripping off any parentheses or implicit casts.
6865e5dd7070Spatrick
6866e5dd7070SpatrickGiven
6867e5dd7070Spatrick  class Y { public: void m(); };
6868e5dd7070Spatrick  Y g();
6869e5dd7070Spatrick  class X : public Y {};
6870e5dd7070Spatrick  void z(Y y, X x) { y.m(); (g()).m(); x.m(); }
6871e5dd7070SpatrickcxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))))
6872e5dd7070Spatrick  matches `y.m()` and `(g()).m()`.
6873e5dd7070SpatrickcxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X")))))
6874e5dd7070Spatrick  matches `x.m()`.
6875e5dd7070SpatrickcxxMemberCallExpr(on(callExpr()))
6876e5dd7070Spatrick  matches `(g()).m()`.
6877e5dd7070Spatrick
6878e5dd7070SpatrickFIXME: Overload to allow directly matching types?
6879e5dd7070Spatrick</pre></td></tr>
6880e5dd7070Spatrick
6881e5dd7070Spatrick
6882e5dd7070Spatrick<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>
6883e5dd7070Spatrick<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration.
6884e5dd7070Spatrick</pre></td></tr>
6885e5dd7070Spatrick
6886e5dd7070Spatrick
6887e5dd7070Spatrick<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>
6888e5dd7070Spatrick<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the type of the expression's implicit object argument either
6889e5dd7070Spatrickmatches the InnerMatcher, or is a pointer to a type that matches the
6890e5dd7070SpatrickInnerMatcher.
6891e5dd7070Spatrick
6892e5dd7070SpatrickGiven
6893e5dd7070Spatrick  class Y { public: void m(); };
6894e5dd7070Spatrick  class X : public Y { void g(); };
6895e5dd7070Spatrick  void z() { Y y; y.m(); Y *p; p-&gt;m(); X x; x.m(); x.g(); }
6896e5dd7070SpatrickcxxMemberCallExpr(thisPointerType(hasDeclaration(
6897e5dd7070Spatrick    cxxRecordDecl(hasName("Y")))))
6898e5dd7070Spatrick  matches `y.m()`, `p-&gt;m()` and `x.m()`.
6899e5dd7070SpatrickcxxMemberCallExpr(thisPointerType(hasDeclaration(
6900e5dd7070Spatrick    cxxRecordDecl(hasName("X")))))
6901e5dd7070Spatrick  matches `x.g()`.
6902e5dd7070Spatrick</pre></td></tr>
6903e5dd7070Spatrick
6904e5dd7070Spatrick
6905e5dd7070Spatrick<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>
6906e5dd7070Spatrick<tr><td colspan="4" class="doc" id="forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may
6907e5dd7070Spatrickproduce multiple matches.
6908e5dd7070Spatrick
6909e5dd7070SpatrickGiven
6910e5dd7070Spatrick  class A { virtual void f(); };
6911e5dd7070Spatrick  class B : public A { void f(); };
6912e5dd7070Spatrick  class C : public B { void f(); };
6913e5dd7070SpatrickcxxMethodDecl(ofClass(hasName("C")),
6914e5dd7070Spatrick              forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
6915e5dd7070Spatrick  matches once, with "b" binding "A::f" and "d" binding "C::f" (Note
6916e5dd7070Spatrick  that B::f is not overridden by C::f).
6917e5dd7070Spatrick
6918e5dd7070SpatrickThe check can produce multiple matches in case of multiple inheritance, e.g.
6919e5dd7070Spatrick  class A1 { virtual void f(); };
6920e5dd7070Spatrick  class A2 { virtual void f(); };
6921e5dd7070Spatrick  class C : public A1, public A2 { void f(); };
6922e5dd7070SpatrickcxxMethodDecl(ofClass(hasName("C")),
6923e5dd7070Spatrick              forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
6924e5dd7070Spatrick  matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and
6925e5dd7070Spatrick  once with "b" binding "A2::f" and "d" binding "C::f".
6926e5dd7070Spatrick</pre></td></tr>
6927e5dd7070Spatrick
6928e5dd7070Spatrick
6929e5dd7070Spatrick<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>
6930e5dd7070Spatrick<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration
6931e5dd7070Spatrickbelongs to.
6932e5dd7070Spatrick
6933e5dd7070SpatrickFIXME: Generalize this for other kinds of declarations.
6934e5dd7070SpatrickFIXME: What other kind of declarations would we need to generalize
6935e5dd7070Spatrickthis to?
6936e5dd7070Spatrick
6937e5dd7070SpatrickExample matches A() in the last line
6938e5dd7070Spatrick    (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl(
6939e5dd7070Spatrick        ofClass(hasName("A"))))))
6940e5dd7070Spatrick  class A {
6941e5dd7070Spatrick   public:
6942e5dd7070Spatrick    A();
6943e5dd7070Spatrick  };
6944e5dd7070Spatrick  A a = A();
6945e5dd7070Spatrick</pre></td></tr>
6946e5dd7070Spatrick
6947e5dd7070Spatrick
6948ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnyPlacementArg0')"><a name="hasAnyPlacementArg0Anchor">hasAnyPlacementArg</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
6949ec727ea7Spatrick<tr><td colspan="4" class="doc" id="hasAnyPlacementArg0"><pre>Matches any placement new expression arguments.
6950ec727ea7Spatrick
6951ec727ea7SpatrickGiven:
6952ec727ea7Spatrick  MyClass *p1 = new (Storage) MyClass();
6953ec727ea7SpatrickcxxNewExpr(hasAnyPlacementArg(anything()))
6954ec727ea7Spatrick  matches the expression 'new (Storage, 16) MyClass()'.
6955ec727ea7Spatrick</pre></td></tr>
6956ec727ea7Spatrick
6957ec727ea7Spatrick
6958e5dd7070Spatrick<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>
6959e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasArraySize0"><pre>Matches array new expressions with a given array size.
6960e5dd7070Spatrick
6961e5dd7070SpatrickGiven:
6962e5dd7070Spatrick  MyClass *p1 = new MyClass[10];
6963e5dd7070SpatrickcxxNewExpr(hasArraySize(integerLiteral(equals(10))))
6964e5dd7070Spatrick  matches the expression 'new MyClass[10]'.
6965e5dd7070Spatrick</pre></td></tr>
6966e5dd7070Spatrick
6967e5dd7070Spatrick
6968ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
6969e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node
6970e5dd7070Spatrickmatches the given matcher.
6971e5dd7070Spatrick
6972e5dd7070SpatrickThe associated declaration is:
6973e5dd7070Spatrick- for type nodes, the declaration of the underlying type
6974e5dd7070Spatrick- for CallExpr, the declaration of the callee
6975e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
6976e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
6977e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
6978e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
6979e5dd7070Spatrick
6980e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
6981e5dd7070Spatricksugared type. Given
6982e5dd7070Spatrick  class X {};
6983e5dd7070Spatrick  typedef X Y;
6984e5dd7070Spatrick  Y y;
6985e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6986e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
6987e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
6988e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
6989e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
6990e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
6991e5dd7070Spatrick
6992e5dd7070SpatrickUsable 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;,
6993e5dd7070Spatrick  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;,
6994e5dd7070Spatrick  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;,
6995e5dd7070Spatrick  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;,
6996e5dd7070Spatrick  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;,
6997e5dd7070Spatrick  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;,
6998e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6999e5dd7070Spatrick</pre></td></tr>
7000e5dd7070Spatrick
7001e5dd7070Spatrick
7002ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;</td><td class="name" onclick="toggle('hasPlacementArg0')"><a name="hasPlacementArg0Anchor">hasPlacementArg</a></td><td>unsigned Index, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
7003ec727ea7Spatrick<tr><td colspan="4" class="doc" id="hasPlacementArg0"><pre>Matches placement new expression arguments.
7004ec727ea7Spatrick
7005ec727ea7SpatrickGiven:
7006ec727ea7Spatrick  MyClass *p1 = new (Storage, 16) MyClass();
7007ec727ea7SpatrickcxxNewExpr(hasPlacementArg(1, integerLiteral(equals(16))))
7008ec727ea7Spatrick  matches the expression 'new (Storage, 16) MyClass()'.
7009ec727ea7Spatrick</pre></td></tr>
7010ec727ea7Spatrick
7011ec727ea7Spatrick
7012a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc4')"><a name="hasTypeLoc4Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
7013a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasTypeLoc4"><pre>Matches if the type location of a node matches the inner matcher.
7014a9ac8606Spatrick
7015a9ac8606SpatrickExamples:
7016a9ac8606Spatrick  int x;
7017a9ac8606SpatrickdeclaratorDecl(hasTypeLoc(loc(asString("int"))))
7018a9ac8606Spatrick  matches int x
7019a9ac8606Spatrick
7020a9ac8606Spatrickauto x = int(3);
7021a9ac8606SpatrickcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7022a9ac8606Spatrick  matches int(3)
7023a9ac8606Spatrick
7024a9ac8606Spatrickstruct Foo { Foo(int, int); };
7025a9ac8606Spatrickauto x = Foo(1, 2);
7026a9ac8606SpatrickcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7027a9ac8606Spatrick  matches Foo(1, 2)
7028a9ac8606Spatrick
7029a9ac8606SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
7030a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
7031a9ac8606Spatrick  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_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
7032a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7033a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7034a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
7035a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
7036a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7037a9ac8606Spatrick</pre></td></tr>
7038a9ac8606Spatrick
7039a9ac8606Spatrick
7040a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;</td><td class="name" onclick="toggle('hasEitherOperand1')"><a name="hasEitherOperand1Anchor">hasEitherOperand</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
7041a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasEitherOperand1"><pre>Matches if either the left hand side or the right hand side of a
7042a9ac8606Spatrickbinary operator matches.
7043a9ac8606Spatrick</pre></td></tr>
7044a9ac8606Spatrick
7045a9ac8606Spatrick
7046a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</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>
7047a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions.
7048a9ac8606Spatrick
7049a9ac8606SpatrickExample matches a (matcher = binaryOperator(hasLHS()))
7050a9ac8606Spatrick  a || b
7051a9ac8606Spatrick</pre></td></tr>
7052a9ac8606Spatrick
7053a9ac8606Spatrick
7054a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;</td><td class="name" onclick="toggle('hasOperands1')"><a name="hasOperands1Anchor">hasOperands</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; Matcher1, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; Matcher2</td></tr>
7055a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasOperands1"><pre>Matches if both matchers match with opposite sides of the binary operator.
7056a9ac8606Spatrick
7057a9ac8606SpatrickExample matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
7058a9ac8606Spatrick                                             integerLiteral(equals(2)))
7059a9ac8606Spatrick  1 + 2 // Match
7060a9ac8606Spatrick  2 + 1 // Match
7061a9ac8606Spatrick  1 + 1 // No match
7062a9ac8606Spatrick  2 + 2 // No match
7063a9ac8606Spatrick</pre></td></tr>
7064a9ac8606Spatrick
7065a9ac8606Spatrick
7066a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</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>
7067a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions.
7068a9ac8606Spatrick
7069a9ac8606SpatrickExample matches b (matcher = binaryOperator(hasRHS()))
7070a9ac8606Spatrick  a || b
7071a9ac8606Spatrick</pre></td></tr>
7072a9ac8606Spatrick
7073a9ac8606Spatrick
7074a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;</td><td class="name" onclick="toggle('hasUnaryOperand1')"><a name="hasUnaryOperand1Anchor">hasUnaryOperand</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
7075a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasUnaryOperand1"><pre>Matches if the operand of a unary operator matches.
7076a9ac8606Spatrick
7077a9ac8606SpatrickExample matches true (matcher = hasUnaryOperand(
7078a9ac8606Spatrick                                  cxxBoolLiteral(equals(true))))
7079a9ac8606Spatrick  !true
7080a9ac8606Spatrick</pre></td></tr>
7081a9ac8606Spatrick
7082a9ac8606Spatrick
7083ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyBase0')"><a name="hasAnyBase0Anchor">hasAnyBase</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt; BaseSpecMatcher</td></tr>
7084ec727ea7Spatrick<tr><td colspan="4" class="doc" id="hasAnyBase0"><pre>Matches C++ classes that have a direct or indirect base matching BaseSpecMatcher.
7085ec727ea7Spatrick
7086ec727ea7SpatrickExample:
7087ec727ea7Spatrickmatcher hasAnyBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))
7088ec727ea7Spatrick  class Foo;
7089ec727ea7Spatrick  class Bar : Foo {};
7090ec727ea7Spatrick  class Baz : Bar {};
7091ec727ea7Spatrick  class SpecialBase;
7092ec727ea7Spatrick  class Proxy : SpecialBase {};  // matches Proxy
7093ec727ea7Spatrick  class IndirectlyDerived : Proxy {};  //matches IndirectlyDerived
7094ec727ea7Spatrick
7095ec727ea7SpatrickFIXME: Refactor this and isDerivedFrom to reuse implementation.
7096ec727ea7Spatrick</pre></td></tr>
7097ec727ea7Spatrick
7098ec727ea7Spatrick
7099ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('hasDirectBase0')"><a name="hasDirectBase0Anchor">hasDirectBase</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt; BaseSpecMatcher</td></tr>
7100ec727ea7Spatrick<tr><td colspan="4" class="doc" id="hasDirectBase0"><pre>Matches C++ classes that have a direct base matching BaseSpecMatcher.
7101ec727ea7Spatrick
7102ec727ea7SpatrickExample:
7103ec727ea7Spatrickmatcher hasDirectBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))
7104ec727ea7Spatrick  class Foo;
7105ec727ea7Spatrick  class Bar : Foo {};
7106ec727ea7Spatrick  class Baz : Bar {};
7107ec727ea7Spatrick  class SpecialBase;
7108ec727ea7Spatrick  class Proxy : SpecialBase {};  // matches Proxy
7109ec727ea7Spatrick  class IndirectlyDerived : Proxy {};  // doesn't match
7110ec727ea7Spatrick</pre></td></tr>
7111ec727ea7Spatrick
7112ec727ea7Spatrick
7113e5dd7070Spatrick<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>
7114e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher.
7115e5dd7070Spatrick
7116e5dd7070SpatrickGiven:
7117e5dd7070Spatrick  class A { void func(); };
7118e5dd7070Spatrick  class B { void member(); };
7119e5dd7070Spatrick
7120e5dd7070SpatrickcxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of
7121e5dd7070SpatrickA but not B.
7122e5dd7070Spatrick</pre></td></tr>
7123e5dd7070Spatrick
7124e5dd7070Spatrick
7125e5dd7070Spatrick<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>
7126e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from a class
7127e5dd7070Spatrickmatching Base, or Objective-C classes that directly or indirectly
7128e5dd7070Spatricksubclass a class matching Base.
7129e5dd7070Spatrick
7130e5dd7070SpatrickNote that a class is not considered to be derived from itself.
7131e5dd7070Spatrick
7132e5dd7070SpatrickExample matches Y, Z, C (Base == hasName("X"))
7133e5dd7070Spatrick  class X;
7134e5dd7070Spatrick  class Y : public X {};  // directly derived
7135e5dd7070Spatrick  class Z : public Y {};  // indirectly derived
7136e5dd7070Spatrick  typedef X A;
7137e5dd7070Spatrick  typedef A B;
7138e5dd7070Spatrick  class C : public B {};  // derived from a typedef of X
7139e5dd7070Spatrick
7140e5dd7070SpatrickIn the following example, Bar matches isDerivedFrom(hasName("X")):
7141e5dd7070Spatrick  class Foo;
7142e5dd7070Spatrick  typedef Foo X;
7143e5dd7070Spatrick  class Bar : public Foo {};  // derived from a type that X is a typedef of
7144e5dd7070Spatrick
7145e5dd7070SpatrickIn the following example, Bar matches isDerivedFrom(hasName("NSObject"))
7146e5dd7070Spatrick  @interface NSObject @end
7147e5dd7070Spatrick  @interface Bar : NSObject @end
7148e5dd7070Spatrick
7149e5dd7070SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>&gt;
7150e5dd7070Spatrick</pre></td></tr>
7151e5dd7070Spatrick
7152e5dd7070Spatrick
7153e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;</td><td class="name" onclick="toggle('isDirectlyDerivedFrom0')"><a name="isDirectlyDerivedFrom0Anchor">isDirectlyDerivedFrom</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt; Base</td></tr>
7154e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom0"><pre>Matches C++ or Objective-C classes that are directly derived from a class
7155e5dd7070Spatrickmatching Base.
7156e5dd7070Spatrick
7157e5dd7070SpatrickNote that a class is not considered to be derived from itself.
7158e5dd7070Spatrick
7159e5dd7070SpatrickExample matches Y, C (Base == hasName("X"))
7160e5dd7070Spatrick  class X;
7161e5dd7070Spatrick  class Y : public X {};  // directly derived
7162e5dd7070Spatrick  class Z : public Y {};  // indirectly derived
7163e5dd7070Spatrick  typedef X A;
7164e5dd7070Spatrick  typedef A B;
7165e5dd7070Spatrick  class C : public B {};  // derived from a typedef of X
7166e5dd7070Spatrick
7167e5dd7070SpatrickIn the following example, Bar matches isDerivedFrom(hasName("X")):
7168e5dd7070Spatrick  class Foo;
7169e5dd7070Spatrick  typedef Foo X;
7170e5dd7070Spatrick  class Bar : public Foo {};  // derived from a type that X is a typedef of
7171e5dd7070Spatrick</pre></td></tr>
7172e5dd7070Spatrick
7173e5dd7070Spatrick
7174e5dd7070Spatrick<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>
7175e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly
7176e5dd7070Spatrickmatch Base.
7177e5dd7070Spatrick</pre></td></tr>
7178e5dd7070Spatrick
7179e5dd7070Spatrick
7180a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasEitherOperand2')"><a name="hasEitherOperand2Anchor">hasEitherOperand</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
7181a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasEitherOperand2"><pre>Matches if either the left hand side or the right hand side of a
7182a9ac8606Spatrickbinary operator matches.
7183a9ac8606Spatrick</pre></td></tr>
7184a9ac8606Spatrick
7185a9ac8606Spatrick
7186a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasLHS2')"><a name="hasLHS2Anchor">hasLHS</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
7187a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasLHS2"><pre>Matches the left hand side of binary operator expressions.
7188a9ac8606Spatrick
7189a9ac8606SpatrickExample matches a (matcher = binaryOperator(hasLHS()))
7190a9ac8606Spatrick  a || b
7191a9ac8606Spatrick</pre></td></tr>
7192a9ac8606Spatrick
7193a9ac8606Spatrick
7194a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasOperands2')"><a name="hasOperands2Anchor">hasOperands</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; Matcher1, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; Matcher2</td></tr>
7195a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasOperands2"><pre>Matches if both matchers match with opposite sides of the binary operator.
7196a9ac8606Spatrick
7197a9ac8606SpatrickExample matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
7198a9ac8606Spatrick                                             integerLiteral(equals(2)))
7199a9ac8606Spatrick  1 + 2 // Match
7200a9ac8606Spatrick  2 + 1 // Match
7201a9ac8606Spatrick  1 + 1 // No match
7202a9ac8606Spatrick  2 + 2 // No match
7203a9ac8606Spatrick</pre></td></tr>
7204a9ac8606Spatrick
7205a9ac8606Spatrick
7206a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasRHS2')"><a name="hasRHS2Anchor">hasRHS</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
7207a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasRHS2"><pre>Matches the right hand side of binary operator expressions.
7208a9ac8606Spatrick
7209a9ac8606SpatrickExample matches b (matcher = binaryOperator(hasRHS()))
7210a9ac8606Spatrick  a || b
7211a9ac8606Spatrick</pre></td></tr>
7212a9ac8606Spatrick
7213a9ac8606Spatrick
7214a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc5')"><a name="hasTypeLoc5Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
7215a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasTypeLoc5"><pre>Matches if the type location of a node matches the inner matcher.
7216a9ac8606Spatrick
7217a9ac8606SpatrickExamples:
7218a9ac8606Spatrick  int x;
7219a9ac8606SpatrickdeclaratorDecl(hasTypeLoc(loc(asString("int"))))
7220a9ac8606Spatrick  matches int x
7221a9ac8606Spatrick
7222a9ac8606Spatrickauto x = int(3);
7223a9ac8606SpatrickcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7224a9ac8606Spatrick  matches int(3)
7225a9ac8606Spatrick
7226a9ac8606Spatrickstruct Foo { Foo(int, int); };
7227a9ac8606Spatrickauto x = Foo(1, 2);
7228a9ac8606SpatrickcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7229a9ac8606Spatrick  matches Foo(1, 2)
7230a9ac8606Spatrick
7231a9ac8606SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
7232a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
7233a9ac8606Spatrick  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_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
7234a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7235a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7236a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
7237a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
7238a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7239a9ac8606Spatrick</pre></td></tr>
7240a9ac8606Spatrick
7241a9ac8606Spatrick
7242e5dd7070Spatrick<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>
7243e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call
7244e5dd7070Spatrickexpression, or an ObjC-message-send expression.
7245e5dd7070Spatrick
7246e5dd7070SpatrickGiven
7247e5dd7070Spatrick  void x(int, int, int) { int y; x(1, y, 42); }
7248e5dd7070SpatrickcallExpr(hasAnyArgument(declRefExpr()))
7249e5dd7070Spatrick  matches x(1, y, 42)
7250e5dd7070Spatrickwith hasAnyArgument(...)
7251e5dd7070Spatrick  matching y
7252e5dd7070Spatrick
7253e5dd7070SpatrickFor ObjectiveC, given
7254e5dd7070Spatrick  @interface I - (void) f:(int) y; @end
7255e5dd7070Spatrick  void foo(I *i) { [i f:12]; }
7256e5dd7070SpatrickobjcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
7257e5dd7070Spatrick  matches [i f:12]
7258e5dd7070Spatrick</pre></td></tr>
7259e5dd7070Spatrick
7260e5dd7070Spatrick
7261a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</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>
7262a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor
7263a9ac8606Spatrickcall expression.
7264a9ac8606Spatrick
7265a9ac8606SpatrickExample matches y in x(y)
7266a9ac8606Spatrick    (matcher = callExpr(hasArgument(0, declRefExpr())))
7267a9ac8606Spatrick  void x(int) { int y; x(y); }
7268a9ac8606Spatrick</pre></td></tr>
7269a9ac8606Spatrick
7270a9ac8606Spatrick
7271a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc6')"><a name="hasTypeLoc6Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
7272a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasTypeLoc6"><pre>Matches if the type location of a node matches the inner matcher.
7273a9ac8606Spatrick
7274a9ac8606SpatrickExamples:
7275a9ac8606Spatrick  int x;
7276a9ac8606SpatrickdeclaratorDecl(hasTypeLoc(loc(asString("int"))))
7277a9ac8606Spatrick  matches int x
7278a9ac8606Spatrick
7279a9ac8606Spatrickauto x = int(3);
7280a9ac8606SpatrickcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7281a9ac8606Spatrick  matches int(3)
7282a9ac8606Spatrick
7283a9ac8606Spatrickstruct Foo { Foo(int, int); };
7284a9ac8606Spatrickauto x = Foo(1, 2);
7285a9ac8606SpatrickcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7286a9ac8606Spatrick  matches Foo(1, 2)
7287a9ac8606Spatrick
7288a9ac8606SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
7289a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
7290a9ac8606Spatrick  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_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
7291a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7292a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7293a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
7294a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
7295a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7296a9ac8606Spatrick</pre></td></tr>
7297a9ac8606Spatrick
7298a9ac8606Spatrick
7299*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('callee2')"><a name="callee2Anchor">callee</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
7300*12c85518Srobert<tr><td colspan="4" class="doc" id="callee2"><pre>Matches 1) if the call expression's callee's declaration matches the
7301*12c85518Srobertgiven matcher; or 2) if the Obj-C message expression's callee's method
7302*12c85518Srobertdeclaration matches the given matcher.
7303e5dd7070Spatrick
7304e5dd7070SpatrickExample matches y.x() (matcher = callExpr(callee(
7305e5dd7070Spatrick                                   cxxMethodDecl(hasName("x")))))
7306e5dd7070Spatrick  class Y { public: void x(); };
7307e5dd7070Spatrick  void z() { Y y; y.x(); }
7308*12c85518Srobert
7309*12c85518SrobertExample 2. Matches [I foo] with
7310*12c85518SrobertobjcMessageExpr(callee(objcMethodDecl(hasName("foo"))))
7311*12c85518Srobert
7312*12c85518Srobert  @interface I: NSObject
7313*12c85518Srobert  +(void)foo;
7314*12c85518Srobert  @end
7315*12c85518Srobert  ...
7316*12c85518Srobert  [I foo]
7317e5dd7070Spatrick</pre></td></tr>
7318e5dd7070Spatrick
7319e5dd7070Spatrick
7320e5dd7070Spatrick<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>
7321e5dd7070Spatrick<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches.
7322e5dd7070Spatrick
7323e5dd7070SpatrickGiven
7324e5dd7070Spatrick  class Y { void x() { this-&gt;x(); x(); Y y; y.x(); } };
7325e5dd7070Spatrick  void f() { f(); }
7326e5dd7070SpatrickcallExpr(callee(expr()))
7327e5dd7070Spatrick  matches this-&gt;x(), x(), y.x(), f()
7328e5dd7070Spatrickwith callee(...)
7329e5dd7070Spatrick  matching this-&gt;x, x, y.x, f respectively
7330e5dd7070Spatrick
7331e5dd7070SpatrickNote: Callee cannot take the more general internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;
7332e5dd7070Spatrickbecause this introduces ambiguous overloads with calls to Callee taking a
7333e5dd7070Spatrickinternal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, as the matcher hierarchy is purely
7334e5dd7070Spatrickimplemented in terms of implicit casts.
7335e5dd7070Spatrick</pre></td></tr>
7336e5dd7070Spatrick
7337e5dd7070Spatrick
7338e5dd7070Spatrick<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>
7339e5dd7070Spatrick<tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl.
7340e5dd7070Spatrick
7341e5dd7070SpatrickGiven
7342e5dd7070Spatrick  void f(int i);
7343e5dd7070Spatrick  int y;
7344e5dd7070Spatrick  f(y);
7345e5dd7070SpatrickcallExpr(
7346e5dd7070Spatrick  forEachArgumentWithParam(
7347e5dd7070Spatrick    declRefExpr(to(varDecl(hasName("y")))),
7348e5dd7070Spatrick    parmVarDecl(hasType(isInteger()))
7349e5dd7070Spatrick))
7350e5dd7070Spatrick  matches f(y);
7351e5dd7070Spatrickwith declRefExpr(...)
7352e5dd7070Spatrick  matching int y
7353e5dd7070Spatrickand parmVarDecl(...)
7354e5dd7070Spatrick  matching int i
7355e5dd7070Spatrick</pre></td></tr>
7356e5dd7070Spatrick
7357e5dd7070Spatrick
7358a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('forEachArgumentWithParamType0')"><a name="forEachArgumentWithParamType0Anchor">forEachArgumentWithParamType</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_1QualType.html">QualType</a>&gt; ParamMatcher</td></tr>
7359a9ac8606Spatrick<tr><td colspan="4" class="doc" id="forEachArgumentWithParamType0"><pre>Matches all arguments and their respective types for a CallExpr or
7360a9ac8606SpatrickCXXConstructExpr. It is very similar to forEachArgumentWithParam but
7361a9ac8606Spatrickit works on calls through function pointers as well.
7362a9ac8606Spatrick
7363a9ac8606SpatrickThe difference is, that function pointers do not provide access to a
7364a9ac8606SpatrickParmVarDecl, but only the QualType for each argument.
7365a9ac8606Spatrick
7366a9ac8606SpatrickGiven
7367a9ac8606Spatrick  void f(int i);
7368a9ac8606Spatrick  int y;
7369a9ac8606Spatrick  f(y);
7370a9ac8606Spatrick  void (*f_ptr)(int) = f;
7371a9ac8606Spatrick  f_ptr(y);
7372a9ac8606SpatrickcallExpr(
7373a9ac8606Spatrick  forEachArgumentWithParamType(
7374a9ac8606Spatrick    declRefExpr(to(varDecl(hasName("y")))),
7375a9ac8606Spatrick    qualType(isInteger()).bind("type)
7376a9ac8606Spatrick))
7377a9ac8606Spatrick  matches f(y) and f_ptr(y)
7378a9ac8606Spatrickwith declRefExpr(...)
7379a9ac8606Spatrick  matching int y
7380a9ac8606Spatrickand qualType(...)
7381a9ac8606Spatrick  matching int
7382a9ac8606Spatrick</pre></td></tr>
7383a9ac8606Spatrick
7384a9ac8606Spatrick
7385e5dd7070Spatrick<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>
7386e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call
7387e5dd7070Spatrickexpression, or an ObjC-message-send expression.
7388e5dd7070Spatrick
7389e5dd7070SpatrickGiven
7390e5dd7070Spatrick  void x(int, int, int) { int y; x(1, y, 42); }
7391e5dd7070SpatrickcallExpr(hasAnyArgument(declRefExpr()))
7392e5dd7070Spatrick  matches x(1, y, 42)
7393e5dd7070Spatrickwith hasAnyArgument(...)
7394e5dd7070Spatrick  matching y
7395e5dd7070Spatrick
7396e5dd7070SpatrickFor ObjectiveC, given
7397e5dd7070Spatrick  @interface I - (void) f:(int) y; @end
7398e5dd7070Spatrick  void foo(I *i) { [i f:12]; }
7399e5dd7070SpatrickobjcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
7400e5dd7070Spatrick  matches [i f:12]
7401e5dd7070Spatrick</pre></td></tr>
7402e5dd7070Spatrick
7403e5dd7070Spatrick
7404e5dd7070Spatrick<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>
7405e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor
7406e5dd7070Spatrickcall expression.
7407e5dd7070Spatrick
7408e5dd7070SpatrickExample matches y in x(y)
7409e5dd7070Spatrick    (matcher = callExpr(hasArgument(0, declRefExpr())))
7410e5dd7070Spatrick  void x(int) { int y; x(y); }
7411e5dd7070Spatrick</pre></td></tr>
7412e5dd7070Spatrick
7413e5dd7070Spatrick
7414ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
7415e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration14"><pre>Matches a node if the declaration associated with that node
7416e5dd7070Spatrickmatches the given matcher.
7417e5dd7070Spatrick
7418e5dd7070SpatrickThe associated declaration is:
7419e5dd7070Spatrick- for type nodes, the declaration of the underlying type
7420e5dd7070Spatrick- for CallExpr, the declaration of the callee
7421e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
7422e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
7423e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
7424e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
7425e5dd7070Spatrick
7426e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
7427e5dd7070Spatricksugared type. Given
7428e5dd7070Spatrick  class X {};
7429e5dd7070Spatrick  typedef X Y;
7430e5dd7070Spatrick  Y y;
7431e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7432e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
7433e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
7434e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
7435e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
7436e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
7437e5dd7070Spatrick
7438e5dd7070SpatrickUsable 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;,
7439e5dd7070Spatrick  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;,
7440e5dd7070Spatrick  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;,
7441e5dd7070Spatrick  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;,
7442e5dd7070Spatrick  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;,
7443e5dd7070Spatrick  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;,
7444e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
7445e5dd7070Spatrick</pre></td></tr>
7446e5dd7070Spatrick
7447e5dd7070Spatrick
7448e5dd7070Spatrick<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>
7449e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range
7450e5dd7070Spatrickextension, matches the constant given in the statement.
7451e5dd7070Spatrick
7452e5dd7070SpatrickGiven
7453e5dd7070Spatrick  switch (1) { case 1: case 1+1: case 3 ... 4: ; }
7454e5dd7070SpatrickcaseStmt(hasCaseConstant(integerLiteral()))
7455e5dd7070Spatrick  matches "case 1:"
7456e5dd7070Spatrick</pre></td></tr>
7457e5dd7070Spatrick
7458e5dd7070Spatrick
7459e5dd7070Spatrick<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>
7460e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression
7461e5dd7070Spatrickor opaque value's source expression matches the given matcher.
7462e5dd7070Spatrick
7463e5dd7070SpatrickExample 1: matches "a string"
7464e5dd7070Spatrick(matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
7465e5dd7070Spatrickclass URL { URL(string); };
7466e5dd7070SpatrickURL url = "a string";
7467e5dd7070Spatrick
7468e5dd7070SpatrickExample 2: matches 'b' (matcher =
7469e5dd7070SpatrickopaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
7470e5dd7070Spatrickint a = b ?: 1;
7471e5dd7070Spatrick</pre></td></tr>
7472e5dd7070Spatrick
7473e5dd7070Spatrick
7474*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;</td><td class="name" onclick="toggle('forEachTemplateArgument0')"><a name="forEachTemplateArgument0Anchor">forEachTemplateArgument</a></td><td>clang::ast_matchers::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
7475*12c85518Srobert<tr><td colspan="4" class="doc" id="forEachTemplateArgument0"><pre>Matches classTemplateSpecialization, templateSpecializationType and
7476*12c85518SrobertfunctionDecl nodes where the template argument matches the inner matcher.
7477*12c85518SrobertThis matcher may produce multiple matches.
7478*12c85518Srobert
7479*12c85518SrobertGiven
7480*12c85518Srobert  template &lt;typename T, unsigned N, unsigned M&gt;
7481*12c85518Srobert  struct Matrix {};
7482*12c85518Srobert
7483*12c85518Srobert  constexpr unsigned R = 2;
7484*12c85518Srobert  Matrix&lt;int, R * 2, R * 4&gt; M;
7485*12c85518Srobert
7486*12c85518Srobert  template &lt;typename T, typename U&gt;
7487*12c85518Srobert  void f(T&amp;&amp; t, U&amp;&amp; u) {}
7488*12c85518Srobert
7489*12c85518Srobert  bool B = false;
7490*12c85518Srobert  f(R, B);
7491*12c85518SroberttemplateSpecializationType(forEachTemplateArgument(isExpr(expr())))
7492*12c85518Srobert  matches twice, with expr() matching 'R * 2' and 'R * 4'
7493*12c85518SrobertfunctionDecl(forEachTemplateArgument(refersToType(builtinType())))
7494*12c85518Srobert  matches the specialization f&lt;unsigned, bool&gt; twice, for 'unsigned'
7495*12c85518Srobert  and 'bool'
7496*12c85518Srobert</pre></td></tr>
7497*12c85518Srobert
7498*12c85518Srobert
7499e5dd7070Spatrick<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>
7500e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and
7501e5dd7070SpatrickfunctionDecl that have at least one TemplateArgument matching the given
7502e5dd7070SpatrickInnerMatcher.
7503e5dd7070Spatrick
7504e5dd7070SpatrickGiven
7505e5dd7070Spatrick  template&lt;typename T&gt; class A {};
7506e5dd7070Spatrick  template&lt;&gt; class A&lt;double&gt; {};
7507e5dd7070Spatrick  A&lt;int&gt; a;
7508e5dd7070Spatrick
7509e5dd7070Spatrick  template&lt;typename T&gt; f() {};
7510e5dd7070Spatrick  void func() { f&lt;int&gt;(); };
7511e5dd7070Spatrick
7512e5dd7070SpatrickclassTemplateSpecializationDecl(hasAnyTemplateArgument(
7513e5dd7070Spatrick    refersToType(asString("int"))))
7514e5dd7070Spatrick  matches the specialization A&lt;int&gt;
7515e5dd7070Spatrick
7516e5dd7070SpatrickfunctionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
7517e5dd7070Spatrick  matches the specialization f&lt;int&gt;
7518e5dd7070Spatrick</pre></td></tr>
7519e5dd7070Spatrick
7520e5dd7070Spatrick
7521e5dd7070Spatrick<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>
7522e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasSpecializedTemplate0"><pre>Matches the specialized template of a specialization declaration.
7523e5dd7070Spatrick
7524e5dd7070SpatrickGiven
7525e5dd7070Spatrick  template&lt;typename T&gt; class A {}; #1
7526e5dd7070Spatrick  template&lt;&gt; class A&lt;int&gt; {}; #2
7527e5dd7070SpatrickclassTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl()))
7528e5dd7070Spatrick  matches '#2' with classTemplateDecl() matching the class template
7529e5dd7070Spatrick  declaration of 'A' at #1.
7530e5dd7070Spatrick</pre></td></tr>
7531e5dd7070Spatrick
7532e5dd7070Spatrick
7533e5dd7070Spatrick<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>
7534e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and
7535e5dd7070SpatrickfunctionDecl where the n'th TemplateArgument matches the given InnerMatcher.
7536e5dd7070Spatrick
7537e5dd7070SpatrickGiven
7538e5dd7070Spatrick  template&lt;typename T, typename U&gt; class A {};
7539e5dd7070Spatrick  A&lt;bool, int&gt; b;
7540e5dd7070Spatrick  A&lt;int, bool&gt; c;
7541e5dd7070Spatrick
7542e5dd7070Spatrick  template&lt;typename T&gt; void f() {}
7543e5dd7070Spatrick  void func() { f&lt;int&gt;(); };
7544e5dd7070SpatrickclassTemplateSpecializationDecl(hasTemplateArgument(
7545e5dd7070Spatrick    1, refersToType(asString("int"))))
7546e5dd7070Spatrick  matches the specialization A&lt;bool, int&gt;
7547e5dd7070Spatrick
7548e5dd7070SpatrickfunctionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
7549e5dd7070Spatrick  matches the specialization f&lt;int&gt;
7550e5dd7070Spatrick</pre></td></tr>
7551e5dd7070Spatrick
7552e5dd7070Spatrick
7553a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc7')"><a name="hasTypeLoc7Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
7554a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasTypeLoc7"><pre>Matches if the type location of a node matches the inner matcher.
7555a9ac8606Spatrick
7556a9ac8606SpatrickExamples:
7557a9ac8606Spatrick  int x;
7558a9ac8606SpatrickdeclaratorDecl(hasTypeLoc(loc(asString("int"))))
7559a9ac8606Spatrick  matches int x
7560a9ac8606Spatrick
7561a9ac8606Spatrickauto x = int(3);
7562a9ac8606SpatrickcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7563a9ac8606Spatrick  matches int(3)
7564a9ac8606Spatrick
7565a9ac8606Spatrickstruct Foo { Foo(int, int); };
7566a9ac8606Spatrickauto x = Foo(1, 2);
7567a9ac8606SpatrickcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7568a9ac8606Spatrick  matches Foo(1, 2)
7569a9ac8606Spatrick
7570a9ac8606SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
7571a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
7572a9ac8606Spatrick  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_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
7573a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7574a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7575a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
7576a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
7577a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7578a9ac8606Spatrick</pre></td></tr>
7579a9ac8606Spatrick
7580a9ac8606Spatrick
7581e5dd7070Spatrick<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>
7582e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element
7583e5dd7070Spatricktype.
7584e5dd7070Spatrick
7585e5dd7070SpatrickGiven
7586e5dd7070Spatrick  struct A {};
7587e5dd7070Spatrick  A a[7];
7588e5dd7070Spatrick  int b[7];
7589e5dd7070SpatrickarrayType(hasElementType(builtinType()))
7590e5dd7070Spatrick  matches "int b[7]"
7591e5dd7070Spatrick
7592e5dd7070SpatrickUsable 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;
7593e5dd7070Spatrick</pre></td></tr>
7594e5dd7070Spatrick
7595e5dd7070Spatrick
7596a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc8')"><a name="hasTypeLoc8Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
7597a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasTypeLoc8"><pre>Matches if the type location of a node matches the inner matcher.
7598a9ac8606Spatrick
7599a9ac8606SpatrickExamples:
7600a9ac8606Spatrick  int x;
7601a9ac8606SpatrickdeclaratorDecl(hasTypeLoc(loc(asString("int"))))
7602a9ac8606Spatrick  matches int x
7603a9ac8606Spatrick
7604a9ac8606Spatrickauto x = int(3);
7605a9ac8606SpatrickcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7606a9ac8606Spatrick  matches int(3)
7607a9ac8606Spatrick
7608a9ac8606Spatrickstruct Foo { Foo(int, int); };
7609a9ac8606Spatrickauto x = Foo(1, 2);
7610a9ac8606SpatrickcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7611a9ac8606Spatrick  matches Foo(1, 2)
7612a9ac8606Spatrick
7613a9ac8606SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
7614a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
7615a9ac8606Spatrick  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_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
7616a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7617a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7618a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
7619a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
7620a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7621a9ac8606Spatrick</pre></td></tr>
7622a9ac8606Spatrick
7623a9ac8606Spatrick
7624e5dd7070Spatrick<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>
7625e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches
7626e5dd7070Spatricka given matcher. Also matches StmtExprs that have CompoundStmt as children.
7627e5dd7070Spatrick
7628e5dd7070SpatrickGiven
7629e5dd7070Spatrick  { {}; 1+2; }
7630e5dd7070SpatrickhasAnySubstatement(compoundStmt())
7631e5dd7070Spatrick  matches '{ {}; 1+2; }'
7632e5dd7070Spatrickwith compoundStmt()
7633e5dd7070Spatrick  matching '{}'
7634e5dd7070Spatrick</pre></td></tr>
7635e5dd7070Spatrick
7636e5dd7070Spatrick
7637e5dd7070Spatrick<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>
7638a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whoes decayed type matches InnerMatcher
7639e5dd7070Spatrick</pre></td></tr>
7640e5dd7070Spatrick
7641e5dd7070Spatrick
7642ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
7643e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node
7644e5dd7070Spatrickmatches the given matcher.
7645e5dd7070Spatrick
7646e5dd7070SpatrickThe associated declaration is:
7647e5dd7070Spatrick- for type nodes, the declaration of the underlying type
7648e5dd7070Spatrick- for CallExpr, the declaration of the callee
7649e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
7650e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
7651e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
7652e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
7653e5dd7070Spatrick
7654e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
7655e5dd7070Spatricksugared type. Given
7656e5dd7070Spatrick  class X {};
7657e5dd7070Spatrick  typedef X Y;
7658e5dd7070Spatrick  Y y;
7659e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7660e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
7661e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
7662e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
7663e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
7664e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
7665e5dd7070Spatrick
7666e5dd7070SpatrickUsable 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;,
7667e5dd7070Spatrick  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;,
7668e5dd7070Spatrick  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;,
7669e5dd7070Spatrick  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;,
7670e5dd7070Spatrick  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;,
7671e5dd7070Spatrick  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;,
7672e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
7673e5dd7070Spatrick</pre></td></tr>
7674e5dd7070Spatrick
7675e5dd7070Spatrick
7676*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;</td><td class="name" onclick="toggle('hasTemplateArgumentLoc0')"><a name="hasTemplateArgumentLoc0Anchor">hasTemplateArgumentLoc</a></td><td>unsigned Index, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt; InnerMatcher</td></tr>
7677*12c85518Srobert<tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc0"><pre>Matches template specialization `TypeLoc`s where the n'th
7678*12c85518Srobert`TemplateArgumentLoc` matches the given `InnerMatcher`.
7679e5dd7070Spatrick
7680e5dd7070SpatrickGiven
7681*12c85518Srobert  template&lt;typename T, typename U&gt; class A {};
7682*12c85518Srobert  A&lt;double, int&gt; b;
7683*12c85518Srobert  A&lt;int, double&gt; c;
7684*12c85518SrobertvarDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
7685*12c85518Srobert  hasTypeLoc(loc(asString("double")))))))
7686*12c85518Srobert  matches `A&lt;double, int&gt; b`, but not `A&lt;int, double&gt; c`.
7687*12c85518Srobert</pre></td></tr>
7688*12c85518Srobert
7689*12c85518Srobert
7690*12c85518Srobert<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; Inner</td></tr>
7691*12c85518Srobert<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches if a node refers to a declaration through a specific
7692*12c85518Srobertusing shadow declaration.
7693*12c85518Srobert
7694*12c85518SrobertExamples:
7695*12c85518Srobert  namespace a { int f(); }
7696e5dd7070Spatrick  using a::f;
7697*12c85518Srobert  int x = f();
7698e5dd7070SpatrickdeclRefExpr(throughUsingDecl(anything()))
7699*12c85518Srobert  matches f
7700*12c85518Srobert
7701*12c85518Srobert  namespace a { class X{}; }
7702*12c85518Srobert  using a::X;
7703*12c85518Srobert  X x;
7704*12c85518SroberttypeLoc(loc(usingType(throughUsingDecl(anything()))))
7705*12c85518Srobert  matches X
7706*12c85518Srobert
7707*12c85518SrobertUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>&gt;
7708e5dd7070Spatrick</pre></td></tr>
7709e5dd7070Spatrick
7710e5dd7070Spatrick
7711e5dd7070Spatrick<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>
7712e5dd7070Spatrick<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the
7713e5dd7070Spatrickspecified matcher.
7714e5dd7070Spatrick
7715e5dd7070SpatrickExample matches x in if(x)
7716e5dd7070Spatrick    (matcher = declRefExpr(to(varDecl(hasName("x")))))
7717e5dd7070Spatrick  bool x;
7718e5dd7070Spatrick  if (x) {}
7719e5dd7070Spatrick</pre></td></tr>
7720e5dd7070Spatrick
7721e5dd7070Spatrick
7722e5dd7070Spatrick<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>
7723e5dd7070Spatrick<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement.
7724e5dd7070Spatrick
7725e5dd7070SpatrickNote that this does not work for global declarations because the AST
7726e5dd7070Spatrickbreaks up multiple-declaration DeclStmt's into multiple single-declaration
7727e5dd7070SpatrickDeclStmt's.
7728e5dd7070SpatrickExample: Given non-global declarations
7729e5dd7070Spatrick  int a, b = 0;
7730e5dd7070Spatrick  int c;
7731e5dd7070Spatrick  int d = 2, e;
7732e5dd7070SpatrickdeclStmt(containsDeclaration(
7733e5dd7070Spatrick      0, varDecl(hasInitializer(anything()))))
7734e5dd7070Spatrick  matches only 'int d = 2, e;', and
7735e5dd7070SpatrickdeclStmt(containsDeclaration(1, varDecl()))
7736e5dd7070Spatrick  matches 'int a, b = 0' as well as 'int d = 2, e;'
7737e5dd7070Spatrick  but 'int c;' is not matched.
7738e5dd7070Spatrick</pre></td></tr>
7739e5dd7070Spatrick
7740e5dd7070Spatrick
7741e5dd7070Spatrick<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>
7742e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration.
7743e5dd7070Spatrick
7744e5dd7070SpatrickGiven
7745e5dd7070Spatrick  int a, b;
7746e5dd7070Spatrick  int c;
7747e5dd7070SpatrickdeclStmt(hasSingleDecl(anything()))
7748e5dd7070Spatrick  matches 'int c;' but not 'int a, b;'.
7749e5dd7070Spatrick</pre></td></tr>
7750e5dd7070Spatrick
7751e5dd7070Spatrick
7752a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc9')"><a name="hasTypeLoc9Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
7753a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasTypeLoc9"><pre>Matches if the type location of a node matches the inner matcher.
7754e5dd7070Spatrick
7755a9ac8606SpatrickExamples:
7756e5dd7070Spatrick  int x;
7757e5dd7070SpatrickdeclaratorDecl(hasTypeLoc(loc(asString("int"))))
7758e5dd7070Spatrick  matches int x
7759a9ac8606Spatrick
7760a9ac8606Spatrickauto x = int(3);
7761a9ac8606SpatrickcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7762a9ac8606Spatrick  matches int(3)
7763a9ac8606Spatrick
7764a9ac8606Spatrickstruct Foo { Foo(int, int); };
7765a9ac8606Spatrickauto x = Foo(1, 2);
7766a9ac8606SpatrickcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7767a9ac8606Spatrick  matches Foo(1, 2)
7768a9ac8606Spatrick
7769a9ac8606SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
7770a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
7771a9ac8606Spatrick  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_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
7772a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7773a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7774a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
7775a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
7776a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7777e5dd7070Spatrick</pre></td></tr>
7778e5dd7070Spatrick
7779e5dd7070Spatrick
7780e5dd7070Spatrick<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>
7781e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a
7782e5dd7070SpatrickDecl, matches InnerMatcher.
7783e5dd7070Spatrick
7784e5dd7070SpatrickGiven
7785e5dd7070Spatrick  namespace N {
7786e5dd7070Spatrick    namespace M {
7787e5dd7070Spatrick      class D {};
7788e5dd7070Spatrick    }
7789e5dd7070Spatrick  }
7790e5dd7070Spatrick
7791e5dd7070SpatrickcxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
7792e5dd7070Spatrickdeclaration of class D.
7793e5dd7070Spatrick</pre></td></tr>
7794e5dd7070Spatrick
7795e5dd7070Spatrick
7796e5dd7070Spatrick<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>
7797*12c85518Srobert<tr><td colspan="4" class="doc" id="hasUnderlyingType0"><pre>Matches DecltypeType or UsingType nodes to find the underlying type.
7798e5dd7070Spatrick
7799e5dd7070SpatrickGiven
7800e5dd7070Spatrick  decltype(1) a = 1;
7801e5dd7070Spatrick  decltype(2.0) b = 2.0;
7802e5dd7070SpatrickdecltypeType(hasUnderlyingType(isInteger()))
7803e5dd7070Spatrick  matches the type of "a"
7804e5dd7070Spatrick
7805*12c85518SrobertUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>&gt;
7806e5dd7070Spatrick</pre></td></tr>
7807e5dd7070Spatrick
7808e5dd7070Spatrick
7809a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DecompositionDecl.html">DecompositionDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyBinding0')"><a name="hasAnyBinding0Anchor">hasAnyBinding</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BindingDecl.html">BindingDecl</a>&gt; InnerMatcher</td></tr>
7810a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasAnyBinding0"><pre>Matches any binding of a DecompositionDecl.
7811e5dd7070Spatrick
7812a9ac8606SpatrickFor example, in:
7813a9ac8606Spatrickvoid foo()
7814a9ac8606Spatrick{
7815a9ac8606Spatrick    int arr[3];
7816a9ac8606Spatrick    auto &amp;[f, s, t] = arr;
7817a9ac8606Spatrick
7818a9ac8606Spatrick    f = 42;
7819a9ac8606Spatrick}
7820a9ac8606SpatrickThe matcher:
7821a9ac8606Spatrick  decompositionDecl(hasAnyBinding(bindingDecl(hasName("f").bind("fBinding"))))
7822a9ac8606Spatrickmatches the decomposition decl with 'f' bound to "fBinding".
7823e5dd7070Spatrick</pre></td></tr>
7824e5dd7070Spatrick
7825e5dd7070Spatrick
7826a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DecompositionDecl.html">DecompositionDecl</a>&gt;</td><td class="name" onclick="toggle('hasBinding0')"><a name="hasBinding0Anchor">hasBinding</a></td><td>unsigned N, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BindingDecl.html">BindingDecl</a>&gt; InnerMatcher</td></tr>
7827a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasBinding0"><pre>Matches the Nth binding of a DecompositionDecl.
7828a9ac8606Spatrick
7829a9ac8606SpatrickFor example, in:
7830a9ac8606Spatrickvoid foo()
7831a9ac8606Spatrick{
7832a9ac8606Spatrick    int arr[3];
7833a9ac8606Spatrick    auto &amp;[f, s, t] = arr;
7834a9ac8606Spatrick
7835a9ac8606Spatrick    f = 42;
7836a9ac8606Spatrick}
7837a9ac8606SpatrickThe matcher:
7838a9ac8606Spatrick  decompositionDecl(hasBinding(0,
7839a9ac8606Spatrick  bindingDecl(hasName("f").bind("fBinding"))))
7840a9ac8606Spatrickmatches the decomposition decl with 'f' bound to "fBinding".
7841a9ac8606Spatrick</pre></td></tr>
7842a9ac8606Spatrick
7843a9ac8606Spatrick
7844a9ac8606Spatrick<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>
7845*12c85518Srobert<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', 'do' statement or a function definition that has
7846*12c85518Sroberta given body. Note that in case of functions this matcher only matches the
7847*12c85518Srobertdefinition itself and not the other declarations of the same function.
7848*12c85518Srobert
7849*12c85518SrobertGiven
7850*12c85518Srobert  for (;;) {}
7851*12c85518SrobertforStmt(hasBody(compoundStmt()))
7852*12c85518Srobert  matches 'for (;;) {}'
7853*12c85518Srobertwith compoundStmt()
7854*12c85518Srobert  matching '{}'
7855*12c85518Srobert
7856*12c85518SrobertGiven
7857*12c85518Srobert  void f();
7858*12c85518Srobert  void f() {}
7859*12c85518SrobertfunctionDecl(hasBody(compoundStmt()))
7860*12c85518Srobert  matches 'void f() {}'
7861*12c85518Srobertwith compoundStmt()
7862*12c85518Srobert  matching '{}'
7863*12c85518Srobert  but does not match 'void f();'
7864*12c85518Srobert</pre></td></tr>
7865a9ac8606Spatrick
7866a9ac8606Spatrick
7867e5dd7070Spatrick<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>
7868e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop,
7869e5dd7070Spatrickswitch statement or conditional operator.
7870e5dd7070Spatrick
7871e5dd7070SpatrickExample matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
7872e5dd7070Spatrick  if (true) {}
7873e5dd7070Spatrick</pre></td></tr>
7874e5dd7070Spatrick
7875e5dd7070Spatrick
7876*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ElaboratedTypeLoc.html">ElaboratedTypeLoc</a>&gt;</td><td class="name" onclick="toggle('hasNamedTypeLoc0')"><a name="hasNamedTypeLoc0Anchor">hasNamedTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; InnerMatcher</td></tr>
7877*12c85518Srobert<tr><td colspan="4" class="doc" id="hasNamedTypeLoc0"><pre>Matches elaborated `TypeLoc`s that have a named `TypeLoc` matching
7878*12c85518Srobert`InnerMatcher`.
7879*12c85518Srobert
7880*12c85518SrobertGiven
7881*12c85518Srobert  template &lt;typename T&gt;
7882*12c85518Srobert  class C {};
7883*12c85518Srobert  class C&lt;int&gt; c;
7884*12c85518Srobert
7885*12c85518Srobert  class D {};
7886*12c85518Srobert  class D d;
7887*12c85518SrobertelaboratedTypeLoc(hasNamedTypeLoc(templateSpecializationTypeLoc()));
7888*12c85518Srobert  matches the `TypeLoc` of the variable declaration of `c`, but not `d`.
7889*12c85518Srobert</pre></td></tr>
7890*12c85518Srobert
7891*12c85518Srobert
7892e5dd7070Spatrick<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>
7893e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
7894e5dd7070Spatrickmatches InnerMatcher if the qualifier exists.
7895e5dd7070Spatrick
7896e5dd7070SpatrickGiven
7897e5dd7070Spatrick  namespace N {
7898e5dd7070Spatrick    namespace M {
7899e5dd7070Spatrick      class D {};
7900e5dd7070Spatrick    }
7901e5dd7070Spatrick  }
7902e5dd7070Spatrick  N::M::D d;
7903e5dd7070Spatrick
7904e5dd7070SpatrickelaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N"))))
7905e5dd7070Spatrickmatches the type of the variable declaration of d.
7906e5dd7070Spatrick</pre></td></tr>
7907e5dd7070Spatrick
7908e5dd7070Spatrick
7909e5dd7070Spatrick<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>
7910e5dd7070Spatrick<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher.
7911e5dd7070Spatrick
7912e5dd7070SpatrickGiven
7913e5dd7070Spatrick  namespace N {
7914e5dd7070Spatrick    namespace M {
7915e5dd7070Spatrick      class D {};
7916e5dd7070Spatrick    }
7917e5dd7070Spatrick  }
7918e5dd7070Spatrick  N::M::D d;
7919e5dd7070Spatrick
7920e5dd7070SpatrickelaboratedType(namesType(recordType(
7921e5dd7070SpatrickhasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable
7922e5dd7070Spatrickdeclaration of d.
7923e5dd7070Spatrick</pre></td></tr>
7924e5dd7070Spatrick
7925e5dd7070Spatrick
7926ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
7927e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node
7928e5dd7070Spatrickmatches the given matcher.
7929e5dd7070Spatrick
7930e5dd7070SpatrickThe associated declaration is:
7931e5dd7070Spatrick- for type nodes, the declaration of the underlying type
7932e5dd7070Spatrick- for CallExpr, the declaration of the callee
7933e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
7934e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
7935e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
7936e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
7937e5dd7070Spatrick
7938e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
7939e5dd7070Spatricksugared type. Given
7940e5dd7070Spatrick  class X {};
7941e5dd7070Spatrick  typedef X Y;
7942e5dd7070Spatrick  Y y;
7943e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7944e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
7945e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
7946e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
7947e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
7948e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
7949e5dd7070Spatrick
7950e5dd7070SpatrickUsable 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;,
7951e5dd7070Spatrick  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;,
7952e5dd7070Spatrick  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;,
7953e5dd7070Spatrick  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;,
7954e5dd7070Spatrick  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;,
7955e5dd7070Spatrick  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;,
7956e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
7957e5dd7070Spatrick</pre></td></tr>
7958e5dd7070Spatrick
7959e5dd7070Spatrick
7960e5dd7070Spatrick<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>
7961e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher.
7962e5dd7070Spatrick
7963e5dd7070Spatrick(Note: Clang's AST refers to other conversions as "casts" too, and calls
7964e5dd7070Spatrickactual casts "explicit" casts.)
7965e5dd7070Spatrick</pre></td></tr>
7966e5dd7070Spatrick
7967e5dd7070Spatrick
7968a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc10')"><a name="hasTypeLoc10Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
7969a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasTypeLoc10"><pre>Matches if the type location of a node matches the inner matcher.
7970a9ac8606Spatrick
7971a9ac8606SpatrickExamples:
7972a9ac8606Spatrick  int x;
7973a9ac8606SpatrickdeclaratorDecl(hasTypeLoc(loc(asString("int"))))
7974a9ac8606Spatrick  matches int x
7975a9ac8606Spatrick
7976a9ac8606Spatrickauto x = int(3);
7977a9ac8606SpatrickcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7978a9ac8606Spatrick  matches int(3)
7979a9ac8606Spatrick
7980a9ac8606Spatrickstruct Foo { Foo(int, int); };
7981a9ac8606Spatrickauto x = Foo(1, 2);
7982a9ac8606SpatrickcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7983a9ac8606Spatrick  matches Foo(1, 2)
7984a9ac8606Spatrick
7985a9ac8606SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
7986a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
7987a9ac8606Spatrick  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_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
7988a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7989a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7990a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
7991a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
7992a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7993a9ac8606Spatrick</pre></td></tr>
7994a9ac8606Spatrick
7995a9ac8606Spatrick
7996a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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>
7997a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasType5"><pre>Overloaded to match the declaration of the expression's or value
7998e5dd7070Spatrickdeclaration's type.
7999e5dd7070Spatrick
8000e5dd7070SpatrickIn case of a value declaration (for example a variable declaration),
8001e5dd7070Spatrickthis resolves one layer of indirection. For example, in the value
8002e5dd7070Spatrickdeclaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
8003e5dd7070SpatrickX, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
8004e5dd7070Spatrickdeclaration of x.
8005e5dd7070Spatrick
8006e5dd7070SpatrickExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
8007e5dd7070Spatrick            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
8008e5dd7070Spatrick            and friend class X (matcher = friendDecl(hasType("X"))
8009a9ac8606Spatrick            and public virtual X (matcher = cxxBaseSpecifier(hasType(
8010a9ac8606Spatrick                                              cxxRecordDecl(hasName("X"))))
8011e5dd7070Spatrick class X {};
8012e5dd7070Spatrick void y(X &amp;x) { x; X z; }
8013e5dd7070Spatrick class Y { friend class X; };
8014a9ac8606Spatrick class Z : public virtual X {};
8015e5dd7070Spatrick
8016ec727ea7SpatrickExample matches class Derived
8017ec727ea7Spatrick(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
8018ec727ea7Spatrickclass Base {};
8019ec727ea7Spatrickclass Derived : Base {};
8020ec727ea7Spatrick
8021ec727ea7SpatrickUsable 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_1FriendDecl.html">FriendDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;,
8022ec727ea7SpatrickMatcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
8023e5dd7070Spatrick</pre></td></tr>
8024e5dd7070Spatrick
8025e5dd7070Spatrick
8026e5dd7070Spatrick<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>
8027e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type
8028e5dd7070Spatrickmatcher.
8029e5dd7070Spatrick
8030e5dd7070SpatrickExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
8031e5dd7070Spatrick            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
8032e5dd7070Spatrick            and U (matcher = typedefDecl(hasType(asString("int")))
8033e5dd7070Spatrick            and friend class X (matcher = friendDecl(hasType("X"))
8034a9ac8606Spatrick            and public virtual X (matcher = cxxBaseSpecifier(hasType(
8035a9ac8606Spatrick                                              asString("class X")))
8036e5dd7070Spatrick class X {};
8037e5dd7070Spatrick void y(X &amp;x) { x; X z; }
8038e5dd7070Spatrick typedef int U;
8039e5dd7070Spatrick class Y { friend class X; };
8040a9ac8606Spatrick class Z : public virtual X {};
8041e5dd7070Spatrick</pre></td></tr>
8042e5dd7070Spatrick
8043e5dd7070Spatrick
8044e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('ignoringElidableConstructorCall0')"><a name="ignoringElidableConstructorCall0Anchor">ignoringElidableConstructorCall</a></td><td>ast_matchers::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
8045e5dd7070Spatrick<tr><td colspan="4" class="doc" id="ignoringElidableConstructorCall0"><pre>Matches expressions that match InnerMatcher that are possibly wrapped in an
8046e5dd7070Spatrickelidable constructor and other corresponding bookkeeping nodes.
8047e5dd7070Spatrick
8048e5dd7070SpatrickIn C++17, elidable copy constructors are no longer being generated in the
8049e5dd7070SpatrickAST as it is not permitted by the standard. They are, however, part of the
8050e5dd7070SpatrickAST in C++14 and earlier. So, a matcher must abstract over these differences
8051e5dd7070Spatrickto work in all language modes. This matcher skips elidable constructor-call
8052e5dd7070SpatrickAST nodes, `ExprWithCleanups` nodes wrapping elidable constructor-calls and
8053e5dd7070Spatrickvarious implicit nodes inside the constructor calls, all of which will not
8054e5dd7070Spatrickappear in the C++17 AST.
8055e5dd7070Spatrick
8056e5dd7070SpatrickGiven
8057e5dd7070Spatrick
8058e5dd7070Spatrickstruct H {};
8059e5dd7070SpatrickH G();
8060e5dd7070Spatrickvoid f() {
8061e5dd7070Spatrick  H D = G();
8062e5dd7070Spatrick}
8063e5dd7070Spatrick
8064e5dd7070Spatrick``varDecl(hasInitializer(ignoringElidableConstructorCall(callExpr())))``
8065e5dd7070Spatrickmatches ``H D = G()`` in C++11 through C++17 (and beyond).
8066e5dd7070Spatrick</pre></td></tr>
8067e5dd7070Spatrick
8068e5dd7070Spatrick
8069e5dd7070Spatrick<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>
8070e5dd7070Spatrick<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts
8071e5dd7070Spatrickare stripped off.
8072e5dd7070Spatrick
8073e5dd7070SpatrickParentheses and explicit casts are not discarded.
8074e5dd7070SpatrickGiven
8075e5dd7070Spatrick  int arr[5];
8076e5dd7070Spatrick  int a = 0;
8077e5dd7070Spatrick  char b = 0;
8078e5dd7070Spatrick  const int c = a;
8079e5dd7070Spatrick  int *d = arr;
8080e5dd7070Spatrick  long e = (long) 0l;
8081e5dd7070SpatrickThe matchers
8082e5dd7070Spatrick   varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
8083e5dd7070Spatrick   varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
8084e5dd7070Spatrickwould match the declarations for a, b, c, and d, but not e.
8085e5dd7070SpatrickWhile
8086e5dd7070Spatrick   varDecl(hasInitializer(integerLiteral()))
8087e5dd7070Spatrick   varDecl(hasInitializer(declRefExpr()))
8088a9ac8606Spatrickonly match the declarations for a.
8089e5dd7070Spatrick</pre></td></tr>
8090e5dd7070Spatrick
8091e5dd7070Spatrick
8092e5dd7070Spatrick<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>
8093e5dd7070Spatrick<tr><td colspan="4" class="doc" id="ignoringImplicit0"><pre>Matches expressions that match InnerMatcher after any implicit AST
8094e5dd7070Spatricknodes are stripped off.
8095e5dd7070Spatrick
8096e5dd7070SpatrickParentheses and explicit casts are not discarded.
8097e5dd7070SpatrickGiven
8098e5dd7070Spatrick  class C {};
8099e5dd7070Spatrick  C a = C();
8100e5dd7070Spatrick  C b;
8101e5dd7070Spatrick  C c = b;
8102e5dd7070SpatrickThe matchers
8103e5dd7070Spatrick   varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr())))
8104e5dd7070Spatrickwould match the declarations for a, b, and c.
8105e5dd7070SpatrickWhile
8106e5dd7070Spatrick   varDecl(hasInitializer(cxxConstructExpr()))
8107e5dd7070Spatrickonly match the declarations for b and c.
8108e5dd7070Spatrick</pre></td></tr>
8109e5dd7070Spatrick
8110e5dd7070Spatrick
8111e5dd7070Spatrick<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>
8112e5dd7070Spatrick<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and
8113e5dd7070Spatrickcasts are stripped off.
8114e5dd7070Spatrick
8115e5dd7070SpatrickImplicit and non-C Style casts are also discarded.
8116e5dd7070SpatrickGiven
8117e5dd7070Spatrick  int a = 0;
8118e5dd7070Spatrick  char b = (0);
8119e5dd7070Spatrick  void* c = reinterpret_cast&lt;char*&gt;(0);
8120e5dd7070Spatrick  char d = char(0);
8121e5dd7070SpatrickThe matcher
8122e5dd7070Spatrick   varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
8123e5dd7070Spatrickwould match the declarations for a, b, c, and d.
8124e5dd7070Spatrickwhile
8125e5dd7070Spatrick   varDecl(hasInitializer(integerLiteral()))
8126e5dd7070Spatrickonly match the declaration for a.
8127e5dd7070Spatrick</pre></td></tr>
8128e5dd7070Spatrick
8129e5dd7070Spatrick
8130e5dd7070Spatrick<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>
8131e5dd7070Spatrick<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and
8132e5dd7070Spatrickparentheses are stripped off.
8133e5dd7070Spatrick
8134e5dd7070SpatrickExplicit casts are not discarded.
8135e5dd7070SpatrickGiven
8136e5dd7070Spatrick  int arr[5];
8137e5dd7070Spatrick  int a = 0;
8138e5dd7070Spatrick  char b = (0);
8139e5dd7070Spatrick  const int c = a;
8140e5dd7070Spatrick  int *d = (arr);
8141e5dd7070Spatrick  long e = ((long) 0l);
8142e5dd7070SpatrickThe matchers
8143e5dd7070Spatrick   varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
8144e5dd7070Spatrick   varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
8145e5dd7070Spatrickwould match the declarations for a, b, c, and d, but not e.
8146e5dd7070Spatrickwhile
8147e5dd7070Spatrick   varDecl(hasInitializer(integerLiteral()))
8148e5dd7070Spatrick   varDecl(hasInitializer(declRefExpr()))
8149e5dd7070Spatrickwould only match the declaration for a.
8150e5dd7070Spatrick</pre></td></tr>
8151e5dd7070Spatrick
8152e5dd7070Spatrick
8153e5dd7070Spatrick<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>
8154e5dd7070Spatrick<tr><td colspan="4" class="doc" id="ignoringParens1"><pre>Overload ignoringParens for Expr.
8155e5dd7070Spatrick
8156e5dd7070SpatrickGiven
8157e5dd7070Spatrick  const char* str = ("my-string");
8158e5dd7070SpatrickThe matcher
8159e5dd7070Spatrick  implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral())))
8160e5dd7070Spatrickwould match the implicit cast resulting from the assignment.
8161e5dd7070Spatrick</pre></td></tr>
8162e5dd7070Spatrick
8163e5dd7070Spatrick
8164e5dd7070Spatrick<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>
8165e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasInClassInitializer0"><pre>Matches non-static data members that have an in-class initializer.
8166e5dd7070Spatrick
8167e5dd7070SpatrickGiven
8168e5dd7070Spatrick  class C {
8169e5dd7070Spatrick    int a = 2;
8170e5dd7070Spatrick    int b = 3;
8171e5dd7070Spatrick    int c;
8172e5dd7070Spatrick  };
8173e5dd7070SpatrickfieldDecl(hasInClassInitializer(integerLiteral(equals(2))))
8174e5dd7070Spatrick  matches 'int a;' but not 'int b;'.
8175e5dd7070SpatrickfieldDecl(hasInClassInitializer(anything()))
8176e5dd7070Spatrick  matches 'int a;' and 'int b;' but not 'int c;'.
8177e5dd7070Spatrick</pre></td></tr>
8178e5dd7070Spatrick
8179e5dd7070Spatrick
8180e5dd7070Spatrick<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>
8181*12c85518Srobert<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', 'do' statement or a function definition that has
8182*12c85518Sroberta given body. Note that in case of functions this matcher only matches the
8183*12c85518Srobertdefinition itself and not the other declarations of the same function.
8184*12c85518Srobert
8185*12c85518SrobertGiven
8186*12c85518Srobert  for (;;) {}
8187*12c85518SrobertforStmt(hasBody(compoundStmt()))
8188*12c85518Srobert  matches 'for (;;) {}'
8189*12c85518Srobertwith compoundStmt()
8190*12c85518Srobert  matching '{}'
8191*12c85518Srobert
8192*12c85518SrobertGiven
8193*12c85518Srobert  void f();
8194*12c85518Srobert  void f() {}
8195*12c85518SrobertfunctionDecl(hasBody(compoundStmt()))
8196*12c85518Srobert  matches 'void f() {}'
8197*12c85518Srobertwith compoundStmt()
8198*12c85518Srobert  matching '{}'
8199*12c85518Srobert  but does not match 'void f();'
8200*12c85518Srobert</pre></td></tr>
8201e5dd7070Spatrick
8202e5dd7070Spatrick
8203e5dd7070Spatrick<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>
8204e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop,
8205e5dd7070Spatrickswitch statement or conditional operator.
8206e5dd7070Spatrick
8207e5dd7070SpatrickExample matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8208e5dd7070Spatrick  if (true) {}
8209e5dd7070Spatrick</pre></td></tr>
8210e5dd7070Spatrick
8211e5dd7070Spatrick
8212e5dd7070Spatrick<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>
8213e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop.
8214e5dd7070Spatrick
8215e5dd7070SpatrickExample:
8216e5dd7070Spatrick    forStmt(hasIncrement(unaryOperator(hasOperatorName("++"))))
8217e5dd7070Spatrickmatches '++x' in
8218e5dd7070Spatrick    for (x; x &lt; N; ++x) { }
8219e5dd7070Spatrick</pre></td></tr>
8220e5dd7070Spatrick
8221e5dd7070Spatrick
8222e5dd7070Spatrick<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>
8223e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop.
8224e5dd7070Spatrick
8225e5dd7070SpatrickExample:
8226e5dd7070Spatrick    forStmt(hasLoopInit(declStmt()))
8227e5dd7070Spatrickmatches 'int x = 0' in
8228e5dd7070Spatrick    for (int x = 0; x &lt; N; ++x) { }
8229e5dd7070Spatrick</pre></td></tr>
8230e5dd7070Spatrick
8231e5dd7070Spatrick
8232a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</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>
8233a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasType6"><pre>Overloaded to match the declaration of the expression's or value
8234e5dd7070Spatrickdeclaration's type.
8235e5dd7070Spatrick
8236e5dd7070SpatrickIn case of a value declaration (for example a variable declaration),
8237e5dd7070Spatrickthis resolves one layer of indirection. For example, in the value
8238e5dd7070Spatrickdeclaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
8239e5dd7070SpatrickX, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
8240e5dd7070Spatrickdeclaration of x.
8241e5dd7070Spatrick
8242e5dd7070SpatrickExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
8243e5dd7070Spatrick            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
8244e5dd7070Spatrick            and friend class X (matcher = friendDecl(hasType("X"))
8245a9ac8606Spatrick            and public virtual X (matcher = cxxBaseSpecifier(hasType(
8246a9ac8606Spatrick                                              cxxRecordDecl(hasName("X"))))
8247e5dd7070Spatrick class X {};
8248e5dd7070Spatrick void y(X &amp;x) { x; X z; }
8249e5dd7070Spatrick class Y { friend class X; };
8250a9ac8606Spatrick class Z : public virtual X {};
8251e5dd7070Spatrick
8252ec727ea7SpatrickExample matches class Derived
8253ec727ea7Spatrick(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
8254ec727ea7Spatrickclass Base {};
8255ec727ea7Spatrickclass Derived : Base {};
8256ec727ea7Spatrick
8257ec727ea7SpatrickUsable 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_1FriendDecl.html">FriendDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;,
8258ec727ea7SpatrickMatcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
8259e5dd7070Spatrick</pre></td></tr>
8260e5dd7070Spatrick
8261e5dd7070Spatrick
8262e5dd7070Spatrick<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>
8263e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type
8264e5dd7070Spatrickmatcher.
8265e5dd7070Spatrick
8266e5dd7070SpatrickExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
8267e5dd7070Spatrick            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
8268e5dd7070Spatrick            and U (matcher = typedefDecl(hasType(asString("int")))
8269e5dd7070Spatrick            and friend class X (matcher = friendDecl(hasType("X"))
8270a9ac8606Spatrick            and public virtual X (matcher = cxxBaseSpecifier(hasType(
8271a9ac8606Spatrick                                              asString("class X")))
8272e5dd7070Spatrick class X {};
8273e5dd7070Spatrick void y(X &amp;x) { x; X z; }
8274e5dd7070Spatrick typedef int U;
8275e5dd7070Spatrick class Y { friend class X; };
8276a9ac8606Spatrick class Z : public virtual X {};
8277a9ac8606Spatrick</pre></td></tr>
8278a9ac8606Spatrick
8279a9ac8606Spatrick
8280*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('forEachTemplateArgument2')"><a name="forEachTemplateArgument2Anchor">forEachTemplateArgument</a></td><td>clang::ast_matchers::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
8281*12c85518Srobert<tr><td colspan="4" class="doc" id="forEachTemplateArgument2"><pre>Matches classTemplateSpecialization, templateSpecializationType and
8282*12c85518SrobertfunctionDecl nodes where the template argument matches the inner matcher.
8283*12c85518SrobertThis matcher may produce multiple matches.
8284*12c85518Srobert
8285*12c85518SrobertGiven
8286*12c85518Srobert  template &lt;typename T, unsigned N, unsigned M&gt;
8287*12c85518Srobert  struct Matrix {};
8288*12c85518Srobert
8289*12c85518Srobert  constexpr unsigned R = 2;
8290*12c85518Srobert  Matrix&lt;int, R * 2, R * 4&gt; M;
8291*12c85518Srobert
8292*12c85518Srobert  template &lt;typename T, typename U&gt;
8293*12c85518Srobert  void f(T&amp;&amp; t, U&amp;&amp; u) {}
8294*12c85518Srobert
8295*12c85518Srobert  bool B = false;
8296*12c85518Srobert  f(R, B);
8297*12c85518SroberttemplateSpecializationType(forEachTemplateArgument(isExpr(expr())))
8298*12c85518Srobert  matches twice, with expr() matching 'R * 2' and 'R * 4'
8299*12c85518SrobertfunctionDecl(forEachTemplateArgument(refersToType(builtinType())))
8300*12c85518Srobert  matches the specialization f&lt;unsigned, bool&gt; twice, for 'unsigned'
8301*12c85518Srobert  and 'bool'
8302*12c85518Srobert</pre></td></tr>
8303*12c85518Srobert
8304*12c85518Srobert
8305a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyBody0')"><a name="hasAnyBody0Anchor">hasAnyBody</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
8306a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasAnyBody0"><pre>Matches a function declaration that has a given body present in the AST.
8307a9ac8606SpatrickNote that this matcher matches all the declarations of a function whose
8308a9ac8606Spatrickbody is present in the AST.
8309a9ac8606Spatrick
8310a9ac8606SpatrickGiven
8311a9ac8606Spatrick  void f();
8312a9ac8606Spatrick  void f() {}
8313a9ac8606Spatrick  void g();
8314a9ac8606SpatrickfunctionDecl(hasAnyBody(compoundStmt()))
8315a9ac8606Spatrick  matches both 'void f();'
8316a9ac8606Spatrick  and 'void f() {}'
8317a9ac8606Spatrickwith compoundStmt()
8318a9ac8606Spatrick  matching '{}'
8319a9ac8606Spatrick  but does not match 'void g();'
8320e5dd7070Spatrick</pre></td></tr>
8321e5dd7070Spatrick
8322e5dd7070Spatrick
8323e5dd7070Spatrick<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>
8324e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function or an ObjC method declaration or a
8325e5dd7070Spatrickblock.
8326e5dd7070Spatrick
8327e5dd7070SpatrickDoes not match the 'this' parameter of a method.
8328e5dd7070Spatrick
8329e5dd7070SpatrickGiven
8330e5dd7070Spatrick  class X { void f(int x, int y, int z) {} };
8331e5dd7070SpatrickcxxMethodDecl(hasAnyParameter(hasName("y")))
8332e5dd7070Spatrick  matches f(int x, int y, int z) {}
8333e5dd7070Spatrickwith hasAnyParameter(...)
8334e5dd7070Spatrick  matching int y
8335e5dd7070Spatrick
8336e5dd7070SpatrickFor ObjectiveC, given
8337e5dd7070Spatrick  @interface I - (void) f:(int) y; @end
8338e5dd7070Spatrick
8339e5dd7070Spatrickthe matcher objcMethodDecl(hasAnyParameter(hasName("y")))
8340e5dd7070Spatrickmatches the declaration of method f with hasParameter
8341e5dd7070Spatrickmatching y.
8342e5dd7070Spatrick
8343e5dd7070SpatrickFor blocks, given
8344e5dd7070Spatrick  b = ^(int y) { printf("%d", y) };
8345e5dd7070Spatrick
8346e5dd7070Spatrickthe matcher blockDecl(hasAnyParameter(hasName("y")))
8347e5dd7070Spatrickmatches the declaration of the block b with hasParameter
8348e5dd7070Spatrickmatching y.
8349e5dd7070Spatrick</pre></td></tr>
8350e5dd7070Spatrick
8351e5dd7070Spatrick
8352e5dd7070Spatrick<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>
8353e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and
8354e5dd7070SpatrickfunctionDecl that have at least one TemplateArgument matching the given
8355e5dd7070SpatrickInnerMatcher.
8356e5dd7070Spatrick
8357e5dd7070SpatrickGiven
8358e5dd7070Spatrick  template&lt;typename T&gt; class A {};
8359e5dd7070Spatrick  template&lt;&gt; class A&lt;double&gt; {};
8360e5dd7070Spatrick  A&lt;int&gt; a;
8361e5dd7070Spatrick
8362e5dd7070Spatrick  template&lt;typename T&gt; f() {};
8363e5dd7070Spatrick  void func() { f&lt;int&gt;(); };
8364e5dd7070Spatrick
8365e5dd7070SpatrickclassTemplateSpecializationDecl(hasAnyTemplateArgument(
8366e5dd7070Spatrick    refersToType(asString("int"))))
8367e5dd7070Spatrick  matches the specialization A&lt;int&gt;
8368e5dd7070Spatrick
8369e5dd7070SpatrickfunctionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
8370e5dd7070Spatrick  matches the specialization f&lt;int&gt;
8371e5dd7070Spatrick</pre></td></tr>
8372e5dd7070Spatrick
8373e5dd7070Spatrick
8374e5dd7070Spatrick<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>
8375*12c85518Srobert<tr><td colspan="4" class="doc" id="hasBody4"><pre>Matches a 'for', 'while', 'do' statement or a function definition that has
8376*12c85518Sroberta given body. Note that in case of functions this matcher only matches the
8377*12c85518Srobertdefinition itself and not the other declarations of the same function.
8378*12c85518Srobert
8379*12c85518SrobertGiven
8380*12c85518Srobert  for (;;) {}
8381*12c85518SrobertforStmt(hasBody(compoundStmt()))
8382*12c85518Srobert  matches 'for (;;) {}'
8383*12c85518Srobertwith compoundStmt()
8384*12c85518Srobert  matching '{}'
8385*12c85518Srobert
8386*12c85518SrobertGiven
8387*12c85518Srobert  void f();
8388*12c85518Srobert  void f() {}
8389*12c85518SrobertfunctionDecl(hasBody(compoundStmt()))
8390*12c85518Srobert  matches 'void f() {}'
8391*12c85518Srobertwith compoundStmt()
8392*12c85518Srobert  matching '{}'
8393*12c85518Srobert  but does not match 'void f();'
8394*12c85518Srobert</pre></td></tr>
8395e5dd7070Spatrick
8396e5dd7070Spatrick
8397e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasExplicitSpecifier0')"><a name="hasExplicitSpecifier0Anchor">hasExplicitSpecifier</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
8398e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasExplicitSpecifier0"><pre>Matches the expression in an explicit specifier if present in the given
8399e5dd7070Spatrickdeclaration.
8400e5dd7070Spatrick
8401e5dd7070SpatrickGiven
8402e5dd7070Spatrick  template&lt;bool b&gt;
8403e5dd7070Spatrick  struct S {
8404e5dd7070Spatrick    S(int); // #1
8405e5dd7070Spatrick    explicit S(double); // #2
8406e5dd7070Spatrick    operator int(); // #3
8407e5dd7070Spatrick    explicit operator bool(); // #4
8408e5dd7070Spatrick    explicit(false) S(bool) // # 7
8409e5dd7070Spatrick    explicit(true) S(char) // # 8
8410e5dd7070Spatrick    explicit(b) S(S) // # 9
8411e5dd7070Spatrick  };
8412e5dd7070Spatrick  S(int) -&gt; S&lt;true&gt; // #5
8413e5dd7070Spatrick  explicit S(double) -&gt; S&lt;false&gt; // #6
8414e5dd7070SpatrickcxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8 and #9, but not #1 or #2.
8415e5dd7070SpatrickcxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or #4.
8416e5dd7070SpatrickcxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not match #5 or #6.
8417e5dd7070Spatrick</pre></td></tr>
8418e5dd7070Spatrick
8419e5dd7070Spatrick
8420e5dd7070Spatrick<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>
8421e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function or an ObjC method
8422e5dd7070Spatrickdeclaration or a block.
8423e5dd7070Spatrick
8424e5dd7070SpatrickGiven
8425e5dd7070Spatrick  class X { void f(int x) {} };
8426e5dd7070SpatrickcxxMethodDecl(hasParameter(0, hasType(varDecl())))
8427e5dd7070Spatrick  matches f(int x) {}
8428e5dd7070Spatrickwith hasParameter(...)
8429e5dd7070Spatrick  matching int x
8430e5dd7070Spatrick
8431e5dd7070SpatrickFor ObjectiveC, given
8432e5dd7070Spatrick  @interface I - (void) f:(int) y; @end
8433e5dd7070Spatrick
8434e5dd7070Spatrickthe matcher objcMethodDecl(hasParameter(0, hasName("y")))
8435e5dd7070Spatrickmatches the declaration of method f with hasParameter
8436e5dd7070Spatrickmatching y.
8437e5dd7070Spatrick</pre></td></tr>
8438e5dd7070Spatrick
8439e5dd7070Spatrick
8440*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasReturnTypeLoc0')"><a name="hasReturnTypeLoc0Anchor">hasReturnTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; ReturnMatcher</td></tr>
8441*12c85518Srobert<tr><td colspan="4" class="doc" id="hasReturnTypeLoc0"><pre>Matches a function declared with the specified return `TypeLoc`.
8442*12c85518Srobert
8443*12c85518SrobertGiven
8444*12c85518Srobert  int f() { return 5; }
8445*12c85518Srobert  void g() {}
8446*12c85518SrobertfunctionDecl(hasReturnTypeLoc(loc(asString("int"))))
8447*12c85518Srobert  matches the declaration of `f`, but not `g`.
8448*12c85518Srobert</pre></td></tr>
8449*12c85518Srobert
8450*12c85518Srobert
8451e5dd7070Spatrick<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>
8452e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and
8453e5dd7070SpatrickfunctionDecl where the n'th TemplateArgument matches the given InnerMatcher.
8454e5dd7070Spatrick
8455e5dd7070SpatrickGiven
8456e5dd7070Spatrick  template&lt;typename T, typename U&gt; class A {};
8457e5dd7070Spatrick  A&lt;bool, int&gt; b;
8458e5dd7070Spatrick  A&lt;int, bool&gt; c;
8459e5dd7070Spatrick
8460e5dd7070Spatrick  template&lt;typename T&gt; void f() {}
8461e5dd7070Spatrick  void func() { f&lt;int&gt;(); };
8462e5dd7070SpatrickclassTemplateSpecializationDecl(hasTemplateArgument(
8463e5dd7070Spatrick    1, refersToType(asString("int"))))
8464e5dd7070Spatrick  matches the specialization A&lt;bool, int&gt;
8465e5dd7070Spatrick
8466e5dd7070SpatrickfunctionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
8467e5dd7070Spatrick  matches the specialization f&lt;int&gt;
8468e5dd7070Spatrick</pre></td></tr>
8469e5dd7070Spatrick
8470e5dd7070Spatrick
8471e5dd7070Spatrick<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>
8472e5dd7070Spatrick<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration.
8473e5dd7070Spatrick
8474e5dd7070SpatrickGiven:
8475e5dd7070Spatrick  class X { int f() { return 1; } };
8476e5dd7070SpatrickcxxMethodDecl(returns(asString("int")))
8477e5dd7070Spatrick  matches int f() { return 1; }
8478e5dd7070Spatrick</pre></td></tr>
8479e5dd7070Spatrick
8480e5dd7070Spatrick
8481e5dd7070Spatrick<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>
8482e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop,
8483e5dd7070Spatrickswitch statement or conditional operator.
8484e5dd7070Spatrick
8485e5dd7070SpatrickExample matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8486e5dd7070Spatrick  if (true) {}
8487e5dd7070Spatrick</pre></td></tr>
8488e5dd7070Spatrick
8489e5dd7070Spatrick
8490e5dd7070Spatrick<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>
8491e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement.
8492e5dd7070Spatrick
8493e5dd7070SpatrickGiven
8494e5dd7070Spatrick  if (A* a = GetAPointer()) {}
8495e5dd7070SpatrickhasConditionVariableStatement(...)
8496e5dd7070Spatrick  matches 'A* a = GetAPointer()'.
8497e5dd7070Spatrick</pre></td></tr>
8498e5dd7070Spatrick
8499e5dd7070Spatrick
8500e5dd7070Spatrick<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>
8501e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement.
8502e5dd7070Spatrick
8503e5dd7070SpatrickExamples matches the if statement
8504e5dd7070Spatrick  (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true)))))
8505e5dd7070Spatrick  if (false) false; else true;
8506e5dd7070Spatrick</pre></td></tr>
8507e5dd7070Spatrick
8508e5dd7070Spatrick
8509e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>&gt;</td><td class="name" onclick="toggle('hasInitStatement0')"><a name="hasInitStatement0Anchor">hasInitStatement</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
8510e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasInitStatement0"><pre>Matches selection statements with initializer.
8511e5dd7070Spatrick
8512e5dd7070SpatrickGiven:
8513e5dd7070Spatrick void foo() {
8514e5dd7070Spatrick   if (int i = foobar(); i &gt; 0) {}
8515e5dd7070Spatrick   switch (int i = foobar(); i) {}
8516e5dd7070Spatrick   for (auto&amp; a = get_range(); auto&amp; x : a) {}
8517e5dd7070Spatrick }
8518e5dd7070Spatrick void bar() {
8519e5dd7070Spatrick   if (foobar() &gt; 0) {}
8520e5dd7070Spatrick   switch (foobar()) {}
8521e5dd7070Spatrick   for (auto&amp; x : get_range()) {}
8522e5dd7070Spatrick }
8523e5dd7070SpatrickifStmt(hasInitStatement(anything()))
8524e5dd7070Spatrick  matches the if statement in foo but not in bar.
8525e5dd7070SpatrickswitchStmt(hasInitStatement(anything()))
8526e5dd7070Spatrick  matches the switch statement in foo but not in bar.
8527e5dd7070SpatrickcxxForRangeStmt(hasInitStatement(anything()))
8528e5dd7070Spatrick  matches the range for statement in foo but not in bar.
8529e5dd7070Spatrick</pre></td></tr>
8530e5dd7070Spatrick
8531e5dd7070Spatrick
8532e5dd7070Spatrick<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>
8533e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement.
8534e5dd7070Spatrick
8535e5dd7070SpatrickExamples matches the if statement
8536e5dd7070Spatrick  (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true)))))
8537e5dd7070Spatrick  if (false) true; else false;
8538e5dd7070Spatrick</pre></td></tr>
8539e5dd7070Spatrick
8540e5dd7070Spatrick
8541e5dd7070Spatrick<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>
8542e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given
8543e5dd7070Spatrickmatcher.
8544e5dd7070Spatrick</pre></td></tr>
8545e5dd7070Spatrick
8546e5dd7070Spatrick
8547e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>&gt;</td><td class="name" onclick="toggle('hasInit0')"><a name="hasInit0Anchor">hasInit</a></td><td>unsigned N, ast_matchers::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
8548e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasInit0"><pre>Matches the n'th item of an initializer list expression.
8549e5dd7070Spatrick
8550e5dd7070SpatrickExample matches y.
8551e5dd7070Spatrick    (matcher = initListExpr(hasInit(0, expr())))
8552e5dd7070Spatrick  int x{y}.
8553e5dd7070Spatrick</pre></td></tr>
8554e5dd7070Spatrick
8555e5dd7070Spatrick
8556e5dd7070Spatrick<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>
8557e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions
8558e5dd7070Spatrick(if expression have it).
8559e5dd7070Spatrick</pre></td></tr>
8560e5dd7070Spatrick
8561e5dd7070Spatrick
8562ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
8563e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node
8564e5dd7070Spatrickmatches the given matcher.
8565e5dd7070Spatrick
8566e5dd7070SpatrickThe associated declaration is:
8567e5dd7070Spatrick- for type nodes, the declaration of the underlying type
8568e5dd7070Spatrick- for CallExpr, the declaration of the callee
8569e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
8570e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
8571e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
8572e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
8573e5dd7070Spatrick
8574e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
8575e5dd7070Spatricksugared type. Given
8576e5dd7070Spatrick  class X {};
8577e5dd7070Spatrick  typedef X Y;
8578e5dd7070Spatrick  Y y;
8579e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8580e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
8581e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
8582e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
8583e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
8584e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
8585e5dd7070Spatrick
8586e5dd7070SpatrickUsable 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;,
8587e5dd7070Spatrick  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;,
8588e5dd7070Spatrick  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;,
8589e5dd7070Spatrick  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;,
8590e5dd7070Spatrick  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;,
8591e5dd7070Spatrick  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;,
8592e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
8593e5dd7070Spatrick</pre></td></tr>
8594e5dd7070Spatrick
8595e5dd7070Spatrick
8596ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
8597e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node
8598e5dd7070Spatrickmatches the given matcher.
8599e5dd7070Spatrick
8600e5dd7070SpatrickThe associated declaration is:
8601e5dd7070Spatrick- for type nodes, the declaration of the underlying type
8602e5dd7070Spatrick- for CallExpr, the declaration of the callee
8603e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
8604e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
8605e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
8606e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
8607e5dd7070Spatrick
8608e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
8609e5dd7070Spatricksugared type. Given
8610e5dd7070Spatrick  class X {};
8611e5dd7070Spatrick  typedef X Y;
8612e5dd7070Spatrick  Y y;
8613e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8614e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
8615e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
8616e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
8617e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
8618e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
8619e5dd7070Spatrick
8620e5dd7070SpatrickUsable 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;,
8621e5dd7070Spatrick  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;,
8622e5dd7070Spatrick  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;,
8623e5dd7070Spatrick  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;,
8624e5dd7070Spatrick  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;,
8625e5dd7070Spatrick  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;,
8626e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
8627e5dd7070Spatrick</pre></td></tr>
8628e5dd7070Spatrick
8629e5dd7070Spatrick
8630*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>&gt;</td><td class="name" onclick="toggle('capturesVar0')"><a name="capturesVar0Anchor">capturesVar</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt; InnerMatcher</td></tr>
8631*12c85518Srobert<tr><td colspan="4" class="doc" id="capturesVar0"><pre>Matches a `LambdaCapture` that refers to the specified `VarDecl`. The
8632*12c85518Srobert`VarDecl` can be a separate variable that is captured by value or
8633*12c85518Srobertreference, or a synthesized variable if the capture has an initializer.
8634e5dd7070Spatrick
8635e5dd7070SpatrickGiven
8636e5dd7070Spatrick  void foo() {
8637e5dd7070Spatrick    int x;
8638e5dd7070Spatrick    auto f = [x](){};
8639*12c85518Srobert    auto g = [x = 1](){};
8640e5dd7070Spatrick  }
8641*12c85518SrobertIn the matcher
8642*12c85518SrobertlambdaExpr(hasAnyCapture(lambdaCapture(capturesVar(hasName("x")))),
8643*12c85518SrobertcapturesVar(hasName("x")) matches `x` and `x = 1`.
8644*12c85518Srobert</pre></td></tr>
8645*12c85518Srobert
8646*12c85518Srobert
8647*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>&gt;</td><td class="name" onclick="toggle('forEachLambdaCapture0')"><a name="forEachLambdaCapture0Anchor">forEachLambdaCapture</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>&gt; InnerMatcher</td></tr>
8648*12c85518Srobert<tr><td colspan="4" class="doc" id="forEachLambdaCapture0"><pre>Matches each lambda capture in a lambda expression.
8649*12c85518Srobert
8650*12c85518SrobertGiven
8651*12c85518Srobert  int main() {
8652*12c85518Srobert    int x, y;
8653*12c85518Srobert    float z;
8654*12c85518Srobert    auto f = [=]() { return x + y + z; };
8655*12c85518Srobert  }
8656*12c85518SrobertlambdaExpr(forEachLambdaCapture(
8657*12c85518Srobert    lambdaCapture(capturesVar(varDecl(hasType(isInteger()))))))
8658*12c85518Srobertwill trigger two matches, binding for 'x' and 'y' respectively.
8659*12c85518Srobert</pre></td></tr>
8660*12c85518Srobert
8661*12c85518Srobert
8662*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnyCapture0')"><a name="hasAnyCapture0Anchor">hasAnyCapture</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>&gt; InnerMatcher</td></tr>
8663*12c85518Srobert<tr><td colspan="4" class="doc" id="hasAnyCapture0"><pre>Matches any capture in a lambda expression.
8664*12c85518Srobert
8665*12c85518SrobertGiven
8666*12c85518Srobert  void foo() {
8667*12c85518Srobert    int t = 5;
8668*12c85518Srobert    auto f = [=](){ return t; };
8669*12c85518Srobert  }
8670*12c85518SrobertlambdaExpr(hasAnyCapture(lambdaCapture())) and
8671*12c85518SrobertlambdaExpr(hasAnyCapture(lambdaCapture(refersToVarDecl(hasName("t")))))
8672*12c85518Srobert  both match `[=](){ return t; }`.
8673e5dd7070Spatrick</pre></td></tr>
8674e5dd7070Spatrick
8675e5dd7070Spatrick
8676ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
8677e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node
8678e5dd7070Spatrickmatches the given matcher.
8679e5dd7070Spatrick
8680e5dd7070SpatrickThe associated declaration is:
8681e5dd7070Spatrick- for type nodes, the declaration of the underlying type
8682e5dd7070Spatrick- for CallExpr, the declaration of the callee
8683e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
8684e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
8685e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
8686e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
8687e5dd7070Spatrick
8688e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
8689e5dd7070Spatricksugared type. Given
8690e5dd7070Spatrick  class X {};
8691e5dd7070Spatrick  typedef X Y;
8692e5dd7070Spatrick  Y y;
8693e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8694e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
8695e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
8696e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
8697e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
8698e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
8699e5dd7070Spatrick
8700e5dd7070SpatrickUsable 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;,
8701e5dd7070Spatrick  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;,
8702e5dd7070Spatrick  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;,
8703e5dd7070Spatrick  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;,
8704e5dd7070Spatrick  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;,
8705e5dd7070Spatrick  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;,
8706e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
8707e5dd7070Spatrick</pre></td></tr>
8708e5dd7070Spatrick
8709e5dd7070Spatrick
8710e5dd7070Spatrick<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>
8711e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is matched by a
8712e5dd7070Spatrickgiven matcher. Implicit object expressions are included; that is, it matches
8713e5dd7070Spatrickuse of implicit `this`.
8714e5dd7070Spatrick
8715e5dd7070SpatrickGiven
8716e5dd7070Spatrick  struct X {
8717e5dd7070Spatrick    int m;
8718e5dd7070Spatrick    int f(X x) { x.m; return m; }
8719e5dd7070Spatrick  };
8720e5dd7070SpatrickmemberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))
8721e5dd7070Spatrick  matches `x.m`, but not `m`; however,
8722e5dd7070SpatrickmemberExpr(hasObjectExpression(hasType(pointsTo(
8723e5dd7070Spatrick     cxxRecordDecl(hasName("X"))))))
8724e5dd7070Spatrick  matches `m` (aka. `this-&gt;m`), but not `x.m`.
8725e5dd7070Spatrick</pre></td></tr>
8726e5dd7070Spatrick
8727e5dd7070Spatrick
8728e5dd7070Spatrick<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>
8729e5dd7070Spatrick<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a
8730e5dd7070Spatrickgiven matcher.
8731e5dd7070Spatrick
8732e5dd7070SpatrickGiven
8733e5dd7070Spatrick  struct { int first, second; } first, second;
8734e5dd7070Spatrick  int i(second.first);
8735e5dd7070Spatrick  int j(first.second);
8736e5dd7070SpatrickmemberExpr(member(hasName("first")))
8737e5dd7070Spatrick  matches second.first
8738e5dd7070Spatrick  but not first.second (because the member name there is "second").
8739e5dd7070Spatrick</pre></td></tr>
8740e5dd7070Spatrick
8741e5dd7070Spatrick
8742e5dd7070Spatrick<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>
8743e5dd7070Spatrick<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the
8744e5dd7070Spatrickpointee matches a given matcher.
8745e5dd7070Spatrick
8746e5dd7070SpatrickGiven
8747e5dd7070Spatrick  int *a;
8748e5dd7070Spatrick  int const *b;
8749e5dd7070Spatrick  float const *f;
8750e5dd7070SpatrickpointerType(pointee(isConstQualified(), isInteger()))
8751e5dd7070Spatrick  matches "int const *b"
8752e5dd7070Spatrick
8753e5dd7070SpatrickUsable 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;,
8754e5dd7070Spatrick  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;
8755e5dd7070Spatrick</pre></td></tr>
8756e5dd7070Spatrick
8757e5dd7070Spatrick
8758e5dd7070Spatrick<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>
8759e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasUnderlyingDecl0"><pre>Matches a NamedDecl whose underlying declaration matches the given
8760e5dd7070Spatrickmatcher.
8761e5dd7070Spatrick
8762e5dd7070SpatrickGiven
8763e5dd7070Spatrick  namespace N { template&lt;class T&gt; void f(T t); }
8764e5dd7070Spatrick  template &lt;class T&gt; void g() { using N::f; f(T()); }
8765e5dd7070SpatrickunresolvedLookupExpr(hasAnyDeclaration(
8766e5dd7070Spatrick    namedDecl(hasUnderlyingDecl(hasName("::N::f")))))
8767e5dd7070Spatrick  matches the use of f in g() .
8768e5dd7070Spatrick</pre></td></tr>
8769e5dd7070Spatrick
8770e5dd7070Spatrick
8771e5dd7070Spatrick<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>
8772e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc.
8773e5dd7070Spatrick
8774e5dd7070SpatrickGiven
8775e5dd7070Spatrick  struct A { struct B { struct C {}; }; };
8776e5dd7070Spatrick  A::B::C c;
8777e5dd7070SpatricknestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A")))))
8778e5dd7070Spatrick  matches "A::"
8779e5dd7070Spatrick</pre></td></tr>
8780e5dd7070Spatrick
8781e5dd7070Spatrick
8782ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>&gt;</td><td class="name" onclick="toggle('loc1')"><a name="loc1Anchor">loc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>&gt; InnerMatcher</td></tr>
8783ec727ea7Spatrick<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner
8784ec727ea7SpatrickNestedNameSpecifier-matcher matches.
8785ec727ea7Spatrick</pre></td></tr>
8786ec727ea7Spatrick
8787ec727ea7Spatrick
8788e5dd7070Spatrick<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>
8789e5dd7070Spatrick<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the
8790e5dd7070Spatrickgiven TypeLoc.
8791e5dd7070Spatrick
8792e5dd7070SpatrickGiven
8793e5dd7070Spatrick  struct A { struct B { struct C {}; }; };
8794e5dd7070Spatrick  A::B::C c;
8795e5dd7070SpatricknestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
8796e5dd7070Spatrick  hasDeclaration(cxxRecordDecl(hasName("A")))))))
8797e5dd7070Spatrick  matches "A::"
8798e5dd7070Spatrick</pre></td></tr>
8799e5dd7070Spatrick
8800e5dd7070Spatrick
8801e5dd7070Spatrick<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>
8802e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier.
8803e5dd7070Spatrick
8804e5dd7070SpatrickGiven
8805e5dd7070Spatrick  struct A { struct B { struct C {}; }; };
8806e5dd7070Spatrick  A::B::C c;
8807e5dd7070SpatricknestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and
8808e5dd7070Spatrick  matches "A::"
8809e5dd7070Spatrick</pre></td></tr>
8810e5dd7070Spatrick
8811e5dd7070Spatrick
8812e5dd7070Spatrick<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>
8813e5dd7070Spatrick<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the
8814e5dd7070Spatrickgiven namespace matcher.
8815e5dd7070Spatrick
8816e5dd7070SpatrickGiven
8817e5dd7070Spatrick  namespace ns { struct A {}; }
8818e5dd7070Spatrick  ns::A a;
8819e5dd7070SpatricknestedNameSpecifier(specifiesNamespace(hasName("ns")))
8820e5dd7070Spatrick  matches "ns::"
8821e5dd7070Spatrick</pre></td></tr>
8822e5dd7070Spatrick
8823e5dd7070Spatrick
8824e5dd7070Spatrick<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>
8825e5dd7070Spatrick<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the
8826e5dd7070Spatrickgiven QualType matcher without qualifiers.
8827e5dd7070Spatrick
8828e5dd7070SpatrickGiven
8829e5dd7070Spatrick  struct A { struct B { struct C {}; }; };
8830e5dd7070Spatrick  A::B::C c;
8831e5dd7070SpatricknestedNameSpecifier(specifiesType(
8832e5dd7070Spatrick  hasDeclaration(cxxRecordDecl(hasName("A")))
8833e5dd7070Spatrick))
8834e5dd7070Spatrick  matches "A::"
8835e5dd7070Spatrick</pre></td></tr>
8836e5dd7070Spatrick
8837e5dd7070Spatrick
8838e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html">OMPExecutableDirective</a>&gt;</td><td class="name" onclick="toggle('hasAnyClause0')"><a name="hasAnyClause0Anchor">hasAnyClause</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPClause.html">OMPClause</a>&gt; InnerMatcher</td></tr>
8839e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnyClause0"><pre>Matches any clause in an OpenMP directive.
8840e5dd7070Spatrick
8841e5dd7070SpatrickGiven
8842e5dd7070Spatrick
8843e5dd7070Spatrick  #pragma omp parallel
8844e5dd7070Spatrick  #pragma omp parallel default(none)
8845e5dd7070Spatrick
8846e5dd7070Spatrick``ompExecutableDirective(hasAnyClause(anything()))`` matches
8847e5dd7070Spatrick``omp parallel default(none)``.
8848e5dd7070Spatrick</pre></td></tr>
8849e5dd7070Spatrick
8850e5dd7070Spatrick
8851e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html">OMPExecutableDirective</a>&gt;</td><td class="name" onclick="toggle('hasStructuredBlock0')"><a name="hasStructuredBlock0Anchor">hasStructuredBlock</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
8852e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasStructuredBlock0"><pre>Matches the structured-block of the OpenMP executable directive
8853e5dd7070Spatrick
8854e5dd7070SpatrickPrerequisite: the executable directive must not be standalone directive.
8855e5dd7070SpatrickIf it is, it will never match.
8856e5dd7070Spatrick
8857e5dd7070SpatrickGiven
8858e5dd7070Spatrick
8859e5dd7070Spatrick   #pragma omp parallel
8860e5dd7070Spatrick   ;
8861e5dd7070Spatrick   #pragma omp parallel
8862e5dd7070Spatrick   {}
8863e5dd7070Spatrick
8864e5dd7070Spatrick``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;``
8865e5dd7070Spatrick</pre></td></tr>
8866e5dd7070Spatrick
8867e5dd7070Spatrick
8868e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>&gt;</td><td class="name" onclick="toggle('isDerivedFrom1')"><a name="isDerivedFrom1Anchor">isDerivedFrom</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt; Base</td></tr>
8869e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Matches C++ classes that are directly or indirectly derived from a class
8870e5dd7070Spatrickmatching Base, or Objective-C classes that directly or indirectly
8871e5dd7070Spatricksubclass a class matching Base.
8872e5dd7070Spatrick
8873e5dd7070SpatrickNote that a class is not considered to be derived from itself.
8874e5dd7070Spatrick
8875e5dd7070SpatrickExample matches Y, Z, C (Base == hasName("X"))
8876e5dd7070Spatrick  class X;
8877e5dd7070Spatrick  class Y : public X {};  // directly derived
8878e5dd7070Spatrick  class Z : public Y {};  // indirectly derived
8879e5dd7070Spatrick  typedef X A;
8880e5dd7070Spatrick  typedef A B;
8881e5dd7070Spatrick  class C : public B {};  // derived from a typedef of X
8882e5dd7070Spatrick
8883e5dd7070SpatrickIn the following example, Bar matches isDerivedFrom(hasName("X")):
8884e5dd7070Spatrick  class Foo;
8885e5dd7070Spatrick  typedef Foo X;
8886e5dd7070Spatrick  class Bar : public Foo {};  // derived from a type that X is a typedef of
8887e5dd7070Spatrick
8888e5dd7070SpatrickIn the following example, Bar matches isDerivedFrom(hasName("NSObject"))
8889e5dd7070Spatrick  @interface NSObject @end
8890e5dd7070Spatrick  @interface Bar : NSObject @end
8891e5dd7070Spatrick
8892e5dd7070SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>&gt;
8893e5dd7070Spatrick</pre></td></tr>
8894e5dd7070Spatrick
8895e5dd7070Spatrick
8896e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>&gt;</td><td class="name" onclick="toggle('isDirectlyDerivedFrom1')"><a name="isDirectlyDerivedFrom1Anchor">isDirectlyDerivedFrom</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt; Base</td></tr>
8897e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom1"><pre>Matches C++ or Objective-C classes that are directly derived from a class
8898e5dd7070Spatrickmatching Base.
8899e5dd7070Spatrick
8900e5dd7070SpatrickNote that a class is not considered to be derived from itself.
8901e5dd7070Spatrick
8902e5dd7070SpatrickExample matches Y, C (Base == hasName("X"))
8903e5dd7070Spatrick  class X;
8904e5dd7070Spatrick  class Y : public X {};  // directly derived
8905e5dd7070Spatrick  class Z : public Y {};  // indirectly derived
8906e5dd7070Spatrick  typedef X A;
8907e5dd7070Spatrick  typedef A B;
8908e5dd7070Spatrick  class C : public B {};  // derived from a typedef of X
8909e5dd7070Spatrick
8910e5dd7070SpatrickIn the following example, Bar matches isDerivedFrom(hasName("X")):
8911e5dd7070Spatrick  class Foo;
8912e5dd7070Spatrick  typedef Foo X;
8913e5dd7070Spatrick  class Bar : public Foo {};  // derived from a type that X is a typedef of
8914e5dd7070Spatrick</pre></td></tr>
8915e5dd7070Spatrick
8916e5dd7070Spatrick
8917e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>&gt;</td><td class="name" onclick="toggle('isSameOrDerivedFrom1')"><a name="isSameOrDerivedFrom1Anchor">isSameOrDerivedFrom</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>&gt; Base</td></tr>
8918e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Similar to isDerivedFrom(), but also matches classes that directly
8919e5dd7070Spatrickmatch Base.
8920e5dd7070Spatrick</pre></td></tr>
8921e5dd7070Spatrick
8922e5dd7070Spatrick
8923*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</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>
8924*12c85518Srobert<tr><td colspan="4" class="doc" id="callee1"><pre>Matches 1) if the call expression's callee's declaration matches the
8925*12c85518Srobertgiven matcher; or 2) if the Obj-C message expression's callee's method
8926*12c85518Srobertdeclaration matches the given matcher.
8927*12c85518Srobert
8928*12c85518SrobertExample matches y.x() (matcher = callExpr(callee(
8929*12c85518Srobert                                   cxxMethodDecl(hasName("x")))))
8930*12c85518Srobert  class Y { public: void x(); };
8931*12c85518Srobert  void z() { Y y; y.x(); }
8932*12c85518Srobert
8933*12c85518SrobertExample 2. Matches [I foo] with
8934*12c85518SrobertobjcMessageExpr(callee(objcMethodDecl(hasName("foo"))))
8935*12c85518Srobert
8936*12c85518Srobert  @interface I: NSObject
8937*12c85518Srobert  +(void)foo;
8938*12c85518Srobert  @end
8939*12c85518Srobert  ...
8940*12c85518Srobert  [I foo]
8941*12c85518Srobert</pre></td></tr>
8942*12c85518Srobert
8943*12c85518Srobert
8944e5dd7070Spatrick<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>
8945e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnyArgument3"><pre>Matches any argument of a call expression or a constructor call
8946e5dd7070Spatrickexpression, or an ObjC-message-send expression.
8947e5dd7070Spatrick
8948e5dd7070SpatrickGiven
8949e5dd7070Spatrick  void x(int, int, int) { int y; x(1, y, 42); }
8950e5dd7070SpatrickcallExpr(hasAnyArgument(declRefExpr()))
8951e5dd7070Spatrick  matches x(1, y, 42)
8952e5dd7070Spatrickwith hasAnyArgument(...)
8953e5dd7070Spatrick  matching y
8954e5dd7070Spatrick
8955e5dd7070SpatrickFor ObjectiveC, given
8956e5dd7070Spatrick  @interface I - (void) f:(int) y; @end
8957e5dd7070Spatrick  void foo(I *i) { [i f:12]; }
8958e5dd7070SpatrickobjcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
8959e5dd7070Spatrick  matches [i f:12]
8960e5dd7070Spatrick</pre></td></tr>
8961e5dd7070Spatrick
8962e5dd7070Spatrick
8963a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('hasArgument3')"><a name="hasArgument3Anchor">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>
8964a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasArgument3"><pre>Matches the n'th argument of a call expression or a constructor
8965e5dd7070Spatrickcall expression.
8966e5dd7070Spatrick
8967e5dd7070SpatrickExample matches y in x(y)
8968e5dd7070Spatrick    (matcher = callExpr(hasArgument(0, declRefExpr())))
8969e5dd7070Spatrick  void x(int) { int y; x(y); }
8970e5dd7070Spatrick</pre></td></tr>
8971e5dd7070Spatrick
8972e5dd7070Spatrick
8973e5dd7070Spatrick<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>
8974e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasReceiver0"><pre>Matches if the Objective-C message is sent to an instance,
8975e5dd7070Spatrickand the inner matcher matches on that instance.
8976e5dd7070Spatrick
8977e5dd7070SpatrickFor example the method call in
8978e5dd7070Spatrick  NSString *x = @"hello";
8979e5dd7070Spatrick  [x containsString:@"h"];
8980e5dd7070Spatrickis matched by
8981e5dd7070SpatrickobjcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x"))))))
8982e5dd7070Spatrick</pre></td></tr>
8983e5dd7070Spatrick
8984e5dd7070Spatrick
8985e5dd7070Spatrick<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>
8986e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression.
8987e5dd7070Spatrick
8988e5dd7070SpatrickExample
8989e5dd7070Spatrickmatcher = objCMessageExpr(hasReceiverType(asString("UIWebView *")));
8990e5dd7070Spatrickmatches the [webView ...] message invocation.
8991e5dd7070Spatrick  NSString *webViewJavaScript = ...
8992e5dd7070Spatrick  UIWebView *webView = ...
8993e5dd7070Spatrick  [webView stringByEvaluatingJavaScriptFromString:webViewJavascript];
8994e5dd7070Spatrick</pre></td></tr>
8995e5dd7070Spatrick
8996e5dd7070Spatrick
8997e5dd7070Spatrick<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>
8998e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnyParameter1"><pre>Matches any parameter of a function or an ObjC method declaration or a
8999e5dd7070Spatrickblock.
9000e5dd7070Spatrick
9001e5dd7070SpatrickDoes not match the 'this' parameter of a method.
9002e5dd7070Spatrick
9003e5dd7070SpatrickGiven
9004e5dd7070Spatrick  class X { void f(int x, int y, int z) {} };
9005e5dd7070SpatrickcxxMethodDecl(hasAnyParameter(hasName("y")))
9006e5dd7070Spatrick  matches f(int x, int y, int z) {}
9007e5dd7070Spatrickwith hasAnyParameter(...)
9008e5dd7070Spatrick  matching int y
9009e5dd7070Spatrick
9010e5dd7070SpatrickFor ObjectiveC, given
9011e5dd7070Spatrick  @interface I - (void) f:(int) y; @end
9012e5dd7070Spatrick
9013e5dd7070Spatrickthe matcher objcMethodDecl(hasAnyParameter(hasName("y")))
9014e5dd7070Spatrickmatches the declaration of method f with hasParameter
9015e5dd7070Spatrickmatching y.
9016e5dd7070Spatrick
9017e5dd7070SpatrickFor blocks, given
9018e5dd7070Spatrick  b = ^(int y) { printf("%d", y) };
9019e5dd7070Spatrick
9020e5dd7070Spatrickthe matcher blockDecl(hasAnyParameter(hasName("y")))
9021e5dd7070Spatrickmatches the declaration of the block b with hasParameter
9022e5dd7070Spatrickmatching y.
9023e5dd7070Spatrick</pre></td></tr>
9024e5dd7070Spatrick
9025e5dd7070Spatrick
9026e5dd7070Spatrick<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>
9027e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasParameter1"><pre>Matches the n'th parameter of a function or an ObjC method
9028e5dd7070Spatrickdeclaration or a block.
9029e5dd7070Spatrick
9030e5dd7070SpatrickGiven
9031e5dd7070Spatrick  class X { void f(int x) {} };
9032e5dd7070SpatrickcxxMethodDecl(hasParameter(0, hasType(varDecl())))
9033e5dd7070Spatrick  matches f(int x) {}
9034e5dd7070Spatrickwith hasParameter(...)
9035e5dd7070Spatrick  matching int x
9036e5dd7070Spatrick
9037e5dd7070SpatrickFor ObjectiveC, given
9038e5dd7070Spatrick  @interface I - (void) f:(int) y; @end
9039e5dd7070Spatrick
9040e5dd7070Spatrickthe matcher objcMethodDecl(hasParameter(0, hasName("y")))
9041e5dd7070Spatrickmatches the declaration of method f with hasParameter
9042e5dd7070Spatrickmatching y.
9043e5dd7070Spatrick</pre></td></tr>
9044e5dd7070Spatrick
9045e5dd7070Spatrick
9046a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc11')"><a name="hasTypeLoc11Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
9047a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasTypeLoc11"><pre>Matches if the type location of a node matches the inner matcher.
9048a9ac8606Spatrick
9049a9ac8606SpatrickExamples:
9050a9ac8606Spatrick  int x;
9051a9ac8606SpatrickdeclaratorDecl(hasTypeLoc(loc(asString("int"))))
9052a9ac8606Spatrick  matches int x
9053a9ac8606Spatrick
9054a9ac8606Spatrickauto x = int(3);
9055a9ac8606SpatrickcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
9056a9ac8606Spatrick  matches int(3)
9057a9ac8606Spatrick
9058a9ac8606Spatrickstruct Foo { Foo(int, int); };
9059a9ac8606Spatrickauto x = Foo(1, 2);
9060a9ac8606SpatrickcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
9061a9ac8606Spatrick  matches Foo(1, 2)
9062a9ac8606Spatrick
9063a9ac8606SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
9064a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
9065a9ac8606Spatrick  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_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
9066a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
9067a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
9068a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
9069a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
9070a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
9071a9ac8606Spatrick</pre></td></tr>
9072a9ac8606Spatrick
9073a9ac8606Spatrick
9074e5dd7070Spatrick<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>
9075e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre>Matches if the cast's source expression
9076e5dd7070Spatrickor opaque value's source expression matches the given matcher.
9077e5dd7070Spatrick
9078e5dd7070SpatrickExample 1: matches "a string"
9079e5dd7070Spatrick(matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
9080e5dd7070Spatrickclass URL { URL(string); };
9081e5dd7070SpatrickURL url = "a string";
9082e5dd7070Spatrick
9083e5dd7070SpatrickExample 2: matches 'b' (matcher =
9084e5dd7070SpatrickopaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
9085e5dd7070Spatrickint a = b ?: 1;
9086e5dd7070Spatrick</pre></td></tr>
9087e5dd7070Spatrick
9088e5dd7070Spatrick
9089e5dd7070Spatrick<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>
9090e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnyDeclaration0"><pre>Matches an OverloadExpr if any of the declarations in the set of
9091e5dd7070Spatrickoverloads matches the given matcher.
9092e5dd7070Spatrick
9093e5dd7070SpatrickGiven
9094e5dd7070Spatrick  template &lt;typename T&gt; void foo(T);
9095e5dd7070Spatrick  template &lt;typename T&gt; void bar(T);
9096e5dd7070Spatrick  template &lt;typename T&gt; void baz(T t) {
9097e5dd7070Spatrick    foo(t);
9098e5dd7070Spatrick    bar(t);
9099e5dd7070Spatrick  }
9100e5dd7070SpatrickunresolvedLookupExpr(hasAnyDeclaration(
9101e5dd7070Spatrick    functionTemplateDecl(hasName("foo"))))
9102e5dd7070Spatrick  matches foo in foo(t); but not bar in bar(t);
9103e5dd7070Spatrick</pre></td></tr>
9104e5dd7070Spatrick
9105e5dd7070Spatrick
9106e5dd7070Spatrick<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>
9107e5dd7070Spatrick<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type.
9108e5dd7070Spatrick
9109e5dd7070SpatrickGiven
9110e5dd7070Spatrick  int (*ptr_to_array)[4];
9111e5dd7070Spatrick  int (*ptr_to_func)(int);
9112e5dd7070Spatrick
9113e5dd7070SpatrickvarDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
9114e5dd7070Spatrickptr_to_func but not ptr_to_array.
9115e5dd7070Spatrick
9116e5dd7070SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>&gt;
9117e5dd7070Spatrick</pre></td></tr>
9118e5dd7070Spatrick
9119e5dd7070Spatrick
9120*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>&gt;</td><td class="name" onclick="toggle('hasPointeeLoc0')"><a name="hasPointeeLoc0Anchor">hasPointeeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; PointeeMatcher</td></tr>
9121*12c85518Srobert<tr><td colspan="4" class="doc" id="hasPointeeLoc0"><pre>Matches pointer `TypeLoc`s that have a pointee `TypeLoc` matching
9122*12c85518Srobert`PointeeMatcher`.
9123*12c85518Srobert
9124*12c85518SrobertGiven
9125*12c85518Srobert  int* x;
9126*12c85518SrobertpointerTypeLoc(hasPointeeLoc(loc(asString("int"))))
9127*12c85518Srobert  matches `int*`.
9128*12c85518Srobert</pre></td></tr>
9129*12c85518Srobert
9130*12c85518Srobert
9131e5dd7070Spatrick<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>
9132e5dd7070Spatrick<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the
9133e5dd7070Spatrickpointee matches a given matcher.
9134e5dd7070Spatrick
9135e5dd7070SpatrickGiven
9136e5dd7070Spatrick  int *a;
9137e5dd7070Spatrick  int const *b;
9138e5dd7070Spatrick  float const *f;
9139e5dd7070SpatrickpointerType(pointee(isConstQualified(), isInteger()))
9140e5dd7070Spatrick  matches "int const *b"
9141e5dd7070Spatrick
9142e5dd7070SpatrickUsable 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;,
9143e5dd7070Spatrick  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;
9144e5dd7070Spatrick</pre></td></tr>
9145e5dd7070Spatrick
9146e5dd7070Spatrick
9147e5dd7070Spatrick<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>
9148e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher.
9149e5dd7070Spatrick
9150e5dd7070SpatrickGiven:
9151e5dd7070Spatrick  typedef int &amp;int_ref;
9152e5dd7070Spatrick  int a;
9153e5dd7070Spatrick  int_ref b = a;
9154e5dd7070Spatrick
9155e5dd7070SpatrickvarDecl(hasType(qualType(referenceType()))))) will not match the
9156e5dd7070Spatrickdeclaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does.
9157e5dd7070Spatrick</pre></td></tr>
9158e5dd7070Spatrick
9159e5dd7070Spatrick
9160ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
9161e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node
9162e5dd7070Spatrickmatches the given matcher.
9163e5dd7070Spatrick
9164e5dd7070SpatrickThe associated declaration is:
9165e5dd7070Spatrick- for type nodes, the declaration of the underlying type
9166e5dd7070Spatrick- for CallExpr, the declaration of the callee
9167e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
9168e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
9169e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
9170e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
9171e5dd7070Spatrick
9172e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
9173e5dd7070Spatricksugared type. Given
9174e5dd7070Spatrick  class X {};
9175e5dd7070Spatrick  typedef X Y;
9176e5dd7070Spatrick  Y y;
9177e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9178e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
9179e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
9180e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
9181e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
9182e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
9183e5dd7070Spatrick
9184e5dd7070SpatrickUsable 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;,
9185e5dd7070Spatrick  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;,
9186e5dd7070Spatrick  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;,
9187e5dd7070Spatrick  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;,
9188e5dd7070Spatrick  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;,
9189e5dd7070Spatrick  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;,
9190e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9191e5dd7070Spatrick</pre></td></tr>
9192e5dd7070Spatrick
9193e5dd7070Spatrick
9194e5dd7070Spatrick<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>
9195e5dd7070Spatrick<tr><td colspan="4" class="doc" id="ignoringParens0"><pre>Matches types that match InnerMatcher after any parens are stripped.
9196e5dd7070Spatrick
9197e5dd7070SpatrickGiven
9198e5dd7070Spatrick  void (*fp)(void);
9199e5dd7070SpatrickThe matcher
9200e5dd7070Spatrick  varDecl(hasType(pointerType(pointee(ignoringParens(functionType())))))
9201e5dd7070Spatrickwould match the declaration for fp.
9202e5dd7070Spatrick</pre></td></tr>
9203e5dd7070Spatrick
9204e5dd7070Spatrick
9205e5dd7070Spatrick<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>
9206e5dd7070Spatrick<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration.
9207e5dd7070Spatrick</pre></td></tr>
9208e5dd7070Spatrick
9209e5dd7070Spatrick
9210e5dd7070Spatrick<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>
9211e5dd7070Spatrick<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type
9212e5dd7070Spatrickmatches the specified matcher.
9213e5dd7070Spatrick
9214e5dd7070SpatrickExample matches y-&gt;x()
9215e5dd7070Spatrick  (matcher = cxxMemberCallExpr(on(hasType(pointsTo
9216e5dd7070Spatrick     cxxRecordDecl(hasName("Y")))))))
9217e5dd7070Spatrick  class Y { public: void x(); };
9218e5dd7070Spatrick  void z() { Y *y; y-&gt;x(); }
9219e5dd7070Spatrick</pre></td></tr>
9220e5dd7070Spatrick
9221e5dd7070Spatrick
9222e5dd7070Spatrick<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>
9223e5dd7070Spatrick<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration.
9224e5dd7070Spatrick</pre></td></tr>
9225e5dd7070Spatrick
9226e5dd7070Spatrick
9227e5dd7070Spatrick<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>
9228e5dd7070Spatrick<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced
9229e5dd7070Spatricktype matches the specified matcher.
9230e5dd7070Spatrick
9231e5dd7070SpatrickExample matches X &amp;x and const X &amp;y
9232e5dd7070Spatrick    (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X"))))))
9233e5dd7070Spatrick  class X {
9234e5dd7070Spatrick    void a(X b) {
9235e5dd7070Spatrick      X &amp;x = b;
9236e5dd7070Spatrick      const X &amp;y = b;
9237e5dd7070Spatrick    }
9238e5dd7070Spatrick  };
9239e5dd7070Spatrick</pre></td></tr>
9240e5dd7070Spatrick
9241e5dd7070Spatrick
9242*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualifiedTypeLoc.html">QualifiedTypeLoc</a>&gt;</td><td class="name" onclick="toggle('hasUnqualifiedLoc0')"><a name="hasUnqualifiedLoc0Anchor">hasUnqualifiedLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; InnerMatcher</td></tr>
9243*12c85518Srobert<tr><td colspan="4" class="doc" id="hasUnqualifiedLoc0"><pre>Matches `QualifiedTypeLoc`s that have an unqualified `TypeLoc` matching
9244*12c85518Srobert`InnerMatcher`.
9245*12c85518Srobert
9246*12c85518SrobertGiven
9247*12c85518Srobert  int* const x;
9248*12c85518Srobert  const int y;
9249*12c85518SrobertqualifiedTypeLoc(hasUnqualifiedLoc(pointerTypeLoc()))
9250*12c85518Srobert  matches the `TypeLoc` of the variable declaration of `x`, but not `y`.
9251*12c85518Srobert</pre></td></tr>
9252*12c85518Srobert
9253*12c85518Srobert
9254ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
9255e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node
9256e5dd7070Spatrickmatches the given matcher.
9257e5dd7070Spatrick
9258e5dd7070SpatrickThe associated declaration is:
9259e5dd7070Spatrick- for type nodes, the declaration of the underlying type
9260e5dd7070Spatrick- for CallExpr, the declaration of the callee
9261e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
9262e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
9263e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
9264e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
9265e5dd7070Spatrick
9266e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
9267e5dd7070Spatricksugared type. Given
9268e5dd7070Spatrick  class X {};
9269e5dd7070Spatrick  typedef X Y;
9270e5dd7070Spatrick  Y y;
9271e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9272e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
9273e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
9274e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
9275e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
9276e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
9277e5dd7070Spatrick
9278e5dd7070SpatrickUsable 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;,
9279e5dd7070Spatrick  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;,
9280e5dd7070Spatrick  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;,
9281e5dd7070Spatrick  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;,
9282e5dd7070Spatrick  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;,
9283e5dd7070Spatrick  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;,
9284e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9285e5dd7070Spatrick</pre></td></tr>
9286e5dd7070Spatrick
9287e5dd7070Spatrick
9288*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>&gt;</td><td class="name" onclick="toggle('hasReferentLoc0')"><a name="hasReferentLoc0Anchor">hasReferentLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; ReferentMatcher</td></tr>
9289*12c85518Srobert<tr><td colspan="4" class="doc" id="hasReferentLoc0"><pre>Matches reference `TypeLoc`s that have a referent `TypeLoc` matching
9290*12c85518Srobert`ReferentMatcher`.
9291*12c85518Srobert
9292*12c85518SrobertGiven
9293*12c85518Srobert  int x = 3;
9294*12c85518Srobert  int&amp; xx = x;
9295*12c85518SrobertreferenceTypeLoc(hasReferentLoc(loc(asString("int"))))
9296*12c85518Srobert  matches `int&amp;`.
9297*12c85518Srobert</pre></td></tr>
9298*12c85518Srobert
9299*12c85518Srobert
9300e5dd7070Spatrick<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>
9301e5dd7070Spatrick<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the
9302e5dd7070Spatrickpointee matches a given matcher.
9303e5dd7070Spatrick
9304e5dd7070SpatrickGiven
9305e5dd7070Spatrick  int *a;
9306e5dd7070Spatrick  int const *b;
9307e5dd7070Spatrick  float const *f;
9308e5dd7070SpatrickpointerType(pointee(isConstQualified(), isInteger()))
9309e5dd7070Spatrick  matches "int const *b"
9310e5dd7070Spatrick
9311e5dd7070SpatrickUsable 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;,
9312e5dd7070Spatrick  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;
9313e5dd7070Spatrick</pre></td></tr>
9314e5dd7070Spatrick
9315e5dd7070Spatrick
9316e5dd7070Spatrick<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>
9317e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement
9318e5dd7070Spatrick
9319e5dd7070SpatrickGiven
9320e5dd7070Spatrick  return a + b;
9321e5dd7070SpatrickhasReturnValue(binaryOperator())
9322e5dd7070Spatrick  matches 'return a + b'
9323e5dd7070Spatrickwith binaryOperator()
9324e5dd7070Spatrick  matching 'a + b'
9325e5dd7070Spatrick</pre></td></tr>
9326e5dd7070Spatrick
9327e5dd7070Spatrick
9328e5dd7070Spatrick<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>
9329e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches
9330e5dd7070Spatricka given matcher. Also matches StmtExprs that have CompoundStmt as children.
9331e5dd7070Spatrick
9332e5dd7070SpatrickGiven
9333e5dd7070Spatrick  { {}; 1+2; }
9334e5dd7070SpatrickhasAnySubstatement(compoundStmt())
9335e5dd7070Spatrick  matches '{ {}; 1+2; }'
9336e5dd7070Spatrickwith compoundStmt()
9337e5dd7070Spatrick  matching '{}'
9338e5dd7070Spatrick</pre></td></tr>
9339e5dd7070Spatrick
9340e5dd7070Spatrick
9341ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt;  InnerMatcher</td></tr>
9342e5dd7070Spatrick<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
9343e5dd7070Spatrickalignof.
9344e5dd7070Spatrick</pre></td></tr>
9345e5dd7070Spatrick
9346e5dd7070Spatrick
9347a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('forCallable0')"><a name="forCallable0Anchor">forCallable</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
9348a9ac8606Spatrick<tr><td colspan="4" class="doc" id="forCallable0"><pre>Matches declaration of the function, method, or block the statement
9349a9ac8606Spatrickbelongs to.
9350a9ac8606Spatrick
9351a9ac8606SpatrickGiven:
9352a9ac8606SpatrickF&amp; operator=(const F&amp; o) {
9353a9ac8606Spatrick  std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v &gt; 0; });
9354a9ac8606Spatrick  return *this;
9355a9ac8606Spatrick}
9356a9ac8606SpatrickreturnStmt(forCallable(functionDecl(hasName("operator="))))
9357a9ac8606Spatrick  matches 'return *this'
9358a9ac8606Spatrick  but does not match 'return v &gt; 0'
9359a9ac8606Spatrick
9360a9ac8606SpatrickGiven:
9361a9ac8606Spatrick-(void) foo {
9362a9ac8606Spatrick  int x = 1;
9363a9ac8606Spatrick  dispatch_sync(queue, ^{ int y = 2; });
9364a9ac8606Spatrick}
9365a9ac8606SpatrickdeclStmt(forCallable(objcMethodDecl()))
9366a9ac8606Spatrick  matches 'int x = 1'
9367a9ac8606Spatrick  but does not match 'int y = 2'.
9368a9ac8606Spatrickwhereas declStmt(forCallable(blockDecl()))
9369a9ac8606Spatrick  matches 'int y = 2'
9370a9ac8606Spatrick  but does not match 'int x = 1'.
9371a9ac8606Spatrick</pre></td></tr>
9372a9ac8606Spatrick
9373a9ac8606Spatrick
9374e5dd7070Spatrick<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>
9375a9ac8606Spatrick<tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statement belongs to.
9376a9ac8606Spatrick
9377a9ac8606SpatrickDeprecated. Use forCallable() to correctly handle the situation when
9378a9ac8606Spatrickthe declaration is not a function (but a block or an Objective-C method).
9379a9ac8606SpatrickforFunction() not only fails to take non-functions into account but also
9380a9ac8606Spatrickmay match the wrong declaration in their presence.
9381e5dd7070Spatrick
9382e5dd7070SpatrickGiven:
9383e5dd7070SpatrickF&amp; operator=(const F&amp; o) {
9384e5dd7070Spatrick  std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v &gt; 0; });
9385e5dd7070Spatrick  return *this;
9386e5dd7070Spatrick}
9387e5dd7070SpatrickreturnStmt(forFunction(hasName("operator=")))
9388e5dd7070Spatrick  matches 'return *this'
9389e5dd7070Spatrick  but does not match 'return v &gt; 0'
9390e5dd7070Spatrick</pre></td></tr>
9391e5dd7070Spatrick
9392e5dd7070Spatrick
9393ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>&gt;  InnerMatcher</td></tr>
9394e5dd7070Spatrick<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
9395e5dd7070Spatricksizeof.
9396e5dd7070Spatrick</pre></td></tr>
9397e5dd7070Spatrick
9398e5dd7070Spatrick
9399e5dd7070Spatrick<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>
9400e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasReplacementType0"><pre>Matches template type parameter substitutions that have a replacement
9401e5dd7070Spatricktype that matches the provided matcher.
9402e5dd7070Spatrick
9403e5dd7070SpatrickGiven
9404e5dd7070Spatrick  template &lt;typename T&gt;
9405e5dd7070Spatrick  double F(T t);
9406e5dd7070Spatrick  int i;
9407e5dd7070Spatrick  double j = F(i);
9408e5dd7070Spatrick
9409e5dd7070SpatricksubstTemplateTypeParmType(hasReplacementType(type())) matches int
9410e5dd7070Spatrick</pre></td></tr>
9411e5dd7070Spatrick
9412e5dd7070Spatrick
9413e5dd7070Spatrick<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>
9414e5dd7070Spatrick<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch
9415e5dd7070Spatrickstatement. This matcher may produce multiple matches.
9416e5dd7070Spatrick
9417e5dd7070SpatrickGiven
9418e5dd7070Spatrick  switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }
9419e5dd7070SpatrickswitchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s")
9420e5dd7070Spatrick  matches four times, with "c" binding each of "case 1:", "case 2:",
9421e5dd7070Spatrick"case 3:" and "case 4:", and "s" respectively binding "switch (1)",
9422e5dd7070Spatrick"switch (1)", "switch (2)" and "switch (2)".
9423e5dd7070Spatrick</pre></td></tr>
9424e5dd7070Spatrick
9425e5dd7070Spatrick
9426e5dd7070Spatrick<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>
9427e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop,
9428e5dd7070Spatrickswitch statement or conditional operator.
9429e5dd7070Spatrick
9430e5dd7070SpatrickExample matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
9431e5dd7070Spatrick  if (true) {}
9432e5dd7070Spatrick</pre></td></tr>
9433e5dd7070Spatrick
9434e5dd7070Spatrick
9435e5dd7070Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>&gt;</td><td class="name" onclick="toggle('hasInitStatement1')"><a name="hasInitStatement1Anchor">hasInitStatement</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
9436e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasInitStatement1"><pre>Matches selection statements with initializer.
9437e5dd7070Spatrick
9438e5dd7070SpatrickGiven:
9439e5dd7070Spatrick void foo() {
9440e5dd7070Spatrick   if (int i = foobar(); i &gt; 0) {}
9441e5dd7070Spatrick   switch (int i = foobar(); i) {}
9442e5dd7070Spatrick   for (auto&amp; a = get_range(); auto&amp; x : a) {}
9443e5dd7070Spatrick }
9444e5dd7070Spatrick void bar() {
9445e5dd7070Spatrick   if (foobar() &gt; 0) {}
9446e5dd7070Spatrick   switch (foobar()) {}
9447e5dd7070Spatrick   for (auto&amp; x : get_range()) {}
9448e5dd7070Spatrick }
9449e5dd7070SpatrickifStmt(hasInitStatement(anything()))
9450e5dd7070Spatrick  matches the if statement in foo but not in bar.
9451e5dd7070SpatrickswitchStmt(hasInitStatement(anything()))
9452e5dd7070Spatrick  matches the switch statement in foo but not in bar.
9453e5dd7070SpatrickcxxForRangeStmt(hasInitStatement(anything()))
9454e5dd7070Spatrick  matches the range for statement in foo but not in bar.
9455e5dd7070Spatrick</pre></td></tr>
9456e5dd7070Spatrick
9457e5dd7070Spatrick
9458ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
9459e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node
9460e5dd7070Spatrickmatches the given matcher.
9461e5dd7070Spatrick
9462e5dd7070SpatrickThe associated declaration is:
9463e5dd7070Spatrick- for type nodes, the declaration of the underlying type
9464e5dd7070Spatrick- for CallExpr, the declaration of the callee
9465e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
9466e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
9467e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
9468e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
9469e5dd7070Spatrick
9470e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
9471e5dd7070Spatricksugared type. Given
9472e5dd7070Spatrick  class X {};
9473e5dd7070Spatrick  typedef X Y;
9474e5dd7070Spatrick  Y y;
9475e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9476e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
9477e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
9478e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
9479e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
9480e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
9481e5dd7070Spatrick
9482e5dd7070SpatrickUsable 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;,
9483e5dd7070Spatrick  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;,
9484e5dd7070Spatrick  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;,
9485e5dd7070Spatrick  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;,
9486e5dd7070Spatrick  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;,
9487e5dd7070Spatrick  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;,
9488e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9489e5dd7070Spatrick</pre></td></tr>
9490e5dd7070Spatrick
9491e5dd7070Spatrick
9492a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc12')"><a name="hasTypeLoc12Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
9493a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasTypeLoc12"><pre>Matches if the type location of a node matches the inner matcher.
9494a9ac8606Spatrick
9495a9ac8606SpatrickExamples:
9496a9ac8606Spatrick  int x;
9497a9ac8606SpatrickdeclaratorDecl(hasTypeLoc(loc(asString("int"))))
9498a9ac8606Spatrick  matches int x
9499a9ac8606Spatrick
9500a9ac8606Spatrickauto x = int(3);
9501a9ac8606SpatrickcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
9502a9ac8606Spatrick  matches int(3)
9503a9ac8606Spatrick
9504a9ac8606Spatrickstruct Foo { Foo(int, int); };
9505a9ac8606Spatrickauto x = Foo(1, 2);
9506a9ac8606SpatrickcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
9507a9ac8606Spatrick  matches Foo(1, 2)
9508a9ac8606Spatrick
9509a9ac8606SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
9510a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
9511a9ac8606Spatrick  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_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
9512a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
9513a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
9514a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
9515a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
9516a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
9517a9ac8606Spatrick</pre></td></tr>
9518a9ac8606Spatrick
9519a9ac8606Spatrick
9520e5dd7070Spatrick<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>
9521e5dd7070Spatrick<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression.
9522e5dd7070Spatrick
9523e5dd7070SpatrickGiven
9524e5dd7070Spatrick  struct B { int next; };
9525e5dd7070Spatrick  template&lt;int(B::*next_ptr)&gt; struct A {};
9526e5dd7070Spatrick  A&lt;&amp;B::next&gt; a;
9527e5dd7070SpatricktemplateSpecializationType(hasAnyTemplateArgument(
9528e5dd7070Spatrick  isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next"))))))))
9529e5dd7070Spatrick  matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
9530e5dd7070Spatrick    B::next
9531e5dd7070Spatrick</pre></td></tr>
9532e5dd7070Spatrick
9533e5dd7070Spatrick
9534e5dd7070Spatrick<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>
9535e5dd7070Spatrick<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain
9536e5dd7070Spatrickdeclaration.
9537e5dd7070Spatrick
9538e5dd7070SpatrickGiven
9539e5dd7070Spatrick  struct B { int next; };
9540e5dd7070Spatrick  template&lt;int(B::*next_ptr)&gt; struct A {};
9541e5dd7070Spatrick  A&lt;&amp;B::next&gt; a;
9542e5dd7070SpatrickclassTemplateSpecializationDecl(hasAnyTemplateArgument(
9543e5dd7070Spatrick    refersToDeclaration(fieldDecl(hasName("next")))))
9544e5dd7070Spatrick  matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
9545e5dd7070Spatrick    B::next
9546e5dd7070Spatrick</pre></td></tr>
9547e5dd7070Spatrick
9548e5dd7070Spatrick
9549e5dd7070Spatrick<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>
9550a9ac8606Spatrick<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that refers to an integral type.
9551e5dd7070Spatrick
9552e5dd7070SpatrickGiven
9553e5dd7070Spatrick  template&lt;int T&gt; struct C {};
9554e5dd7070Spatrick  C&lt;42&gt; c;
9555e5dd7070SpatrickclassTemplateSpecializationDecl(
9556e5dd7070Spatrick  hasAnyTemplateArgument(refersToIntegralType(asString("int"))))
9557e5dd7070Spatrick  matches the implicit instantiation of C in C&lt;42&gt;.
9558e5dd7070Spatrick</pre></td></tr>
9559e5dd7070Spatrick
9560e5dd7070Spatrick
9561e5dd7070Spatrick<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>
9562e5dd7070Spatrick<tr><td colspan="4" class="doc" id="refersToTemplate0"><pre>Matches a TemplateArgument that refers to a certain template.
9563e5dd7070Spatrick
9564e5dd7070SpatrickGiven
9565e5dd7070Spatrick  template&lt;template &lt;typename&gt; class S&gt; class X {};
9566e5dd7070Spatrick  template&lt;typename T&gt; class Y {};
9567e5dd7070Spatrick  X&lt;Y&gt; xi;
9568e5dd7070SpatrickclassTemplateSpecializationDecl(hasAnyTemplateArgument(
9569e5dd7070Spatrick    refersToTemplate(templateName())))
9570e5dd7070Spatrick  matches the specialization X&lt;Y&gt;
9571e5dd7070Spatrick</pre></td></tr>
9572e5dd7070Spatrick
9573e5dd7070Spatrick
9574e5dd7070Spatrick<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>
9575e5dd7070Spatrick<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type.
9576e5dd7070Spatrick
9577e5dd7070SpatrickGiven
9578e5dd7070Spatrick  struct X {};
9579e5dd7070Spatrick  template&lt;typename T&gt; struct A {};
9580e5dd7070Spatrick  A&lt;X&gt; a;
9581*12c85518SrobertclassTemplateSpecializationDecl(hasAnyTemplateArgument(refersToType(
9582*12c85518Srobert  recordType(hasDeclaration(recordDecl(hasName("X")))))))
9583*12c85518Srobertmatches the specialization of struct A generated by A&lt;X&gt;.
9584*12c85518Srobert</pre></td></tr>
9585*12c85518Srobert
9586*12c85518Srobert
9587*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>&gt;</td><td class="name" onclick="toggle('hasAnyTemplateArgumentLoc0')"><a name="hasAnyTemplateArgumentLoc0Anchor">hasAnyTemplateArgumentLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt; InnerMatcher</td></tr>
9588*12c85518Srobert<tr><td colspan="4" class="doc" id="hasAnyTemplateArgumentLoc0"><pre>Matches template specialization `TypeLoc`s that have at least one
9589*12c85518Srobert`TemplateArgumentLoc` matching the given `InnerMatcher`.
9590*12c85518Srobert
9591*12c85518SrobertGiven
9592*12c85518Srobert  template&lt;typename T&gt; class A {};
9593*12c85518Srobert  A&lt;int&gt; a;
9594*12c85518SrobertvarDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc(
9595*12c85518Srobert  hasTypeLoc(loc(asString("int")))))))
9596*12c85518Srobert  matches `A&lt;int&gt; a`.
9597*12c85518Srobert</pre></td></tr>
9598*12c85518Srobert
9599*12c85518Srobert
9600*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>&gt;</td><td class="name" onclick="toggle('hasTemplateArgumentLoc1')"><a name="hasTemplateArgumentLoc1Anchor">hasTemplateArgumentLoc</a></td><td>unsigned Index, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt; InnerMatcher</td></tr>
9601*12c85518Srobert<tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc1"><pre>Matches template specialization `TypeLoc`s where the n'th
9602*12c85518Srobert`TemplateArgumentLoc` matches the given `InnerMatcher`.
9603*12c85518Srobert
9604*12c85518SrobertGiven
9605*12c85518Srobert  template&lt;typename T, typename U&gt; class A {};
9606*12c85518Srobert  A&lt;double, int&gt; b;
9607*12c85518Srobert  A&lt;int, double&gt; c;
9608*12c85518SrobertvarDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
9609*12c85518Srobert  hasTypeLoc(loc(asString("double")))))))
9610*12c85518Srobert  matches `A&lt;double, int&gt; b`, but not `A&lt;int, double&gt; c`.
9611*12c85518Srobert</pre></td></tr>
9612*12c85518Srobert
9613*12c85518Srobert
9614*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('forEachTemplateArgument1')"><a name="forEachTemplateArgument1Anchor">forEachTemplateArgument</a></td><td>clang::ast_matchers::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
9615*12c85518Srobert<tr><td colspan="4" class="doc" id="forEachTemplateArgument1"><pre>Matches classTemplateSpecialization, templateSpecializationType and
9616*12c85518SrobertfunctionDecl nodes where the template argument matches the inner matcher.
9617*12c85518SrobertThis matcher may produce multiple matches.
9618*12c85518Srobert
9619*12c85518SrobertGiven
9620*12c85518Srobert  template &lt;typename T, unsigned N, unsigned M&gt;
9621*12c85518Srobert  struct Matrix {};
9622*12c85518Srobert
9623*12c85518Srobert  constexpr unsigned R = 2;
9624*12c85518Srobert  Matrix&lt;int, R * 2, R * 4&gt; M;
9625*12c85518Srobert
9626*12c85518Srobert  template &lt;typename T, typename U&gt;
9627*12c85518Srobert  void f(T&amp;&amp; t, U&amp;&amp; u) {}
9628*12c85518Srobert
9629*12c85518Srobert  bool B = false;
9630*12c85518Srobert  f(R, B);
9631*12c85518SroberttemplateSpecializationType(forEachTemplateArgument(isExpr(expr())))
9632*12c85518Srobert  matches twice, with expr() matching 'R * 2' and 'R * 4'
9633*12c85518SrobertfunctionDecl(forEachTemplateArgument(refersToType(builtinType())))
9634*12c85518Srobert  matches the specialization f&lt;unsigned, bool&gt; twice, for 'unsigned'
9635*12c85518Srobert  and 'bool'
9636e5dd7070Spatrick</pre></td></tr>
9637e5dd7070Spatrick
9638e5dd7070Spatrick
9639e5dd7070Spatrick<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>
9640e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and
9641e5dd7070SpatrickfunctionDecl that have at least one TemplateArgument matching the given
9642e5dd7070SpatrickInnerMatcher.
9643e5dd7070Spatrick
9644e5dd7070SpatrickGiven
9645e5dd7070Spatrick  template&lt;typename T&gt; class A {};
9646e5dd7070Spatrick  template&lt;&gt; class A&lt;double&gt; {};
9647e5dd7070Spatrick  A&lt;int&gt; a;
9648e5dd7070Spatrick
9649e5dd7070Spatrick  template&lt;typename T&gt; f() {};
9650e5dd7070Spatrick  void func() { f&lt;int&gt;(); };
9651e5dd7070Spatrick
9652e5dd7070SpatrickclassTemplateSpecializationDecl(hasAnyTemplateArgument(
9653e5dd7070Spatrick    refersToType(asString("int"))))
9654e5dd7070Spatrick  matches the specialization A&lt;int&gt;
9655e5dd7070Spatrick
9656e5dd7070SpatrickfunctionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
9657e5dd7070Spatrick  matches the specialization f&lt;int&gt;
9658e5dd7070Spatrick</pre></td></tr>
9659e5dd7070Spatrick
9660e5dd7070Spatrick
9661ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
9662e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node
9663e5dd7070Spatrickmatches the given matcher.
9664e5dd7070Spatrick
9665e5dd7070SpatrickThe associated declaration is:
9666e5dd7070Spatrick- for type nodes, the declaration of the underlying type
9667e5dd7070Spatrick- for CallExpr, the declaration of the callee
9668e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
9669e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
9670e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
9671e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
9672e5dd7070Spatrick
9673e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
9674e5dd7070Spatricksugared type. Given
9675e5dd7070Spatrick  class X {};
9676e5dd7070Spatrick  typedef X Y;
9677e5dd7070Spatrick  Y y;
9678e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9679e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
9680e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
9681e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
9682e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
9683e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
9684e5dd7070Spatrick
9685e5dd7070SpatrickUsable 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;,
9686e5dd7070Spatrick  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;,
9687e5dd7070Spatrick  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;,
9688e5dd7070Spatrick  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;,
9689e5dd7070Spatrick  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;,
9690e5dd7070Spatrick  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;,
9691e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9692e5dd7070Spatrick</pre></td></tr>
9693e5dd7070Spatrick
9694e5dd7070Spatrick
9695e5dd7070Spatrick<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>
9696e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and
9697e5dd7070SpatrickfunctionDecl where the n'th TemplateArgument matches the given InnerMatcher.
9698e5dd7070Spatrick
9699e5dd7070SpatrickGiven
9700e5dd7070Spatrick  template&lt;typename T, typename U&gt; class A {};
9701e5dd7070Spatrick  A&lt;bool, int&gt; b;
9702e5dd7070Spatrick  A&lt;int, bool&gt; c;
9703e5dd7070Spatrick
9704e5dd7070Spatrick  template&lt;typename T&gt; void f() {}
9705e5dd7070Spatrick  void func() { f&lt;int&gt;(); };
9706e5dd7070SpatrickclassTemplateSpecializationDecl(hasTemplateArgument(
9707e5dd7070Spatrick    1, refersToType(asString("int"))))
9708e5dd7070Spatrick  matches the specialization A&lt;bool, int&gt;
9709e5dd7070Spatrick
9710e5dd7070SpatrickfunctionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
9711e5dd7070Spatrick  matches the specialization f&lt;int&gt;
9712e5dd7070Spatrick</pre></td></tr>
9713e5dd7070Spatrick
9714e5dd7070Spatrick
9715ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
9716e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node
9717e5dd7070Spatrickmatches the given matcher.
9718e5dd7070Spatrick
9719e5dd7070SpatrickThe associated declaration is:
9720e5dd7070Spatrick- for type nodes, the declaration of the underlying type
9721e5dd7070Spatrick- for CallExpr, the declaration of the callee
9722e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
9723e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
9724e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
9725e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
9726e5dd7070Spatrick
9727e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
9728e5dd7070Spatricksugared type. Given
9729e5dd7070Spatrick  class X {};
9730e5dd7070Spatrick  typedef X Y;
9731e5dd7070Spatrick  Y y;
9732e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9733e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
9734e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
9735e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
9736e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
9737e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
9738e5dd7070Spatrick
9739e5dd7070SpatrickUsable 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;,
9740e5dd7070Spatrick  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;,
9741e5dd7070Spatrick  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;,
9742e5dd7070Spatrick  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;,
9743e5dd7070Spatrick  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;,
9744e5dd7070Spatrick  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;,
9745e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9746e5dd7070Spatrick</pre></td></tr>
9747e5dd7070Spatrick
9748e5dd7070Spatrick
9749ec727ea7Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('loc0')"><a name="loc0Anchor">loc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>&gt; InnerMatcher</td></tr>
9750ec727ea7Spatrick<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner
9751ec727ea7SpatrickQualType-matcher matches.
9752e5dd7070Spatrick</pre></td></tr>
9753e5dd7070Spatrick
9754e5dd7070Spatrick
9755a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc13')"><a name="hasTypeLoc13Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
9756a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasTypeLoc13"><pre>Matches if the type location of a node matches the inner matcher.
9757a9ac8606Spatrick
9758a9ac8606SpatrickExamples:
9759a9ac8606Spatrick  int x;
9760a9ac8606SpatrickdeclaratorDecl(hasTypeLoc(loc(asString("int"))))
9761a9ac8606Spatrick  matches int x
9762a9ac8606Spatrick
9763a9ac8606Spatrickauto x = int(3);
9764a9ac8606SpatrickcxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
9765a9ac8606Spatrick  matches int(3)
9766a9ac8606Spatrick
9767a9ac8606Spatrickstruct Foo { Foo(int, int); };
9768a9ac8606Spatrickauto x = Foo(1, 2);
9769a9ac8606SpatrickcxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
9770a9ac8606Spatrick  matches Foo(1, 2)
9771a9ac8606Spatrick
9772a9ac8606SpatrickUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
9773a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
9774a9ac8606Spatrick  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_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
9775a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
9776a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
9777a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
9778a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
9779a9ac8606Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
9780a9ac8606Spatrick</pre></td></tr>
9781a9ac8606Spatrick
9782a9ac8606Spatrick
9783e5dd7070Spatrick<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>
9784e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type
9785e5dd7070Spatrickmatcher.
9786e5dd7070Spatrick
9787e5dd7070SpatrickExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
9788e5dd7070Spatrick            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
9789e5dd7070Spatrick            and U (matcher = typedefDecl(hasType(asString("int")))
9790e5dd7070Spatrick            and friend class X (matcher = friendDecl(hasType("X"))
9791a9ac8606Spatrick            and public virtual X (matcher = cxxBaseSpecifier(hasType(
9792a9ac8606Spatrick                                              asString("class X")))
9793e5dd7070Spatrick class X {};
9794e5dd7070Spatrick void y(X &amp;x) { x; X z; }
9795e5dd7070Spatrick typedef int U;
9796e5dd7070Spatrick class Y { friend class X; };
9797a9ac8606Spatrick class Z : public virtual X {};
9798e5dd7070Spatrick</pre></td></tr>
9799e5dd7070Spatrick
9800e5dd7070Spatrick
9801ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
9802e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node
9803e5dd7070Spatrickmatches the given matcher.
9804e5dd7070Spatrick
9805e5dd7070SpatrickThe associated declaration is:
9806e5dd7070Spatrick- for type nodes, the declaration of the underlying type
9807e5dd7070Spatrick- for CallExpr, the declaration of the callee
9808e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
9809e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
9810e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
9811e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
9812e5dd7070Spatrick
9813e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
9814e5dd7070Spatricksugared type. Given
9815e5dd7070Spatrick  class X {};
9816e5dd7070Spatrick  typedef X Y;
9817e5dd7070Spatrick  Y y;
9818e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9819e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
9820e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
9821e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
9822e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
9823e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
9824e5dd7070Spatrick
9825e5dd7070SpatrickUsable 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;,
9826e5dd7070Spatrick  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;,
9827e5dd7070Spatrick  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;,
9828e5dd7070Spatrick  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;,
9829e5dd7070Spatrick  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;,
9830e5dd7070Spatrick  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;,
9831e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9832e5dd7070Spatrick</pre></td></tr>
9833e5dd7070Spatrick
9834e5dd7070Spatrick
9835e5dd7070Spatrick<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>
9836e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasUnqualifiedDesugaredType0"><pre>Matches if the matched type matches the unqualified desugared
9837e5dd7070Spatricktype of the matched node.
9838e5dd7070Spatrick
9839e5dd7070SpatrickFor example, in:
9840e5dd7070Spatrick  class A {};
9841e5dd7070Spatrick  using B = A;
9842e5dd7070SpatrickThe matcher type(hasUnqualifiedDesugaredType(recordType())) matches
9843e5dd7070Spatrickboth B and A.
9844e5dd7070Spatrick</pre></td></tr>
9845e5dd7070Spatrick
9846e5dd7070Spatrick
9847e5dd7070Spatrick<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>
9848e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument.
9849e5dd7070Spatrick
9850e5dd7070SpatrickGiven
9851e5dd7070Spatrick  int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
9852e5dd7070SpatrickunaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
9853e5dd7070Spatrick  matches sizeof(a) and alignof(c)
9854e5dd7070Spatrick</pre></td></tr>
9855e5dd7070Spatrick
9856e5dd7070Spatrick
9857e5dd7070Spatrick<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>
9858e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches.
9859e5dd7070Spatrick
9860e5dd7070SpatrickExample matches true (matcher = hasUnaryOperand(
9861e5dd7070Spatrick                                  cxxBoolLiteral(equals(true))))
9862e5dd7070Spatrick  !true
9863e5dd7070Spatrick</pre></td></tr>
9864e5dd7070Spatrick
9865e5dd7070Spatrick
9866e5dd7070Spatrick<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>
9867e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasObjectExpression1"><pre>Matches a member expression where the object expression is matched by a
9868e5dd7070Spatrickgiven matcher. Implicit object expressions are included; that is, it matches
9869e5dd7070Spatrickuse of implicit `this`.
9870e5dd7070Spatrick
9871e5dd7070SpatrickGiven
9872e5dd7070Spatrick  struct X {
9873e5dd7070Spatrick    int m;
9874e5dd7070Spatrick    int f(X x) { x.m; return m; }
9875e5dd7070Spatrick  };
9876e5dd7070SpatrickmemberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))
9877e5dd7070Spatrick  matches `x.m`, but not `m`; however,
9878e5dd7070SpatrickmemberExpr(hasObjectExpression(hasType(pointsTo(
9879e5dd7070Spatrick     cxxRecordDecl(hasName("X"))))))
9880e5dd7070Spatrick  matches `m` (aka. `this-&gt;m`), but not `x.m`.
9881e5dd7070Spatrick</pre></td></tr>
9882e5dd7070Spatrick
9883e5dd7070Spatrick
9884ec727ea7Spatrick<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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;  InnerMatcher</td></tr>
9885e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node
9886e5dd7070Spatrickmatches the given matcher.
9887e5dd7070Spatrick
9888e5dd7070SpatrickThe associated declaration is:
9889e5dd7070Spatrick- for type nodes, the declaration of the underlying type
9890e5dd7070Spatrick- for CallExpr, the declaration of the callee
9891e5dd7070Spatrick- for MemberExpr, the declaration of the referenced member
9892e5dd7070Spatrick- for CXXConstructExpr, the declaration of the constructor
9893e5dd7070Spatrick- for CXXNewExpr, the declaration of the operator new
9894e5dd7070Spatrick- for ObjCIvarExpr, the declaration of the ivar
9895e5dd7070Spatrick
9896e5dd7070SpatrickFor type nodes, hasDeclaration will generally match the declaration of the
9897e5dd7070Spatricksugared type. Given
9898e5dd7070Spatrick  class X {};
9899e5dd7070Spatrick  typedef X Y;
9900e5dd7070Spatrick  Y y;
9901e5dd7070Spatrickin varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9902e5dd7070SpatricktypedefDecl. A common use case is to match the underlying, desugared type.
9903e5dd7070SpatrickThis can be achieved by using the hasUnqualifiedDesugaredType matcher:
9904e5dd7070Spatrick  varDecl(hasType(hasUnqualifiedDesugaredType(
9905e5dd7070Spatrick      recordType(hasDeclaration(decl())))))
9906e5dd7070SpatrickIn this matcher, the decl will match the CXXRecordDecl of class X.
9907e5dd7070Spatrick
9908e5dd7070SpatrickUsable 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;,
9909e5dd7070Spatrick  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;,
9910e5dd7070Spatrick  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;,
9911e5dd7070Spatrick  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;,
9912e5dd7070Spatrick  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;,
9913e5dd7070Spatrick  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;,
9914e5dd7070Spatrick  Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9915e5dd7070Spatrick</pre></td></tr>
9916e5dd7070Spatrick
9917e5dd7070Spatrick
9918e5dd7070Spatrick<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>
9919e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is
9920e5dd7070Spatrickmatched by the given matcher.
9921e5dd7070Spatrick
9922e5dd7070SpatrickGiven
9923e5dd7070Spatrick  namespace X { int a; void b(); }
9924e5dd7070Spatrick  using X::a;
9925e5dd7070Spatrick  using X::b;
9926e5dd7070SpatrickusingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
9927e5dd7070Spatrick  matches using X::b but not using X::a </pre></td></tr>
9928e5dd7070Spatrick
9929e5dd7070Spatrick
9930*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>&gt;</td><td class="name" onclick="toggle('hasUnderlyingType1')"><a name="hasUnderlyingType1Anchor">hasUnderlyingType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td></tr>
9931*12c85518Srobert<tr><td colspan="4" class="doc" id="hasUnderlyingType1"><pre>Matches DecltypeType or UsingType nodes to find the underlying type.
9932*12c85518Srobert
9933*12c85518SrobertGiven
9934*12c85518Srobert  decltype(1) a = 1;
9935*12c85518Srobert  decltype(2.0) b = 2.0;
9936*12c85518SrobertdecltypeType(hasUnderlyingType(isInteger()))
9937*12c85518Srobert  matches the type of "a"
9938*12c85518Srobert
9939*12c85518SrobertUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>&gt;
9940*12c85518Srobert</pre></td></tr>
9941*12c85518Srobert
9942*12c85518Srobert
9943*12c85518Srobert<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>&gt;</td><td class="name" onclick="toggle('throughUsingDecl1')"><a name="throughUsingDecl1Anchor">throughUsingDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>&gt; Inner</td></tr>
9944*12c85518Srobert<tr><td colspan="4" class="doc" id="throughUsingDecl1"><pre>Matches if a node refers to a declaration through a specific
9945*12c85518Srobertusing shadow declaration.
9946*12c85518Srobert
9947*12c85518SrobertExamples:
9948*12c85518Srobert  namespace a { int f(); }
9949*12c85518Srobert  using a::f;
9950*12c85518Srobert  int x = f();
9951*12c85518SrobertdeclRefExpr(throughUsingDecl(anything()))
9952*12c85518Srobert  matches f
9953*12c85518Srobert
9954*12c85518Srobert  namespace a { class X{}; }
9955*12c85518Srobert  using a::X;
9956*12c85518Srobert  X x;
9957*12c85518SroberttypeLoc(loc(usingType(throughUsingDecl(anything()))))
9958*12c85518Srobert  matches X
9959*12c85518Srobert
9960*12c85518SrobertUsable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>&gt;
9961*12c85518Srobert</pre></td></tr>
9962*12c85518Srobert
9963*12c85518Srobert
9964a9ac8606Spatrick<tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;</td><td class="name" onclick="toggle('hasType7')"><a name="hasType7Anchor">hasType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
9965a9ac8606Spatrick<tr><td colspan="4" class="doc" id="hasType7"><pre>Overloaded to match the declaration of the expression's or value
9966e5dd7070Spatrickdeclaration's type.
9967e5dd7070Spatrick
9968e5dd7070SpatrickIn case of a value declaration (for example a variable declaration),
9969e5dd7070Spatrickthis resolves one layer of indirection. For example, in the value
9970e5dd7070Spatrickdeclaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
9971e5dd7070SpatrickX, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
9972e5dd7070Spatrickdeclaration of x.
9973e5dd7070Spatrick
9974e5dd7070SpatrickExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
9975e5dd7070Spatrick            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
9976e5dd7070Spatrick            and friend class X (matcher = friendDecl(hasType("X"))
9977a9ac8606Spatrick            and public virtual X (matcher = cxxBaseSpecifier(hasType(
9978a9ac8606Spatrick                                              cxxRecordDecl(hasName("X"))))
9979e5dd7070Spatrick class X {};
9980e5dd7070Spatrick void y(X &amp;x) { x; X z; }
9981e5dd7070Spatrick class Y { friend class X; };
9982a9ac8606Spatrick class Z : public virtual X {};
9983e5dd7070Spatrick
9984ec727ea7SpatrickExample matches class Derived
9985ec727ea7Spatrick(matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
9986ec727ea7Spatrickclass Base {};
9987ec727ea7Spatrickclass Derived : Base {};
9988ec727ea7Spatrick
9989ec727ea7SpatrickUsable 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_1FriendDecl.html">FriendDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>&gt;,
9990ec727ea7SpatrickMatcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
9991e5dd7070Spatrick</pre></td></tr>
9992e5dd7070Spatrick
9993e5dd7070Spatrick
9994e5dd7070Spatrick<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>
9995e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasType3"><pre>Matches if the expression's or declaration's type matches a type
9996e5dd7070Spatrickmatcher.
9997e5dd7070Spatrick
9998e5dd7070SpatrickExample matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
9999e5dd7070Spatrick            and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
10000e5dd7070Spatrick            and U (matcher = typedefDecl(hasType(asString("int")))
10001e5dd7070Spatrick            and friend class X (matcher = friendDecl(hasType("X"))
10002a9ac8606Spatrick            and public virtual X (matcher = cxxBaseSpecifier(hasType(
10003a9ac8606Spatrick                                              asString("class X")))
10004e5dd7070Spatrick class X {};
10005e5dd7070Spatrick void y(X &amp;x) { x; X z; }
10006e5dd7070Spatrick typedef int U;
10007e5dd7070Spatrick class Y { friend class X; };
10008a9ac8606Spatrick class Z : public virtual X {};
10009e5dd7070Spatrick</pre></td></tr>
10010e5dd7070Spatrick
10011e5dd7070Spatrick
10012e5dd7070Spatrick<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>
10013e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression
10014e5dd7070Spatrickthat matches the given matcher.
10015e5dd7070Spatrick
10016e5dd7070SpatrickExample matches x (matcher = varDecl(hasInitializer(callExpr())))
10017e5dd7070Spatrick  bool y() { return true; }
10018e5dd7070Spatrick  bool x = y();
10019e5dd7070Spatrick</pre></td></tr>
10020e5dd7070Spatrick
10021e5dd7070Spatrick
10022e5dd7070Spatrick<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>
10023e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size
10024e5dd7070Spatrickexpression.
10025e5dd7070Spatrick
10026e5dd7070SpatrickGiven
10027e5dd7070Spatrick  void f(int b) {
10028e5dd7070Spatrick    int a[b];
10029e5dd7070Spatrick  }
10030e5dd7070SpatrickvariableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
10031e5dd7070Spatrick  varDecl(hasName("b")))))))
10032e5dd7070Spatrick  matches "int a[b]"
10033e5dd7070Spatrick</pre></td></tr>
10034e5dd7070Spatrick
10035e5dd7070Spatrick
10036e5dd7070Spatrick<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>
10037*12c85518Srobert<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', 'do' statement or a function definition that has
10038*12c85518Sroberta given body. Note that in case of functions this matcher only matches the
10039*12c85518Srobertdefinition itself and not the other declarations of the same function.
10040*12c85518Srobert
10041*12c85518SrobertGiven
10042*12c85518Srobert  for (;;) {}
10043*12c85518SrobertforStmt(hasBody(compoundStmt()))
10044*12c85518Srobert  matches 'for (;;) {}'
10045*12c85518Srobertwith compoundStmt()
10046*12c85518Srobert  matching '{}'
10047*12c85518Srobert
10048*12c85518SrobertGiven
10049*12c85518Srobert  void f();
10050*12c85518Srobert  void f() {}
10051*12c85518SrobertfunctionDecl(hasBody(compoundStmt()))
10052*12c85518Srobert  matches 'void f() {}'
10053*12c85518Srobertwith compoundStmt()
10054*12c85518Srobert  matching '{}'
10055*12c85518Srobert  but does not match 'void f();'
10056*12c85518Srobert</pre></td></tr>
10057e5dd7070Spatrick
10058e5dd7070Spatrick
10059e5dd7070Spatrick<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>
10060e5dd7070Spatrick<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop,
10061e5dd7070Spatrickswitch statement or conditional operator.
10062e5dd7070Spatrick
10063e5dd7070SpatrickExample matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
10064e5dd7070Spatrick  if (true) {}
10065e5dd7070Spatrick</pre></td></tr>
10066e5dd7070Spatrick
10067e5dd7070Spatrick<!--END_TRAVERSAL_MATCHERS -->
10068e5dd7070Spatrick</table>
10069e5dd7070Spatrick
10070e5dd7070Spatrick</div>
10071e5dd7070Spatrick</body>
10072e5dd7070Spatrick</html>
10073e5dd7070Spatrick
10074e5dd7070Spatrick
10075