Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / docs / LibASTMatchersReference.html
blobfcd3114bb5231052fea5094f635913fffad80d66
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
3 <html>
4 <head>
5 <title>AST Matcher Reference</title>
6 <link type="text/css" rel="stylesheet" href="../menu.css" />
7 <link type="text/css" rel="stylesheet" href="../content.css" />
8 <style type="text/css">
9 td {
10 padding: .33em;
12 td.doc {
13 display: none;
14 border-bottom: 1px solid black;
16 td.name:hover {
17 color: blue;
18 cursor: pointer;
20 span.mono { font-family: monospace; }
22 .traverse_compare, .traverse_compare td, .traverse_compare th {
23 border: 1px solid black;
24 border-collapse: collapse;
26 </style>
27 <script type="text/javascript">
28 function toggle(id) {
29 if (!id) return;
30 row = document.getElementById(id);
31 if (row.style.display != 'table-cell')
32 row.style.display = 'table-cell';
33 else
34 row.style.display = 'none';
36 </script>
37 </head>
38 <body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))">
40 <!--#include virtual="../menu.html.incl"-->
42 <div id="content">
44 <h1>AST Matcher Reference</h1>
46 <p>This document shows all currently implemented matchers. The matchers are grouped
47 by category and node type they match. You can click on matcher names to show the
48 matcher's source documentation.</p>
50 <p>There are three different basic categories of matchers:
51 <ul>
52 <li><a href="#decl-matchers">Node Matchers:</a> Matchers that match a specific type of AST node.</li>
53 <li><a href="#narrowing-matchers">Narrowing Matchers:</a> Matchers that match attributes on AST nodes.</li>
54 <li><a href="#traversal-matchers">Traversal Matchers:</a> Matchers that allow traversal between AST nodes.</li>
55 </ul>
56 </p>
58 <p>Within each category the matchers are ordered by node type they match on.
59 Note that if a matcher can match multiple node types, it will appear
60 multiple times. This means that by searching for Matcher&lt;Stmt&gt; you can
61 find all matchers that can be used to match on Stmt nodes.</p>
63 <p>The exception to that rule are matchers that can match on any node. Those
64 are marked with a * and are listed in the beginning of each category.</p>
66 <p>Note that the categorization of matchers is a great help when you combine
67 them into matcher expressions. You will usually want to form matcher expressions
68 that read like english sentences by alternating between node matchers and
69 narrowing or traversal matchers, like this:
70 <pre>
71 recordDecl(hasDescendant(
72 ifStmt(hasTrueExpression(
73 expr(hasDescendant(
74 ifStmt()))))))
75 </pre>
76 </p>
78 <!-- ======================================================================= -->
79 <h2 id="traverse-mode">Traverse Mode</h2>
80 <!-- ======================================================================= -->
82 <p>The default mode of operation of AST Matchers visits all nodes in the AST,
83 even if they are not spelled in the source. This is
84 <span class="mono">AsIs</span> mode. This mode requires writing AST matchers
85 that explicitly traverse or ignore implicit nodes, such as parentheses
86 surrounding an expression or expressions with cleanups. These implicit
87 nodes are not always obvious from the syntax of the source code, and so this
88 mode requires careful consideration and testing to get the desired behavior
89 from an AST matcher.
90 </p>
92 <p>In addition, because template instantiations are matched in the default mode,
93 transformations can be accidentally made to template declarations. Finally,
94 because implicit nodes are matched by default, transformations can be made on
95 entirely incorrect places in the code.</p>
97 <p>For these reasons, it is possible to ignore AST nodes which are not spelled
98 in the source using the <span class="mono">IgnoreUnlessSpelledInSource</span>
99 mode. This is likely to be far less error-prone for users who are not already
100 very familiar with where implicit nodes appear in the AST. It is also likely
101 to be less error-prone for experienced AST users, as difficult cases do not
102 need to be encountered and matcher expressions adjusted for these cases.</p>
104 <p>In clang-query, the mode can be changed with
105 <pre>
106 set traversal IgnoreUnlessSpelledInSource
107 </pre>
108 </p>
109 This affects both matchers and AST dump output in results.
111 <p>When using the C++ API such as in clang-tidy checks, the
112 <span class="mono">traverse()</span> matcher is used to set the mode:
113 <pre>
114 Finder->addMatcher(traverse(TK_IgnoreUnlessSpelledInSource,
115 returnStmt(hasReturnValue(integerLiteral(equals(0))))
116 ), this);
117 </pre>
118 </p>
119 <p>The following table compares the <span class="mono">AsIs</span> mode with
120 the <span class="mono">IgnoreUnlessSpelledInSource</span> mode:</p>
122 <table class="traverse_compare">
123 <tr>
124 <th></th>
125 <th><span class="mono">AsIs</span></th>
126 <th><span class="mono">IgnoreUnlessSpelledInSource</span></th>
127 </tr>
128 <tr>
129 <td>AST dump of <span class="mono">func1</span>:
130 <pre>
131 struct B {
132 B(int);
135 B func1() { return 42; }
136 </pre>
138 </td>
139 <td>
140 C++98 dialect:
141 <pre>
142 FunctionDecl
143 `-CompoundStmt
144 `-ReturnStmt
145 `-ExprWithCleanups
146 `-CXXConstructExpr
147 `-MaterializeTemporaryExpr
148 `-ImplicitCastExpr
149 `-ImplicitCastExpr
150 `-CXXConstructExpr
151 `-IntegerLiteral 'int' 42
152 </pre>
153 C++11, C++14 dialect:
154 <pre>
155 FunctionDecl
156 `-CompoundStmt
157 `-ReturnStmt
158 `-ExprWithCleanups
159 `-CXXConstructExpr
160 `-MaterializeTemporaryExpr
161 `-ImplicitCastExpr
162 `-CXXConstructExpr
163 `-IntegerLiteral 'int' 42
164 </pre>
165 C++17, C++20 dialect:
166 <pre>
167 FunctionDecl
168 `-CompoundStmt
169 `-ReturnStmt
170 `-ImplicitCastExpr
171 `-CXXConstructExpr
172 `-IntegerLiteral 'int' 42
173 </pre>
174 </td>
175 <td>
176 All dialects:
177 <pre>
178 FunctionDecl
179 `-CompoundStmt
180 `-ReturnStmt
181 `-IntegerLiteral 'int' 42
182 </pre></td>
183 </tr>
185 <tr>
186 <td>Matcher for returned <span class="mono">42</span>:
187 <pre>
188 struct B {
189 B(int);
192 B func1() { return 42; }
193 </pre>
195 </td>
196 <td>
197 All dialects:
198 <pre>
199 returnStmt(hasReturnValue(
200 ignoringImplicit(
201 ignoringElidableConstructorCall(
202 ignoringImplicit(
203 cxxConstructExpr(hasArgument(0,
204 ignoringImplicit(
205 integerLiteral().bind("returnVal")
212 </pre></td>
213 <td>
214 All dialects:
215 <pre>
216 returnStmt(hasReturnValue(
217 integerLiteral().bind("returnVal")
219 </pre></td>
220 </tr>
221 <tr>
222 <td>Match result for
223 <pre>implicitCastExpr()</pre>
224 given:
225 <pre>
226 struct B {
227 B(int);
230 B func1() { return 42; }
231 </pre>
233 </td>
234 <td>
235 Match found.</td>
236 <td>
237 No match.</td>
238 </tr>
239 <tr>
240 <td>Match result for:
241 <pre>
242 cxxConstructorDecl(
243 isCopyConstructor()
244 ).bind("prepend_explicit")
245 </pre>
246 given:
247 <pre>
248 struct Other {};
249 struct Copyable {
250 Other m_o;
251 Copyable();
253 </pre>
254 </td>
255 <td>
256 Match found. Insertion produces incorrect output:
257 <pre>
258 struct Other {};
259 struct explicit Copyable {
260 Other m_o;
261 Copyable();
263 </pre>
264 </td>
265 <td>
266 No match found. Incorrect replacement not possible.
267 </td>
268 </tr>
269 <tr>
270 <td>Replacement of <span class="mono">begin()</span>
271 with <span class="mono">cbegin()</span>:
272 <pre>
273 cxxMemberCallExpr(
274 on(ConstContainerExpr),
275 callee(cxxMethodDecl(hasName("begin")))
276 ).bind("replace_with_cbegin")
277 </pre>
278 given:
279 <pre>
280 void foo() {
281 const Container c;
282 c.begin();
284 for (auto i : c) {
287 </pre>
288 </td>
289 <td>
290 2 matches found. Replacement produces incorrect output:
291 <pre>
292 void foo() {
293 const Container c;
294 c.cbegin();
296 for (auto i :.cbegin() c) {
299 </pre>
300 </td>
301 <td>
302 1 match found. Replacement produces correct output:
303 <pre>
304 void foo() {
305 const Container c;
306 c.cbegin();
308 for (auto i : c) {
311 </pre>
312 </td>
313 </tr>
314 <tr>
315 <td>Replacement of <span class="mono">int</span> member
316 with <span class="mono">safe_int</span>:
317 <pre>
318 fieldDecl(
319 hasType(asString("int"))
320 ).bind("use_safe_int")
321 </pre>
322 given:
323 <pre>
324 struct S {
325 int m_i;
328 template &lt;typename T&gt; struct TemplStruct {
329 TemplStruct() {}
330 ~TemplStruct() {}
332 private:
333 T m_t;
336 void instantiate() { TemplStruct&lt;int&gt; ti; }
337 </pre>
338 </td>
339 <td>
340 2 matches found. Replacement produces incorrect output:
341 <pre>
342 struct S {
343 safe_int m_i;
346 template &lt;typename T&gt; struct TemplStruct {
347 TemplStruct() {}
348 ~TemplStruct() {}
350 private:
351 safe_int m_t;
354 void instantiate() { TemplStruct&lt;int&gt; ti; }
355 </pre>
356 </td>
357 <td>
358 1 match found. Replacement produces correct output:
359 <pre>
360 struct S {
361 safe_int m_i;
364 template &lt;typename T&gt; struct TemplStruct {
365 TemplStruct() {}
366 ~TemplStruct() {}
368 private:
369 T m_t;
372 void instantiate() { TemplStruct&lt;int&gt; ti; }
373 </pre>
374 </td>
375 </tr>
376 <tr>
377 <td>Add prefix to member initializer
378 <pre>
379 cxxCtorInitializer(
380 forField(fieldDecl())
381 ).bind("add_prefix")
382 </pre>
383 given:
384 <pre>
385 struct Simple {};
387 struct Record {
388 Record() : i(42) {}
389 private:
390 int i;
391 Simple s;
393 </pre>
394 </td>
395 <td>
396 2 matches found. Replacement produces incorrect output:
397 <pre>
398 struct Simple {};
400 struct Record {
401 m_Record() : m_i(42) {}
402 private:
403 int i;
404 Simple s;
406 </pre>
407 </td>
408 <td>
409 1 match found. Replacement produces correct output:
410 <pre>
411 struct Simple {};
413 struct Record {
414 Record() : m_i(42) {}
415 private:
416 int i;
417 Simple s;
419 </pre>
420 </td>
421 </tr>
422 <tr>
423 <td>Ignored default arguments
424 <pre>
425 callExpr(
426 callee(functionDecl(
427 hasName("hasDefaultArg")
429 argumentCountIs(1)
430 ).bind("add_prefix")
431 </pre>
432 given:
433 <pre>
434 void hasDefaultArg(int i, int j = 0) {}
435 void callDefaultArg() { hasDefaultArg(42); }
436 </pre>
437 </td>
438 <td>
439 No match.
440 </td>
441 <td>
442 1 match found.
443 </td>
444 </tr>
445 <tr>
446 <td>Lambda fields
447 <pre>
448 fieldDecl(
449 hasType(asString("int"))
450 ).bind("make_safe")
451 </pre>
452 given:
453 <pre>
454 struct S {
455 int m_i;
458 void func() {
459 int a = 0;
460 int c = 0;
462 auto l = [a, b = c](int d) { int e = d; };
463 l(43);
465 </pre>
466 </td>
467 <td>
468 2 matches found. Replacement produces incorrect output:
469 <pre>
470 struct S {
471 safe_int m_i;
474 void func() {
475 int a = 0;
476 int c = 0;
478 auto l = [safe_a, safe_b = c](int d) { int e = d; };
479 l(43);
481 </pre>
482 </td>
483 <td>
484 1 match found. Replacement produces correct output:
485 <pre>
486 struct S {
487 safe_int m_i;
490 void func() {
491 int a = 0;
492 int c = 0;
494 auto l = [a, b = c](int d) { int e = d; };
495 l(43);
497 </pre>
498 </td>
500 </tr>
506 <tr>
507 <td>Rewritten binary operators
508 <pre>
509 binaryOperator(
510 hasOperatorName("&lt;"),
511 hasRHS(hasDescendant(integerLiteral(equals(0))))
513 </pre>
514 given:
515 <pre>
516 #include &lt;compare&gt;
518 class HasSpaceship {
519 public:
520 int x;
521 bool operator==(const HasSpaceship&) const = default;
522 std::strong_ordering operator<=>(const HasSpaceship&) const = default;
525 bool isLess(const HasSpaceship& a, const HasSpaceship& b) {
526 return a < b;
528 </pre>
529 </td>
530 <td>
531 1 match found.
533 <pre>
534 return a < b;
535 ^~~~~
536 </pre>
538 </td>
539 <td>
540 No match found.
541 </td>
542 </tr>
543 </table>
545 <!-- ======================================================================= -->
546 <h2 id="decl-matchers">Node Matchers</h2>
547 <!-- ======================================================================= -->
549 <p>Node matchers are at the core of matcher expressions - they specify the type
550 of node that is expected. Every match expression starts with a node matcher,
551 which can then be further refined with a narrowing or traversal matcher. All
552 traversal matchers take node matchers as their arguments.</p>
554 <p>For convenience, all node matchers take an arbitrary number of arguments
555 and implicitly act as allOf matchers.</p>
557 <p>Node matchers are the only matchers that support the bind("id") call to
558 bind the matched node to the given string, to be later retrieved from the
559 match callback.</p>
561 <p>It is important to remember that the arguments to node matchers are
562 predicates on the same node, just with additional information about the type.
563 This is often useful to make matcher expression more readable by inlining bind
564 calls into redundant node matchers inside another node matcher:
565 <pre>
566 // This binds the CXXRecordDecl to "id", as the decl() matcher will stay on
567 // the same node.
568 recordDecl(decl().bind("id"), hasName("::MyClass"))
569 </pre>
570 </p>
572 <table>
573 <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
574 <!-- START_DECL_MATCHERS -->
576 <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 <tr><td colspan="4" class="doc" id="attr0"><pre>Matches attributes.
578 Attributes may be attached with a variety of different syntaxes (including
579 keywords, C++11 attributes, GNU ``__attribute``` and MSVC `__declspec``,
580 and ``#pragma``s). They may also be implicit.
582 Given
583 struct [[nodiscard]] Foo{};
584 void bar(int * __attribute__((nonnull)) );
585 __declspec(noinline) void baz();
587 #pragma omp declare simd
588 int min();
589 attr()
590 matches "nodiscard", "nonnull", "noinline", and the whole "#pragma" line.
591 </pre></td></tr>
594 <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>
595 <tr><td colspan="4" class="doc" id="cxxBaseSpecifier0"><pre>Matches class bases.
597 Examples matches public virtual B.
598 class B {};
599 class C : public virtual B {};
600 </pre></td></tr>
603 <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>
604 <tr><td colspan="4" class="doc" id="cxxCtorInitializer0"><pre>Matches constructor initializers.
606 Examples matches i(42).
607 class C {
608 C() : i(42) {}
609 int i;
611 </pre></td></tr>
614 <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>
615 <tr><td colspan="4" class="doc" id="accessSpecDecl0"><pre>Matches C++ access specifier declarations.
617 Given
618 class C {
619 public:
620 int a;
622 accessSpecDecl()
623 matches 'public:'
624 </pre></td></tr>
627 <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>
628 <tr><td colspan="4" class="doc" id="bindingDecl0"><pre>Matches binding declarations
629 Example matches foo and bar
630 (matcher = bindingDecl()
632 auto [foo, bar] = std::make_pair{42, 42};
633 </pre></td></tr>
636 <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>
637 <tr><td colspan="4" class="doc" id="blockDecl0"><pre>Matches block declarations.
639 Example matches the declaration of the nameless block printing an input
640 integer.
642 myFunc(^(int p) {
643 printf("%d", p);
645 </pre></td></tr>
648 <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>
649 <tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations.
651 Example matches Z
652 template&lt;class T&gt; class Z {};
653 </pre></td></tr>
656 <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>
657 <tr><td colspan="4" class="doc" id="classTemplatePartialSpecializationDecl0"><pre>Matches C++ class template partial specializations.
659 Given
660 template&lt;class T1, class T2, int I&gt;
661 class A {};
663 template&lt;class T, int I&gt;
664 class A&lt;T, T*, I&gt; {};
666 template&lt;&gt;
667 class A&lt;int, int, 1&gt; {};
668 classTemplatePartialSpecializationDecl()
669 matches the specialization A&lt;T,T*,I&gt; but not A&lt;int,int,1&gt;
670 </pre></td></tr>
673 <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>
674 <tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations.
676 Given
677 template&lt;typename T&gt; class A {};
678 template&lt;&gt; class A&lt;double&gt; {};
679 A&lt;int&gt; a;
680 classTemplateSpecializationDecl()
681 matches the specializations A&lt;int&gt; and A&lt;double&gt;
682 </pre></td></tr>
685 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('conceptDecl0')"><a name="conceptDecl0Anchor">conceptDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ConceptDecl.html">ConceptDecl</a>&gt;...</td></tr>
686 <tr><td colspan="4" class="doc" id="conceptDecl0"><pre>Matches concept declarations.
688 Example matches integral
689 template&lt;typename T&gt;
690 concept integral = std::is_integral_v&lt;T&gt;;
691 </pre></td></tr>
694 <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>
695 <tr><td colspan="4" class="doc" id="cxxConstructorDecl0"><pre>Matches C++ constructor declarations.
697 Example matches Foo::Foo() and Foo::Foo(int)
698 class Foo {
699 public:
700 Foo();
701 Foo(int);
702 int DoSomething();
704 </pre></td></tr>
707 <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>
708 <tr><td colspan="4" class="doc" id="cxxConversionDecl0"><pre>Matches conversion operator declarations.
710 Example matches the operator.
711 class X { operator int() const; };
712 </pre></td></tr>
715 <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>
716 <tr><td colspan="4" class="doc" id="cxxDeductionGuideDecl0"><pre>Matches user-defined and implicitly generated deduction guide.
718 Example matches the deduction guide.
719 template&lt;typename T&gt;
720 class X { X(int) };
721 X(int) -&gt; X&lt;int&gt;;
722 </pre></td></tr>
725 <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>
726 <tr><td colspan="4" class="doc" id="cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations.
728 Example matches Foo::~Foo()
729 class Foo {
730 public:
731 virtual ~Foo();
733 </pre></td></tr>
736 <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>
737 <tr><td colspan="4" class="doc" id="cxxMethodDecl0"><pre>Matches method declarations.
739 Example matches y
740 class X { void y(); };
741 </pre></td></tr>
744 <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>
745 <tr><td colspan="4" class="doc" id="cxxRecordDecl0"><pre>Matches C++ class declarations.
747 Example matches X, Z
748 class X;
749 template&lt;class T&gt; class Z {};
750 </pre></td></tr>
753 <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>
754 <tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations.
756 Examples matches X, C, and the friend declaration inside C;
757 void X();
758 class C {
759 friend X;
761 </pre></td></tr>
764 <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>
765 <tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function
766 and non-type template parameter declarations).
768 Given
769 class X { int y; };
770 declaratorDecl()
771 matches int y.
772 </pre></td></tr>
775 <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>
776 <tr><td colspan="4" class="doc" id="decompositionDecl0"><pre>Matches decomposition-declarations.
778 Examples matches the declaration node with foo and bar, but not
779 number.
780 (matcher = declStmt(has(decompositionDecl())))
782 int number = 42;
783 auto [foo, bar] = std::make_pair{42, 42};
784 </pre></td></tr>
787 <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>
788 <tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants.
790 Example matches A, B, C
791 enum X {
792 A, B, C
794 </pre></td></tr>
797 <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>
798 <tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations.
800 Example matches X
801 enum X {
802 A, B, C
804 </pre></td></tr>
807 <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>
808 <tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations.
810 Given
811 class X { int m; };
812 fieldDecl()
813 matches 'm'.
814 </pre></td></tr>
817 <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>
818 <tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations.
820 Given
821 class X { friend void foo(); };
822 friendDecl()
823 matches 'friend void foo()'.
824 </pre></td></tr>
827 <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>
828 <tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations.
830 Example matches f
831 void f();
832 </pre></td></tr>
835 <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>
836 <tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations.
838 Example matches f
839 template&lt;class T&gt; void f(T t) {}
840 </pre></td></tr>
843 <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>
844 <tr><td colspan="4" class="doc" id="indirectFieldDecl0"><pre>Matches indirect field declarations.
846 Given
847 struct X { struct { int a; }; };
848 indirectFieldDecl()
849 matches 'a'.
850 </pre></td></tr>
853 <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>
854 <tr><td colspan="4" class="doc" id="labelDecl0"><pre>Matches a declaration of label.
856 Given
857 goto FOO;
858 FOO: bar();
859 labelDecl()
860 matches 'FOO:'
861 </pre></td></tr>
864 <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>
865 <tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification.
867 Given
868 extern "C" {}
869 linkageSpecDecl()
870 matches "extern "C" {}"
871 </pre></td></tr>
874 <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>
875 <tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name.
877 Example matches X, S, the anonymous union type, i, and U;
878 typedef int X;
879 struct S {
880 union {
881 int i;
882 } U;
884 </pre></td></tr>
887 <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>
888 <tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias.
890 Given
891 namespace test {}
892 namespace alias = ::test;
893 namespaceAliasDecl()
894 matches "namespace alias" but not "namespace test"
895 </pre></td></tr>
898 <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>
899 <tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace.
901 Given
902 namespace {}
903 namespace test {}
904 namespaceDecl()
905 matches "namespace {}" and "namespace test {}"
906 </pre></td></tr>
909 <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>
910 <tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations.
912 Given
913 template &lt;typename T, int N&gt; struct C {};
914 nonTypeTemplateParmDecl()
915 matches 'N', but not 'T'.
916 </pre></td></tr>
919 <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>
920 <tr><td colspan="4" class="doc" id="objcCategoryDecl0"><pre>Matches Objective-C category declarations.
922 Example matches Foo (Additions)
923 @interface Foo (Additions)
924 @end
925 </pre></td></tr>
928 <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>
929 <tr><td colspan="4" class="doc" id="objcCategoryImplDecl0"><pre>Matches Objective-C category definitions.
931 Example matches Foo (Additions)
932 @implementation Foo (Additions)
933 @end
934 </pre></td></tr>
937 <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>
938 <tr><td colspan="4" class="doc" id="objcImplementationDecl0"><pre>Matches Objective-C implementation declarations.
940 Example matches Foo
941 @implementation Foo
942 @end
943 </pre></td></tr>
946 <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>
947 <tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations.
949 Example matches Foo
950 @interface Foo
951 @end
952 </pre></td></tr>
955 <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>
956 <tr><td colspan="4" class="doc" id="objcIvarDecl0"><pre>Matches Objective-C instance variable declarations.
958 Example matches _enabled
959 @implementation Foo {
960 BOOL _enabled;
962 @end
963 </pre></td></tr>
966 <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>
967 <tr><td colspan="4" class="doc" id="objcMethodDecl0"><pre>Matches Objective-C method declarations.
969 Example matches both declaration and definition of -[Foo method]
970 @interface Foo
971 - (void)method;
972 @end
974 @implementation Foo
975 - (void)method {}
976 @end
977 </pre></td></tr>
980 <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>
981 <tr><td colspan="4" class="doc" id="objcPropertyDecl0"><pre>Matches Objective-C property declarations.
983 Example matches enabled
984 @interface Foo
985 @property BOOL enabled;
986 @end
987 </pre></td></tr>
990 <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>
991 <tr><td colspan="4" class="doc" id="objcProtocolDecl0"><pre>Matches Objective-C protocol declarations.
993 Example matches FooDelegate
994 @protocol FooDelegate
995 @end
996 </pre></td></tr>
999 <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>
1000 <tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations.
1002 Given
1003 void f(int x);
1004 parmVarDecl()
1005 matches int x.
1006 </pre></td></tr>
1009 <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>
1010 <tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations.
1012 Example matches X, Z, U, and S
1013 class X;
1014 template&lt;class T&gt; class Z {};
1015 struct S {};
1016 union U {};
1017 </pre></td></tr>
1020 <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>
1021 <tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration.
1023 Example:
1024 staticAssertDecl()
1025 matches
1026 static_assert(sizeof(S) == sizeof(int))
1028 struct S {
1029 int x;
1031 static_assert(sizeof(S) == sizeof(int));
1032 </pre></td></tr>
1035 <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>
1036 <tr><td colspan="4" class="doc" id="tagDecl0"><pre>Matches tag declarations.
1038 Example matches X, Z, U, S, E
1039 class X;
1040 template&lt;class T&gt; class Z {};
1041 struct S {};
1042 union U {};
1043 enum E {
1044 A, B, C
1046 </pre></td></tr>
1049 <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>
1050 <tr><td colspan="4" class="doc" id="templateTemplateParmDecl0"><pre>Matches template template parameter declarations.
1052 Given
1053 template &lt;template &lt;typename&gt; class Z, int N&gt; struct C {};
1054 templateTypeParmDecl()
1055 matches 'Z', but not 'N'.
1056 </pre></td></tr>
1059 <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>
1060 <tr><td colspan="4" class="doc" id="templateTypeParmDecl0"><pre>Matches template type parameter declarations.
1062 Given
1063 template &lt;typename T, int N&gt; struct C {};
1064 templateTypeParmDecl()
1065 matches 'T', but not 'N'.
1066 </pre></td></tr>
1069 <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>
1070 <tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context.
1072 Given
1073 int X;
1074 namespace NS {
1075 int Y;
1076 } // namespace NS
1077 decl(hasDeclContext(translationUnitDecl()))
1078 matches "int X", but not "int Y".
1079 </pre></td></tr>
1082 <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>
1083 <tr><td colspan="4" class="doc" id="typeAliasDecl0"><pre>Matches type alias declarations.
1085 Given
1086 typedef int X;
1087 using Y = int;
1088 typeAliasDecl()
1089 matches "using Y = int", but not "typedef int X"
1090 </pre></td></tr>
1093 <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>
1094 <tr><td colspan="4" class="doc" id="typeAliasTemplateDecl0"><pre>Matches type alias template declarations.
1096 typeAliasTemplateDecl() matches
1097 template &lt;typename T&gt;
1098 using Y = X&lt;T&gt;;
1099 </pre></td></tr>
1102 <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>
1103 <tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations.
1105 Given
1106 typedef int X;
1107 using Y = int;
1108 typedefDecl()
1109 matches "typedef int X", but not "using Y = int"
1110 </pre></td></tr>
1113 <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>
1114 <tr><td colspan="4" class="doc" id="typedefNameDecl0"><pre>Matches typedef name declarations.
1116 Given
1117 typedef int X;
1118 using Y = int;
1119 typedefNameDecl()
1120 matches "typedef int X" and "using Y = int"
1121 </pre></td></tr>
1124 <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>
1125 <tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the
1126 typename.
1128 Given
1129 template &lt;typename T&gt;
1130 struct Base { typedef T Foo; };
1132 template&lt;typename T&gt;
1133 struct S : private Base&lt;T&gt; {
1134 using typename Base&lt;T&gt;::Foo;
1136 unresolvedUsingTypenameDecl()
1137 matches using Base&lt;T&gt;::Foo </pre></td></tr>
1140 <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>
1141 <tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations.
1143 Given
1144 template&lt;typename X&gt;
1145 class C : private X {
1146 using X::x;
1148 unresolvedUsingValueDecl()
1149 matches using X::x </pre></td></tr>
1152 <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>
1153 <tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations.
1155 Given
1156 namespace X { int x; }
1157 using X::x;
1158 usingDecl()
1159 matches using X::x </pre></td></tr>
1162 <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>
1163 <tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations.
1165 Given
1166 namespace X { int x; }
1167 using namespace X;
1168 usingDirectiveDecl()
1169 matches using namespace X </pre></td></tr>
1172 <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>
1173 <tr><td colspan="4" class="doc" id="usingEnumDecl0"><pre>Matches using-enum declarations.
1175 Given
1176 namespace X { enum x {...}; }
1177 using enum X::x;
1178 usingEnumDecl()
1179 matches using enum X::x </pre></td></tr>
1182 <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>
1183 <tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration.
1185 Example matches A, B, C and F
1186 enum X { A, B, C };
1187 void F();
1188 </pre></td></tr>
1191 <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>
1192 <tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations.
1194 Note: this does not match declarations of member variables, which are
1195 "field" declarations in Clang parlance.
1197 Example matches a
1198 int a;
1199 </pre></td></tr>
1202 <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>
1203 <tr><td colspan="4" class="doc" id="lambdaCapture0"><pre>Matches lambda captures.
1205 Given
1206 int main() {
1207 int x;
1208 auto f = [x](){};
1209 auto g = [x = 1](){};
1211 In the matcher `lambdaExpr(hasAnyCapture(lambdaCapture()))`,
1212 `lambdaCapture()` matches `x` and `x=1`.
1213 </pre></td></tr>
1216 <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>
1217 <tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
1218 </pre></td></tr>
1221 <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>
1222 <tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers.
1224 Given
1225 namespace ns {
1226 struct A { static void f(); };
1227 void A::f() {}
1228 void g() { A::f(); }
1230 ns::A a;
1231 nestedNameSpecifier()
1232 matches "ns::" and both "A::"
1233 </pre></td></tr>
1236 <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>
1237 <tr><td colspan="4" class="doc" id="ompDefaultClause0"><pre>Matches OpenMP ``default`` clause.
1239 Given
1241 #pragma omp parallel default(none)
1242 #pragma omp parallel default(shared)
1243 #pragma omp parallel default(private)
1244 #pragma omp parallel default(firstprivate)
1245 #pragma omp parallel
1247 ``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``,
1248 `` default(private)`` and ``default(firstprivate)``
1249 </pre></td></tr>
1252 <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>
1253 <tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST.
1254 </pre></td></tr>
1257 <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>
1258 <tr><td colspan="4" class="doc" id="addrLabelExpr0"><pre>Matches address of label statements (GNU extension).
1260 Given
1261 FOO: bar();
1262 void *ptr = &amp;&amp;FOO;
1263 goto *bar;
1264 addrLabelExpr()
1265 matches '&amp;&amp;FOO'
1266 </pre></td></tr>
1269 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('arrayInitIndexExpr0')"><a name="arrayInitIndexExpr0Anchor">arrayInitIndexExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ArrayInitIndexExpr.html">ArrayInitIndexExpr</a>&gt;...</td></tr>
1270 <tr><td colspan="4" class="doc" id="arrayInitIndexExpr0"><pre>The arrayInitIndexExpr consists of two subexpressions: a common expression
1271 (the source array) that is evaluated once up-front, and a per-element initializer
1272 that runs once for each array element. Within the per-element initializer,
1273 the current index may be obtained via an ArrayInitIndexExpr.
1275 Given
1276 void testStructBinding() {
1277 int a[2] = {1, 2};
1278 auto [x, y] = a;
1280 arrayInitIndexExpr() matches the array index that implicitly iterates
1281 over the array `a` to copy each element to the anonymous array
1282 that backs the structured binding `[x, y]` elements of which are
1283 referred to by their aliases `x` and `y`.
1284 </pre></td></tr>
1287 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('arrayInitLoopExpr0')"><a name="arrayInitLoopExpr0Anchor">arrayInitLoopExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ArrayInitLoopExpr.html">ArrayInitLoopExpr</a>&gt;...</td></tr>
1288 <tr><td colspan="4" class="doc" id="arrayInitLoopExpr0"><pre>Matches a loop initializing the elements of an array in a number of contexts:
1289 * in the implicit copy/move constructor for a class with an array member
1290 * when a lambda-expression captures an array by value
1291 * when a decomposition declaration decomposes an array
1293 Given
1294 void testLambdaCapture() {
1295 int a[10];
1296 auto Lam1 = [a]() {
1297 return;
1300 arrayInitLoopExpr() matches the implicit loop that initializes each element of
1301 the implicit array field inside the lambda object, that represents the array `a`
1302 captured by value.
1303 </pre></td></tr>
1306 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1307 <tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions.
1309 Given
1310 int i = a[1];
1311 arraySubscriptExpr()
1312 matches "a[1]"
1313 </pre></td></tr>
1316 <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>
1317 <tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements.
1319 int i = 100;
1320 __asm("mov al, 2");
1321 asmStmt()
1322 matches '__asm("mov al, 2")'
1323 </pre></td></tr>
1326 <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>
1327 <tr><td colspan="4" class="doc" id="atomicExpr0"><pre>Matches atomic builtins.
1328 Example matches __atomic_load_n(ptr, 1)
1329 void foo() { int *ptr; __atomic_load_n(ptr, 1); }
1330 </pre></td></tr>
1333 <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>
1334 <tr><td colspan="4" class="doc" id="autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement.
1336 Given
1337 @autoreleasepool {
1338 int x = 0;
1340 autoreleasePoolStmt(stmt()) matches the declaration of "x"
1341 inside the autorelease pool.
1342 </pre></td></tr>
1345 <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>
1346 <tr><td colspan="4" class="doc" id="binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension).
1348 Example matches a ?: b
1349 (a ?: b) + 42;
1350 </pre></td></tr>
1353 <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>
1354 <tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions.
1356 Example matches a || b
1357 !(a || b)
1358 See also the binaryOperation() matcher for more-general matching.
1359 </pre></td></tr>
1362 <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>
1363 <tr><td colspan="4" class="doc" id="blockExpr0"><pre>Matches a reference to a block.
1365 Example: matches "^{}":
1366 void f() { ^{}(); }
1367 </pre></td></tr>
1370 <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>
1371 <tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements.
1373 Given
1374 while (true) { break; }
1375 breakStmt()
1376 matches 'break'
1377 </pre></td></tr>
1380 <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>
1381 <tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression.
1383 Example: Matches (int) 2.2f in
1384 int i = (int) 2.2f;
1385 </pre></td></tr>
1388 <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>
1389 <tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions.
1391 Example matches x.y() and y()
1392 X x;
1393 x.y();
1394 y();
1395 </pre></td></tr>
1398 <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>
1399 <tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements.
1401 Given
1402 switch(a) { case 42: break; default: break; }
1403 caseStmt()
1404 matches 'case 42:'.
1405 </pre></td></tr>
1408 <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>
1409 <tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST.
1411 Example: castExpr() matches each of the following:
1412 (int) 3;
1413 const_cast&lt;Expr *&gt;(SubExpr);
1414 char c = 0;
1415 but does not match
1416 int i = (0);
1417 int k = 0;
1418 </pre></td></tr>
1421 <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>
1422 <tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t).
1424 Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
1425 though.
1427 Example matches 'a', L'a'
1428 char ch = 'a';
1429 wchar_t chw = L'a';
1430 </pre></td></tr>
1433 <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>
1434 <tr><td colspan="4" class="doc" id="chooseExpr0"><pre>Matches GNU __builtin_choose_expr.
1435 </pre></td></tr>
1438 <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>
1439 <tr><td colspan="4" class="doc" id="coawaitExpr0"><pre>Matches co_await expressions.
1441 Given
1442 co_await 1;
1443 coawaitExpr()
1444 matches 'co_await 1'
1445 </pre></td></tr>
1448 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1449 <tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals
1451 Example match: {1}, (1, 2)
1452 int array[4] = {1};
1453 vector int myvec = (vector int)(1, 2);
1454 </pre></td></tr>
1457 <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>
1458 <tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements.
1460 Example matches '{}' and '{{}}' in 'for (;;) {{}}'
1461 for (;;) {{}}
1462 </pre></td></tr>
1465 <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>
1466 <tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions.
1468 Example matches a ? b : c
1469 (a ? b : c) + 42
1470 </pre></td></tr>
1473 <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>
1474 <tr><td colspan="4" class="doc" id="constantExpr0"><pre>Matches a constant expression wrapper.
1476 Example matches the constant in the case statement:
1477 (matcher = constantExpr())
1478 switch (a) {
1479 case 37: break;
1481 </pre></td></tr>
1484 <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>
1485 <tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements.
1487 Given
1488 while (true) { continue; }
1489 continueStmt()
1490 matches 'continue'
1491 </pre></td></tr>
1494 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('convertVectorExpr0')"><a name="convertVectorExpr0Anchor">convertVectorExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ConvertVectorExpr.html">ConvertVectorExpr</a>&gt;...</td></tr>
1495 <tr><td colspan="4" class="doc" id="convertVectorExpr0"><pre>Matches builtin function __builtin_convertvector.
1496 </pre></td></tr>
1499 <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>
1500 <tr><td colspan="4" class="doc" id="coreturnStmt0"><pre>Matches co_return statements.
1502 Given
1503 while (true) { co_return; }
1504 coreturnStmt()
1505 matches 'co_return'
1506 </pre></td></tr>
1509 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('coroutineBodyStmt0')"><a name="coroutineBodyStmt0Anchor">coroutineBodyStmt</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CoroutineBodyStmt.html">CoroutineBodyStmt</a>&gt;...</td></tr>
1510 <tr><td colspan="4" class="doc" id="coroutineBodyStmt0"><pre>Matches coroutine body statements.
1512 coroutineBodyStmt() matches the coroutine below
1513 generator&lt;int&gt; gen() {
1514 co_return;
1516 </pre></td></tr>
1519 <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>
1520 <tr><td colspan="4" class="doc" id="coyieldExpr0"><pre>Matches co_yield expressions.
1522 Given
1523 co_yield 1;
1524 coyieldExpr()
1525 matches 'co_yield 1'
1526 </pre></td></tr>
1529 <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>
1530 <tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression.
1532 Example matches,
1533 kernel&lt;&lt;&lt;i,j&gt;&gt;&gt;();
1534 </pre></td></tr>
1537 <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>
1538 <tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created.
1540 Example matches FunctionTakesString(GetStringByValue())
1541 (matcher = cxxBindTemporaryExpr())
1542 FunctionTakesString(GetStringByValue());
1543 FunctionTakesStringByPointer(GetStringPointer());
1544 </pre></td></tr>
1547 <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>
1548 <tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals.
1550 Example matches true
1551 true
1552 </pre></td></tr>
1555 <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>
1556 <tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements.
1558 try {} catch(int i) {}
1559 cxxCatchStmt()
1560 matches 'catch(int i)'
1561 </pre></td></tr>
1564 <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>
1565 <tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression.
1567 Example: Matches const_cast&lt;int*&gt;(&amp;r) in
1568 int n = 42;
1569 const int &amp;r(n);
1570 int* p = const_cast&lt;int*&gt;(&amp;r);
1571 </pre></td></tr>
1574 <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>
1575 <tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones).
1577 Example matches string(ptr, n) and ptr within arguments of f
1578 (matcher = cxxConstructExpr())
1579 void f(const string &amp;a, const string &amp;b);
1580 char *ptr;
1581 int n;
1582 f(string(ptr, n), ptr);
1583 </pre></td></tr>
1586 <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>
1587 <tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site.
1589 Example matches the CXXDefaultArgExpr placeholder inserted for the
1590 default value of the second parameter in the call expression f(42)
1591 (matcher = cxxDefaultArgExpr())
1592 void f(int x, int y = 0);
1593 f(42);
1594 </pre></td></tr>
1597 <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>
1598 <tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions.
1600 Given
1601 delete X;
1602 cxxDeleteExpr()
1603 matches 'delete X'.
1604 </pre></td></tr>
1607 <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>
1608 <tr><td colspan="4" class="doc" id="cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be
1609 resolved because the base expression or the member name was dependent.
1611 Given
1612 template &lt;class T&gt; void f() { T t; t.g(); }
1613 cxxDependentScopeMemberExpr()
1614 matches t.g
1615 </pre></td></tr>
1618 <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>
1619 <tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression.
1621 Example:
1622 cxxDynamicCastExpr()
1623 matches
1624 dynamic_cast&lt;D*&gt;(&amp;b);
1626 struct B { virtual ~B() {} }; struct D : B {};
1627 B b;
1628 D* p = dynamic_cast&lt;D*&gt;(&amp;b);
1629 </pre></td></tr>
1632 <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>
1633 <tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements.
1635 cxxForRangeStmt() matches 'for (auto a : i)'
1636 int i[] = {1, 2, 3}; for (auto a : i);
1637 for(int j = 0; j &lt; 5; ++j);
1638 </pre></td></tr>
1641 <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>
1642 <tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions
1644 Example: Matches Foo(bar);
1645 Foo f = bar;
1646 Foo g = (Foo) bar;
1647 Foo h = Foo(bar);
1648 </pre></td></tr>
1651 <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>
1652 <tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions.
1654 Example matches x.y()
1655 X x;
1656 x.y();
1657 </pre></td></tr>
1660 <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>
1661 <tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions.
1663 Given
1664 new X;
1665 cxxNewExpr()
1666 matches 'new X'.
1667 </pre></td></tr>
1670 <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>
1671 <tr><td colspan="4" class="doc" id="cxxNoexceptExpr0"><pre>Matches noexcept expressions.
1673 Given
1674 bool a() noexcept;
1675 bool b() noexcept(true);
1676 bool c() noexcept(false);
1677 bool d() noexcept(noexcept(a()));
1678 bool e = noexcept(b()) || noexcept(c());
1679 cxxNoexceptExpr()
1680 matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`.
1681 doesn't match the noexcept specifier in the declarations a, b, c or d.
1682 </pre></td></tr>
1685 <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>
1686 <tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal.
1687 </pre></td></tr>
1690 <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>
1691 <tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls.
1693 Note that if an operator isn't overloaded, it won't match. Instead, use
1694 binaryOperator matcher.
1695 Currently it does not match operators such as new delete.
1696 FIXME: figure out why these do not match?
1698 Example matches both operator&lt;&lt;((o &lt;&lt; b), c) and operator&lt;&lt;(o, b)
1699 (matcher = cxxOperatorCallExpr())
1700 ostream &amp;operator&lt;&lt; (ostream &amp;out, int i) { };
1701 ostream &amp;o; int b = 1, c = 1;
1702 o &lt;&lt; b &lt;&lt; c;
1703 See also the binaryOperation() matcher for more-general matching of binary
1704 uses of this AST node.
1705 </pre></td></tr>
1708 <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>
1709 <tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression.
1711 Either the source expression or the destination type can be matched
1712 using has(), but hasDestinationType() is more specific and can be
1713 more readable.
1715 Example matches reinterpret_cast&lt;char*&gt;(&amp;p) in
1716 void* p = reinterpret_cast&lt;char*&gt;(&amp;p);
1717 </pre></td></tr>
1720 <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>
1721 <tr><td colspan="4" class="doc" id="cxxRewrittenBinaryOperator0"><pre>Matches rewritten binary operators
1723 Example matches use of "&lt;":
1724 #include &lt;compare&gt;
1725 struct HasSpaceshipMem {
1726 int a;
1727 constexpr auto operator&lt;=&gt;(const HasSpaceshipMem&amp;) const = default;
1729 void compare() {
1730 HasSpaceshipMem hs1, hs2;
1731 if (hs1 &lt; hs2)
1732 return;
1734 See also the binaryOperation() matcher for more-general matching
1735 of this AST node.
1736 </pre></td></tr>
1739 <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>
1740 <tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression.
1742 See also: hasDestinationType
1743 See also: reinterpretCast
1745 Example:
1746 cxxStaticCastExpr()
1747 matches
1748 static_cast&lt;long&gt;(8)
1750 long eight(static_cast&lt;long&gt;(8));
1751 </pre></td></tr>
1754 <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>
1755 <tr><td colspan="4" class="doc" id="cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions.
1757 Given
1758 std::vector&lt;int&gt; a({ 1, 2, 3 });
1759 std::vector&lt;int&gt; b = { 4, 5 };
1760 int c[] = { 6, 7 };
1761 std::pair&lt;int, int&gt; d = { 8, 9 };
1762 cxxStdInitializerListExpr()
1763 matches "{ 1, 2, 3 }" and "{ 4, 5 }"
1764 </pre></td></tr>
1767 <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>
1768 <tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments
1770 Example: Matches Foo(bar, bar)
1771 Foo h = Foo(bar, bar);
1772 </pre></td></tr>
1775 <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>
1776 <tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions.
1778 Example matches the implicit this expression in "return i".
1779 (matcher = cxxThisExpr())
1780 struct foo {
1781 int i;
1782 int f() { return i; }
1784 </pre></td></tr>
1787 <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>
1788 <tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions.
1790 try { throw 5; } catch(int i) {}
1791 cxxThrowExpr()
1792 matches 'throw 5'
1793 </pre></td></tr>
1796 <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>
1797 <tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements.
1799 try {} catch(int i) {}
1800 cxxTryStmt()
1801 matches 'try {}'
1802 </pre></td></tr>
1805 <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>
1806 <tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions.
1808 Example matches T(t) in return statement of f
1809 (matcher = cxxUnresolvedConstructExpr())
1810 template &lt;typename T&gt;
1811 void f(const T&amp; t) { return T(t); }
1812 </pre></td></tr>
1815 <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>
1816 <tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations.
1818 Example matches x in if (x)
1819 bool x;
1820 if (x) {}
1821 </pre></td></tr>
1824 <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>
1825 <tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements.
1827 Given
1828 int a;
1829 declStmt()
1830 matches 'int a'.
1831 </pre></td></tr>
1834 <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>
1835 <tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements.
1837 Given
1838 switch(a) { case 42: break; default: break; }
1839 defaultStmt()
1840 matches 'default:'.
1841 </pre></td></tr>
1844 <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>
1845 <tr><td colspan="4" class="doc" id="dependentCoawaitExpr0"><pre>Matches co_await expressions where the type of the promise is dependent
1846 </pre></td></tr>
1849 <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>
1850 <tr><td colspan="4" class="doc" id="designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99 6.7.8].
1852 Example: Matches { [2].y = 1.0, [0].x = 1.0 }
1853 point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
1854 </pre></td></tr>
1857 <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>
1858 <tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements.
1860 Given
1861 do {} while (true);
1862 doStmt()
1863 matches 'do {} while(true)'
1864 </pre></td></tr>
1867 <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>
1868 <tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions.
1870 Matches any cast expression written in user code, whether it be a
1871 C-style cast, a functional-style cast, or a keyword cast.
1873 Does not match implicit conversions.
1875 Note: the name "explicitCast" is chosen to match Clang's terminology, as
1876 Clang uses the term "cast" to apply to implicit conversions as well as to
1877 actual cast expressions.
1879 See also: hasDestinationType.
1881 Example: matches all five of the casts in
1882 int((int)(reinterpret_cast&lt;int&gt;(static_cast&lt;int&gt;(const_cast&lt;int&gt;(42)))))
1883 but does not match the implicit conversion in
1884 long ell = 42;
1885 </pre></td></tr>
1888 <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>
1889 <tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions.
1891 Example matches x()
1892 void f() { x(); }
1893 </pre></td></tr>
1896 <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>
1897 <tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end
1898 of the sub-expression's evaluation.
1900 Example matches std::string()
1901 const std::string str = std::string();
1902 </pre></td></tr>
1905 <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>
1906 <tr><td colspan="4" class="doc" id="fixedPointLiteral0"><pre>Matches fixed point literals
1907 </pre></td></tr>
1910 <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>
1911 <tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes / encodings, e.g.
1912 1.0, 1.0f, 1.0L and 1e10.
1914 Does not match implicit conversions such as
1915 float a = 10;
1916 </pre></td></tr>
1919 <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>
1920 <tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements.
1922 Example matches 'for (;;) {}'
1923 for (;;) {}
1924 int i[] = {1, 2, 3}; for (auto a : i);
1925 </pre></td></tr>
1928 <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>
1929 <tr><td colspan="4" class="doc" id="genericSelectionExpr0"><pre>Matches C11 _Generic expression.
1930 </pre></td></tr>
1933 <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>
1934 <tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression.
1935 </pre></td></tr>
1938 <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>
1939 <tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements.
1941 Given
1942 goto FOO;
1943 FOO: bar();
1944 gotoStmt()
1945 matches 'goto FOO'
1946 </pre></td></tr>
1949 <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>
1950 <tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements.
1952 Example matches 'if (x) {}'
1953 if (x) {}
1954 </pre></td></tr>
1957 <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>
1958 <tr><td colspan="4" class="doc" id="imaginaryLiteral0"><pre>Matches imaginary literals, which are based on integer and floating
1959 point literals e.g.: 1i, 1.0i
1960 </pre></td></tr>
1963 <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>
1964 <tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST.
1966 This matches many different places, including function call return value
1967 eliding, as well as any type conversions.
1968 </pre></td></tr>
1971 <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>
1972 <tr><td colspan="4" class="doc" id="implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions.
1974 Given
1975 point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 };
1976 implicitValueInitExpr()
1977 matches "[0].y" (implicitly)
1978 </pre></td></tr>
1981 <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>
1982 <tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions.
1984 Given
1985 int a[] = { 1, 2 };
1986 struct B { int x, y; };
1987 B b = { 5, 6 };
1988 initListExpr()
1989 matches "{ 1, 2 }" and "{ 5, 6 }"
1990 </pre></td></tr>
1993 <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>
1994 <tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes / encodings, e.g.
1995 1, 1L, 0x1 and 1U.
1997 Does not match character-encoded integers such as L'a'.
1998 </pre></td></tr>
2001 <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>
2002 <tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements.
2004 Given
2005 goto FOO;
2006 FOO: bar();
2007 labelStmt()
2008 matches 'FOO:'
2009 </pre></td></tr>
2012 <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>
2013 <tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions.
2015 Example matches [&amp;](){return 5;}
2016 [&amp;](){return 5;}
2017 </pre></td></tr>
2020 <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>
2021 <tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized.
2023 Example: Given
2024 struct T {void func();};
2025 T f();
2026 void g(T);
2027 materializeTemporaryExpr() matches 'f()' in these statements
2028 T u(f());
2029 g(f());
2030 f().func();
2031 but does not match
2032 f();
2033 </pre></td></tr>
2036 <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>
2037 <tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions.
2039 Given
2040 class Y {
2041 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
2042 int a; static int b;
2044 memberExpr()
2045 matches this-&gt;x, x, y.x, a, this-&gt;b
2046 </pre></td></tr>
2049 <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>
2050 <tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements.
2052 foo();;
2053 nullStmt()
2054 matches the second ';'
2055 </pre></td></tr>
2058 <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>
2059 <tr><td colspan="4" class="doc" id="objcCatchStmt0"><pre>Matches Objective-C @catch statements.
2061 Example matches @catch
2062 @try {}
2063 @catch (...) {}
2064 </pre></td></tr>
2067 <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>
2068 <tr><td colspan="4" class="doc" id="objcFinallyStmt0"><pre>Matches Objective-C @finally statements.
2070 Example matches @finally
2071 @try {}
2072 @finally {}
2073 </pre></td></tr>
2076 <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>
2077 <tr><td colspan="4" class="doc" id="objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar.
2079 Example: matches "a" in "init" method:
2080 @implementation A {
2081 NSString *a;
2083 - (void) init {
2084 a = @"hello";
2086 </pre></td></tr>
2089 <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>
2090 <tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions.
2092 The innermost message send invokes the "alloc" class method on the
2093 NSString class, while the outermost message send invokes the
2094 "initWithString" instance method on the object returned from
2095 NSString's "alloc". This matcher should match both message sends.
2096 [[NSString alloc] initWithString:@"Hello"]
2097 </pre></td></tr>
2100 <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>
2101 <tr><td colspan="4" class="doc" id="objcStringLiteral0"><pre>Matches ObjectiveC String literal expressions.
2103 Example matches @"abcd"
2104 NSString *s = @"abcd";
2105 </pre></td></tr>
2108 <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>
2109 <tr><td colspan="4" class="doc" id="objcThrowStmt0"><pre>Matches Objective-C statements.
2111 Example matches @throw obj;
2112 </pre></td></tr>
2115 <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>
2116 <tr><td colspan="4" class="doc" id="objcTryStmt0"><pre>Matches Objective-C @try statements.
2118 Example matches @try
2119 @try {}
2120 @catch (...) {}
2121 </pre></td></tr>
2124 <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>
2125 <tr><td colspan="4" class="doc" id="ompExecutableDirective0"><pre>Matches any ``#pragma omp`` executable directive.
2127 Given
2129 #pragma omp parallel
2130 #pragma omp parallel default(none)
2131 #pragma omp taskyield
2133 ``ompExecutableDirective()`` matches ``omp parallel``,
2134 ``omp parallel default(none)`` and ``omp taskyield``.
2135 </pre></td></tr>
2138 <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>
2139 <tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers
2140 to reference another expressions and can be met
2141 in BinaryConditionalOperators, for example.
2143 Example matches 'a'
2144 (a ?: c) + 42;
2145 </pre></td></tr>
2148 <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>
2149 <tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions.
2151 Example matches (foo() + 1)
2152 int foo() { return 1; }
2153 int a = (foo() + 1);
2154 </pre></td></tr>
2157 <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>
2158 <tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions.
2159 ParenListExprs don't have a predefined type and are used for late parsing.
2160 In the final AST, they can be met in template declarations.
2162 Given
2163 template&lt;typename T&gt; class X {
2164 void f() {
2165 X x(*this);
2166 int a = 0, b = 1; int i = (a, b);
2169 parenListExpr() matches "*this" but NOT matches (a, b) because (a, b)
2170 has a predefined type and is a ParenExpr, not a ParenListExpr.
2171 </pre></td></tr>
2174 <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>
2175 <tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2].
2177 Example: Matches __func__
2178 printf("%s", __func__);
2179 </pre></td></tr>
2182 <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>
2183 <tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements.
2185 Given
2186 return 1;
2187 returnStmt()
2188 matches 'return 1'
2189 </pre></td></tr>
2192 <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>
2193 <tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements.
2195 Given
2196 { ++a; }
2197 stmt()
2198 matches both the compound statement '{ ++a; }' and '++a'.
2199 </pre></td></tr>
2202 <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>
2203 <tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension).
2205 Example match: ({ int X = 4; X; })
2206 int C = ({ int X = 4; X; });
2207 </pre></td></tr>
2210 <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>
2211 <tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals).
2213 Example matches "abcd", L"abcd"
2214 char *s = "abcd";
2215 wchar_t *ws = L"abcd";
2216 </pre></td></tr>
2219 <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>
2220 <tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters.
2222 Given
2223 template &lt;int N&gt;
2224 struct A { static const int n = N; };
2225 struct B : public A&lt;42&gt; {};
2226 substNonTypeTemplateParmExpr()
2227 matches "N" in the right-hand side of "static const int n = N;"
2228 </pre></td></tr>
2231 <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>
2232 <tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements.
2234 Given
2235 switch(a) { case 42: break; default: break; }
2236 switchCase()
2237 matches 'case 42:' and 'default:'.
2238 </pre></td></tr>
2241 <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>
2242 <tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements.
2244 Given
2245 switch(a) { case 42: break; default: break; }
2246 switchStmt()
2247 matches 'switch(a)'.
2248 </pre></td></tr>
2251 <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>
2252 <tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
2254 Given
2255 Foo x = bar;
2256 int y = sizeof(x) + alignof(x);
2257 unaryExprOrTypeTraitExpr()
2258 matches sizeof(x) and alignof(x)
2259 </pre></td></tr>
2262 <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>
2263 <tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions.
2265 Example matches !a
2266 !a || b
2267 </pre></td></tr>
2270 <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>
2271 <tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing
2272 but could not be resolved to a specific declaration.
2274 Given
2275 template&lt;typename T&gt;
2276 T foo() { T a; return a; }
2277 template&lt;typename T&gt;
2278 void bar() {
2279 foo&lt;T&gt;();
2281 unresolvedLookupExpr()
2282 matches foo&lt;T&gt;() </pre></td></tr>
2285 <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>
2286 <tr><td colspan="4" class="doc" id="unresolvedMemberExpr0"><pre>Matches unresolved member expressions.
2288 Given
2289 struct X {
2290 template &lt;class T&gt; void f();
2291 void g();
2293 template &lt;class T&gt; void h() { X x; x.f&lt;T&gt;(); x.g(); }
2294 unresolvedMemberExpr()
2295 matches x.f&lt;T&gt;
2296 </pre></td></tr>
2299 <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>
2300 <tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call.
2302 Example match: "foo"_suffix
2303 </pre></td></tr>
2306 <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>
2307 <tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements.
2309 Given
2310 while (true) {}
2311 whileStmt()
2312 matches 'while (true) {}'.
2313 </pre></td></tr>
2316 <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>
2317 <tr><td colspan="4" class="doc" id="templateArgumentLoc0"><pre>Matches template arguments (with location info).
2319 Given
2320 template &lt;typename T&gt; struct C {};
2321 C&lt;int&gt; c;
2322 templateArgumentLoc()
2323 matches 'int' in C&lt;int&gt;.
2324 </pre></td></tr>
2327 <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>
2328 <tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments.
2330 Given
2331 template &lt;typename T&gt; struct C {};
2332 C&lt;int&gt; c;
2333 templateArgument()
2334 matches 'int' in C&lt;int&gt;.
2335 </pre></td></tr>
2338 <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>
2339 <tr><td colspan="4" class="doc" id="templateName0"><pre>Matches template name.
2341 Given
2342 template &lt;typename T&gt; class X { };
2343 X&lt;int&gt; xi;
2344 templateName()
2345 matches 'X' in X&lt;int&gt;.
2346 </pre></td></tr>
2349 <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>
2350 <tr><td colspan="4" class="doc" id="elaboratedTypeLoc0"><pre>Matches C or C++ elaborated `TypeLoc`s.
2352 Given
2353 struct s {};
2354 struct s ss;
2355 elaboratedTypeLoc()
2356 matches the `TypeLoc` of the variable declaration of `ss`.
2357 </pre></td></tr>
2360 <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>
2361 <tr><td colspan="4" class="doc" id="pointerTypeLoc0"><pre>Matches pointer `TypeLoc`s.
2363 Given
2364 int* x;
2365 pointerTypeLoc()
2366 matches `int*`.
2367 </pre></td></tr>
2370 <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>
2371 <tr><td colspan="4" class="doc" id="qualifiedTypeLoc0"><pre>Matches `QualifiedTypeLoc`s in the clang AST.
2373 Given
2374 const int x = 0;
2375 qualifiedTypeLoc()
2376 matches `const int`.
2377 </pre></td></tr>
2380 <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>
2381 <tr><td colspan="4" class="doc" id="referenceTypeLoc0"><pre>Matches reference `TypeLoc`s.
2383 Given
2384 int x = 3;
2385 int&amp; l = x;
2386 int&amp;&amp; r = 3;
2387 referenceTypeLoc()
2388 matches `int&amp;` and `int&amp;&amp;`.
2389 </pre></td></tr>
2392 <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>
2393 <tr><td colspan="4" class="doc" id="templateSpecializationTypeLoc0"><pre>Matches template specialization `TypeLoc`s.
2395 Given
2396 template &lt;typename T&gt; class C {};
2397 C&lt;char&gt; var;
2398 varDecl(hasTypeLoc(templateSpecializationTypeLoc(typeLoc())))
2399 matches `C&lt;char&gt; var`.
2400 </pre></td></tr>
2403 <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>
2404 <tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST.
2405 </pre></td></tr>
2408 <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>
2409 <tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays.
2411 Given
2412 int a[] = { 2, 3 };
2413 int b[4];
2414 void f() { int c[a[0]]; }
2415 arrayType()
2416 matches "int a[]", "int b[4]" and "int c[a[0]]";
2417 </pre></td></tr>
2420 <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>
2421 <tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types.
2423 Given
2424 _Atomic(int) i;
2425 atomicType()
2426 matches "_Atomic(int) i"
2427 </pre></td></tr>
2430 <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>
2431 <tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types.
2433 Given:
2434 auto n = 4;
2435 int v[] = { 2, 3 }
2436 for (auto i : v) { }
2437 autoType()
2438 matches "auto n" and "auto i"
2439 </pre></td></tr>
2442 <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>
2443 <tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as
2444 "void (^)(int)".
2446 The pointee is always required to be a FunctionType.
2447 </pre></td></tr>
2450 <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>
2451 <tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types.
2453 Given
2454 struct A {};
2455 A a;
2456 int b;
2457 float c;
2458 bool d;
2459 builtinType()
2460 matches "int b", "float c" and "bool d"
2461 </pre></td></tr>
2464 <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>
2465 <tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types.
2467 Given
2468 _Complex float f;
2469 complexType()
2470 matches "_Complex float f"
2471 </pre></td></tr>
2474 <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>
2475 <tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size.
2477 Given
2478 void() {
2479 int a[2];
2480 int b[] = { 2, 3 };
2481 int c[b[0]];
2483 constantArrayType()
2484 matches "int a[2]"
2485 </pre></td></tr>
2488 <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>
2489 <tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type
2490 Example matches i[] in declaration of f.
2491 (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
2492 Example matches i[1].
2493 (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())))))
2494 void f(int i[]) {
2495 i[1] = 0;
2497 </pre></td></tr>
2500 <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>
2501 <tr><td colspan="4" class="doc" id="decltypeType0"><pre>Matches types nodes representing C++11 decltype(&lt;expr&gt;) types.
2503 Given:
2504 short i = 1;
2505 int j = 42;
2506 decltype(i + j) result = i + j;
2507 decltypeType()
2508 matches "decltype(i + j)"
2509 </pre></td></tr>
2512 <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>
2513 <tr><td colspan="4" class="doc" id="deducedTemplateSpecializationType0"><pre>Matches C++17 deduced template specialization types, e.g. deduced class
2514 template types.
2516 Given
2517 template &lt;typename T&gt;
2518 class C { public: C(T); };
2520 C c(123);
2521 deducedTemplateSpecializationType() matches the type in the declaration
2522 of the variable c.
2523 </pre></td></tr>
2526 <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>
2527 <tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression.
2529 Given
2530 template&lt;typename T, int Size&gt;
2531 class array {
2532 T data[Size];
2534 dependentSizedArrayType()
2535 matches "T data[Size]"
2536 </pre></td></tr>
2539 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('dependentSizedExtVectorType0')"><a name="dependentSizedExtVectorType0Anchor">dependentSizedExtVectorType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentSizedExtVectorType.html">DependentSizedExtVectorType</a>&gt;...</td></tr>
2540 <tr><td colspan="4" class="doc" id="dependentSizedExtVectorType0"><pre>Matches C++ extended vector type where either the type or size is
2541 dependent.
2543 Given
2544 template&lt;typename T, int Size&gt;
2545 class vector {
2546 typedef T __attribute__((ext_vector_type(Size))) type;
2548 dependentSizedExtVectorType()
2549 matches "T __attribute__((ext_vector_type(Size)))"
2550 </pre></td></tr>
2553 <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>
2554 <tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a
2555 qualified name.
2557 Given
2558 namespace N {
2559 namespace M {
2560 class D {};
2563 class C {};
2565 class C c;
2566 N::M::D d;
2568 elaboratedType() matches the type of the variable declarations of both
2569 c and d.
2570 </pre></td></tr>
2573 <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>
2574 <tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types.
2576 Given
2577 enum C { Green };
2578 enum class S { Red };
2580 C c;
2581 S s;
2583 enumType() matches the type of the variable declarations of both c and
2585 </pre></td></tr>
2588 <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>
2589 <tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes.
2591 Given
2592 int (*f)(int);
2593 void g();
2594 functionProtoType()
2595 matches "int (*f)(int)" and the type of "g" in C++ mode.
2596 In C mode, "g" is not matched because it does not contain a prototype.
2597 </pre></td></tr>
2600 <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>
2601 <tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes.
2603 Given
2604 int (*f)(int);
2605 void g();
2606 functionType()
2607 matches "int (*f)(int)" and the type of "g".
2608 </pre></td></tr>
2611 <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>
2612 <tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size.
2614 Given
2615 int a[] = { 2, 3 };
2616 int b[42];
2617 void f(int c[]) { int d[a[0]]; };
2618 incompleteArrayType()
2619 matches "int a[]" and "int c[]"
2620 </pre></td></tr>
2623 <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>
2624 <tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types.
2626 Example matches S s, but not S&lt;T&gt; s.
2627 (matcher = parmVarDecl(hasType(injectedClassNameType())))
2628 template &lt;typename T&gt; struct S {
2629 void f(S s);
2630 void g(S&lt;T&gt; s);
2632 </pre></td></tr>
2635 <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>
2636 <tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types.
2638 Given:
2639 int *a;
2640 int &amp;b = *a;
2641 int &amp;&amp;c = 1;
2642 auto &amp;d = b;
2643 auto &amp;&amp;e = c;
2644 auto &amp;&amp;f = 2;
2645 int g = 5;
2647 lValueReferenceType() matches the types of b, d, and e. e is
2648 matched since the type is deduced as int&amp; by reference collapsing rules.
2649 </pre></td></tr>
2652 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('macroQualifiedType0')"><a name="macroQualifiedType0Anchor">macroQualifiedType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1MacroQualifiedType.html">MacroQualifiedType</a>&gt;...</td></tr>
2653 <tr><td colspan="4" class="doc" id="macroQualifiedType0"><pre>Matches qualified types when the qualifier is applied via a macro.
2655 Given
2656 #define CDECL __attribute__((cdecl))
2657 typedef void (CDECL *X)();
2658 typedef void (__attribute__((cdecl)) *Y)();
2659 macroQualifiedType()
2660 matches the type of the typedef declaration of X but not Y.
2661 </pre></td></tr>
2664 <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>
2665 <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types.
2666 Given
2667 struct A { int i; }
2668 A::* ptr = A::i;
2669 memberPointerType()
2670 matches "A::* ptr"
2671 </pre></td></tr>
2674 <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>
2675 <tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from
2676 a pointer type, despite being syntactically similar.
2678 Given
2679 int *a;
2681 @interface Foo
2682 @end
2683 Foo *f;
2684 pointerType()
2685 matches "Foo *f", but does not match "int *a".
2686 </pre></td></tr>
2689 <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>
2690 <tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes.
2692 Given
2693 int (*ptr_to_array)[4];
2694 int *array_of_ptrs[4];
2696 varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not
2697 array_of_ptrs.
2698 </pre></td></tr>
2701 <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>
2702 <tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer
2703 types.
2705 Given
2706 int *a;
2707 int &amp;b = *a;
2708 int c = 5;
2710 @interface Foo
2711 @end
2712 Foo *f;
2713 pointerType()
2714 matches "int *a", but does not match "Foo *f".
2715 </pre></td></tr>
2718 <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>
2719 <tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types.
2721 Given:
2722 int *a;
2723 int &amp;b = *a;
2724 int &amp;&amp;c = 1;
2725 auto &amp;d = b;
2726 auto &amp;&amp;e = c;
2727 auto &amp;&amp;f = 2;
2728 int g = 5;
2730 rValueReferenceType() matches the types of c and f. e is not
2731 matched as it is deduced to int&amp; by reference collapsing rules.
2732 </pre></td></tr>
2735 <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>
2736 <tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes).
2738 Given
2739 class C {};
2740 struct S {};
2742 C c;
2743 S s;
2745 recordType() matches the type of the variable declarations of both c
2746 and s.
2747 </pre></td></tr>
2750 <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>
2751 <tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types.
2753 Given
2754 int *a;
2755 int &amp;b = *a;
2756 int &amp;&amp;c = 1;
2757 auto &amp;d = b;
2758 auto &amp;&amp;e = c;
2759 auto &amp;&amp;f = 2;
2760 int g = 5;
2762 referenceType() matches the types of b, c, d, e, and f.
2763 </pre></td></tr>
2766 <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>
2767 <tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a
2768 template type parameter.
2770 Given
2771 template &lt;typename T&gt;
2772 void F(T t) {
2773 int i = 1 + t;
2776 substTemplateTypeParmType() matches the type of 't' but not '1'
2777 </pre></td></tr>
2780 <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>
2781 <tr><td colspan="4" class="doc" id="tagType0"><pre>Matches tag types (record and enum types).
2783 Given
2784 enum E {};
2785 class C {};
2787 E e;
2788 C c;
2790 tagType() matches the type of the variable declarations of both e
2791 and c.
2792 </pre></td></tr>
2795 <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>
2796 <tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types.
2798 Given
2799 template &lt;typename T&gt;
2800 class C { };
2802 template class C&lt;int&gt;; // A
2803 C&lt;char&gt; var; // B
2805 templateSpecializationType() matches the type of the explicit
2806 instantiation in A and the type of the variable declaration in B.
2807 </pre></td></tr>
2810 <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>
2811 <tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types.
2813 Example matches T, but not int.
2814 (matcher = templateTypeParmType())
2815 template &lt;typename T&gt; void f(int i);
2816 </pre></td></tr>
2819 <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>
2820 <tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST.
2821 </pre></td></tr>
2824 <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>
2825 <tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types.
2827 Given
2828 typedef int X;
2829 typedefType()
2830 matches "typedef int X"
2831 </pre></td></tr>
2834 <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>
2835 <tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations.
2837 Given:
2838 typedef __underlying_type(T) type;
2839 unaryTransformType()
2840 matches "__underlying_type(T)"
2841 </pre></td></tr>
2844 <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>
2845 <tr><td colspan="4" class="doc" id="usingType0"><pre>Matches types specified through a using declaration.
2847 Given
2848 namespace a { struct S {}; }
2849 using a::S;
2850 S s;
2852 usingType() matches the type of the variable declaration of s.
2853 </pre></td></tr>
2856 <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>
2857 <tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an
2858 integer-constant-expression.
2860 Given
2861 void f() {
2862 int a[] = { 2, 3 }
2863 int b[42];
2864 int c[a[0]];
2866 variableArrayType()
2867 matches "int c[a[0]]"
2868 </pre></td></tr>
2870 <!--END_DECL_MATCHERS -->
2871 </table>
2873 <!-- ======================================================================= -->
2874 <h2 id="narrowing-matchers">Narrowing Matchers</h2>
2875 <!-- ======================================================================= -->
2877 <p>Narrowing matchers match certain attributes on the current node, thus
2878 narrowing down the set of nodes of the current type to match on.</p>
2880 <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless)
2881 which allow users to create more powerful match expressions.</p>
2883 <table>
2884 <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
2885 <!-- START_NARROWING_MATCHERS -->
2887 <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>
2888 <tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match.
2890 Usable as: Any Matcher
2891 </pre></td></tr>
2894 <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>
2895 <tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches.
2897 Usable as: Any Matcher
2898 </pre></td></tr>
2901 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr>
2902 <tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node.
2904 Useful when another matcher requires a child matcher, but there's no
2905 additional constraint. This will often be used with an explicit conversion
2906 to an internal::Matcher&lt;&gt; type such as TypeMatcher.
2908 Example: DeclarationMatcher(anything()) matches all declarations, e.g.,
2909 "int* p" and "void f()" in
2910 int* p;
2911 void f();
2913 Usable as: Any Matcher
2914 </pre></td></tr>
2917 <tr><td><em>unspecified</em></td><td class="name" onclick="toggle('mapAnyOf0')"><a name="mapAnyOf0Anchor">mapAnyOf</a></td><td>nodeMatcherFunction...</td></tr>
2918 <tr><td colspan="4" class="doc" id="mapAnyOf0"><pre>Matches any of the NodeMatchers with InnerMatchers nested within
2920 Given
2921 if (true);
2922 for (; true; );
2923 with the matcher
2924 mapAnyOf(ifStmt, forStmt).with(
2925 hasCondition(cxxBoolLiteralExpr(equals(true)))
2926 ).bind("trueCond")
2927 matches the if and the for. It is equivalent to:
2928 auto trueCond = hasCondition(cxxBoolLiteralExpr(equals(true)));
2929 anyOf(
2930 ifStmt(trueCond).bind("trueCond"),
2931 forStmt(trueCond).bind("trueCond")
2934 The with() chain-call accepts zero or more matchers which are combined
2935 as-if with allOf() in each of the node matchers.
2936 Usable as: Any Matcher
2937 </pre></td></tr>
2940 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher&lt;*&gt;</td></tr>
2941 <tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match.
2943 Example matches Y (matcher = cxxRecordDecl(unless(hasName("X"))))
2944 class X {};
2945 class Y {};
2947 Usable as: Any Matcher
2948 </pre></td></tr>
2951 <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>
2952 <tr><td colspan="4" class="doc" id="isImplicit1"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
2953 implicit default/copy constructors).
2954 </pre></td></tr>
2957 <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>
2958 <tr><td colspan="4" class="doc" id="hasAnyOperatorName0"><pre>Matches operator expressions (binary or unary) that have any of the
2959 specified names.
2961 hasAnyOperatorName("+", "-")
2962 Is equivalent to
2963 anyOf(hasOperatorName("+"), hasOperatorName("-"))
2964 </pre></td></tr>
2967 <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>
2968 <tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or
2969 unary).
2971 Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
2972 !(a || b)
2973 </pre></td></tr>
2976 <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>
2977 <tr><td colspan="4" class="doc" id="isAssignmentOperator0"><pre>Matches all kinds of assignment operators.
2979 Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
2980 if (a == b)
2981 a += b;
2983 Example 2: matches s1 = s2
2984 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
2985 struct S { S&amp; operator=(const S&amp;); };
2986 void x() { S s1, s2; s1 = s2; }
2987 </pre></td></tr>
2990 <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>
2991 <tr><td colspan="4" class="doc" id="isComparisonOperator0"><pre>Matches comparison operators.
2993 Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
2994 if (a == b)
2995 a += b;
2997 Example 2: matches s1 &lt; s2
2998 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
2999 struct S { bool operator&lt;(const S&amp; other); };
3000 void x(S s1, S s2) { bool b1 = s1 &lt; s2; }
3001 </pre></td></tr>
3004 <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>
3005 <tr><td colspan="4" class="doc" id="isPrivate1"><pre>Matches private C++ declarations and C++ base specifers that specify private
3006 inheritance.
3008 Examples:
3009 class C {
3010 public: int a;
3011 protected: int b;
3012 private: int c; // fieldDecl(isPrivate()) matches 'c'
3015 struct Base {};
3016 struct Derived1 : private Base {}; // matches 'Base'
3017 class Derived2 : Base {}; // matches 'Base'
3018 </pre></td></tr>
3021 <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>
3022 <tr><td colspan="4" class="doc" id="isProtected1"><pre>Matches protected C++ declarations and C++ base specifers that specify
3023 protected inheritance.
3025 Examples:
3026 class C {
3027 public: int a;
3028 protected: int b; // fieldDecl(isProtected()) matches 'b'
3029 private: int c;
3032 class Base {};
3033 class Derived : protected Base {}; // matches 'Base'
3034 </pre></td></tr>
3037 <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>
3038 <tr><td colspan="4" class="doc" id="isPublic1"><pre>Matches public C++ declarations and C++ base specifers that specify public
3039 inheritance.
3041 Examples:
3042 class C {
3043 public: int a; // fieldDecl(isPublic()) matches 'a'
3044 protected: int b;
3045 private: int c;
3048 class Base {};
3049 class Derived1 : public Base {}; // matches 'Base'
3050 struct Derived2 : Base {}; // matches 'Base'
3051 </pre></td></tr>
3054 <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>
3055 <tr><td colspan="4" class="doc" id="isVirtual1"><pre>Matches declarations of virtual methods and C++ base specifers that specify
3056 virtual inheritance.
3058 Example:
3059 class A {
3060 public:
3061 virtual void x(); // matches x
3064 Example:
3065 class Base {};
3066 class DirectlyDerived : virtual Base {}; // matches Base
3067 class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
3069 Usable 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;
3070 </pre></td></tr>
3073 <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>
3074 <tr><td colspan="4" class="doc" id="equals5"><pre></pre></td></tr>
3077 <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>
3078 <tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value of type ValueT.
3080 Given
3081 f('false, 3.14, 42);
3082 characterLiteral(equals(0))
3083 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
3084 match false
3085 floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
3086 match 3.14
3087 integerLiteral(equals(42))
3088 matches 42
3090 Note that you cannot directly match a negative numeric literal because the
3091 minus sign is not part of the literal: It is a unary operator whose operand
3092 is the positive numeric literal. Instead, you must use a unaryOperator()
3093 matcher to match the minus sign:
3095 unaryOperator(hasOperatorName("-"),
3096 hasUnaryOperand(integerLiteral(equals(13))))
3098 Usable 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;,
3099 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;
3100 </pre></td></tr>
3103 <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>
3104 <tr><td colspan="4" class="doc" id="equals11"><pre></pre></td></tr>
3107 <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>
3108 <tr><td colspan="4" class="doc" id="equals8"><pre></pre></td></tr>
3111 <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>
3112 <tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler.
3114 Given
3115 try {
3116 // ...
3117 } catch (int) {
3118 // ...
3119 } catch (...) {
3120 // ...
3122 cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
3123 </pre></td></tr>
3126 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>&gt;</td><td class="name" onclick="toggle('argumentCountAtLeast1')"><a name="argumentCountAtLeast1Anchor">argumentCountAtLeast</a></td><td>unsigned N</td></tr>
3127 <tr><td colspan="4" class="doc" id="argumentCountAtLeast1"><pre>Checks that a call expression or a constructor call expression has at least
3128 the specified number of arguments (including absent default arguments).
3130 Example matches f(0, 0) and g(0, 0, 0)
3131 (matcher = callExpr(argumentCountAtLeast(2)))
3132 void f(int x, int y);
3133 void g(int x, int y, int z);
3134 f(0, 0);
3135 g(0, 0, 0);
3136 </pre></td></tr>
3139 <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>
3140 <tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has
3141 a specific number of arguments (including absent default arguments).
3143 Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
3144 void f(int x, int y);
3145 f(0, 0);
3146 </pre></td></tr>
3149 <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>
3150 <tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization.
3151 </pre></td></tr>
3154 <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>
3155 <tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires
3156 zero initialization.
3158 Given
3159 void foo() {
3160 struct point { double x; double y; };
3161 point pt[2] = { { 1.0, 2.0 } };
3163 initListExpr(has(cxxConstructExpr(requiresZeroInitialization()))
3164 will match the implicit array filler for pt[1].
3165 </pre></td></tr>
3168 <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>
3169 <tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors.
3171 Given
3172 struct S {
3173 S(); // #1
3174 S(const S &amp;); // #2
3175 S(S &amp;&amp;); // #3
3177 cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
3178 </pre></td></tr>
3181 <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>
3182 <tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors.
3184 Given
3185 struct S {
3186 S(); // #1
3187 S(const S &amp;); // #2
3188 S(S &amp;&amp;); // #3
3190 cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
3191 </pre></td></tr>
3194 <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>
3195 <tr><td colspan="4" class="doc" id="isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor.
3197 Given
3198 struct S {
3199 S(); // #1
3200 S(int) {} // #2
3201 S(S &amp;&amp;) : S() {} // #3
3203 S::S() : S(0) {} // #4
3204 cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not
3205 #1 or #2.
3206 </pre></td></tr>
3209 <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>
3210 <tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor, conversion function, and deduction guide declarations
3211 that have an explicit specifier if this explicit specifier is resolved to
3212 true.
3214 Given
3215 template&lt;bool b&gt;
3216 struct S {
3217 S(int); // #1
3218 explicit S(double); // #2
3219 operator int(); // #3
3220 explicit operator bool(); // #4
3221 explicit(false) S(bool) // # 7
3222 explicit(true) S(char) // # 8
3223 explicit(b) S(S) // # 9
3225 S(int) -&gt; S&lt;true&gt; // #5
3226 explicit S(double) -&gt; S&lt;false&gt; // #6
3227 cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
3228 cxxConversionDecl(isExplicit()) will match #4, but not #3.
3229 cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
3230 </pre></td></tr>
3233 <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>
3234 <tr><td colspan="4" class="doc" id="isInheritingConstructor0"><pre></pre></td></tr>
3237 <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>
3238 <tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors.
3240 Given
3241 struct S {
3242 S(); // #1
3243 S(const S &amp;); // #2
3244 S(S &amp;&amp;); // #3
3246 cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
3247 </pre></td></tr>
3250 <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>
3251 <tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor, conversion function, and deduction guide declarations
3252 that have an explicit specifier if this explicit specifier is resolved to
3253 true.
3255 Given
3256 template&lt;bool b&gt;
3257 struct S {
3258 S(int); // #1
3259 explicit S(double); // #2
3260 operator int(); // #3
3261 explicit operator bool(); // #4
3262 explicit(false) S(bool) // # 7
3263 explicit(true) S(char) // # 8
3264 explicit(b) S(S) // # 9
3266 S(int) -&gt; S&lt;true&gt; // #5
3267 explicit S(double) -&gt; S&lt;false&gt; // #6
3268 cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
3269 cxxConversionDecl(isExplicit()) will match #4, but not #3.
3270 cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
3271 </pre></td></tr>
3274 <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>
3275 <tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as
3276 opposed to a member.
3278 Given
3279 struct B {};
3280 struct D : B {
3281 int I;
3282 D(int i) : I(i) {}
3284 struct E : B {
3285 E() : B() {}
3287 cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
3288 will match E(), but not match D(int).
3289 </pre></td></tr>
3292 <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>
3293 <tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as
3294 opposed to a base.
3296 Given
3297 struct B {};
3298 struct D : B {
3299 int I;
3300 D(int i) : I(i) {}
3302 struct E : B {
3303 E() : B() {}
3305 cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
3306 will match D(int), but not match E().
3307 </pre></td></tr>
3310 <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>
3311 <tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in
3312 code (as opposed to implicitly added by the compiler).
3314 Given
3315 struct Foo {
3316 Foo() { }
3317 Foo(int) : foo_("A") { }
3318 string foo_;
3320 cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
3321 will match Foo(int), but not Foo()
3322 </pre></td></tr>
3325 <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>
3326 <tr><td colspan="4" class="doc" id="isExplicit2"><pre>Matches constructor, conversion function, and deduction guide declarations
3327 that have an explicit specifier if this explicit specifier is resolved to
3328 true.
3330 Given
3331 template&lt;bool b&gt;
3332 struct S {
3333 S(int); // #1
3334 explicit S(double); // #2
3335 operator int(); // #3
3336 explicit operator bool(); // #4
3337 explicit(false) S(bool) // # 7
3338 explicit(true) S(char) // # 8
3339 explicit(b) S(S) // # 9
3341 S(int) -&gt; S&lt;true&gt; // #5
3342 explicit S(double) -&gt; S&lt;false&gt; // #6
3343 cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
3344 cxxConversionDecl(isExplicit()) will match #4, but not #3.
3345 cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
3346 </pre></td></tr>
3349 <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>
3350 <tr><td colspan="4" class="doc" id="hasMemberName0"><pre>Matches template-dependent, but known, member names.
3352 In template declarations, dependent members are not resolved and so can
3353 not be matched to particular named declarations.
3355 This matcher allows to match on the known name of members.
3357 Given
3358 template &lt;typename T&gt;
3359 struct S {
3360 void mem();
3362 template &lt;typename T&gt;
3363 void x() {
3364 S&lt;T&gt; s;
3365 s.mem();
3367 cxxDependentScopeMemberExpr(hasMemberName("mem")) matches `s.mem()`
3368 </pre></td></tr>
3371 <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>
3372 <tr><td colspan="4" class="doc" id="isArrow2"><pre>Matches member expressions that are called with '-&gt;' as opposed
3373 to '.'.
3375 Member calls on the implicit this pointer match as called with '-&gt;'.
3377 Given
3378 class Y {
3379 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
3380 template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
3381 int a;
3382 static int b;
3384 template &lt;class T&gt;
3385 class Z {
3386 void x() { this-&gt;m; }
3388 memberExpr(isArrow())
3389 matches this-&gt;x, x, y.x, a, this-&gt;b
3390 cxxDependentScopeMemberExpr(isArrow())
3391 matches this-&gt;m
3392 unresolvedMemberExpr(isArrow())
3393 matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
3394 </pre></td></tr>
3397 <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>
3398 <tr><td colspan="4" class="doc" id="memberHasSameNameAsBoundNode0"><pre>Matches template-dependent, but known, member names against an already-bound
3399 node
3401 In template declarations, dependent members are not resolved and so can
3402 not be matched to particular named declarations.
3404 This matcher allows to match on the name of already-bound VarDecl, FieldDecl
3405 and CXXMethodDecl nodes.
3407 Given
3408 template &lt;typename T&gt;
3409 struct S {
3410 void mem();
3412 template &lt;typename T&gt;
3413 void x() {
3414 S&lt;T&gt; s;
3415 s.mem();
3417 The matcher
3418 @code
3419 cxxDependentScopeMemberExpr(
3420 hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
3421 hasDeclaration(classTemplateDecl(has(cxxRecordDecl(has(
3422 cxxMethodDecl(hasName("mem")).bind("templMem")
3423 )))))
3424 )))),
3425 memberHasSameNameAsBoundNode("templMem")
3427 @endcode
3428 first matches and binds the @c mem member of the @c S template, then
3429 compares its name to the usage in @c s.mem() in the @c x function template
3430 </pre></td></tr>
3433 <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>
3434 <tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const.
3436 Given
3437 struct A {
3438 void foo() const;
3439 void bar();
3442 cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
3443 </pre></td></tr>
3446 <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>
3447 <tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment
3448 operator.
3450 Given
3451 struct A {
3452 A &amp;operator=(const A &amp;);
3453 A &amp;operator=(A &amp;&amp;);
3456 cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not
3457 the second one.
3458 </pre></td></tr>
3461 <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>
3462 <tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final.
3464 Given:
3465 class A final {};
3467 struct B {
3468 virtual void f();
3471 struct C : B {
3472 void f() final;
3474 matches A and C::f, but not B, C, or B::f
3475 </pre></td></tr>
3478 <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>
3479 <tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment
3480 operator.
3482 Given
3483 struct A {
3484 A &amp;operator=(const A &amp;);
3485 A &amp;operator=(A &amp;&amp;);
3488 cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not
3489 the first one.
3490 </pre></td></tr>
3493 <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>
3494 <tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method.
3496 Given
3497 class A {
3498 public:
3499 virtual void x();
3501 class B : public A {
3502 public:
3503 virtual void x();
3505 matches B::x
3506 </pre></td></tr>
3509 <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>
3510 <tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure.
3512 Given
3513 class A {
3514 public:
3515 virtual void x() = 0;
3517 matches A::x
3518 </pre></td></tr>
3521 <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>
3522 <tr><td colspan="4" class="doc" id="isUserProvided0"><pre>Matches method declarations that are user-provided.
3524 Given
3525 struct S {
3526 S(); // #1
3527 S(const S &amp;) = default; // #2
3528 S(S &amp;&amp;) = delete; // #3
3530 cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
3531 </pre></td></tr>
3534 <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>
3535 <tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches declarations of virtual methods and C++ base specifers that specify
3536 virtual inheritance.
3538 Example:
3539 class A {
3540 public:
3541 virtual void x(); // matches x
3544 Example:
3545 class Base {};
3546 class DirectlyDerived : virtual Base {}; // matches Base
3547 class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
3549 Usable 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;
3550 </pre></td></tr>
3553 <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>
3554 <tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual".
3556 Given
3557 class A {
3558 public:
3559 virtual void x();
3561 class B : public A {
3562 public:
3563 void x();
3565 matches A::x but not B::x
3566 </pre></td></tr>
3569 <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>
3570 <tr><td colspan="4" class="doc" id="isArray0"><pre>Matches array new expressions.
3572 Given:
3573 MyClass *p1 = new MyClass[10];
3574 cxxNewExpr(isArray())
3575 matches the expression 'new MyClass[10]'.
3576 </pre></td></tr>
3579 <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>
3580 <tr><td colspan="4" class="doc" id="hasAnyOperatorName1"><pre>Matches operator expressions (binary or unary) that have any of the
3581 specified names.
3583 hasAnyOperatorName("+", "-")
3584 Is equivalent to
3585 anyOf(hasOperatorName("+"), hasOperatorName("-"))
3586 </pre></td></tr>
3589 <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>
3590 <tr><td colspan="4" class="doc" id="hasAnyOverloadedOperatorName0"><pre>Matches overloaded operator names.
3592 Matches overloaded operator names specified in strings without the
3593 "operator" prefix: e.g. "&lt;&lt;".
3595 hasAnyOverloadedOperatorName("+", "-")
3596 Is equivalent to
3597 anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
3598 </pre></td></tr>
3601 <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>
3602 <tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or
3603 unary).
3605 Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
3606 !(a || b)
3607 </pre></td></tr>
3610 <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>
3611 <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names.
3613 Matches overloaded operator names specified in strings without the
3614 "operator" prefix: e.g. "&lt;&lt;".
3616 Given:
3617 class A { int operator*(); };
3618 const A &amp;operator&lt;&lt;(const A &amp;a, const A &amp;b);
3619 A a;
3620 a &lt;&lt; a; // &lt;-- This matches
3622 cxxOperatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the
3623 specified line and
3624 cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
3625 matches the declaration of A.
3627 Usable 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;
3628 </pre></td></tr>
3631 <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>
3632 <tr><td colspan="4" class="doc" id="isAssignmentOperator1"><pre>Matches all kinds of assignment operators.
3634 Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3635 if (a == b)
3636 a += b;
3638 Example 2: matches s1 = s2
3639 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3640 struct S { S&amp; operator=(const S&amp;); };
3641 void x() { S s1, s2; s1 = s2; }
3642 </pre></td></tr>
3645 <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>
3646 <tr><td colspan="4" class="doc" id="isComparisonOperator1"><pre>Matches comparison operators.
3648 Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3649 if (a == b)
3650 a += b;
3652 Example 2: matches s1 &lt; s2
3653 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3654 struct S { bool operator&lt;(const S&amp; other); };
3655 void x(S s1, S s2) { bool b1 = s1 &lt; s2; }
3656 </pre></td></tr>
3659 <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>
3660 <tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined.
3662 Example matches x (matcher = cxxRecordDecl(hasDefinition()))
3663 class x {};
3664 class y;
3665 </pre></td></tr>
3668 <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>
3669 <tr><td colspan="4" class="doc" id="isDerivedFrom2"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
3670 </pre></td></tr>
3673 <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>
3674 <tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom2"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
3675 </pre></td></tr>
3678 <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>
3679 <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or
3680 static member variable template instantiations.
3682 Given
3683 template&lt;typename T&gt; void A(T t) { }
3684 template&lt;&gt; void A(int N) { }
3685 functionDecl(isExplicitTemplateSpecialization())
3686 matches the specialization A&lt;int&gt;().
3688 Usable 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;
3689 </pre></td></tr>
3692 <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>
3693 <tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final.
3695 Given:
3696 class A final {};
3698 struct B {
3699 virtual void f();
3702 struct C : B {
3703 void f() final;
3705 matches A and C::f, but not B, C, or B::f
3706 </pre></td></tr>
3709 <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>
3710 <tr><td colspan="4" class="doc" id="isLambda0"><pre>Matches the generated class of lambda expressions.
3712 Given:
3713 auto x = []{};
3715 cxxRecordDecl(isLambda()) matches the implicit class declaration of
3716 decltype(x)
3717 </pre></td></tr>
3720 <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>
3721 <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom2"><pre>Overloaded method as shortcut for
3722 isSameOrDerivedFrom(hasName(...)).
3723 </pre></td></tr>
3726 <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>
3727 <tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static
3728 member variable template instantiations.
3730 Given
3731 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
3733 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
3735 template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
3736 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
3737 matches the template instantiation of X&lt;A&gt;.
3739 But given
3740 template &lt;typename T&gt; class X {}; class A {};
3741 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
3742 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
3743 does not match, as X&lt;A&gt; is an explicit template specialization.
3745 Usable 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;
3746 </pre></td></tr>
3749 <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>
3750 <tr><td colspan="4" class="doc" id="hasAnyOperatorName2"><pre>Matches operator expressions (binary or unary) that have any of the
3751 specified names.
3753 hasAnyOperatorName("+", "-")
3754 Is equivalent to
3755 anyOf(hasOperatorName("+"), hasOperatorName("-"))
3756 </pre></td></tr>
3759 <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>
3760 <tr><td colspan="4" class="doc" id="hasOperatorName2"><pre>Matches the operator Name of operator expressions (binary or
3761 unary).
3763 Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
3764 !(a || b)
3765 </pre></td></tr>
3768 <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>
3769 <tr><td colspan="4" class="doc" id="isAssignmentOperator2"><pre>Matches all kinds of assignment operators.
3771 Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3772 if (a == b)
3773 a += b;
3775 Example 2: matches s1 = s2
3776 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3777 struct S { S&amp; operator=(const S&amp;); };
3778 void x() { S s1, s2; s1 = s2; }
3779 </pre></td></tr>
3782 <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>
3783 <tr><td colspan="4" class="doc" id="isComparisonOperator2"><pre>Matches comparison operators.
3785 Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3786 if (a == b)
3787 a += b;
3789 Example 2: matches s1 &lt; s2
3790 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3791 struct S { bool operator&lt;(const S&amp; other); };
3792 void x(S s1, S s2) { bool b1 = s1 &lt; s2; }
3793 </pre></td></tr>
3796 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;</td><td class="name" onclick="toggle('argumentCountAtLeast2')"><a name="argumentCountAtLeast2Anchor">argumentCountAtLeast</a></td><td>unsigned N</td></tr>
3797 <tr><td colspan="4" class="doc" id="argumentCountAtLeast2"><pre>Checks that a call expression or a constructor call expression has at least
3798 the specified number of arguments (including absent default arguments).
3800 Example matches f(0, 0) and g(0, 0, 0)
3801 (matcher = callExpr(argumentCountAtLeast(2)))
3802 void f(int x, int y);
3803 void g(int x, int y, int z);
3804 f(0, 0);
3805 g(0, 0, 0);
3806 </pre></td></tr>
3809 <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>
3810 <tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has
3811 a specific number of arguments (including absent default arguments).
3813 Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
3814 void f(int x, int y);
3815 f(0, 0);
3816 </pre></td></tr>
3819 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('argumentCountAtLeast0')"><a name="argumentCountAtLeast0Anchor">argumentCountAtLeast</a></td><td>unsigned N</td></tr>
3820 <tr><td colspan="4" class="doc" id="argumentCountAtLeast0"><pre>Checks that a call expression or a constructor call expression has at least
3821 the specified number of arguments (including absent default arguments).
3823 Example matches f(0, 0) and g(0, 0, 0)
3824 (matcher = callExpr(argumentCountAtLeast(2)))
3825 void f(int x, int y);
3826 void g(int x, int y, int z);
3827 f(0, 0);
3828 g(0, 0, 0);
3829 </pre></td></tr>
3832 <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>
3833 <tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has
3834 a specific number of arguments (including absent default arguments).
3836 Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
3837 void f(int x, int y);
3838 f(0, 0);
3839 </pre></td></tr>
3842 <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>
3843 <tr><td colspan="4" class="doc" id="usesADL0"><pre>Matches call expressions which were resolved using ADL.
3845 Example matches y(x) but not y(42) or NS::y(x).
3846 namespace NS {
3847 struct X {};
3848 void y(X);
3851 void y(...);
3853 void test() {
3854 NS::X x;
3855 y(x); // Matches
3856 NS::y(x); // Doesn't match
3857 y(42); // Doesn't match
3858 using NS::y;
3859 y(x); // Found by both unqualified lookup and ADL, doesn't match
3861 </pre></td></tr>
3864 <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>
3865 <tr><td colspan="4" class="doc" id="hasCastKind0"><pre>Matches casts that has a given cast kind.
3867 Example: matches the implicit cast around 0
3868 (matcher = castExpr(hasCastKind(CK_NullToPointer)))
3869 int *p = 0;
3871 If the matcher is use from clang-query, CastKind parameter
3872 should be passed as a quoted string. e.g., hasCastKind("CK_NullToPointer").
3873 </pre></td></tr>
3876 <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>
3877 <tr><td colspan="4" class="doc" id="equals4"><pre></pre></td></tr>
3880 <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>
3881 <tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value of type ValueT.
3883 Given
3884 f('false, 3.14, 42);
3885 characterLiteral(equals(0))
3886 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
3887 match false
3888 floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
3889 match 3.14
3890 integerLiteral(equals(42))
3891 matches 42
3893 Note that you cannot directly match a negative numeric literal because the
3894 minus sign is not part of the literal: It is a unary operator whose operand
3895 is the positive numeric literal. Instead, you must use a unaryOperator()
3896 matcher to match the minus sign:
3898 unaryOperator(hasOperatorName("-"),
3899 hasUnaryOperand(integerLiteral(equals(13))))
3901 Usable 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;,
3902 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;
3903 </pre></td></tr>
3906 <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>
3907 <tr><td colspan="4" class="doc" id="equals10"><pre></pre></td></tr>
3910 <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>
3911 <tr><td colspan="4" class="doc" id="equals7"><pre></pre></td></tr>
3914 <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>
3915 <tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N.
3917 Given
3918 template&lt;typename T&gt; struct C {};
3919 C&lt;int&gt; c;
3920 classTemplateSpecializationDecl(templateArgumentCountIs(1))
3921 matches C&lt;int&gt;.
3922 </pre></td></tr>
3925 <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>
3926 <tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of
3927 child statements.
3929 Example: Given
3930 { for (;;) {} }
3931 compoundStmt(statementCountIs(0)))
3932 matches '{}'
3933 but does not match the outer compound statement.
3934 </pre></td></tr>
3937 <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>
3938 <tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches nodes that have the specified size.
3940 Given
3941 int a[42];
3942 int b[2 * 21];
3943 int c[41], d[43];
3944 char *s = "abcd";
3945 wchar_t *ws = L"abcd";
3946 char *w = "a";
3947 constantArrayType(hasSize(42))
3948 matches "int a[42]" and "int b[2 * 21]"
3949 stringLiteral(hasSize(4))
3950 matches "abcd", L"abcd"
3951 </pre></td></tr>
3954 <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>
3955 <tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of
3956 declarations.
3958 Example: Given
3959 int a, b;
3960 int c;
3961 int d = 2, e;
3962 declCountIs(2)
3963 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.
3964 </pre></td></tr>
3967 <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>
3968 <tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node.
3970 Matches a node if it equals the node previously bound to ID.
3972 Given
3973 class X { int a; int b; };
3974 cxxRecordDecl(
3975 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
3976 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
3977 matches the class X, as a and b have the same type.
3979 Note that when multiple matches are involved via forEach* matchers,
3980 equalsBoundNodes acts as a filter.
3981 For example:
3982 compoundStmt(
3983 forEachDescendant(varDecl().bind("d")),
3984 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
3985 will trigger a match for each combination of variable declaration
3986 and reference to that variable declaration within a compound statement.
3987 </pre></td></tr>
3990 <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>
3991 <tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node.
3993 Decl has pointer identity in the AST.
3994 </pre></td></tr>
3997 <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>
3998 <tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute.
4000 Given
4001 __attribute__((device)) void f() { ... }
4002 decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
4003 f. If the matcher is used from clang-query, attr::Kind parameter should be
4004 passed as a quoted string. e.g., hasAttr("attr::CUDADevice").
4005 </pre></td></tr>
4008 <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>
4009 <tr><td colspan="4" class="doc" id="isExpandedFromMacro0"><pre>Matches statements that are (transitively) expanded from the named macro.
4010 Does not match if only part of the statement is expanded from that macro or
4011 if different parts of the statement are expanded from different
4012 appearances of the macro.
4013 </pre></td></tr>
4016 <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>
4017 <tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is
4018 partially matching a given regex.
4020 Example matches Y but not X
4021 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
4022 #include "ASTMatcher.h"
4023 class X {};
4024 ASTMatcher.h:
4025 class Y {};
4027 Usable 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;
4029 If the matcher is used in clang-query, RegexFlags parameter
4030 should be passed as a quoted string. e.g: "NoFlags".
4031 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
4032 </pre></td></tr>
4035 <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>
4036 <tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file.
4038 Example matches X but not Y
4039 (matcher = cxxRecordDecl(isExpansionInMainFile())
4040 #include &lt;Y.h&gt;
4041 class X {};
4042 Y.h:
4043 class Y {};
4045 Usable 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;
4046 </pre></td></tr>
4049 <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>
4050 <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files.
4052 Example matches Y but not X
4053 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
4054 #include &lt;SystemHeader.h&gt;
4055 class X {};
4056 SystemHeader.h:
4057 class Y {};
4059 Usable 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;
4060 </pre></td></tr>
4063 <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>
4064 <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
4065 implicit default/copy constructors).
4066 </pre></td></tr>
4069 <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>
4070 <tr><td colspan="4" class="doc" id="isInAnonymousNamespace0"><pre>Matches declarations in an anonymous namespace.
4072 Given
4073 class vector {};
4074 namespace foo {
4075 class vector {};
4076 namespace {
4077 class vector {}; // #1
4080 namespace {
4081 class vector {}; // #2
4082 namespace foo {
4083 class vector{}; // #3
4086 cxxRecordDecl(hasName("vector"), isInAnonymousNamespace()) will match
4087 #1, #2 and #3.
4088 </pre></td></tr>
4091 <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>
4092 <tr><td colspan="4" class="doc" id="isInStdNamespace0"><pre>Matches declarations in the namespace `std`, but not in nested namespaces.
4094 Given
4095 class vector {};
4096 namespace foo {
4097 class vector {};
4098 namespace std {
4099 class vector {};
4102 namespace std {
4103 inline namespace __1 {
4104 class vector {}; // #1
4105 namespace experimental {
4106 class vector {};
4110 cxxRecordDecl(hasName("vector"), isInStdNamespace()) will match only #1.
4111 </pre></td></tr>
4114 <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>
4115 <tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside
4116 template instantiations.
4118 Given
4119 template&lt;typename T&gt; void A(T t) { T i; }
4120 A(0);
4121 A(0U);
4122 functionDecl(isInstantiated())
4123 matches 'A(int) {...};' and 'A(unsigned) {...}'.
4124 </pre></td></tr>
4127 <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>
4128 <tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations and C++ base specifers that specify private
4129 inheritance.
4131 Examples:
4132 class C {
4133 public: int a;
4134 protected: int b;
4135 private: int c; // fieldDecl(isPrivate()) matches 'c'
4138 struct Base {};
4139 struct Derived1 : private Base {}; // matches 'Base'
4140 class Derived2 : Base {}; // matches 'Base'
4141 </pre></td></tr>
4144 <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>
4145 <tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations and C++ base specifers that specify
4146 protected inheritance.
4148 Examples:
4149 class C {
4150 public: int a;
4151 protected: int b; // fieldDecl(isProtected()) matches 'b'
4152 private: int c;
4155 class Base {};
4156 class Derived : protected Base {}; // matches 'Base'
4157 </pre></td></tr>
4160 <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>
4161 <tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations and C++ base specifers that specify public
4162 inheritance.
4164 Examples:
4165 class C {
4166 public: int a; // fieldDecl(isPublic()) matches 'a'
4167 protected: int b;
4168 private: int c;
4171 class Base {};
4172 class Derived1 : public Base {}; // matches 'Base'
4173 struct Derived2 : Base {}; // matches 'Base'
4174 </pre></td></tr>
4177 <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>
4178 <tr><td colspan="4" class="doc" id="designatorCountIs0"><pre>Matches designated initializer expressions that contain
4179 a specific number of designators.
4181 Example: Given
4182 point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
4183 point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 };
4184 designatorCountIs(2)
4185 matches '{ [2].y = 1.0, [0].x = 1.0 }',
4186 but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'.
4187 </pre></td></tr>
4190 <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>
4191 <tr><td colspan="4" class="doc" id="isScoped0"><pre>Matches C++11 scoped enum declaration.
4193 Example matches Y (matcher = enumDecl(isScoped()))
4194 enum X {};
4195 enum class Y {};
4196 </pre></td></tr>
4199 <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>
4200 <tr><td colspan="4" class="doc" id="isInstantiationDependent0"><pre>Matches expressions that are instantiation-dependent even if it is
4201 neither type- nor value-dependent.
4203 In the following example, the expression sizeof(sizeof(T() + T()))
4204 is instantiation-dependent (since it involves a template parameter T),
4205 but is neither type- nor value-dependent, since the type of the inner
4206 sizeof is known (std::size_t) and therefore the size of the outer
4207 sizeof is known.
4208 template&lt;typename T&gt;
4209 void f(T x, T y) { sizeof(sizeof(T() + T()); }
4210 expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T())
4211 </pre></td></tr>
4214 <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>
4215 <tr><td colspan="4" class="doc" id="isTypeDependent0"><pre>Matches expressions that are type-dependent because the template type
4216 is not yet instantiated.
4218 For example, the expressions "x" and "x + y" are type-dependent in
4219 the following code, but "y" is not type-dependent:
4220 template&lt;typename T&gt;
4221 void add(T x, int y) {
4222 x + y;
4224 expr(isTypeDependent()) matches x + y
4225 </pre></td></tr>
4228 <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>
4229 <tr><td colspan="4" class="doc" id="isValueDependent0"><pre>Matches expression that are value-dependent because they contain a
4230 non-type template parameter.
4232 For example, the array bound of "Chars" in the following example is
4233 value-dependent.
4234 template&lt;int Size&gt; int f() { return Size; }
4235 expr(isValueDependent()) matches return Size
4236 </pre></td></tr>
4239 <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>
4240 <tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as
4241 GNU's __null, C++11's nullptr, or C's NULL macro.
4243 Given:
4244 void *v1 = NULL;
4245 void *v2 = nullptr;
4246 void *v3 = __null; // GNU extension
4247 char *cp = (char *)0;
4248 int *ip = 0;
4249 int i = 0;
4250 expr(nullPointerConstant())
4251 matches the initializer for v1, v2, v3, cp, and ip. Does not match the
4252 initializer for i.
4253 </pre></td></tr>
4256 <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>
4257 <tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified
4258 bit width.
4260 Given
4261 class C {
4262 int a : 2;
4263 int b : 4;
4264 int c : 2;
4266 fieldDecl(hasBitWidth(2))
4267 matches 'int a;' and 'int c;' but not 'int b;'.
4268 </pre></td></tr>
4271 <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>
4272 <tr><td colspan="4" class="doc" id="isBitField0"><pre>Matches non-static data members that are bit-fields.
4274 Given
4275 class C {
4276 int a : 2;
4277 int b;
4279 fieldDecl(isBitField())
4280 matches 'int a;' but not 'int b;'.
4281 </pre></td></tr>
4284 <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>
4285 <tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value of type ValueT.
4287 Given
4288 f('false, 3.14, 42);
4289 characterLiteral(equals(0))
4290 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
4291 match false
4292 floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
4293 match 3.14
4294 integerLiteral(equals(42))
4295 matches 42
4297 Note that you cannot directly match a negative numeric literal because the
4298 minus sign is not part of the literal: It is a unary operator whose operand
4299 is the positive numeric literal. Instead, you must use a unaryOperator()
4300 matcher to match the minus sign:
4302 unaryOperator(hasOperatorName("-"),
4303 hasUnaryOperand(integerLiteral(equals(13))))
4305 Usable 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;,
4306 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;
4307 </pre></td></tr>
4310 <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>
4311 <tr><td colspan="4" class="doc" id="equals12"><pre></pre></td></tr>
4314 <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>
4315 <tr><td colspan="4" class="doc" id="hasAnyOverloadedOperatorName1"><pre>Matches overloaded operator names.
4317 Matches overloaded operator names specified in strings without the
4318 "operator" prefix: e.g. "&lt;&lt;".
4320 hasAnyOverloadedOperatorName("+", "-")
4321 Is equivalent to
4322 anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
4323 </pre></td></tr>
4326 <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>
4327 <tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification.
4329 Given:
4330 void f();
4331 void g() noexcept;
4332 void h() noexcept(true);
4333 void i() noexcept(false);
4334 void j() throw();
4335 void k() throw(int);
4336 void l() throw(...);
4337 functionDecl(hasDynamicExceptionSpec()) and
4338 functionProtoType(hasDynamicExceptionSpec())
4339 match the declarations of j, k, and l, but not f, g, h, or i.
4340 </pre></td></tr>
4343 <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>
4344 <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names.
4346 Matches overloaded operator names specified in strings without the
4347 "operator" prefix: e.g. "&lt;&lt;".
4349 Given:
4350 class A { int operator*(); };
4351 const A &amp;operator&lt;&lt;(const A &amp;a, const A &amp;b);
4352 A a;
4353 a &lt;&lt; a; // &lt;-- This matches
4355 cxxOperatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the
4356 specified line and
4357 cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
4358 matches the declaration of A.
4360 Usable 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;
4361 </pre></td></tr>
4364 <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>
4365 <tr><td colspan="4" class="doc" id="hasTrailingReturn0"><pre>Matches a function declared with a trailing return type.
4367 Example matches Y (matcher = functionDecl(hasTrailingReturn()))
4368 int X() {}
4369 auto Y() -&gt; int {}
4370 </pre></td></tr>
4373 <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>
4374 <tr><td colspan="4" class="doc" id="isConsteval0"><pre>Matches consteval function declarations and if consteval/if ! consteval
4375 statements.
4377 Given:
4378 consteval int a();
4379 void b() { if consteval {} }
4380 void c() { if ! consteval {} }
4381 void d() { if ! consteval {} else {} }
4382 functionDecl(isConsteval())
4383 matches the declaration of "int a()".
4384 ifStmt(isConsteval())
4385 matches the if statement in "void b()", "void c()", "void d()".
4386 </pre></td></tr>
4389 <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>
4390 <tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations,
4391 and if constexpr.
4393 Given:
4394 constexpr int foo = 42;
4395 constexpr int bar();
4396 void baz() { if constexpr(1 &gt; 0) {} }
4397 varDecl(isConstexpr())
4398 matches the declaration of foo.
4399 functionDecl(isConstexpr())
4400 matches the declaration of bar.
4401 ifStmt(isConstexpr())
4402 matches the if statement in baz.
4403 </pre></td></tr>
4406 <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>
4407 <tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations.
4409 Given:
4410 class A { ~A(); };
4411 class B { ~B() = default; };
4412 functionDecl(isDefaulted())
4413 matches the declaration of ~B, but not ~A.
4414 </pre></td></tr>
4417 <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>
4418 <tr><td colspan="4" class="doc" id="isDefinition3"><pre>Matches if a declaration has a body attached.
4420 Example matches A, va, fa
4421 class A {};
4422 class B; // Doesn't match, as it has no body.
4423 int va;
4424 extern int vb; // Doesn't match, as it doesn't define the variable.
4425 void fa() {}
4426 void fb(); // Doesn't match, as it has no body.
4427 @interface X
4428 - (void)ma; // Doesn't match, interface is declaration.
4429 @end
4430 @implementation X
4431 - (void)ma {}
4432 @end
4434 Usable 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;,
4435 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
4436 </pre></td></tr>
4439 <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>
4440 <tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations.
4442 Given:
4443 void Func();
4444 void DeletedFunc() = delete;
4445 functionDecl(isDeleted())
4446 matches the declaration of DeletedFunc, but not Func.
4447 </pre></td></tr>
4450 <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>
4451 <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or
4452 static member variable template instantiations.
4454 Given
4455 template&lt;typename T&gt; void A(T t) { }
4456 template&lt;&gt; void A(int N) { }
4457 functionDecl(isExplicitTemplateSpecialization())
4458 matches the specialization A&lt;int&gt;().
4460 Usable 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;
4461 </pre></td></tr>
4464 <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>
4465 <tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function or variable declarations.
4467 Given:
4468 extern "C" void f() {}
4469 extern "C" { void g() {} }
4470 void h() {}
4471 extern "C" int x = 1;
4472 extern "C" int y = 2;
4473 int z = 3;
4474 functionDecl(isExternC())
4475 matches the declaration of f and g, but not the declaration of h.
4476 varDecl(isExternC())
4477 matches the declaration of x and y, but not the declaration of z.
4478 </pre></td></tr>
4481 <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>
4482 <tr><td colspan="4" class="doc" id="isInline1"><pre>Matches functions, variables and namespace declarations that are marked with
4483 the inline keyword.
4485 Given
4486 inline void f();
4487 void g();
4488 namespace n {
4489 inline namespace m {}
4491 inline int Foo = 5;
4492 functionDecl(isInline()) will match ::f().
4493 namespaceDecl(isInline()) will match n::m.
4494 varDecl(isInline()) will match Foo;
4495 </pre></td></tr>
4498 <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>
4499 <tr><td colspan="4" class="doc" id="isMain0"><pre>Determines whether the function is "main", which is the entry point
4500 into an executable program.
4501 </pre></td></tr>
4504 <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>
4505 <tr><td colspan="4" class="doc" id="isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute.
4507 Given
4508 void nope();
4509 [[noreturn]] void a();
4510 __attribute__((noreturn)) void b();
4511 struct c { [[noreturn]] c(); };
4512 functionDecl(isNoReturn())
4513 matches all of those except
4514 void nope();
4515 </pre></td></tr>
4518 <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>
4519 <tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification.
4521 Given:
4522 void f();
4523 void g() noexcept;
4524 void h() throw();
4525 void i() throw(int);
4526 void j() noexcept(false);
4527 functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
4528 match the declarations of g, and h, but not f, i or j.
4529 </pre></td></tr>
4532 <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>
4533 <tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variable/function declarations that have "static" storage
4534 class specifier ("static" keyword) written in the source.
4536 Given:
4537 static void f() {}
4538 static int i = 0;
4539 extern int j;
4540 int k;
4541 functionDecl(isStaticStorageClass())
4542 matches the function declaration f.
4543 varDecl(isStaticStorageClass())
4544 matches the variable declaration i.
4545 </pre></td></tr>
4548 <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>
4549 <tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static
4550 member variable template instantiations.
4552 Given
4553 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
4555 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
4557 template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
4558 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
4559 matches the template instantiation of X&lt;A&gt;.
4561 But given
4562 template &lt;typename T&gt; class X {}; class A {};
4563 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
4564 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
4565 does not match, as X&lt;A&gt; is an explicit template specialization.
4567 Usable 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;
4568 </pre></td></tr>
4571 <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>
4572 <tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic.
4574 Example matches f, but not g or h. The function i will not match, even when
4575 compiled in C mode.
4576 void f(...);
4577 void g(int);
4578 template &lt;typename... Ts&gt; void h(Ts...);
4579 void i();
4580 </pre></td></tr>
4583 <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>
4584 <tr><td colspan="4" class="doc" id="isWeak0"><pre>Matches weak function declarations.
4586 Given:
4587 void foo() __attribute__((__weakref__("__foo")));
4588 void bar();
4589 functionDecl(isWeak())
4590 matches the weak declaration "foo", but not "bar".
4591 </pre></td></tr>
4594 <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>
4595 <tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
4596 specific parameter count.
4598 Given
4599 void f(int i) {}
4600 void g(int i, int j) {}
4601 void h(int i, int j);
4602 void j(int i);
4603 void k(int x, int y, int z, ...);
4604 functionDecl(parameterCountIs(2))
4605 matches g and h
4606 functionProtoType(parameterCountIs(2))
4607 matches g and h
4608 functionProtoType(parameterCountIs(3))
4609 matches k
4610 </pre></td></tr>
4613 <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>
4614 <tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification.
4616 Given:
4617 void f();
4618 void g() noexcept;
4619 void h() noexcept(true);
4620 void i() noexcept(false);
4621 void j() throw();
4622 void k() throw(int);
4623 void l() throw(...);
4624 functionDecl(hasDynamicExceptionSpec()) and
4625 functionProtoType(hasDynamicExceptionSpec())
4626 match the declarations of j, k, and l, but not f, g, h, or i.
4627 </pre></td></tr>
4630 <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>
4631 <tr><td colspan="4" class="doc" id="isNoThrow1"><pre>Matches functions that have a non-throwing exception specification.
4633 Given:
4634 void f();
4635 void g() noexcept;
4636 void h() throw();
4637 void i() throw(int);
4638 void j() noexcept(false);
4639 functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
4640 match the declarations of g, and h, but not f, i or j.
4641 </pre></td></tr>
4644 <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>
4645 <tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
4646 specific parameter count.
4648 Given
4649 void f(int i) {}
4650 void g(int i, int j) {}
4651 void h(int i, int j);
4652 void j(int i);
4653 void k(int x, int y, int z, ...);
4654 functionDecl(parameterCountIs(2))
4655 matches g and h
4656 functionProtoType(parameterCountIs(2))
4657 matches g and h
4658 functionProtoType(parameterCountIs(3))
4659 matches k
4660 </pre></td></tr>
4663 <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>
4664 <tr><td colspan="4" class="doc" id="isConsteval1"><pre>Matches consteval function declarations and if consteval/if ! consteval
4665 statements.
4667 Given:
4668 consteval int a();
4669 void b() { if consteval {} }
4670 void c() { if ! consteval {} }
4671 void d() { if ! consteval {} else {} }
4672 functionDecl(isConsteval())
4673 matches the declaration of "int a()".
4674 ifStmt(isConsteval())
4675 matches the if statement in "void b()", "void c()", "void d()".
4676 </pre></td></tr>
4679 <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>
4680 <tr><td colspan="4" class="doc" id="isConstexpr2"><pre>Matches constexpr variable and function declarations,
4681 and if constexpr.
4683 Given:
4684 constexpr int foo = 42;
4685 constexpr int bar();
4686 void baz() { if constexpr(1 &gt; 0) {} }
4687 varDecl(isConstexpr())
4688 matches the declaration of foo.
4689 functionDecl(isConstexpr())
4690 matches the declaration of bar.
4691 ifStmt(isConstexpr())
4692 matches the if statement in baz.
4693 </pre></td></tr>
4696 <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>
4697 <tr><td colspan="4" class="doc" id="equals6"><pre></pre></td></tr>
4700 <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>
4701 <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value of type ValueT.
4703 Given
4704 f('false, 3.14, 42);
4705 characterLiteral(equals(0))
4706 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
4707 match false
4708 floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
4709 match 3.14
4710 integerLiteral(equals(42))
4711 matches 42
4713 Note that you cannot directly match a negative numeric literal because the
4714 minus sign is not part of the literal: It is a unary operator whose operand
4715 is the positive numeric literal. Instead, you must use a unaryOperator()
4716 matcher to match the minus sign:
4718 unaryOperator(hasOperatorName("-"),
4719 hasUnaryOperand(integerLiteral(equals(13))))
4721 Usable 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;,
4722 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;
4723 </pre></td></tr>
4726 <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>
4727 <tr><td colspan="4" class="doc" id="equals13"><pre></pre></td></tr>
4730 <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>
4731 <tr><td colspan="4" class="doc" id="equals9"><pre></pre></td></tr>
4734 <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>
4735 <tr><td colspan="4" class="doc" id="capturesThis0"><pre>Matches a `LambdaCapture` that refers to 'this'.
4737 Given
4738 class C {
4739 int cc;
4740 int f() {
4741 auto l = [this]() { return cc; };
4742 return l();
4745 lambdaExpr(hasAnyCapture(lambdaCapture(capturesThis())))
4746 matches `[this]() { return cc; }`.
4747 </pre></td></tr>
4750 <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>
4751 <tr><td colspan="4" class="doc" id="isImplicit2"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
4752 implicit default/copy constructors).
4753 </pre></td></tr>
4756 <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>
4757 <tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '-&gt;' as opposed
4758 to '.'.
4760 Member calls on the implicit this pointer match as called with '-&gt;'.
4762 Given
4763 class Y {
4764 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
4765 template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
4766 int a;
4767 static int b;
4769 template &lt;class T&gt;
4770 class Z {
4771 void x() { this-&gt;m; }
4773 memberExpr(isArrow())
4774 matches this-&gt;x, x, y.x, a, this-&gt;b
4775 cxxDependentScopeMemberExpr(isArrow())
4776 matches this-&gt;m
4777 unresolvedMemberExpr(isArrow())
4778 matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
4779 </pre></td></tr>
4782 <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>
4783 <tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names.
4785 This matcher is only provided as a performance optimization of hasName.
4786 hasAnyName(a, b, c)
4787 is equivalent to, but faster than
4788 anyOf(hasName(a), hasName(b), hasName(c))
4789 </pre></td></tr>
4792 <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>
4793 <tr><td colspan="4" class="doc" id="hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage.
4795 Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))
4796 void f() {
4797 int x;
4798 static int y;
4800 int z;
4802 Example matches f() because it has external formal linkage despite being
4803 unique to the translation unit as though it has internal likage
4804 (matcher = functionDecl(hasExternalFormalLinkage()))
4806 namespace {
4807 void f() {}
4809 </pre></td></tr>
4812 <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>
4813 <tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name.
4815 Supports specifying enclosing namespaces or classes by prefixing the name
4816 with '&lt;enclosing&gt;::'.
4817 Does not match typedefs of an underlying type with the given name.
4819 Example matches X (Name == "X")
4820 class X;
4822 Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
4823 namespace a { namespace b { class X; } }
4824 </pre></td></tr>
4827 <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>
4828 <tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain
4829 a substring matched by the given RegExp.
4831 Supports specifying enclosing namespaces or classes by
4832 prefixing the name with '&lt;enclosing&gt;::'. Does not match typedefs
4833 of an underlying type with the given name.
4835 Example matches X (regexp == "::X")
4836 class X;
4838 Example matches X (regexp is one of "::X", "^foo::.*X", among others)
4839 namespace foo { namespace bar { class X; } }
4841 If the matcher is used in clang-query, RegexFlags parameter
4842 should be passed as a quoted string. e.g: "NoFlags".
4843 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
4844 </pre></td></tr>
4847 <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>
4848 <tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations.
4850 Given
4851 namespace n {
4852 namespace {} // #1
4854 namespaceDecl(isAnonymous()) will match #1 but not ::n.
4855 </pre></td></tr>
4858 <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>
4859 <tr><td colspan="4" class="doc" id="isInline0"><pre>Matches functions, variables and namespace declarations that are marked with
4860 the inline keyword.
4862 Given
4863 inline void f();
4864 void g();
4865 namespace n {
4866 inline namespace m {}
4868 inline int Foo = 5;
4869 functionDecl(isInline()) will match ::f().
4870 namespaceDecl(isInline()) will match n::m.
4871 varDecl(isInline()) will match Foo;
4872 </pre></td></tr>
4875 <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>
4876 <tr><td colspan="4" class="doc" id="isFirstPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``firstprivate`` kind
4877 specified.
4879 Given
4881 #pragma omp parallel
4882 #pragma omp parallel default(none)
4883 #pragma omp parallel default(shared)
4884 #pragma omp parallel default(private)
4885 #pragma omp parallel default(firstprivate)
4887 ``ompDefaultClause(isFirstPrivateKind())`` matches only
4888 ``default(firstprivate)``.
4889 </pre></td></tr>
4892 <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>
4893 <tr><td colspan="4" class="doc" id="isNoneKind0"><pre>Matches if the OpenMP ``default`` clause has ``none`` kind specified.
4895 Given
4897 #pragma omp parallel
4898 #pragma omp parallel default(none)
4899 #pragma omp parallel default(shared)
4900 #pragma omp parallel default(private)
4901 #pragma omp parallel default(firstprivate)
4903 ``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
4904 </pre></td></tr>
4907 <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>
4908 <tr><td colspan="4" class="doc" id="isPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``private`` kind
4909 specified.
4911 Given
4913 #pragma omp parallel
4914 #pragma omp parallel default(none)
4915 #pragma omp parallel default(shared)
4916 #pragma omp parallel default(private)
4917 #pragma omp parallel default(firstprivate)
4919 ``ompDefaultClause(isPrivateKind())`` matches only
4920 ``default(private)``.
4921 </pre></td></tr>
4924 <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>
4925 <tr><td colspan="4" class="doc" id="isSharedKind0"><pre>Matches if the OpenMP ``default`` clause has ``shared`` kind specified.
4927 Given
4929 #pragma omp parallel
4930 #pragma omp parallel default(none)
4931 #pragma omp parallel default(shared)
4932 #pragma omp parallel default(private)
4933 #pragma omp parallel default(firstprivate)
4935 ``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``.
4936 </pre></td></tr>
4939 <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>
4940 <tr><td colspan="4" class="doc" id="isAllowedToContainClauseKind0"><pre>Matches if the OpenMP directive is allowed to contain the specified OpenMP
4941 clause kind.
4943 Given
4945 #pragma omp parallel
4946 #pragma omp parallel for
4947 #pragma omp for
4949 `ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches
4950 ``omp parallel`` and ``omp parallel for``.
4952 If the matcher is use from clang-query, ``OpenMPClauseKind`` parameter
4953 should be passed as a quoted string. e.g.,
4954 ``isAllowedToContainClauseKind("OMPC_default").``
4955 </pre></td></tr>
4958 <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>
4959 <tr><td colspan="4" class="doc" id="isStandaloneDirective0"><pre>Matches standalone OpenMP directives,
4960 i.e., directives that can't have a structured block.
4962 Given
4964 #pragma omp parallel
4966 #pragma omp taskyield
4968 ``ompExecutableDirective(isStandaloneDirective()))`` matches
4969 ``omp taskyield``.
4970 </pre></td></tr>
4973 <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>
4974 <tr><td colspan="4" class="doc" id="isDerivedFrom3"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
4975 </pre></td></tr>
4978 <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>
4979 <tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom3"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
4980 </pre></td></tr>
4983 <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>
4984 <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom3"><pre>Overloaded method as shortcut for
4985 isSameOrDerivedFrom(hasName(...)).
4986 </pre></td></tr>
4989 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('argumentCountAtLeast3')"><a name="argumentCountAtLeast3Anchor">argumentCountAtLeast</a></td><td>unsigned N</td></tr>
4990 <tr><td colspan="4" class="doc" id="argumentCountAtLeast3"><pre>Checks that a call expression or a constructor call expression has at least
4991 the specified number of arguments (including absent default arguments).
4993 Example matches f(0, 0) and g(0, 0, 0)
4994 (matcher = callExpr(argumentCountAtLeast(2)))
4995 void f(int x, int y);
4996 void g(int x, int y, int z);
4997 f(0, 0);
4998 g(0, 0, 0);
4999 </pre></td></tr>
5002 <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>
5003 <tr><td colspan="4" class="doc" id="argumentCountIs3"><pre>Checks that a call expression or a constructor call expression has
5004 a specific number of arguments (including absent default arguments).
5006 Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
5007 void f(int x, int y);
5008 f(0, 0);
5009 </pre></td></tr>
5012 <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>
5013 <tr><td colspan="4" class="doc" id="hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the
5014 Selector.getAsString()
5016 matcher = objCMessageExpr(hasSelector("methodA:", "methodB:"));
5017 matches both of the expressions below:
5018 [myObj methodA:argA];
5019 [myObj methodB:argB];
5020 </pre></td></tr>
5023 <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>
5024 <tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector
5026 objCMessageExpr(hasKeywordSelector()) matches the generated setFrame
5027 message expression in
5029 UIWebView *webView = ...;
5030 CGRect bodyFrame = webView.frame;
5031 bodyFrame.size.height = self.bodyContentHeight;
5032 webView.frame = bodyFrame;
5033 // ^---- matches here
5034 </pre></td></tr>
5037 <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>
5038 <tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector
5040 Matches only when the selector of the objCMessageExpr is NULL. This may
5041 represent an error condition in the tree!
5042 </pre></td></tr>
5045 <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>
5046 <tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString()
5048 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:"));
5049 matches the outer message expr in the code below, but NOT the message
5050 invocation for self.bodyView.
5051 [self.bodyView loadHTMLString:html baseURL:NULL];
5052 </pre></td></tr>
5055 <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>
5056 <tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector
5058 matcher = objCMessageExpr(matchesSelector(hasUnarySelector());
5059 matches self.bodyView in the code below, but NOT the outer message
5060 invocation of "loadHTMLString:baseURL:".
5061 [self.bodyView loadHTMLString:html baseURL:NULL];
5062 </pre></td></tr>
5065 <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>
5066 <tr><td colspan="4" class="doc" id="isClassMessage0"><pre>Returns true when the Objective-C message is sent to a class.
5068 Example
5069 matcher = objcMessageExpr(isClassMessage())
5070 matches
5071 [NSString stringWithFormat:@"format"];
5072 but not
5073 NSString *x = @"hello";
5074 [x containsString:@"h"];
5075 </pre></td></tr>
5078 <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>
5079 <tr><td colspan="4" class="doc" id="isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance.
5081 Example
5082 matcher = objcMessageExpr(isInstanceMessage())
5083 matches
5084 NSString *x = @"hello";
5085 [x containsString:@"h"];
5086 but not
5087 [NSString stringWithFormat:@"format"];
5088 </pre></td></tr>
5091 <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>
5092 <tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains
5093 a substring matched by the given RegExp.
5094 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message
5095 invocation for self.bodyView.
5096 [self.bodyView loadHTMLString:html baseURL:NULL];
5098 If the matcher is used in clang-query, RegexFlags parameter
5099 should be passed as a quoted string. e.g: "NoFlags".
5100 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
5101 </pre></td></tr>
5104 <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>
5105 <tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments
5107 matcher = objCMessageExpr(numSelectorArgs(0));
5108 matches self.bodyView in the code below
5110 matcher = objCMessageExpr(numSelectorArgs(2));
5111 matches the invocation of "loadHTMLString:baseURL:" but not that
5112 of self.bodyView
5113 [self.bodyView loadHTMLString:html baseURL:NULL];
5114 </pre></td></tr>
5117 <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>
5118 <tr><td colspan="4" class="doc" id="isClassMethod0"><pre>Returns true when the Objective-C method declaration is a class method.
5120 Example
5121 matcher = objcMethodDecl(isClassMethod())
5122 matches
5123 @interface I + (void)foo; @end
5124 but not
5125 @interface I - (void)bar; @end
5126 </pre></td></tr>
5129 <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>
5130 <tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached.
5132 Example matches A, va, fa
5133 class A {};
5134 class B; // Doesn't match, as it has no body.
5135 int va;
5136 extern int vb; // Doesn't match, as it doesn't define the variable.
5137 void fa() {}
5138 void fb(); // Doesn't match, as it has no body.
5139 @interface X
5140 - (void)ma; // Doesn't match, interface is declaration.
5141 @end
5142 @implementation X
5143 - (void)ma {}
5144 @end
5146 Usable 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;,
5147 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
5148 </pre></td></tr>
5151 <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>
5152 <tr><td colspan="4" class="doc" id="isInstanceMethod0"><pre>Returns true when the Objective-C method declaration is an instance method.
5154 Example
5155 matcher = objcMethodDecl(isInstanceMethod())
5156 matches
5157 @interface I - (void)bar; @end
5158 but not
5159 @interface I + (void)foo; @end
5160 </pre></td></tr>
5163 <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>
5164 <tr><td colspan="4" class="doc" id="hasDefaultArgument0"><pre>Matches a declaration that has default arguments.
5166 Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
5167 void x(int val) {}
5168 void y(int val = 0) {}
5170 Deprecated. Use hasInitializer() instead to be able to
5171 match on the contents of the default argument. For example:
5173 void x(int val = 7) {}
5174 void y(int val = 42) {}
5175 parmVarDecl(hasInitializer(integerLiteral(equals(42))))
5176 matches the parameter of y
5178 A matcher such as
5179 parmVarDecl(hasInitializer(anything()))
5180 is equivalent to parmVarDecl(hasDefaultArgument()).
5181 </pre></td></tr>
5184 <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>
5185 <tr><td colspan="4" class="doc" id="isAtPosition0"><pre>Matches the ParmVarDecl nodes that are at the N'th position in the parameter
5186 list. The parameter list could be that of either a block, function, or
5187 objc-method.
5190 Given
5192 void f(int a, int b, int c) {
5195 ``parmVarDecl(isAtPosition(0))`` matches ``int a``.
5197 ``parmVarDecl(isAtPosition(1))`` matches ``int b``.
5198 </pre></td></tr>
5201 <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>
5202 <tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string.
5204 Given
5205 class Y { public: void x(); };
5206 void z() { Y* y; y-&gt;x(); }
5207 cxxMemberCallExpr(on(hasType(asString("class Y *"))))
5208 matches y-&gt;x()
5209 </pre></td></tr>
5212 <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>
5213 <tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node.
5215 Matches a node if it equals the node previously bound to ID.
5217 Given
5218 class X { int a; int b; };
5219 cxxRecordDecl(
5220 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
5221 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
5222 matches the class X, as a and b have the same type.
5224 Note that when multiple matches are involved via forEach* matchers,
5225 equalsBoundNodes acts as a filter.
5226 For example:
5227 compoundStmt(
5228 forEachDescendant(varDecl().bind("d")),
5229 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
5230 will trigger a match for each combination of variable declaration
5231 and reference to that variable declaration within a compound statement.
5232 </pre></td></tr>
5235 <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>
5236 <tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to
5237 the node, not hidden within a typedef.
5239 Given
5240 typedef const int const_int;
5241 const_int i;
5242 int *const j;
5243 int *volatile k;
5244 int m;
5245 varDecl(hasType(hasLocalQualifiers())) matches only j and k.
5246 i is const-qualified but the qualifier is not local.
5247 </pre></td></tr>
5250 <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>
5251 <tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type.
5253 Given
5254 void a(char);
5255 void b(wchar_t);
5256 void c(double);
5257 functionDecl(hasAnyParameter(hasType(isAnyCharacter())))
5258 matches "a(char)", "b(wchar_t)", but not "c(double)".
5259 </pre></td></tr>
5262 <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>
5263 <tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type; this includes
5264 the Objective-C object pointer type, which is different despite being
5265 syntactically similar.
5267 Given
5268 int *i = nullptr;
5270 @interface Foo
5271 @end
5272 Foo *f;
5274 int j;
5275 varDecl(hasType(isAnyPointer()))
5276 matches "int *i" and "Foo *f", but not "int j".
5277 </pre></td></tr>
5280 <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>
5281 <tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that
5282 include "top-level" const.
5284 Given
5285 void a(int);
5286 void b(int const);
5287 void c(const int);
5288 void d(const int*);
5289 void e(int const) {};
5290 functionDecl(hasAnyParameter(hasType(isConstQualified())))
5291 matches "void b(int const)", "void c(const int)" and
5292 "void e(int const) {}". It does not match d as there
5293 is no top-level const on the parameter type "const int *".
5294 </pre></td></tr>
5297 <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>
5298 <tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type.
5300 Given
5301 void a(int);
5302 void b(long);
5303 void c(double);
5304 functionDecl(hasAnyParameter(hasType(isInteger())))
5305 matches "a(int)", "b(long)", but not "c(double)".
5306 </pre></td></tr>
5309 <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>
5310 <tr><td colspan="4" class="doc" id="isSignedInteger0"><pre>Matches QualType nodes that are of signed integer type.
5312 Given
5313 void a(int);
5314 void b(unsigned long);
5315 void c(double);
5316 functionDecl(hasAnyParameter(hasType(isSignedInteger())))
5317 matches "a(int)", but not "b(unsigned long)" and "c(double)".
5318 </pre></td></tr>
5321 <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>
5322 <tr><td colspan="4" class="doc" id="isUnsignedInteger0"><pre>Matches QualType nodes that are of unsigned integer type.
5324 Given
5325 void a(int);
5326 void b(unsigned long);
5327 void c(double);
5328 functionDecl(hasAnyParameter(hasType(isUnsignedInteger())))
5329 matches "b(unsigned long)", but not "a(int)" and "c(double)".
5330 </pre></td></tr>
5333 <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>
5334 <tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that
5335 include "top-level" volatile.
5337 Given
5338 void a(int);
5339 void b(int volatile);
5340 void c(volatile int);
5341 void d(volatile int*);
5342 void e(int volatile) {};
5343 functionDecl(hasAnyParameter(hasType(isVolatileQualified())))
5344 matches "void b(int volatile)", "void c(volatile int)" and
5345 "void e(int volatile) {}". It does not match d as there
5346 is no top-level volatile on the parameter type "volatile int *".
5347 </pre></td></tr>
5350 <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>
5351 <tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node.
5353 Matches a node if it equals the node previously bound to ID.
5355 Given
5356 class X { int a; int b; };
5357 cxxRecordDecl(
5358 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
5359 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
5360 matches the class X, as a and b have the same type.
5362 Note that when multiple matches are involved via forEach* matchers,
5363 equalsBoundNodes acts as a filter.
5364 For example:
5365 compoundStmt(
5366 forEachDescendant(varDecl().bind("d")),
5367 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
5368 will trigger a match for each combination of variable declaration
5369 and reference to that variable declaration within a compound statement.
5370 </pre></td></tr>
5373 <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>
5374 <tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node.
5376 Stmt has pointer identity in the AST.
5377 </pre></td></tr>
5380 <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>
5381 <tr><td colspan="4" class="doc" id="isExpandedFromMacro1"><pre>Matches statements that are (transitively) expanded from the named macro.
5382 Does not match if only part of the statement is expanded from that macro or
5383 if different parts of the statement are expanded from different
5384 appearances of the macro.
5385 </pre></td></tr>
5388 <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>
5389 <tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is
5390 partially matching a given regex.
5392 Example matches Y but not X
5393 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
5394 #include "ASTMatcher.h"
5395 class X {};
5396 ASTMatcher.h:
5397 class Y {};
5399 Usable 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;
5401 If the matcher is used in clang-query, RegexFlags parameter
5402 should be passed as a quoted string. e.g: "NoFlags".
5403 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
5404 </pre></td></tr>
5407 <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>
5408 <tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file.
5410 Example matches X but not Y
5411 (matcher = cxxRecordDecl(isExpansionInMainFile())
5412 #include &lt;Y.h&gt;
5413 class X {};
5414 Y.h:
5415 class Y {};
5417 Usable 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;
5418 </pre></td></tr>
5421 <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>
5422 <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files.
5424 Example matches Y but not X
5425 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
5426 #include &lt;SystemHeader.h&gt;
5427 class X {};
5428 SystemHeader.h:
5429 class Y {};
5431 Usable 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;
5432 </pre></td></tr>
5435 <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>
5436 <tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation.
5438 Given
5439 int j;
5440 template&lt;typename T&gt; void A(T t) { T i; j += 42;}
5441 A(0);
5442 A(0U);
5443 declStmt(isInTemplateInstantiation())
5444 matches 'int i;' and 'unsigned i'.
5445 unless(stmt(isInTemplateInstantiation()))
5446 will NOT match j += 42; as it's shared between the template definition and
5447 instantiation.
5448 </pre></td></tr>
5451 <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>
5452 <tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size.
5454 Given
5455 int a[42];
5456 int b[2 * 21];
5457 int c[41], d[43];
5458 char *s = "abcd";
5459 wchar_t *ws = L"abcd";
5460 char *w = "a";
5461 constantArrayType(hasSize(42))
5462 matches "int a[42]" and "int b[2 * 21]"
5463 stringLiteral(hasSize(4))
5464 matches "abcd", L"abcd"
5465 </pre></td></tr>
5468 <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>
5469 <tr><td colspan="4" class="doc" id="isClass0"><pre>Matches TagDecl object that are spelled with "class."
5471 Example matches C, but not S, U or E.
5472 struct S {};
5473 class C {};
5474 union U {};
5475 enum E {};
5476 </pre></td></tr>
5479 <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>
5480 <tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached.
5482 Example matches A, va, fa
5483 class A {};
5484 class B; // Doesn't match, as it has no body.
5485 int va;
5486 extern int vb; // Doesn't match, as it doesn't define the variable.
5487 void fa() {}
5488 void fb(); // Doesn't match, as it has no body.
5489 @interface X
5490 - (void)ma; // Doesn't match, interface is declaration.
5491 @end
5492 @implementation X
5493 - (void)ma {}
5494 @end
5496 Usable 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;,
5497 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
5498 </pre></td></tr>
5501 <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>
5502 <tr><td colspan="4" class="doc" id="isEnum0"><pre>Matches TagDecl object that are spelled with "enum."
5504 Example matches E, but not C, S or U.
5505 struct S {};
5506 class C {};
5507 union U {};
5508 enum E {};
5509 </pre></td></tr>
5512 <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>
5513 <tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches TagDecl object that are spelled with "struct."
5515 Example matches S, but not C, U or E.
5516 struct S {};
5517 class C {};
5518 union U {};
5519 enum E {};
5520 </pre></td></tr>
5523 <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>
5524 <tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches TagDecl object that are spelled with "union."
5526 Example matches U, but not C, S or E.
5527 struct S {};
5528 class C {};
5529 union U {};
5530 enum E {};
5531 </pre></td></tr>
5534 <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>
5535 <tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value.
5537 Note that 'Value' is a string as the template argument's value is
5538 an arbitrary precision integer. 'Value' must be euqal to the canonical
5539 representation of that integral value in base 10.
5541 Given
5542 template&lt;int T&gt; struct C {};
5543 C&lt;42&gt; c;
5544 classTemplateSpecializationDecl(
5545 hasAnyTemplateArgument(equalsIntegralValue("42")))
5546 matches the implicit instantiation of C in C&lt;42&gt;.
5547 </pre></td></tr>
5550 <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>
5551 <tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value.
5553 Given
5554 template&lt;int T&gt; struct C {};
5555 C&lt;42&gt; c;
5556 classTemplateSpecializationDecl(
5557 hasAnyTemplateArgument(isIntegral()))
5558 matches the implicit instantiation of C in C&lt;42&gt;
5559 with isIntegral() matching 42.
5560 </pre></td></tr>
5563 <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>
5564 <tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N.
5566 Given
5567 template&lt;typename T&gt; struct C {};
5568 C&lt;int&gt; c;
5569 classTemplateSpecializationDecl(templateArgumentCountIs(1))
5570 matches C&lt;int&gt;.
5571 </pre></td></tr>
5574 <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>
5575 <tr><td colspan="4" class="doc" id="isExpandedFromMacro2"><pre>Matches statements that are (transitively) expanded from the named macro.
5576 Does not match if only part of the statement is expanded from that macro or
5577 if different parts of the statement are expanded from different
5578 appearances of the macro.
5579 </pre></td></tr>
5582 <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>
5583 <tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is
5584 partially matching a given regex.
5586 Example matches Y but not X
5587 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
5588 #include "ASTMatcher.h"
5589 class X {};
5590 ASTMatcher.h:
5591 class Y {};
5593 Usable 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;
5595 If the matcher is used in clang-query, RegexFlags parameter
5596 should be passed as a quoted string. e.g: "NoFlags".
5597 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
5598 </pre></td></tr>
5601 <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>
5602 <tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file.
5604 Example matches X but not Y
5605 (matcher = cxxRecordDecl(isExpansionInMainFile())
5606 #include &lt;Y.h&gt;
5607 class X {};
5608 Y.h:
5609 class Y {};
5611 Usable 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;
5612 </pre></td></tr>
5615 <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>
5616 <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files.
5618 Example matches Y but not X
5619 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
5620 #include &lt;SystemHeader.h&gt;
5621 class X {};
5622 SystemHeader.h:
5623 class Y {};
5625 Usable 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;
5626 </pre></td></tr>
5629 <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>
5630 <tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool.
5632 Given
5633 struct S { bool func(); };
5634 functionDecl(returns(booleanType()))
5635 matches "bool func();"
5636 </pre></td></tr>
5639 <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>
5640 <tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node.
5642 Matches a node if it equals the node previously bound to ID.
5644 Given
5645 class X { int a; int b; };
5646 cxxRecordDecl(
5647 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
5648 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
5649 matches the class X, as a and b have the same type.
5651 Note that when multiple matches are involved via forEach* matchers,
5652 equalsBoundNodes acts as a filter.
5653 For example:
5654 compoundStmt(
5655 forEachDescendant(varDecl().bind("d")),
5656 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
5657 will trigger a match for each combination of variable declaration
5658 and reference to that variable declaration within a compound statement.
5659 </pre></td></tr>
5662 <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>
5663 <tr><td colspan="4" class="doc" id="equalsNode2"><pre>Matches if a node equals another node.
5665 Type has pointer identity in the AST.
5666 </pre></td></tr>
5669 <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>
5670 <tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double).
5672 Given
5673 int i;
5674 float f;
5675 realFloatingPointType()
5676 matches "float f" but not "int i"
5677 </pre></td></tr>
5680 <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>
5681 <tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void.
5683 Given
5684 struct S { void func(); };
5685 functionDecl(returns(voidType()))
5686 matches "void func();"
5687 </pre></td></tr>
5690 <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>
5691 <tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind.
5693 Given
5694 int x;
5695 int s = sizeof(x) + alignof(x)
5696 unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
5697 matches sizeof(x)
5699 If the matcher is use from clang-query, UnaryExprOrTypeTrait parameter
5700 should be passed as a quoted string. e.g., ofKind("UETT_SizeOf").
5701 </pre></td></tr>
5704 <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>
5705 <tr><td colspan="4" class="doc" id="hasAnyOperatorName3"><pre>Matches operator expressions (binary or unary) that have any of the
5706 specified names.
5708 hasAnyOperatorName("+", "-")
5709 Is equivalent to
5710 anyOf(hasOperatorName("+"), hasOperatorName("-"))
5711 </pre></td></tr>
5714 <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>
5715 <tr><td colspan="4" class="doc" id="hasOperatorName3"><pre>Matches the operator Name of operator expressions (binary or
5716 unary).
5718 Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
5719 !(a || b)
5720 </pre></td></tr>
5723 <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>
5724 <tr><td colspan="4" class="doc" id="isArrow1"><pre>Matches member expressions that are called with '-&gt;' as opposed
5725 to '.'.
5727 Member calls on the implicit this pointer match as called with '-&gt;'.
5729 Given
5730 class Y {
5731 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
5732 template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
5733 int a;
5734 static int b;
5736 template &lt;class T&gt;
5737 class Z {
5738 void x() { this-&gt;m; }
5740 memberExpr(isArrow())
5741 matches this-&gt;x, x, y.x, a, this-&gt;b
5742 cxxDependentScopeMemberExpr(isArrow())
5743 matches this-&gt;m
5744 unresolvedMemberExpr(isArrow())
5745 matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
5746 </pre></td></tr>
5749 <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>
5750 <tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration.
5752 Example matches x, but not y, z, or a.
5753 (matcher = varDecl(hasAutomaticStorageDuration())
5754 void f() {
5755 int x;
5756 static int y;
5757 thread_local int z;
5759 int a;
5760 </pre></td></tr>
5763 <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>
5764 <tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage.
5766 Example matches y and z (matcher = varDecl(hasGlobalStorage())
5767 void f() {
5768 int x;
5769 static int y;
5771 int z;
5772 </pre></td></tr>
5775 <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>
5776 <tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a
5777 non-static local variable.
5779 Example matches x (matcher = varDecl(hasLocalStorage())
5780 void f() {
5781 int x;
5782 static int y;
5784 int z;
5785 </pre></td></tr>
5788 <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>
5789 <tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration.
5790 It includes the variable declared at namespace scope and those declared
5791 with "static" and "extern" storage class specifiers.
5793 void f() {
5794 int x;
5795 static int y;
5796 thread_local int z;
5798 int a;
5799 static int b;
5800 extern int c;
5801 varDecl(hasStaticStorageDuration())
5802 matches the function declaration y, a, b and c.
5803 </pre></td></tr>
5806 <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>
5807 <tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration.
5809 Example matches z, but not x, z, or a.
5810 (matcher = varDecl(hasThreadStorageDuration())
5811 void f() {
5812 int x;
5813 static int y;
5814 thread_local int z;
5816 int a;
5817 </pre></td></tr>
5820 <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>
5821 <tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations,
5822 and if constexpr.
5824 Given:
5825 constexpr int foo = 42;
5826 constexpr int bar();
5827 void baz() { if constexpr(1 &gt; 0) {} }
5828 varDecl(isConstexpr())
5829 matches the declaration of foo.
5830 functionDecl(isConstexpr())
5831 matches the declaration of bar.
5832 ifStmt(isConstexpr())
5833 matches the if statement in baz.
5834 </pre></td></tr>
5837 <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>
5838 <tr><td colspan="4" class="doc" id="isConstinit0"><pre>Matches constinit variable declarations.
5840 Given:
5841 constinit int foo = 42;
5842 constinit const char* bar = "bar";
5843 int baz = 42;
5844 [[clang::require_constant_initialization]] int xyz = 42;
5845 varDecl(isConstinit())
5846 matches the declaration of `foo` and `bar`, but not `baz` and `xyz`.
5847 </pre></td></tr>
5850 <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>
5851 <tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached.
5853 Example matches A, va, fa
5854 class A {};
5855 class B; // Doesn't match, as it has no body.
5856 int va;
5857 extern int vb; // Doesn't match, as it doesn't define the variable.
5858 void fa() {}
5859 void fb(); // Doesn't match, as it has no body.
5860 @interface X
5861 - (void)ma; // Doesn't match, interface is declaration.
5862 @end
5863 @implementation X
5864 - (void)ma {}
5865 @end
5867 Usable 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;,
5868 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
5869 </pre></td></tr>
5872 <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>
5873 <tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from
5874 a C++ catch block, or an Objective-C statement.
5876 Example matches x (matcher = varDecl(isExceptionVariable())
5877 void f(int y) {
5878 try {
5879 } catch (int x) {
5882 </pre></td></tr>
5885 <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>
5886 <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or
5887 static member variable template instantiations.
5889 Given
5890 template&lt;typename T&gt; void A(T t) { }
5891 template&lt;&gt; void A(int N) { }
5892 functionDecl(isExplicitTemplateSpecialization())
5893 matches the specialization A&lt;int&gt;().
5895 Usable 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;
5896 </pre></td></tr>
5899 <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>
5900 <tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function or variable declarations.
5902 Given:
5903 extern "C" void f() {}
5904 extern "C" { void g() {} }
5905 void h() {}
5906 extern "C" int x = 1;
5907 extern "C" int y = 2;
5908 int z = 3;
5909 functionDecl(isExternC())
5910 matches the declaration of f and g, but not the declaration of h.
5911 varDecl(isExternC())
5912 matches the declaration of x and y, but not the declaration of z.
5913 </pre></td></tr>
5916 <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>
5917 <tr><td colspan="4" class="doc" id="isInitCapture0"><pre>Matches a variable serving as the implicit variable for a lambda init-
5918 capture.
5920 Example matches x (matcher = varDecl(isInitCapture()))
5921 auto f = [x=3]() { return x; };
5922 </pre></td></tr>
5925 <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>
5926 <tr><td colspan="4" class="doc" id="isInline2"><pre>Matches functions, variables and namespace declarations that are marked with
5927 the inline keyword.
5929 Given
5930 inline void f();
5931 void g();
5932 namespace n {
5933 inline namespace m {}
5935 inline int Foo = 5;
5936 functionDecl(isInline()) will match ::f().
5937 namespaceDecl(isInline()) will match n::m.
5938 varDecl(isInline()) will match Foo;
5939 </pre></td></tr>
5942 <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>
5943 <tr><td colspan="4" class="doc" id="isStaticLocal0"><pre>Matches a static variable with local scope.
5945 Example matches y (matcher = varDecl(isStaticLocal()))
5946 void f() {
5947 int x;
5948 static int y;
5950 static int z;
5951 </pre></td></tr>
5954 <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>
5955 <tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variable/function declarations that have "static" storage
5956 class specifier ("static" keyword) written in the source.
5958 Given:
5959 static void f() {}
5960 static int i = 0;
5961 extern int j;
5962 int k;
5963 functionDecl(isStaticStorageClass())
5964 matches the function declaration f.
5965 varDecl(isStaticStorageClass())
5966 matches the variable declaration i.
5967 </pre></td></tr>
5970 <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>
5971 <tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static
5972 member variable template instantiations.
5974 Given
5975 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
5977 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
5979 template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
5980 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
5981 matches the template instantiation of X&lt;A&gt;.
5983 But given
5984 template &lt;typename T&gt; class X {}; class A {};
5985 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
5986 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
5987 does not match, as X&lt;A&gt; is an explicit template specialization.
5989 Usable 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;
5990 </pre></td></tr>
5992 <!--END_NARROWING_MATCHERS -->
5993 </table>
5995 <!-- ======================================================================= -->
5996 <h2 id="traversal-matchers">AST Traversal Matchers</h2>
5997 <!-- ======================================================================= -->
5999 <p>Traversal matchers specify the relationship to other nodes that are
6000 reachable from the current node.</p>
6002 <p>Note that there are special traversal matchers (has, hasDescendant, forEach and
6003 forEachDescendant) which work on all nodes and allow users to write more generic
6004 match expressions.</p>
6006 <table>
6007 <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
6008 <!-- START_TRAVERSAL_MATCHERS -->
6010 <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>
6011 <tr><td colspan="4" class="doc" id="binaryOperation0"><pre>Matches nodes which can be used with binary operators.
6013 The code
6014 var1 != var2;
6015 might be represented in the clang AST as a binaryOperator, a
6016 cxxOperatorCallExpr or a cxxRewrittenBinaryOperator, depending on
6018 * whether the types of var1 and var2 are fundamental (binaryOperator) or at
6019 least one is a class type (cxxOperatorCallExpr)
6020 * whether the code appears in a template declaration, if at least one of the
6021 vars is a dependent-type (binaryOperator)
6022 * whether the code relies on a rewritten binary operator, such as a
6023 spaceship operator or an inverted equality operator
6024 (cxxRewrittenBinaryOperator)
6026 This matcher elides details in places where the matchers for the nodes are
6027 compatible.
6029 Given
6030 binaryOperation(
6031 hasOperatorName("!="),
6032 hasLHS(expr().bind("lhs")),
6033 hasRHS(expr().bind("rhs"))
6035 matches each use of "!=" in:
6036 struct S{
6037 bool operator!=(const S&amp;) const;
6040 void foo()
6042 1 != 2;
6043 S() != S();
6046 template&lt;typename T&gt;
6047 void templ()
6049 1 != 2;
6050 T() != S();
6052 struct HasOpEq
6054 bool operator==(const HasOpEq &amp;) const;
6057 void inverse()
6059 HasOpEq s1;
6060 HasOpEq s2;
6061 if (s1 != s2)
6062 return;
6065 struct HasSpaceship
6067 bool operator&lt;=&gt;(const HasOpEq &amp;) const;
6070 void use_spaceship()
6072 HasSpaceship s1;
6073 HasSpaceship s2;
6074 if (s1 != s2)
6075 return;
6077 </pre></td></tr>
6080 <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>
6081 <tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches.
6083 Unlike anyOf, eachOf will generate a match result for each
6084 matching submatcher.
6086 For example, in:
6087 class A { int a; int b; };
6088 The matcher:
6089 cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
6090 has(fieldDecl(hasName("b")).bind("v"))))
6091 will generate two results binding "v", the first of which binds
6092 the field declaration of a, the second the field declaration of
6095 Usable as: Any Matcher
6096 </pre></td></tr>
6099 <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>
6100 <tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches.
6102 Generates results for each match.
6104 For example, in:
6105 class A { class B {}; class C {}; };
6106 The matcher:
6107 cxxRecordDecl(hasName("::A"),
6108 findAll(cxxRecordDecl(isDefinition()).bind("m")))
6109 will generate results for A, B and C.
6111 Usable as: Any Matcher
6112 </pre></td></tr>
6115 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher&lt;*&gt;</td></tr>
6116 <tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
6117 provided matcher.
6119 Example matches X, A, A::X, B, B::C, B::C::X
6120 (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))
6121 class X {};
6122 class A { class X {}; }; // Matches A, because A::X is a class of name
6123 // X inside A.
6124 class B { class C { class X {}; }; };
6126 DescendantT must be an AST base type.
6128 As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
6129 each result that matches instead of only on the first one.
6131 Note: Recursively combined ForEachDescendant can cause many matches:
6132 cxxRecordDecl(forEachDescendant(cxxRecordDecl(
6133 forEachDescendant(cxxRecordDecl())
6135 will match 10 times (plus injected class name matches) on:
6136 class A { class B { class C { class D { class E {}; }; }; }; };
6138 Usable as: Any Matcher
6139 </pre></td></tr>
6142 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher&lt;*&gt;</td></tr>
6143 <tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the
6144 provided matcher.
6146 Example matches X, Y, Y::X, Z::Y, Z::Y::X
6147 (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
6148 class X {};
6149 class Y { class X {}; }; // Matches Y, because Y::X is a class of name X
6150 // inside Y.
6151 class Z { class Y { class X {}; }; }; // Does not match Z.
6153 ChildT must be an AST base type.
6155 As opposed to 'has', 'forEach' will cause a match for each result that
6156 matches instead of only on the first one.
6158 Usable as: Any Matcher
6159 </pre></td></tr>
6162 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher&lt;*&gt;</td></tr>
6163 <tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided
6164 matcher.
6166 Given
6167 void f() { if (true) { int x = 42; } }
6168 void g() { for (;;) { int x = 43; } }
6169 expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.
6171 Usable as: Any Matcher
6172 </pre></td></tr>
6175 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher&lt;*&gt;</td></tr>
6176 <tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
6177 provided matcher.
6179 Example matches X, Y, Z
6180 (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X")))))
6181 class X {}; // Matches X, because X::X is a class of name X inside X.
6182 class Y { class X {}; };
6183 class Z { class Y { class X {}; }; };
6185 DescendantT must be an AST base type.
6187 Usable as: Any Matcher
6188 </pre></td></tr>
6191 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher&lt;*&gt;</td></tr>
6192 <tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the
6193 provided matcher.
6195 Example matches X, Y
6196 (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X")))
6197 class X {}; // Matches X, because X::X is a class of name X inside X.
6198 class Y { class X {}; };
6199 class Z { class Y { class X {}; }; }; // Does not match Z.
6201 ChildT must be an AST base type.
6203 Usable as: Any Matcher
6204 Note that has is direct matcher, so it also matches things like implicit
6205 casts and paren casts. If you are matching with expr then you should
6206 probably consider using ignoringParenImpCasts like:
6207 has(ignoringParenImpCasts(expr())).
6208 </pre></td></tr>
6211 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher&lt;*&gt;</td></tr>
6212 <tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided
6213 matcher.
6215 Given
6216 void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
6217 compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".
6219 Usable as: Any Matcher
6220 </pre></td></tr>
6223 <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>
6224 <tr><td colspan="4" class="doc" id="invocation0"><pre>Matches function calls and constructor calls
6226 Because CallExpr and CXXConstructExpr do not share a common
6227 base class with API accessing arguments etc, AST Matchers for code
6228 which should match both are typically duplicated. This matcher
6229 removes the need for duplication.
6231 Given code
6232 struct ConstructorTakesInt
6234 ConstructorTakesInt(int i) {}
6237 void callTakesInt(int i)
6241 void doCall()
6243 callTakesInt(42);
6246 void doConstruct()
6248 ConstructorTakesInt cti(42);
6251 The matcher
6252 invocation(hasArgument(0, integerLiteral(equals(42))))
6253 matches the expression in both doCall and doConstruct
6254 </pre></td></tr>
6257 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('optionally0')"><a name="optionally0Anchor">optionally</a></td><td>Matcher&lt;*&gt;</td></tr>
6258 <tr><td colspan="4" class="doc" id="optionally0"><pre>Matches any node regardless of the submatcher.
6260 However, optionally will retain any bindings generated by the submatcher.
6261 Useful when additional information which may or may not present about a main
6262 matching node is desired.
6264 For example, in:
6265 class Foo {
6266 int bar;
6268 The matcher:
6269 cxxRecordDecl(
6270 optionally(has(
6271 fieldDecl(hasName("bar")).bind("var")
6272 ))).bind("record")
6273 will produce a result binding for both "record" and "var".
6274 The matcher will produce a "record" binding for even if there is no data
6275 member named "bar" in that class.
6277 Usable as: Any Matcher
6278 </pre></td></tr>
6281 <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>
6282 <tr><td colspan="4" class="doc" id="traverse0"><pre>Causes all nested matchers to be matched with the specified traversal kind.
6284 Given
6285 void foo()
6287 int i = 3.0;
6289 The matcher
6290 traverse(TK_IgnoreUnlessSpelledInSource,
6291 varDecl(hasInitializer(floatLiteral().bind("init")))
6293 matches the variable declaration with "init" bound to the "3.0".
6294 </pre></td></tr>
6297 <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>
6298 <tr><td colspan="4" class="doc" id="hasCondition5"><pre>Matches the condition expression of an if statement, for loop,
6299 switch statement or conditional operator.
6301 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
6302 if (true) {}
6303 </pre></td></tr>
6306 <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>
6307 <tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator
6308 (binary or ternary).
6310 Example matches b
6311 condition ? a : b
6312 condition ?: b
6313 </pre></td></tr>
6316 <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>
6317 <tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator.
6319 Example 1 (conditional ternary operator): matches a
6320 condition ? a : b
6322 Example 2 (conditional binary operator): matches opaqueValueExpr(condition)
6323 condition ?: b
6324 </pre></td></tr>
6327 <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>
6328 <tr><td colspan="4" class="doc" id="hasDeclaration15"><pre>Matches a node if the declaration associated with that node
6329 matches the given matcher.
6331 The associated declaration is:
6332 - for type nodes, the declaration of the underlying type
6333 - for CallExpr, the declaration of the callee
6334 - for MemberExpr, the declaration of the referenced member
6335 - for CXXConstructExpr, the declaration of the constructor
6336 - for CXXNewExpr, the declaration of the operator new
6337 - for ObjCIvarExpr, the declaration of the ivar
6339 For type nodes, hasDeclaration will generally match the declaration of the
6340 sugared type. Given
6341 class X {};
6342 typedef X Y;
6343 Y y;
6344 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6345 typedefDecl. A common use case is to match the underlying, desugared type.
6346 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6347 varDecl(hasType(hasUnqualifiedDesugaredType(
6348 recordType(hasDeclaration(decl())))))
6349 In this matcher, the decl will match the CXXRecordDecl of class X.
6351 Usable 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;,
6352 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;,
6353 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;,
6354 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;,
6355 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;,
6356 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;,
6357 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6358 </pre></td></tr>
6361 <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>
6362 <tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression.
6364 Given
6365 int i[5];
6366 void f() { i[1] = 42; }
6367 arraySubscriptExpression(hasBase(implicitCastExpr(
6368 hasSourceExpression(declRefExpr()))))
6369 matches i[1] with the declRefExpr() matching i
6370 </pre></td></tr>
6373 <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>
6374 <tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression.
6376 Given
6377 int i[5];
6378 void f() { i[1] = 42; }
6379 arraySubscriptExpression(hasIndex(integerLiteral()))
6380 matches i[1] with the integerLiteral() matching 1
6381 </pre></td></tr>
6384 <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>
6385 <tr><td colspan="4" class="doc" id="hasLHS3"><pre>Matches the left hand side of binary operator expressions.
6387 Example matches a (matcher = binaryOperator(hasLHS()))
6388 a || b
6389 </pre></td></tr>
6392 <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>
6393 <tr><td colspan="4" class="doc" id="hasRHS3"><pre>Matches the right hand side of binary operator expressions.
6395 Example matches b (matcher = binaryOperator(hasRHS()))
6396 a || b
6397 </pre></td></tr>
6400 <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>
6401 <tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element
6402 type.
6404 Given
6405 struct A {};
6406 A a[7];
6407 int b[7];
6408 arrayType(hasElementType(builtinType()))
6409 matches "int b[7]"
6411 Usable 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;
6412 </pre></td></tr>
6415 <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>
6416 <tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type.
6418 Given
6419 _Atomic(int) i;
6420 _Atomic(float) f;
6421 atomicType(hasValueType(isInteger()))
6422 matches "_Atomic(int) i"
6424 Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
6425 </pre></td></tr>
6428 <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>
6429 <tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type.
6431 Note: There is no TypeLoc for the deduced type and thus no
6432 getDeducedLoc() matcher.
6434 Given
6435 auto a = 1;
6436 auto b = 2.0;
6437 autoType(hasDeducedType(isInteger()))
6438 matches "auto a"
6440 Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>&gt;
6441 </pre></td></tr>
6444 <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>
6445 <tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration.
6447 Given
6448 namespace X { void b(); }
6449 using X::b;
6450 usingDecl(hasAnyUsingShadowDecl(hasName("b"))))
6451 matches using X::b </pre></td></tr>
6454 <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>
6455 <tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a
6456 binary operator matches.
6457 </pre></td></tr>
6460 <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>
6461 <tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions.
6463 Example matches a (matcher = binaryOperator(hasLHS()))
6464 a || b
6465 </pre></td></tr>
6468 <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>
6469 <tr><td colspan="4" class="doc" id="hasOperands0"><pre>Matches if both matchers match with opposite sides of the binary operator.
6471 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
6472 integerLiteral(equals(2)))
6473 1 + 2 // Match
6474 2 + 1 // Match
6475 1 + 1 // No match
6476 2 + 2 // No match
6477 </pre></td></tr>
6480 <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>
6481 <tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions.
6483 Example matches b (matcher = binaryOperator(hasRHS()))
6484 a || b
6485 </pre></td></tr>
6488 <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>
6489 <tr><td colspan="4" class="doc" id="forDecomposition0"><pre>Matches the DecompositionDecl the binding belongs to.
6491 For example, in:
6492 void foo()
6494 int arr[3];
6495 auto &amp;[f, s, t] = arr;
6497 f = 42;
6499 The matcher:
6500 bindingDecl(hasName("f"),
6501 forDecomposition(decompositionDecl())
6502 matches 'f' in 'auto &amp;[f, s, t]'.
6503 </pre></td></tr>
6506 <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>
6507 <tr><td colspan="4" class="doc" id="hasAnyParameter2"><pre>Matches any parameter of a function or an ObjC method declaration or a
6508 block.
6510 Does not match the 'this' parameter of a method.
6512 Given
6513 class X { void f(int x, int y, int z) {} };
6514 cxxMethodDecl(hasAnyParameter(hasName("y")))
6515 matches f(int x, int y, int z) {}
6516 with hasAnyParameter(...)
6517 matching int y
6519 For ObjectiveC, given
6520 @interface I - (void) f:(int) y; @end
6522 the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
6523 matches the declaration of method f with hasParameter
6524 matching y.
6526 For blocks, given
6527 b = ^(int y) { printf("%d", y) };
6529 the matcher blockDecl(hasAnyParameter(hasName("y")))
6530 matches the declaration of the block b with hasParameter
6531 matching y.
6532 </pre></td></tr>
6535 <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>
6536 <tr><td colspan="4" class="doc" id="hasParameter2"><pre>Matches the n'th parameter of a function or an ObjC method
6537 declaration or a block.
6539 Given
6540 class X { void f(int x) {} };
6541 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
6542 matches f(int x) {}
6543 with hasParameter(...)
6544 matching int x
6546 For ObjectiveC, given
6547 @interface I - (void) f:(int) y; @end
6549 the matcher objcMethodDecl(hasParameter(0, hasName("y")))
6550 matches the declaration of method f with hasParameter
6551 matching y.
6552 </pre></td></tr>
6555 <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>
6556 <tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of a node matches the inner matcher.
6558 Examples:
6559 int x;
6560 declaratorDecl(hasTypeLoc(loc(asString("int"))))
6561 matches int x
6563 auto x = int(3);
6564 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6565 matches int(3)
6567 struct Foo { Foo(int, int); };
6568 auto x = Foo(1, 2);
6569 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6570 matches Foo(1, 2)
6572 Usable 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;,
6573 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;,
6574 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;,
6575 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6576 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;,
6577 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;,
6578 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;,
6579 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6580 </pre></td></tr>
6583 <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>
6584 <tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the
6585 pointee matches a given matcher.
6587 Given
6588 int *a;
6589 int const *b;
6590 float const *f;
6591 pointerType(pointee(isConstQualified(), isInteger()))
6592 matches "int const *b"
6594 Usable 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;,
6595 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;
6596 </pre></td></tr>
6599 <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>
6600 <tr><td colspan="4" class="doc" id="hasTypeLoc1"><pre>Matches if the type location of a node matches the inner matcher.
6602 Examples:
6603 int x;
6604 declaratorDecl(hasTypeLoc(loc(asString("int"))))
6605 matches int x
6607 auto x = int(3);
6608 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6609 matches int(3)
6611 struct Foo { Foo(int, int); };
6612 auto x = Foo(1, 2);
6613 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6614 matches Foo(1, 2)
6616 Usable 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;,
6617 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;,
6618 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;,
6619 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6620 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;,
6621 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;,
6622 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;,
6623 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6624 </pre></td></tr>
6627 <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>
6628 <tr><td colspan="4" class="doc" id="hasType8"><pre>Overloaded to match the declaration of the expression's or value
6629 declaration's type.
6631 In case of a value declaration (for example a variable declaration),
6632 this resolves one layer of indirection. For example, in the value
6633 declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
6634 X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
6635 declaration of x.
6637 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
6638 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
6639 and friend class X (matcher = friendDecl(hasType("X"))
6640 and public virtual X (matcher = cxxBaseSpecifier(hasType(
6641 cxxRecordDecl(hasName("X"))))
6642 class X {};
6643 void y(X &amp;x) { x; X z; }
6644 class Y { friend class X; };
6645 class Z : public virtual X {};
6647 Example matches class Derived
6648 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
6649 class Base {};
6650 class Derived : Base {};
6652 Usable 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;,
6653 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
6654 </pre></td></tr>
6657 <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>
6658 <tr><td colspan="4" class="doc" id="hasType4"><pre>Matches if the expression's or declaration's type matches a type
6659 matcher.
6661 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
6662 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
6663 and U (matcher = typedefDecl(hasType(asString("int")))
6664 and friend class X (matcher = friendDecl(hasType("X"))
6665 and public virtual X (matcher = cxxBaseSpecifier(hasType(
6666 asString("class X")))
6667 class X {};
6668 void y(X &amp;x) { x; X z; }
6669 typedef int U;
6670 class Y { friend class X; };
6671 class Z : public virtual X {};
6672 </pre></td></tr>
6675 <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>
6676 <tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl.
6678 Given
6679 void f(int i);
6680 int y;
6681 f(y);
6682 callExpr(
6683 forEachArgumentWithParam(
6684 declRefExpr(to(varDecl(hasName("y")))),
6685 parmVarDecl(hasType(isInteger()))
6687 matches f(y);
6688 with declRefExpr(...)
6689 matching int y
6690 and parmVarDecl(...)
6691 matching int i
6692 </pre></td></tr>
6695 <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>
6696 <tr><td colspan="4" class="doc" id="forEachArgumentWithParamType1"><pre>Matches all arguments and their respective types for a CallExpr or
6697 CXXConstructExpr. It is very similar to forEachArgumentWithParam but
6698 it works on calls through function pointers as well.
6700 The difference is, that function pointers do not provide access to a
6701 ParmVarDecl, but only the QualType for each argument.
6703 Given
6704 void f(int i);
6705 int y;
6706 f(y);
6707 void (*f_ptr)(int) = f;
6708 f_ptr(y);
6709 callExpr(
6710 forEachArgumentWithParamType(
6711 declRefExpr(to(varDecl(hasName("y")))),
6712 qualType(isInteger()).bind("type)
6714 matches f(y) and f_ptr(y)
6715 with declRefExpr(...)
6716 matching int y
6717 and qualType(...)
6718 matching int
6719 </pre></td></tr>
6722 <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>
6723 <tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call
6724 expression, or an ObjC-message-send expression.
6726 Given
6727 void x(int, int, int) { int y; x(1, y, 42); }
6728 callExpr(hasAnyArgument(declRefExpr()))
6729 matches x(1, y, 42)
6730 with hasAnyArgument(...)
6731 matching y
6733 For ObjectiveC, given
6734 @interface I - (void) f:(int) y; @end
6735 void foo(I *i) { [i f:12]; }
6736 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
6737 matches [i f:12]
6738 </pre></td></tr>
6741 <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>
6742 <tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor
6743 call expression.
6745 Example matches y in x(y)
6746 (matcher = callExpr(hasArgument(0, declRefExpr())))
6747 void x(int) { int y; x(y); }
6748 </pre></td></tr>
6751 <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>
6752 <tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node
6753 matches the given matcher.
6755 The associated declaration is:
6756 - for type nodes, the declaration of the underlying type
6757 - for CallExpr, the declaration of the callee
6758 - for MemberExpr, the declaration of the referenced member
6759 - for CXXConstructExpr, the declaration of the constructor
6760 - for CXXNewExpr, the declaration of the operator new
6761 - for ObjCIvarExpr, the declaration of the ivar
6763 For type nodes, hasDeclaration will generally match the declaration of the
6764 sugared type. Given
6765 class X {};
6766 typedef X Y;
6767 Y y;
6768 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6769 typedefDecl. A common use case is to match the underlying, desugared type.
6770 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6771 varDecl(hasType(hasUnqualifiedDesugaredType(
6772 recordType(hasDeclaration(decl())))))
6773 In this matcher, the decl will match the CXXRecordDecl of class X.
6775 Usable 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;,
6776 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;,
6777 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;,
6778 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;,
6779 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;,
6780 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;,
6781 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6782 </pre></td></tr>
6785 <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>
6786 <tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition.
6788 Given
6789 class A { A() : i(42), j(42) {} int i; int j; };
6790 cxxConstructorDecl(forEachConstructorInitializer(
6791 forField(decl().bind("x"))
6793 will trigger two matches, binding for 'i' and 'j' respectively.
6794 </pre></td></tr>
6797 <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>
6798 <tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer.
6800 Given
6801 struct Foo {
6802 Foo() : foo_(1) { }
6803 int foo_;
6805 cxxRecordDecl(has(cxxConstructorDecl(
6806 hasAnyConstructorInitializer(anything())
6808 record matches Foo, hasAnyConstructorInitializer matches foo_(1)
6809 </pre></td></tr>
6812 <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>
6813 <tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer.
6815 Given
6816 struct Foo {
6817 Foo() : foo_(1) { }
6818 int foo_;
6820 cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
6821 forField(hasName("foo_"))))))
6822 matches Foo
6823 with forField matching foo_
6824 </pre></td></tr>
6827 <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>
6828 <tr><td colspan="4" class="doc" id="hasTypeLoc2"><pre>Matches if the type location of a node matches the inner matcher.
6830 Examples:
6831 int x;
6832 declaratorDecl(hasTypeLoc(loc(asString("int"))))
6833 matches int x
6835 auto x = int(3);
6836 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6837 matches int(3)
6839 struct Foo { Foo(int, int); };
6840 auto x = Foo(1, 2);
6841 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6842 matches Foo(1, 2)
6844 Usable 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;,
6845 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;,
6846 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;,
6847 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6848 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;,
6849 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;,
6850 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;,
6851 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6852 </pre></td></tr>
6855 <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>
6856 <tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer.
6858 Given
6859 struct Foo {
6860 Foo() : foo_(1) { }
6861 int foo_;
6863 cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
6864 withInitializer(integerLiteral(equals(1)))))))
6865 matches Foo
6866 with withInitializer matching (1)
6867 </pre></td></tr>
6870 <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>
6871 <tr><td colspan="4" class="doc" id="hasObjectExpression2"><pre>Matches a member expression where the object expression is matched by a
6872 given matcher. Implicit object expressions are included; that is, it matches
6873 use of implicit `this`.
6875 Given
6876 struct X {
6877 int m;
6878 int f(X x) { x.m; return m; }
6880 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))
6881 matches `x.m`, but not `m`; however,
6882 memberExpr(hasObjectExpression(hasType(pointsTo(
6883 cxxRecordDecl(hasName("X"))))))
6884 matches `m` (aka. `this-&gt;m`), but not `x.m`.
6885 </pre></td></tr>
6888 <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>
6889 <tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
6890 definition that has a given body. Note that in case of functions or
6891 coroutines this matcher only matches the definition itself and not the
6892 other declarations of the same function or coroutine.
6894 Given
6895 for (;;) {}
6896 forStmt(hasBody(compoundStmt()))
6897 matches 'for (;;) {}'
6898 with compoundStmt()
6899 matching '{}'
6901 Given
6902 void f();
6903 void f() {}
6904 functionDecl(hasBody(compoundStmt()))
6905 matches 'void f() {}'
6906 with compoundStmt()
6907 matching '{}'
6908 but does not match 'void f();'
6909 </pre></td></tr>
6912 <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>
6913 <tr><td colspan="4" class="doc" id="hasInitStatement2"><pre>Matches selection statements with initializer.
6915 Given:
6916 void foo() {
6917 if (int i = foobar(); i &gt; 0) {}
6918 switch (int i = foobar(); i) {}
6919 for (auto&amp; a = get_range(); auto&amp; x : a) {}
6921 void bar() {
6922 if (foobar() &gt; 0) {}
6923 switch (foobar()) {}
6924 for (auto&amp; x : get_range()) {}
6926 ifStmt(hasInitStatement(anything()))
6927 matches the if statement in foo but not in bar.
6928 switchStmt(hasInitStatement(anything()))
6929 matches the switch statement in foo but not in bar.
6930 cxxForRangeStmt(hasInitStatement(anything()))
6931 matches the range for statement in foo but not in bar.
6932 </pre></td></tr>
6935 <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>
6936 <tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop.
6938 Example:
6939 forStmt(hasLoopVariable(anything()))
6940 matches 'int x' in
6941 for (int x : a) { }
6942 </pre></td></tr>
6945 <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>
6946 <tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop.
6948 Example:
6949 forStmt(hasRangeInit(anything()))
6950 matches 'a' in
6951 for (int x : a) { }
6952 </pre></td></tr>
6955 <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>
6956 <tr><td colspan="4" class="doc" id="hasTypeLoc3"><pre>Matches if the type location of a node matches the inner matcher.
6958 Examples:
6959 int x;
6960 declaratorDecl(hasTypeLoc(loc(asString("int"))))
6961 matches int x
6963 auto x = int(3);
6964 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6965 matches int(3)
6967 struct Foo { Foo(int, int); };
6968 auto x = Foo(1, 2);
6969 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6970 matches Foo(1, 2)
6972 Usable 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;,
6973 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;,
6974 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;,
6975 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6976 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;,
6977 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;,
6978 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;,
6979 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6980 </pre></td></tr>
6983 <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>
6984 <tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre>Matches on the implicit object argument of a member call expression. Unlike
6985 `on`, matches the argument directly without stripping away anything.
6987 Given
6988 class Y { public: void m(); };
6989 Y g();
6990 class X : public Y { void g(); };
6991 void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); }
6992 cxxMemberCallExpr(onImplicitObjectArgument(hasType(
6993 cxxRecordDecl(hasName("Y")))))
6994 matches `y.m()`, `x.m()` and (g()).m(), but not `x.g()`.
6995 cxxMemberCallExpr(on(callExpr()))
6996 does not match `(g()).m()`, because the parens are not ignored.
6998 FIXME: Overload to allow directly matching types?
6999 </pre></td></tr>
7002 <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>
7003 <tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression, after
7004 stripping off any parentheses or implicit casts.
7006 Given
7007 class Y { public: void m(); };
7008 Y g();
7009 class X : public Y {};
7010 void z(Y y, X x) { y.m(); (g()).m(); x.m(); }
7011 cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))))
7012 matches `y.m()` and `(g()).m()`.
7013 cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X")))))
7014 matches `x.m()`.
7015 cxxMemberCallExpr(on(callExpr()))
7016 matches `(g()).m()`.
7018 FIXME: Overload to allow directly matching types?
7019 </pre></td></tr>
7022 <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>
7023 <tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration.
7024 </pre></td></tr>
7027 <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>
7028 <tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the type of the expression's implicit object argument either
7029 matches the InnerMatcher, or is a pointer to a type that matches the
7030 InnerMatcher.
7032 Given
7033 class Y { public: void m(); };
7034 class X : public Y { void g(); };
7035 void z() { Y y; y.m(); Y *p; p-&gt;m(); X x; x.m(); x.g(); }
7036 cxxMemberCallExpr(thisPointerType(hasDeclaration(
7037 cxxRecordDecl(hasName("Y")))))
7038 matches `y.m()`, `p-&gt;m()` and `x.m()`.
7039 cxxMemberCallExpr(thisPointerType(hasDeclaration(
7040 cxxRecordDecl(hasName("X")))))
7041 matches `x.g()`.
7042 </pre></td></tr>
7045 <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>
7046 <tr><td colspan="4" class="doc" id="forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may
7047 produce multiple matches.
7049 Given
7050 class A { virtual void f(); };
7051 class B : public A { void f(); };
7052 class C : public B { void f(); };
7053 cxxMethodDecl(ofClass(hasName("C")),
7054 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
7055 matches once, with "b" binding "A::f" and "d" binding "C::f" (Note
7056 that B::f is not overridden by C::f).
7058 The check can produce multiple matches in case of multiple inheritance, e.g.
7059 class A1 { virtual void f(); };
7060 class A2 { virtual void f(); };
7061 class C : public A1, public A2 { void f(); };
7062 cxxMethodDecl(ofClass(hasName("C")),
7063 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
7064 matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and
7065 once with "b" binding "A2::f" and "d" binding "C::f".
7066 </pre></td></tr>
7069 <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>
7070 <tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration
7071 belongs to.
7073 FIXME: Generalize this for other kinds of declarations.
7074 FIXME: What other kind of declarations would we need to generalize
7075 this to?
7077 Example matches A() in the last line
7078 (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl(
7079 ofClass(hasName("A"))))))
7080 class A {
7081 public:
7082 A();
7084 A a = A();
7085 </pre></td></tr>
7088 <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>
7089 <tr><td colspan="4" class="doc" id="hasAnyPlacementArg0"><pre>Matches any placement new expression arguments.
7091 Given:
7092 MyClass *p1 = new (Storage) MyClass();
7093 cxxNewExpr(hasAnyPlacementArg(anything()))
7094 matches the expression 'new (Storage, 16) MyClass()'.
7095 </pre></td></tr>
7098 <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>
7099 <tr><td colspan="4" class="doc" id="hasArraySize0"><pre>Matches array new expressions with a given array size.
7101 Given:
7102 MyClass *p1 = new MyClass[10];
7103 cxxNewExpr(hasArraySize(integerLiteral(equals(10))))
7104 matches the expression 'new MyClass[10]'.
7105 </pre></td></tr>
7108 <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>
7109 <tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node
7110 matches the given matcher.
7112 The associated declaration is:
7113 - for type nodes, the declaration of the underlying type
7114 - for CallExpr, the declaration of the callee
7115 - for MemberExpr, the declaration of the referenced member
7116 - for CXXConstructExpr, the declaration of the constructor
7117 - for CXXNewExpr, the declaration of the operator new
7118 - for ObjCIvarExpr, the declaration of the ivar
7120 For type nodes, hasDeclaration will generally match the declaration of the
7121 sugared type. Given
7122 class X {};
7123 typedef X Y;
7124 Y y;
7125 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7126 typedefDecl. A common use case is to match the underlying, desugared type.
7127 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7128 varDecl(hasType(hasUnqualifiedDesugaredType(
7129 recordType(hasDeclaration(decl())))))
7130 In this matcher, the decl will match the CXXRecordDecl of class X.
7132 Usable 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;,
7133 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;,
7134 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;,
7135 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;,
7136 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;,
7137 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;,
7138 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
7139 </pre></td></tr>
7142 <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>
7143 <tr><td colspan="4" class="doc" id="hasPlacementArg0"><pre>Matches placement new expression arguments.
7145 Given:
7146 MyClass *p1 = new (Storage, 16) MyClass();
7147 cxxNewExpr(hasPlacementArg(1, integerLiteral(equals(16))))
7148 matches the expression 'new (Storage, 16) MyClass()'.
7149 </pre></td></tr>
7152 <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>
7153 <tr><td colspan="4" class="doc" id="hasTypeLoc4"><pre>Matches if the type location of a node matches the inner matcher.
7155 Examples:
7156 int x;
7157 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7158 matches int x
7160 auto x = int(3);
7161 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7162 matches int(3)
7164 struct Foo { Foo(int, int); };
7165 auto x = Foo(1, 2);
7166 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7167 matches Foo(1, 2)
7169 Usable 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;,
7170 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;,
7171 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;,
7172 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7173 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;,
7174 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;,
7175 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;,
7176 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7177 </pre></td></tr>
7180 <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>
7181 <tr><td colspan="4" class="doc" id="hasEitherOperand1"><pre>Matches if either the left hand side or the right hand side of a
7182 binary operator matches.
7183 </pre></td></tr>
7186 <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>
7187 <tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions.
7189 Example matches a (matcher = binaryOperator(hasLHS()))
7190 a || b
7191 </pre></td></tr>
7194 <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>
7195 <tr><td colspan="4" class="doc" id="hasOperands1"><pre>Matches if both matchers match with opposite sides of the binary operator.
7197 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
7198 integerLiteral(equals(2)))
7199 1 + 2 // Match
7200 2 + 1 // Match
7201 1 + 1 // No match
7202 2 + 2 // No match
7203 </pre></td></tr>
7206 <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>
7207 <tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions.
7209 Example matches b (matcher = binaryOperator(hasRHS()))
7210 a || b
7211 </pre></td></tr>
7214 <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>
7215 <tr><td colspan="4" class="doc" id="hasUnaryOperand1"><pre>Matches if the operand of a unary operator matches.
7217 Example matches true (matcher = hasUnaryOperand(
7218 cxxBoolLiteral(equals(true))))
7219 !true
7220 </pre></td></tr>
7223 <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>
7224 <tr><td colspan="4" class="doc" id="hasAnyBase0"><pre>Matches C++ classes that have a direct or indirect base matching BaseSpecMatcher.
7226 Example:
7227 matcher hasAnyBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))
7228 class Foo;
7229 class Bar : Foo {};
7230 class Baz : Bar {};
7231 class SpecialBase;
7232 class Proxy : SpecialBase {}; // matches Proxy
7233 class IndirectlyDerived : Proxy {}; //matches IndirectlyDerived
7235 FIXME: Refactor this and isDerivedFrom to reuse implementation.
7236 </pre></td></tr>
7239 <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>
7240 <tr><td colspan="4" class="doc" id="hasDirectBase0"><pre>Matches C++ classes that have a direct base matching BaseSpecMatcher.
7242 Example:
7243 matcher hasDirectBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))
7244 class Foo;
7245 class Bar : Foo {};
7246 class Baz : Bar {};
7247 class SpecialBase;
7248 class Proxy : SpecialBase {}; // matches Proxy
7249 class IndirectlyDerived : Proxy {}; // doesn't match
7250 </pre></td></tr>
7253 <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>
7254 <tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher.
7256 Given:
7257 class A { void func(); };
7258 class B { void member(); };
7260 cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of
7261 A but not B.
7262 </pre></td></tr>
7265 <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>
7266 <tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from a class
7267 matching Base, or Objective-C classes that directly or indirectly
7268 subclass a class matching Base.
7270 Note that a class is not considered to be derived from itself.
7272 Example matches Y, Z, C (Base == hasName("X"))
7273 class X;
7274 class Y : public X {}; // directly derived
7275 class Z : public Y {}; // indirectly derived
7276 typedef X A;
7277 typedef A B;
7278 class C : public B {}; // derived from a typedef of X
7280 In the following example, Bar matches isDerivedFrom(hasName("X")):
7281 class Foo;
7282 typedef Foo X;
7283 class Bar : public Foo {}; // derived from a type that X is a typedef of
7285 In the following example, Bar matches isDerivedFrom(hasName("NSObject"))
7286 @interface NSObject @end
7287 @interface Bar : NSObject @end
7289 Usable 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;
7290 </pre></td></tr>
7293 <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>
7294 <tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom0"><pre>Matches C++ or Objective-C classes that are directly derived from a class
7295 matching Base.
7297 Note that a class is not considered to be derived from itself.
7299 Example matches Y, C (Base == hasName("X"))
7300 class X;
7301 class Y : public X {}; // directly derived
7302 class Z : public Y {}; // indirectly derived
7303 typedef X A;
7304 typedef A B;
7305 class C : public B {}; // derived from a typedef of X
7307 In the following example, Bar matches isDerivedFrom(hasName("X")):
7308 class Foo;
7309 typedef Foo X;
7310 class Bar : public Foo {}; // derived from a type that X is a typedef of
7311 </pre></td></tr>
7314 <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>
7315 <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly
7316 match Base.
7317 </pre></td></tr>
7320 <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>
7321 <tr><td colspan="4" class="doc" id="hasEitherOperand2"><pre>Matches if either the left hand side or the right hand side of a
7322 binary operator matches.
7323 </pre></td></tr>
7326 <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>
7327 <tr><td colspan="4" class="doc" id="hasLHS2"><pre>Matches the left hand side of binary operator expressions.
7329 Example matches a (matcher = binaryOperator(hasLHS()))
7330 a || b
7331 </pre></td></tr>
7334 <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>
7335 <tr><td colspan="4" class="doc" id="hasOperands2"><pre>Matches if both matchers match with opposite sides of the binary operator.
7337 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
7338 integerLiteral(equals(2)))
7339 1 + 2 // Match
7340 2 + 1 // Match
7341 1 + 1 // No match
7342 2 + 2 // No match
7343 </pre></td></tr>
7346 <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>
7347 <tr><td colspan="4" class="doc" id="hasRHS2"><pre>Matches the right hand side of binary operator expressions.
7349 Example matches b (matcher = binaryOperator(hasRHS()))
7350 a || b
7351 </pre></td></tr>
7354 <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>
7355 <tr><td colspan="4" class="doc" id="hasTypeLoc5"><pre>Matches if the type location of a node matches the inner matcher.
7357 Examples:
7358 int x;
7359 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7360 matches int x
7362 auto x = int(3);
7363 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7364 matches int(3)
7366 struct Foo { Foo(int, int); };
7367 auto x = Foo(1, 2);
7368 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7369 matches Foo(1, 2)
7371 Usable 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;,
7372 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;,
7373 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;,
7374 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7375 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;,
7376 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;,
7377 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;,
7378 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7379 </pre></td></tr>
7382 <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>
7383 <tr><td colspan="4" class="doc" id="hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call
7384 expression, or an ObjC-message-send expression.
7386 Given
7387 void x(int, int, int) { int y; x(1, y, 42); }
7388 callExpr(hasAnyArgument(declRefExpr()))
7389 matches x(1, y, 42)
7390 with hasAnyArgument(...)
7391 matching y
7393 For ObjectiveC, given
7394 @interface I - (void) f:(int) y; @end
7395 void foo(I *i) { [i f:12]; }
7396 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
7397 matches [i f:12]
7398 </pre></td></tr>
7401 <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>
7402 <tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor
7403 call expression.
7405 Example matches y in x(y)
7406 (matcher = callExpr(hasArgument(0, declRefExpr())))
7407 void x(int) { int y; x(y); }
7408 </pre></td></tr>
7411 <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>
7412 <tr><td colspan="4" class="doc" id="hasTypeLoc6"><pre>Matches if the type location of a node matches the inner matcher.
7414 Examples:
7415 int x;
7416 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7417 matches int x
7419 auto x = int(3);
7420 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7421 matches int(3)
7423 struct Foo { Foo(int, int); };
7424 auto x = Foo(1, 2);
7425 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7426 matches Foo(1, 2)
7428 Usable 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;,
7429 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;,
7430 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;,
7431 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7432 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;,
7433 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;,
7434 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;,
7435 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7436 </pre></td></tr>
7439 <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>
7440 <tr><td colspan="4" class="doc" id="callee2"><pre>Matches 1) if the call expression's callee's declaration matches the
7441 given matcher; or 2) if the Obj-C message expression's callee's method
7442 declaration matches the given matcher.
7444 Example matches y.x() (matcher = callExpr(callee(
7445 cxxMethodDecl(hasName("x")))))
7446 class Y { public: void x(); };
7447 void z() { Y y; y.x(); }
7449 Example 2. Matches [I foo] with
7450 objcMessageExpr(callee(objcMethodDecl(hasName("foo"))))
7452 @interface I: NSObject
7453 +(void)foo;
7454 @end
7456 [I foo]
7457 </pre></td></tr>
7460 <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>
7461 <tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches.
7463 Given
7464 class Y { void x() { this-&gt;x(); x(); Y y; y.x(); } };
7465 void f() { f(); }
7466 callExpr(callee(expr()))
7467 matches this-&gt;x(), x(), y.x(), f()
7468 with callee(...)
7469 matching this-&gt;x, x, y.x, f respectively
7471 Note: Callee cannot take the more general internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;
7472 because this introduces ambiguous overloads with calls to Callee taking a
7473 internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, as the matcher hierarchy is purely
7474 implemented in terms of implicit casts.
7475 </pre></td></tr>
7478 <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>
7479 <tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl.
7481 Given
7482 void f(int i);
7483 int y;
7484 f(y);
7485 callExpr(
7486 forEachArgumentWithParam(
7487 declRefExpr(to(varDecl(hasName("y")))),
7488 parmVarDecl(hasType(isInteger()))
7490 matches f(y);
7491 with declRefExpr(...)
7492 matching int y
7493 and parmVarDecl(...)
7494 matching int i
7495 </pre></td></tr>
7498 <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>
7499 <tr><td colspan="4" class="doc" id="forEachArgumentWithParamType0"><pre>Matches all arguments and their respective types for a CallExpr or
7500 CXXConstructExpr. It is very similar to forEachArgumentWithParam but
7501 it works on calls through function pointers as well.
7503 The difference is, that function pointers do not provide access to a
7504 ParmVarDecl, but only the QualType for each argument.
7506 Given
7507 void f(int i);
7508 int y;
7509 f(y);
7510 void (*f_ptr)(int) = f;
7511 f_ptr(y);
7512 callExpr(
7513 forEachArgumentWithParamType(
7514 declRefExpr(to(varDecl(hasName("y")))),
7515 qualType(isInteger()).bind("type)
7517 matches f(y) and f_ptr(y)
7518 with declRefExpr(...)
7519 matching int y
7520 and qualType(...)
7521 matching int
7522 </pre></td></tr>
7525 <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>
7526 <tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call
7527 expression, or an ObjC-message-send expression.
7529 Given
7530 void x(int, int, int) { int y; x(1, y, 42); }
7531 callExpr(hasAnyArgument(declRefExpr()))
7532 matches x(1, y, 42)
7533 with hasAnyArgument(...)
7534 matching y
7536 For ObjectiveC, given
7537 @interface I - (void) f:(int) y; @end
7538 void foo(I *i) { [i f:12]; }
7539 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
7540 matches [i f:12]
7541 </pre></td></tr>
7544 <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>
7545 <tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor
7546 call expression.
7548 Example matches y in x(y)
7549 (matcher = callExpr(hasArgument(0, declRefExpr())))
7550 void x(int) { int y; x(y); }
7551 </pre></td></tr>
7554 <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>
7555 <tr><td colspan="4" class="doc" id="hasDeclaration14"><pre>Matches a node if the declaration associated with that node
7556 matches the given matcher.
7558 The associated declaration is:
7559 - for type nodes, the declaration of the underlying type
7560 - for CallExpr, the declaration of the callee
7561 - for MemberExpr, the declaration of the referenced member
7562 - for CXXConstructExpr, the declaration of the constructor
7563 - for CXXNewExpr, the declaration of the operator new
7564 - for ObjCIvarExpr, the declaration of the ivar
7566 For type nodes, hasDeclaration will generally match the declaration of the
7567 sugared type. Given
7568 class X {};
7569 typedef X Y;
7570 Y y;
7571 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7572 typedefDecl. A common use case is to match the underlying, desugared type.
7573 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7574 varDecl(hasType(hasUnqualifiedDesugaredType(
7575 recordType(hasDeclaration(decl())))))
7576 In this matcher, the decl will match the CXXRecordDecl of class X.
7578 Usable 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;,
7579 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;,
7580 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;,
7581 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;,
7582 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;,
7583 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;,
7584 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
7585 </pre></td></tr>
7588 <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>
7589 <tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range
7590 extension, matches the constant given in the statement.
7592 Given
7593 switch (1) { case 1: case 1+1: case 3 ... 4: ; }
7594 caseStmt(hasCaseConstant(integerLiteral()))
7595 matches "case 1:"
7596 </pre></td></tr>
7599 <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>
7600 <tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression
7601 or opaque value's source expression matches the given matcher.
7603 Example 1: matches "a string"
7604 (matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
7605 class URL { URL(string); };
7606 URL url = "a string";
7608 Example 2: matches 'b' (matcher =
7609 opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
7610 int a = b ?: 1;
7611 </pre></td></tr>
7614 <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>
7615 <tr><td colspan="4" class="doc" id="forEachTemplateArgument0"><pre>Matches classTemplateSpecialization, templateSpecializationType and
7616 functionDecl nodes where the template argument matches the inner matcher.
7617 This matcher may produce multiple matches.
7619 Given
7620 template &lt;typename T, unsigned N, unsigned M&gt;
7621 struct Matrix {};
7623 constexpr unsigned R = 2;
7624 Matrix&lt;int, R * 2, R * 4&gt; M;
7626 template &lt;typename T, typename U&gt;
7627 void f(T&amp;&amp; t, U&amp;&amp; u) {}
7629 bool B = false;
7630 f(R, B);
7631 templateSpecializationType(forEachTemplateArgument(isExpr(expr())))
7632 matches twice, with expr() matching 'R * 2' and 'R * 4'
7633 functionDecl(forEachTemplateArgument(refersToType(builtinType())))
7634 matches the specialization f&lt;unsigned, bool&gt; twice, for 'unsigned'
7635 and 'bool'
7636 </pre></td></tr>
7639 <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>
7640 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and
7641 functionDecl that have at least one TemplateArgument matching the given
7642 InnerMatcher.
7644 Given
7645 template&lt;typename T&gt; class A {};
7646 template&lt;&gt; class A&lt;double&gt; {};
7647 A&lt;int&gt; a;
7649 template&lt;typename T&gt; f() {};
7650 void func() { f&lt;int&gt;(); };
7652 classTemplateSpecializationDecl(hasAnyTemplateArgument(
7653 refersToType(asString("int"))))
7654 matches the specialization A&lt;int&gt;
7656 functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
7657 matches the specialization f&lt;int&gt;
7658 </pre></td></tr>
7661 <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>
7662 <tr><td colspan="4" class="doc" id="hasSpecializedTemplate0"><pre>Matches the specialized template of a specialization declaration.
7664 Given
7665 template&lt;typename T&gt; class A {}; #1
7666 template&lt;&gt; class A&lt;int&gt; {}; #2
7667 classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl()))
7668 matches '#2' with classTemplateDecl() matching the class template
7669 declaration of 'A' at #1.
7670 </pre></td></tr>
7673 <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>
7674 <tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and
7675 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
7677 Given
7678 template&lt;typename T, typename U&gt; class A {};
7679 A&lt;bool, int&gt; b;
7680 A&lt;int, bool&gt; c;
7682 template&lt;typename T&gt; void f() {}
7683 void func() { f&lt;int&gt;(); };
7684 classTemplateSpecializationDecl(hasTemplateArgument(
7685 1, refersToType(asString("int"))))
7686 matches the specialization A&lt;bool, int&gt;
7688 functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
7689 matches the specialization f&lt;int&gt;
7690 </pre></td></tr>
7693 <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>
7694 <tr><td colspan="4" class="doc" id="hasTypeLoc7"><pre>Matches if the type location of a node matches the inner matcher.
7696 Examples:
7697 int x;
7698 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7699 matches int x
7701 auto x = int(3);
7702 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7703 matches int(3)
7705 struct Foo { Foo(int, int); };
7706 auto x = Foo(1, 2);
7707 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7708 matches Foo(1, 2)
7710 Usable 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;,
7711 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;,
7712 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;,
7713 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7714 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;,
7715 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;,
7716 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;,
7717 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7718 </pre></td></tr>
7721 <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>
7722 <tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element
7723 type.
7725 Given
7726 struct A {};
7727 A a[7];
7728 int b[7];
7729 arrayType(hasElementType(builtinType()))
7730 matches "int b[7]"
7732 Usable 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;
7733 </pre></td></tr>
7736 <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>
7737 <tr><td colspan="4" class="doc" id="hasTypeLoc8"><pre>Matches if the type location of a node matches the inner matcher.
7739 Examples:
7740 int x;
7741 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7742 matches int x
7744 auto x = int(3);
7745 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7746 matches int(3)
7748 struct Foo { Foo(int, int); };
7749 auto x = Foo(1, 2);
7750 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7751 matches Foo(1, 2)
7753 Usable 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;,
7754 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;,
7755 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;,
7756 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7757 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;,
7758 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;,
7759 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;,
7760 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7761 </pre></td></tr>
7764 <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>
7765 <tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches
7766 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
7768 Given
7769 { {}; 1+2; }
7770 hasAnySubstatement(compoundStmt())
7771 matches '{ {}; 1+2; }'
7772 with compoundStmt()
7773 matching '{}'
7774 </pre></td></tr>
7777 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CoroutineBodyStmt.html">CoroutineBodyStmt</a>&gt;</td><td class="name" onclick="toggle('hasBody5')"><a name="hasBody5Anchor">hasBody</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
7778 <tr><td colspan="4" class="doc" id="hasBody5"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
7779 definition that has a given body. Note that in case of functions or
7780 coroutines this matcher only matches the definition itself and not the
7781 other declarations of the same function or coroutine.
7783 Given
7784 for (;;) {}
7785 forStmt(hasBody(compoundStmt()))
7786 matches 'for (;;) {}'
7787 with compoundStmt()
7788 matching '{}'
7790 Given
7791 void f();
7792 void f() {}
7793 functionDecl(hasBody(compoundStmt()))
7794 matches 'void f() {}'
7795 with compoundStmt()
7796 matching '{}'
7797 but does not match 'void f();'
7798 </pre></td></tr>
7801 <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>
7802 <tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whoes decayed type matches InnerMatcher
7803 </pre></td></tr>
7806 <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>
7807 <tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node
7808 matches the given matcher.
7810 The associated declaration is:
7811 - for type nodes, the declaration of the underlying type
7812 - for CallExpr, the declaration of the callee
7813 - for MemberExpr, the declaration of the referenced member
7814 - for CXXConstructExpr, the declaration of the constructor
7815 - for CXXNewExpr, the declaration of the operator new
7816 - for ObjCIvarExpr, the declaration of the ivar
7818 For type nodes, hasDeclaration will generally match the declaration of the
7819 sugared type. Given
7820 class X {};
7821 typedef X Y;
7822 Y y;
7823 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7824 typedefDecl. A common use case is to match the underlying, desugared type.
7825 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7826 varDecl(hasType(hasUnqualifiedDesugaredType(
7827 recordType(hasDeclaration(decl())))))
7828 In this matcher, the decl will match the CXXRecordDecl of class X.
7830 Usable 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;,
7831 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;,
7832 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;,
7833 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;,
7834 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;,
7835 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;,
7836 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
7837 </pre></td></tr>
7840 <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>
7841 <tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc0"><pre>Matches template specialization `TypeLoc`s where the n'th
7842 `TemplateArgumentLoc` matches the given `InnerMatcher`.
7844 Given
7845 template&lt;typename T, typename U&gt; class A {};
7846 A&lt;double, int&gt; b;
7847 A&lt;int, double&gt; c;
7848 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
7849 hasTypeLoc(loc(asString("double")))))))
7850 matches `A&lt;double, int&gt; b`, but not `A&lt;int, double&gt; c`.
7851 </pre></td></tr>
7854 <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>
7855 <tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches if a node refers to a declaration through a specific
7856 using shadow declaration.
7858 Examples:
7859 namespace a { int f(); }
7860 using a::f;
7861 int x = f();
7862 declRefExpr(throughUsingDecl(anything()))
7863 matches f
7865 namespace a { class X{}; }
7866 using a::X;
7867 X x;
7868 typeLoc(loc(usingType(throughUsingDecl(anything()))))
7869 matches X
7871 Usable 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;
7872 </pre></td></tr>
7875 <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>
7876 <tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the
7877 specified matcher.
7879 Example matches x in if(x)
7880 (matcher = declRefExpr(to(varDecl(hasName("x")))))
7881 bool x;
7882 if (x) {}
7883 </pre></td></tr>
7886 <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>
7887 <tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement.
7889 Note that this does not work for global declarations because the AST
7890 breaks up multiple-declaration DeclStmt's into multiple single-declaration
7891 DeclStmt's.
7892 Example: Given non-global declarations
7893 int a, b = 0;
7894 int c;
7895 int d = 2, e;
7896 declStmt(containsDeclaration(
7897 0, varDecl(hasInitializer(anything()))))
7898 matches only 'int d = 2, e;', and
7899 declStmt(containsDeclaration(1, varDecl()))
7900 matches 'int a, b = 0' as well as 'int d = 2, e;'
7901 but 'int c;' is not matched.
7902 </pre></td></tr>
7905 <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>
7906 <tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration.
7908 Given
7909 int a, b;
7910 int c;
7911 declStmt(hasSingleDecl(anything()))
7912 matches 'int c;' but not 'int a, b;'.
7913 </pre></td></tr>
7916 <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>
7917 <tr><td colspan="4" class="doc" id="hasTypeLoc9"><pre>Matches if the type location of a node matches the inner matcher.
7919 Examples:
7920 int x;
7921 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7922 matches int x
7924 auto x = int(3);
7925 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7926 matches int(3)
7928 struct Foo { Foo(int, int); };
7929 auto x = Foo(1, 2);
7930 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7931 matches Foo(1, 2)
7933 Usable 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;,
7934 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;,
7935 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;,
7936 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7937 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;,
7938 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;,
7939 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;,
7940 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7941 </pre></td></tr>
7944 <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>
7945 <tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a
7946 Decl, matches InnerMatcher.
7948 Given
7949 namespace N {
7950 namespace M {
7951 class D {};
7955 cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
7956 declaration of class D.
7957 </pre></td></tr>
7960 <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>
7961 <tr><td colspan="4" class="doc" id="hasUnderlyingType0"><pre>Matches DecltypeType or UsingType nodes to find the underlying type.
7963 Given
7964 decltype(1) a = 1;
7965 decltype(2.0) b = 2.0;
7966 decltypeType(hasUnderlyingType(isInteger()))
7967 matches the type of "a"
7969 Usable 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;
7970 </pre></td></tr>
7973 <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>
7974 <tr><td colspan="4" class="doc" id="hasAnyBinding0"><pre>Matches any binding of a DecompositionDecl.
7976 For example, in:
7977 void foo()
7979 int arr[3];
7980 auto &amp;[f, s, t] = arr;
7982 f = 42;
7984 The matcher:
7985 decompositionDecl(hasAnyBinding(bindingDecl(hasName("f").bind("fBinding"))))
7986 matches the decomposition decl with 'f' bound to "fBinding".
7987 </pre></td></tr>
7990 <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>
7991 <tr><td colspan="4" class="doc" id="hasBinding0"><pre>Matches the Nth binding of a DecompositionDecl.
7993 For example, in:
7994 void foo()
7996 int arr[3];
7997 auto &amp;[f, s, t] = arr;
7999 f = 42;
8001 The matcher:
8002 decompositionDecl(hasBinding(0,
8003 bindingDecl(hasName("f").bind("fBinding"))))
8004 matches the decomposition decl with 'f' bound to "fBinding".
8005 </pre></td></tr>
8008 <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>
8009 <tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
8010 definition that has a given body. Note that in case of functions or
8011 coroutines this matcher only matches the definition itself and not the
8012 other declarations of the same function or coroutine.
8014 Given
8015 for (;;) {}
8016 forStmt(hasBody(compoundStmt()))
8017 matches 'for (;;) {}'
8018 with compoundStmt()
8019 matching '{}'
8021 Given
8022 void f();
8023 void f() {}
8024 functionDecl(hasBody(compoundStmt()))
8025 matches 'void f() {}'
8026 with compoundStmt()
8027 matching '{}'
8028 but does not match 'void f();'
8029 </pre></td></tr>
8032 <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>
8033 <tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop,
8034 switch statement or conditional operator.
8036 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8037 if (true) {}
8038 </pre></td></tr>
8041 <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>
8042 <tr><td colspan="4" class="doc" id="hasNamedTypeLoc0"><pre>Matches elaborated `TypeLoc`s that have a named `TypeLoc` matching
8043 `InnerMatcher`.
8045 Given
8046 template &lt;typename T&gt;
8047 class C {};
8048 class C&lt;int&gt; c;
8050 class D {};
8051 class D d;
8052 elaboratedTypeLoc(hasNamedTypeLoc(templateSpecializationTypeLoc()));
8053 matches the `TypeLoc` of the variable declaration of `c`, but not `d`.
8054 </pre></td></tr>
8057 <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>
8058 <tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
8059 matches InnerMatcher if the qualifier exists.
8061 Given
8062 namespace N {
8063 namespace M {
8064 class D {};
8067 N::M::D d;
8069 elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N"))))
8070 matches the type of the variable declaration of d.
8071 </pre></td></tr>
8074 <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>
8075 <tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher.
8077 Given
8078 namespace N {
8079 namespace M {
8080 class D {};
8083 N::M::D d;
8085 elaboratedType(namesType(recordType(
8086 hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable
8087 declaration of d.
8088 </pre></td></tr>
8091 <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>
8092 <tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node
8093 matches the given matcher.
8095 The associated declaration is:
8096 - for type nodes, the declaration of the underlying type
8097 - for CallExpr, the declaration of the callee
8098 - for MemberExpr, the declaration of the referenced member
8099 - for CXXConstructExpr, the declaration of the constructor
8100 - for CXXNewExpr, the declaration of the operator new
8101 - for ObjCIvarExpr, the declaration of the ivar
8103 For type nodes, hasDeclaration will generally match the declaration of the
8104 sugared type. Given
8105 class X {};
8106 typedef X Y;
8107 Y y;
8108 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8109 typedefDecl. A common use case is to match the underlying, desugared type.
8110 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8111 varDecl(hasType(hasUnqualifiedDesugaredType(
8112 recordType(hasDeclaration(decl())))))
8113 In this matcher, the decl will match the CXXRecordDecl of class X.
8115 Usable 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;,
8116 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;,
8117 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;,
8118 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;,
8119 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;,
8120 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;,
8121 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
8122 </pre></td></tr>
8125 <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>
8126 <tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher.
8128 (Note: Clang's AST refers to other conversions as "casts" too, and calls
8129 actual casts "explicit" casts.)
8130 </pre></td></tr>
8133 <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>
8134 <tr><td colspan="4" class="doc" id="hasTypeLoc10"><pre>Matches if the type location of a node matches the inner matcher.
8136 Examples:
8137 int x;
8138 declaratorDecl(hasTypeLoc(loc(asString("int"))))
8139 matches int x
8141 auto x = int(3);
8142 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
8143 matches int(3)
8145 struct Foo { Foo(int, int); };
8146 auto x = Foo(1, 2);
8147 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
8148 matches Foo(1, 2)
8150 Usable 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;,
8151 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;,
8152 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;,
8153 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
8154 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;,
8155 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;,
8156 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;,
8157 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
8158 </pre></td></tr>
8161 <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>
8162 <tr><td colspan="4" class="doc" id="hasType5"><pre>Overloaded to match the declaration of the expression's or value
8163 declaration's type.
8165 In case of a value declaration (for example a variable declaration),
8166 this resolves one layer of indirection. For example, in the value
8167 declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
8168 X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
8169 declaration of x.
8171 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
8172 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
8173 and friend class X (matcher = friendDecl(hasType("X"))
8174 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8175 cxxRecordDecl(hasName("X"))))
8176 class X {};
8177 void y(X &amp;x) { x; X z; }
8178 class Y { friend class X; };
8179 class Z : public virtual X {};
8181 Example matches class Derived
8182 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
8183 class Base {};
8184 class Derived : Base {};
8186 Usable 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;,
8187 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
8188 </pre></td></tr>
8191 <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>
8192 <tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type
8193 matcher.
8195 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
8196 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
8197 and U (matcher = typedefDecl(hasType(asString("int")))
8198 and friend class X (matcher = friendDecl(hasType("X"))
8199 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8200 asString("class X")))
8201 class X {};
8202 void y(X &amp;x) { x; X z; }
8203 typedef int U;
8204 class Y { friend class X; };
8205 class Z : public virtual X {};
8206 </pre></td></tr>
8209 <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>
8210 <tr><td colspan="4" class="doc" id="ignoringElidableConstructorCall0"><pre>Matches expressions that match InnerMatcher that are possibly wrapped in an
8211 elidable constructor and other corresponding bookkeeping nodes.
8213 In C++17, elidable copy constructors are no longer being generated in the
8214 AST as it is not permitted by the standard. They are, however, part of the
8215 AST in C++14 and earlier. So, a matcher must abstract over these differences
8216 to work in all language modes. This matcher skips elidable constructor-call
8217 AST nodes, `ExprWithCleanups` nodes wrapping elidable constructor-calls and
8218 various implicit nodes inside the constructor calls, all of which will not
8219 appear in the C++17 AST.
8221 Given
8223 struct H {};
8224 H G();
8225 void f() {
8226 H D = G();
8229 ``varDecl(hasInitializer(ignoringElidableConstructorCall(callExpr())))``
8230 matches ``H D = G()`` in C++11 through C++17 (and beyond).
8231 </pre></td></tr>
8234 <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>
8235 <tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts
8236 are stripped off.
8238 Parentheses and explicit casts are not discarded.
8239 Given
8240 int arr[5];
8241 int a = 0;
8242 char b = 0;
8243 const int c = a;
8244 int *d = arr;
8245 long e = (long) 0l;
8246 The matchers
8247 varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
8248 varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
8249 would match the declarations for a, b, c, and d, but not e.
8250 While
8251 varDecl(hasInitializer(integerLiteral()))
8252 varDecl(hasInitializer(declRefExpr()))
8253 only match the declarations for a.
8254 </pre></td></tr>
8257 <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>
8258 <tr><td colspan="4" class="doc" id="ignoringImplicit0"><pre>Matches expressions that match InnerMatcher after any implicit AST
8259 nodes are stripped off.
8261 Parentheses and explicit casts are not discarded.
8262 Given
8263 class C {};
8264 C a = C();
8265 C b;
8266 C c = b;
8267 The matchers
8268 varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr())))
8269 would match the declarations for a, b, and c.
8270 While
8271 varDecl(hasInitializer(cxxConstructExpr()))
8272 only match the declarations for b and c.
8273 </pre></td></tr>
8276 <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>
8277 <tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and
8278 casts are stripped off.
8280 Implicit and non-C Style casts are also discarded.
8281 Given
8282 int a = 0;
8283 char b = (0);
8284 void* c = reinterpret_cast&lt;char*&gt;(0);
8285 char d = char(0);
8286 The matcher
8287 varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
8288 would match the declarations for a, b, c, and d.
8289 while
8290 varDecl(hasInitializer(integerLiteral()))
8291 only match the declaration for a.
8292 </pre></td></tr>
8295 <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>
8296 <tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and
8297 parentheses are stripped off.
8299 Explicit casts are not discarded.
8300 Given
8301 int arr[5];
8302 int a = 0;
8303 char b = (0);
8304 const int c = a;
8305 int *d = (arr);
8306 long e = ((long) 0l);
8307 The matchers
8308 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
8309 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
8310 would match the declarations for a, b, c, and d, but not e.
8311 while
8312 varDecl(hasInitializer(integerLiteral()))
8313 varDecl(hasInitializer(declRefExpr()))
8314 would only match the declaration for a.
8315 </pre></td></tr>
8318 <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>
8319 <tr><td colspan="4" class="doc" id="ignoringParens1"><pre>Overload ignoringParens for Expr.
8321 Given
8322 const char* str = ("my-string");
8323 The matcher
8324 implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral())))
8325 would match the implicit cast resulting from the assignment.
8326 </pre></td></tr>
8329 <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>
8330 <tr><td colspan="4" class="doc" id="hasInClassInitializer0"><pre>Matches non-static data members that have an in-class initializer.
8332 Given
8333 class C {
8334 int a = 2;
8335 int b = 3;
8336 int c;
8338 fieldDecl(hasInClassInitializer(integerLiteral(equals(2))))
8339 matches 'int a;' but not 'int b;'.
8340 fieldDecl(hasInClassInitializer(anything()))
8341 matches 'int a;' and 'int b;' but not 'int c;'.
8342 </pre></td></tr>
8345 <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>
8346 <tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
8347 definition that has a given body. Note that in case of functions or
8348 coroutines this matcher only matches the definition itself and not the
8349 other declarations of the same function or coroutine.
8351 Given
8352 for (;;) {}
8353 forStmt(hasBody(compoundStmt()))
8354 matches 'for (;;) {}'
8355 with compoundStmt()
8356 matching '{}'
8358 Given
8359 void f();
8360 void f() {}
8361 functionDecl(hasBody(compoundStmt()))
8362 matches 'void f() {}'
8363 with compoundStmt()
8364 matching '{}'
8365 but does not match 'void f();'
8366 </pre></td></tr>
8369 <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>
8370 <tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop,
8371 switch statement or conditional operator.
8373 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8374 if (true) {}
8375 </pre></td></tr>
8378 <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>
8379 <tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop.
8381 Example:
8382 forStmt(hasIncrement(unaryOperator(hasOperatorName("++"))))
8383 matches '++x' in
8384 for (x; x &lt; N; ++x) { }
8385 </pre></td></tr>
8388 <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>
8389 <tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop.
8391 Example:
8392 forStmt(hasLoopInit(declStmt()))
8393 matches 'int x = 0' in
8394 for (int x = 0; x &lt; N; ++x) { }
8395 </pre></td></tr>
8398 <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>
8399 <tr><td colspan="4" class="doc" id="hasType6"><pre>Overloaded to match the declaration of the expression's or value
8400 declaration's type.
8402 In case of a value declaration (for example a variable declaration),
8403 this resolves one layer of indirection. For example, in the value
8404 declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
8405 X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
8406 declaration of x.
8408 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
8409 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
8410 and friend class X (matcher = friendDecl(hasType("X"))
8411 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8412 cxxRecordDecl(hasName("X"))))
8413 class X {};
8414 void y(X &amp;x) { x; X z; }
8415 class Y { friend class X; };
8416 class Z : public virtual X {};
8418 Example matches class Derived
8419 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
8420 class Base {};
8421 class Derived : Base {};
8423 Usable 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;,
8424 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
8425 </pre></td></tr>
8428 <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>
8429 <tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type
8430 matcher.
8432 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
8433 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
8434 and U (matcher = typedefDecl(hasType(asString("int")))
8435 and friend class X (matcher = friendDecl(hasType("X"))
8436 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8437 asString("class X")))
8438 class X {};
8439 void y(X &amp;x) { x; X z; }
8440 typedef int U;
8441 class Y { friend class X; };
8442 class Z : public virtual X {};
8443 </pre></td></tr>
8446 <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>
8447 <tr><td colspan="4" class="doc" id="forEachTemplateArgument2"><pre>Matches classTemplateSpecialization, templateSpecializationType and
8448 functionDecl nodes where the template argument matches the inner matcher.
8449 This matcher may produce multiple matches.
8451 Given
8452 template &lt;typename T, unsigned N, unsigned M&gt;
8453 struct Matrix {};
8455 constexpr unsigned R = 2;
8456 Matrix&lt;int, R * 2, R * 4&gt; M;
8458 template &lt;typename T, typename U&gt;
8459 void f(T&amp;&amp; t, U&amp;&amp; u) {}
8461 bool B = false;
8462 f(R, B);
8463 templateSpecializationType(forEachTemplateArgument(isExpr(expr())))
8464 matches twice, with expr() matching 'R * 2' and 'R * 4'
8465 functionDecl(forEachTemplateArgument(refersToType(builtinType())))
8466 matches the specialization f&lt;unsigned, bool&gt; twice, for 'unsigned'
8467 and 'bool'
8468 </pre></td></tr>
8471 <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>
8472 <tr><td colspan="4" class="doc" id="hasAnyBody0"><pre>Matches a function declaration that has a given body present in the AST.
8473 Note that this matcher matches all the declarations of a function whose
8474 body is present in the AST.
8476 Given
8477 void f();
8478 void f() {}
8479 void g();
8480 functionDecl(hasAnyBody(compoundStmt()))
8481 matches both 'void f();'
8482 and 'void f() {}'
8483 with compoundStmt()
8484 matching '{}'
8485 but does not match 'void g();'
8486 </pre></td></tr>
8489 <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>
8490 <tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function or an ObjC method declaration or a
8491 block.
8493 Does not match the 'this' parameter of a method.
8495 Given
8496 class X { void f(int x, int y, int z) {} };
8497 cxxMethodDecl(hasAnyParameter(hasName("y")))
8498 matches f(int x, int y, int z) {}
8499 with hasAnyParameter(...)
8500 matching int y
8502 For ObjectiveC, given
8503 @interface I - (void) f:(int) y; @end
8505 the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
8506 matches the declaration of method f with hasParameter
8507 matching y.
8509 For blocks, given
8510 b = ^(int y) { printf("%d", y) };
8512 the matcher blockDecl(hasAnyParameter(hasName("y")))
8513 matches the declaration of the block b with hasParameter
8514 matching y.
8515 </pre></td></tr>
8518 <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>
8519 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and
8520 functionDecl that have at least one TemplateArgument matching the given
8521 InnerMatcher.
8523 Given
8524 template&lt;typename T&gt; class A {};
8525 template&lt;&gt; class A&lt;double&gt; {};
8526 A&lt;int&gt; a;
8528 template&lt;typename T&gt; f() {};
8529 void func() { f&lt;int&gt;(); };
8531 classTemplateSpecializationDecl(hasAnyTemplateArgument(
8532 refersToType(asString("int"))))
8533 matches the specialization A&lt;int&gt;
8535 functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
8536 matches the specialization f&lt;int&gt;
8537 </pre></td></tr>
8540 <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>
8541 <tr><td colspan="4" class="doc" id="hasBody4"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
8542 definition that has a given body. Note that in case of functions or
8543 coroutines this matcher only matches the definition itself and not the
8544 other declarations of the same function or coroutine.
8546 Given
8547 for (;;) {}
8548 forStmt(hasBody(compoundStmt()))
8549 matches 'for (;;) {}'
8550 with compoundStmt()
8551 matching '{}'
8553 Given
8554 void f();
8555 void f() {}
8556 functionDecl(hasBody(compoundStmt()))
8557 matches 'void f() {}'
8558 with compoundStmt()
8559 matching '{}'
8560 but does not match 'void f();'
8561 </pre></td></tr>
8564 <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>
8565 <tr><td colspan="4" class="doc" id="hasExplicitSpecifier0"><pre>Matches the expression in an explicit specifier if present in the given
8566 declaration.
8568 Given
8569 template&lt;bool b&gt;
8570 struct S {
8571 S(int); // #1
8572 explicit S(double); // #2
8573 operator int(); // #3
8574 explicit operator bool(); // #4
8575 explicit(false) S(bool) // # 7
8576 explicit(true) S(char) // # 8
8577 explicit(b) S(S) // # 9
8579 S(int) -&gt; S&lt;true&gt; // #5
8580 explicit S(double) -&gt; S&lt;false&gt; // #6
8581 cxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8 and #9, but not #1 or #2.
8582 cxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or #4.
8583 cxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not match #5 or #6.
8584 </pre></td></tr>
8587 <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>
8588 <tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function or an ObjC method
8589 declaration or a block.
8591 Given
8592 class X { void f(int x) {} };
8593 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
8594 matches f(int x) {}
8595 with hasParameter(...)
8596 matching int x
8598 For ObjectiveC, given
8599 @interface I - (void) f:(int) y; @end
8601 the matcher objcMethodDecl(hasParameter(0, hasName("y")))
8602 matches the declaration of method f with hasParameter
8603 matching y.
8604 </pre></td></tr>
8607 <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>
8608 <tr><td colspan="4" class="doc" id="hasReturnTypeLoc0"><pre>Matches a function declared with the specified return `TypeLoc`.
8610 Given
8611 int f() { return 5; }
8612 void g() {}
8613 functionDecl(hasReturnTypeLoc(loc(asString("int"))))
8614 matches the declaration of `f`, but not `g`.
8615 </pre></td></tr>
8618 <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>
8619 <tr><td colspan="4" class="doc" id="hasTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and
8620 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
8622 Given
8623 template&lt;typename T, typename U&gt; class A {};
8624 A&lt;bool, int&gt; b;
8625 A&lt;int, bool&gt; c;
8627 template&lt;typename T&gt; void f() {}
8628 void func() { f&lt;int&gt;(); };
8629 classTemplateSpecializationDecl(hasTemplateArgument(
8630 1, refersToType(asString("int"))))
8631 matches the specialization A&lt;bool, int&gt;
8633 functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
8634 matches the specialization f&lt;int&gt;
8635 </pre></td></tr>
8638 <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>
8639 <tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration.
8641 Given:
8642 class X { int f() { return 1; } };
8643 cxxMethodDecl(returns(asString("int")))
8644 matches int f() { return 1; }
8645 </pre></td></tr>
8648 <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>
8649 <tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop,
8650 switch statement or conditional operator.
8652 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8653 if (true) {}
8654 </pre></td></tr>
8657 <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>
8658 <tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement.
8660 Given
8661 if (A* a = GetAPointer()) {}
8662 hasConditionVariableStatement(...)
8663 matches 'A* a = GetAPointer()'.
8664 </pre></td></tr>
8667 <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>
8668 <tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement.
8670 Examples matches the if statement
8671 (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true)))))
8672 if (false) false; else true;
8673 </pre></td></tr>
8676 <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>
8677 <tr><td colspan="4" class="doc" id="hasInitStatement0"><pre>Matches selection statements with initializer.
8679 Given:
8680 void foo() {
8681 if (int i = foobar(); i &gt; 0) {}
8682 switch (int i = foobar(); i) {}
8683 for (auto&amp; a = get_range(); auto&amp; x : a) {}
8685 void bar() {
8686 if (foobar() &gt; 0) {}
8687 switch (foobar()) {}
8688 for (auto&amp; x : get_range()) {}
8690 ifStmt(hasInitStatement(anything()))
8691 matches the if statement in foo but not in bar.
8692 switchStmt(hasInitStatement(anything()))
8693 matches the switch statement in foo but not in bar.
8694 cxxForRangeStmt(hasInitStatement(anything()))
8695 matches the range for statement in foo but not in bar.
8696 </pre></td></tr>
8699 <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>
8700 <tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement.
8702 Examples matches the if statement
8703 (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true)))))
8704 if (false) true; else false;
8705 </pre></td></tr>
8708 <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>
8709 <tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given
8710 matcher.
8711 </pre></td></tr>
8714 <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>
8715 <tr><td colspan="4" class="doc" id="hasInit0"><pre>Matches the n'th item of an initializer list expression.
8717 Example matches y.
8718 (matcher = initListExpr(hasInit(0, expr())))
8719 int x{y}.
8720 </pre></td></tr>
8723 <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>
8724 <tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions
8725 (if expression have it).
8726 </pre></td></tr>
8729 <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>
8730 <tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node
8731 matches the given matcher.
8733 The associated declaration is:
8734 - for type nodes, the declaration of the underlying type
8735 - for CallExpr, the declaration of the callee
8736 - for MemberExpr, the declaration of the referenced member
8737 - for CXXConstructExpr, the declaration of the constructor
8738 - for CXXNewExpr, the declaration of the operator new
8739 - for ObjCIvarExpr, the declaration of the ivar
8741 For type nodes, hasDeclaration will generally match the declaration of the
8742 sugared type. Given
8743 class X {};
8744 typedef X Y;
8745 Y y;
8746 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8747 typedefDecl. A common use case is to match the underlying, desugared type.
8748 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8749 varDecl(hasType(hasUnqualifiedDesugaredType(
8750 recordType(hasDeclaration(decl())))))
8751 In this matcher, the decl will match the CXXRecordDecl of class X.
8753 Usable 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;,
8754 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;,
8755 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;,
8756 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;,
8757 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;,
8758 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;,
8759 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
8760 </pre></td></tr>
8763 <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>
8764 <tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node
8765 matches the given matcher.
8767 The associated declaration is:
8768 - for type nodes, the declaration of the underlying type
8769 - for CallExpr, the declaration of the callee
8770 - for MemberExpr, the declaration of the referenced member
8771 - for CXXConstructExpr, the declaration of the constructor
8772 - for CXXNewExpr, the declaration of the operator new
8773 - for ObjCIvarExpr, the declaration of the ivar
8775 For type nodes, hasDeclaration will generally match the declaration of the
8776 sugared type. Given
8777 class X {};
8778 typedef X Y;
8779 Y y;
8780 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8781 typedefDecl. A common use case is to match the underlying, desugared type.
8782 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8783 varDecl(hasType(hasUnqualifiedDesugaredType(
8784 recordType(hasDeclaration(decl())))))
8785 In this matcher, the decl will match the CXXRecordDecl of class X.
8787 Usable 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;,
8788 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;,
8789 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;,
8790 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;,
8791 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;,
8792 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;,
8793 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
8794 </pre></td></tr>
8797 <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>
8798 <tr><td colspan="4" class="doc" id="capturesVar0"><pre>Matches a `LambdaCapture` that refers to the specified `VarDecl`. The
8799 `VarDecl` can be a separate variable that is captured by value or
8800 reference, or a synthesized variable if the capture has an initializer.
8802 Given
8803 void foo() {
8804 int x;
8805 auto f = [x](){};
8806 auto g = [x = 1](){};
8808 In the matcher
8809 lambdaExpr(hasAnyCapture(lambdaCapture(capturesVar(hasName("x")))),
8810 capturesVar(hasName("x")) matches `x` and `x = 1`.
8811 </pre></td></tr>
8814 <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>
8815 <tr><td colspan="4" class="doc" id="forEachLambdaCapture0"><pre>Matches each lambda capture in a lambda expression.
8817 Given
8818 int main() {
8819 int x, y;
8820 float z;
8821 auto f = [=]() { return x + y + z; };
8823 lambdaExpr(forEachLambdaCapture(
8824 lambdaCapture(capturesVar(varDecl(hasType(isInteger()))))))
8825 will trigger two matches, binding for 'x' and 'y' respectively.
8826 </pre></td></tr>
8829 <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>
8830 <tr><td colspan="4" class="doc" id="hasAnyCapture0"><pre>Matches any capture in a lambda expression.
8832 Given
8833 void foo() {
8834 int t = 5;
8835 auto f = [=](){ return t; };
8837 lambdaExpr(hasAnyCapture(lambdaCapture())) and
8838 lambdaExpr(hasAnyCapture(lambdaCapture(refersToVarDecl(hasName("t")))))
8839 both match `[=](){ return t; }`.
8840 </pre></td></tr>
8843 <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>
8844 <tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node
8845 matches the given matcher.
8847 The associated declaration is:
8848 - for type nodes, the declaration of the underlying type
8849 - for CallExpr, the declaration of the callee
8850 - for MemberExpr, the declaration of the referenced member
8851 - for CXXConstructExpr, the declaration of the constructor
8852 - for CXXNewExpr, the declaration of the operator new
8853 - for ObjCIvarExpr, the declaration of the ivar
8855 For type nodes, hasDeclaration will generally match the declaration of the
8856 sugared type. Given
8857 class X {};
8858 typedef X Y;
8859 Y y;
8860 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8861 typedefDecl. A common use case is to match the underlying, desugared type.
8862 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8863 varDecl(hasType(hasUnqualifiedDesugaredType(
8864 recordType(hasDeclaration(decl())))))
8865 In this matcher, the decl will match the CXXRecordDecl of class X.
8867 Usable 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;,
8868 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;,
8869 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;,
8870 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;,
8871 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;,
8872 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;,
8873 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
8874 </pre></td></tr>
8877 <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>
8878 <tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is matched by a
8879 given matcher. Implicit object expressions are included; that is, it matches
8880 use of implicit `this`.
8882 Given
8883 struct X {
8884 int m;
8885 int f(X x) { x.m; return m; }
8887 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))
8888 matches `x.m`, but not `m`; however,
8889 memberExpr(hasObjectExpression(hasType(pointsTo(
8890 cxxRecordDecl(hasName("X"))))))
8891 matches `m` (aka. `this-&gt;m`), but not `x.m`.
8892 </pre></td></tr>
8895 <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>
8896 <tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a
8897 given matcher.
8899 Given
8900 struct { int first, second; } first, second;
8901 int i(second.first);
8902 int j(first.second);
8903 memberExpr(member(hasName("first")))
8904 matches second.first
8905 but not first.second (because the member name there is "second").
8906 </pre></td></tr>
8909 <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>
8910 <tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the
8911 pointee matches a given matcher.
8913 Given
8914 int *a;
8915 int const *b;
8916 float const *f;
8917 pointerType(pointee(isConstQualified(), isInteger()))
8918 matches "int const *b"
8920 Usable 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;,
8921 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;
8922 </pre></td></tr>
8925 <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>
8926 <tr><td colspan="4" class="doc" id="hasUnderlyingDecl0"><pre>Matches a NamedDecl whose underlying declaration matches the given
8927 matcher.
8929 Given
8930 namespace N { template&lt;class T&gt; void f(T t); }
8931 template &lt;class T&gt; void g() { using N::f; f(T()); }
8932 unresolvedLookupExpr(hasAnyDeclaration(
8933 namedDecl(hasUnderlyingDecl(hasName("::N::f")))))
8934 matches the use of f in g() .
8935 </pre></td></tr>
8938 <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>
8939 <tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc.
8941 Given
8942 struct A { struct B { struct C {}; }; };
8943 A::B::C c;
8944 nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A")))))
8945 matches "A::"
8946 </pre></td></tr>
8949 <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>
8950 <tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner
8951 NestedNameSpecifier-matcher matches.
8952 </pre></td></tr>
8955 <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>
8956 <tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the
8957 given TypeLoc.
8959 Given
8960 struct A { struct B { struct C {}; }; };
8961 A::B::C c;
8962 nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
8963 hasDeclaration(cxxRecordDecl(hasName("A")))))))
8964 matches "A::"
8965 </pre></td></tr>
8968 <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>
8969 <tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier.
8971 Given
8972 struct A { struct B { struct C {}; }; };
8973 A::B::C c;
8974 nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and
8975 matches "A::"
8976 </pre></td></tr>
8979 <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>
8980 <tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the
8981 given namespace matcher.
8983 Given
8984 namespace ns { struct A {}; }
8985 ns::A a;
8986 nestedNameSpecifier(specifiesNamespace(hasName("ns")))
8987 matches "ns::"
8988 </pre></td></tr>
8991 <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>
8992 <tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the
8993 given QualType matcher without qualifiers.
8995 Given
8996 struct A { struct B { struct C {}; }; };
8997 A::B::C c;
8998 nestedNameSpecifier(specifiesType(
8999 hasDeclaration(cxxRecordDecl(hasName("A")))
9001 matches "A::"
9002 </pre></td></tr>
9005 <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>
9006 <tr><td colspan="4" class="doc" id="hasAnyClause0"><pre>Matches any clause in an OpenMP directive.
9008 Given
9010 #pragma omp parallel
9011 #pragma omp parallel default(none)
9013 ``ompExecutableDirective(hasAnyClause(anything()))`` matches
9014 ``omp parallel default(none)``.
9015 </pre></td></tr>
9018 <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>
9019 <tr><td colspan="4" class="doc" id="hasStructuredBlock0"><pre>Matches the structured-block of the OpenMP executable directive
9021 Prerequisite: the executable directive must not be standalone directive.
9022 If it is, it will never match.
9024 Given
9026 #pragma omp parallel
9028 #pragma omp parallel
9031 ``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;``
9032 </pre></td></tr>
9035 <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>
9036 <tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Matches C++ classes that are directly or indirectly derived from a class
9037 matching Base, or Objective-C classes that directly or indirectly
9038 subclass a class matching Base.
9040 Note that a class is not considered to be derived from itself.
9042 Example matches Y, Z, C (Base == hasName("X"))
9043 class X;
9044 class Y : public X {}; // directly derived
9045 class Z : public Y {}; // indirectly derived
9046 typedef X A;
9047 typedef A B;
9048 class C : public B {}; // derived from a typedef of X
9050 In the following example, Bar matches isDerivedFrom(hasName("X")):
9051 class Foo;
9052 typedef Foo X;
9053 class Bar : public Foo {}; // derived from a type that X is a typedef of
9055 In the following example, Bar matches isDerivedFrom(hasName("NSObject"))
9056 @interface NSObject @end
9057 @interface Bar : NSObject @end
9059 Usable 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;
9060 </pre></td></tr>
9063 <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>
9064 <tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom1"><pre>Matches C++ or Objective-C classes that are directly derived from a class
9065 matching Base.
9067 Note that a class is not considered to be derived from itself.
9069 Example matches Y, C (Base == hasName("X"))
9070 class X;
9071 class Y : public X {}; // directly derived
9072 class Z : public Y {}; // indirectly derived
9073 typedef X A;
9074 typedef A B;
9075 class C : public B {}; // derived from a typedef of X
9077 In the following example, Bar matches isDerivedFrom(hasName("X")):
9078 class Foo;
9079 typedef Foo X;
9080 class Bar : public Foo {}; // derived from a type that X is a typedef of
9081 </pre></td></tr>
9084 <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>
9085 <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Similar to isDerivedFrom(), but also matches classes that directly
9086 match Base.
9087 </pre></td></tr>
9090 <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>
9091 <tr><td colspan="4" class="doc" id="callee1"><pre>Matches 1) if the call expression's callee's declaration matches the
9092 given matcher; or 2) if the Obj-C message expression's callee's method
9093 declaration matches the given matcher.
9095 Example matches y.x() (matcher = callExpr(callee(
9096 cxxMethodDecl(hasName("x")))))
9097 class Y { public: void x(); };
9098 void z() { Y y; y.x(); }
9100 Example 2. Matches [I foo] with
9101 objcMessageExpr(callee(objcMethodDecl(hasName("foo"))))
9103 @interface I: NSObject
9104 +(void)foo;
9105 @end
9107 [I foo]
9108 </pre></td></tr>
9111 <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>
9112 <tr><td colspan="4" class="doc" id="hasAnyArgument3"><pre>Matches any argument of a call expression or a constructor call
9113 expression, or an ObjC-message-send expression.
9115 Given
9116 void x(int, int, int) { int y; x(1, y, 42); }
9117 callExpr(hasAnyArgument(declRefExpr()))
9118 matches x(1, y, 42)
9119 with hasAnyArgument(...)
9120 matching y
9122 For ObjectiveC, given
9123 @interface I - (void) f:(int) y; @end
9124 void foo(I *i) { [i f:12]; }
9125 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
9126 matches [i f:12]
9127 </pre></td></tr>
9130 <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>
9131 <tr><td colspan="4" class="doc" id="hasArgument3"><pre>Matches the n'th argument of a call expression or a constructor
9132 call expression.
9134 Example matches y in x(y)
9135 (matcher = callExpr(hasArgument(0, declRefExpr())))
9136 void x(int) { int y; x(y); }
9137 </pre></td></tr>
9140 <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>
9141 <tr><td colspan="4" class="doc" id="hasReceiver0"><pre>Matches if the Objective-C message is sent to an instance,
9142 and the inner matcher matches on that instance.
9144 For example the method call in
9145 NSString *x = @"hello";
9146 [x containsString:@"h"];
9147 is matched by
9148 objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x"))))))
9149 </pre></td></tr>
9152 <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>
9153 <tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression.
9155 Example
9156 matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *")));
9157 matches the [webView ...] message invocation.
9158 NSString *webViewJavaScript = ...
9159 UIWebView *webView = ...
9160 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript];
9161 </pre></td></tr>
9164 <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>
9165 <tr><td colspan="4" class="doc" id="hasAnyParameter1"><pre>Matches any parameter of a function or an ObjC method declaration or a
9166 block.
9168 Does not match the 'this' parameter of a method.
9170 Given
9171 class X { void f(int x, int y, int z) {} };
9172 cxxMethodDecl(hasAnyParameter(hasName("y")))
9173 matches f(int x, int y, int z) {}
9174 with hasAnyParameter(...)
9175 matching int y
9177 For ObjectiveC, given
9178 @interface I - (void) f:(int) y; @end
9180 the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
9181 matches the declaration of method f with hasParameter
9182 matching y.
9184 For blocks, given
9185 b = ^(int y) { printf("%d", y) };
9187 the matcher blockDecl(hasAnyParameter(hasName("y")))
9188 matches the declaration of the block b with hasParameter
9189 matching y.
9190 </pre></td></tr>
9193 <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>
9194 <tr><td colspan="4" class="doc" id="hasParameter1"><pre>Matches the n'th parameter of a function or an ObjC method
9195 declaration or a block.
9197 Given
9198 class X { void f(int x) {} };
9199 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
9200 matches f(int x) {}
9201 with hasParameter(...)
9202 matching int x
9204 For ObjectiveC, given
9205 @interface I - (void) f:(int) y; @end
9207 the matcher objcMethodDecl(hasParameter(0, hasName("y")))
9208 matches the declaration of method f with hasParameter
9209 matching y.
9210 </pre></td></tr>
9213 <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>
9214 <tr><td colspan="4" class="doc" id="hasTypeLoc11"><pre>Matches if the type location of a node matches the inner matcher.
9216 Examples:
9217 int x;
9218 declaratorDecl(hasTypeLoc(loc(asString("int"))))
9219 matches int x
9221 auto x = int(3);
9222 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
9223 matches int(3)
9225 struct Foo { Foo(int, int); };
9226 auto x = Foo(1, 2);
9227 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
9228 matches Foo(1, 2)
9230 Usable 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;,
9231 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;,
9232 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;,
9233 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
9234 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;,
9235 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;,
9236 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;,
9237 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
9238 </pre></td></tr>
9241 <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>
9242 <tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre>Matches if the cast's source expression
9243 or opaque value's source expression matches the given matcher.
9245 Example 1: matches "a string"
9246 (matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
9247 class URL { URL(string); };
9248 URL url = "a string";
9250 Example 2: matches 'b' (matcher =
9251 opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
9252 int a = b ?: 1;
9253 </pre></td></tr>
9256 <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>
9257 <tr><td colspan="4" class="doc" id="hasAnyDeclaration0"><pre>Matches an OverloadExpr if any of the declarations in the set of
9258 overloads matches the given matcher.
9260 Given
9261 template &lt;typename T&gt; void foo(T);
9262 template &lt;typename T&gt; void bar(T);
9263 template &lt;typename T&gt; void baz(T t) {
9264 foo(t);
9265 bar(t);
9267 unresolvedLookupExpr(hasAnyDeclaration(
9268 functionTemplateDecl(hasName("foo"))))
9269 matches foo in foo(t); but not bar in bar(t);
9270 </pre></td></tr>
9273 <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>
9274 <tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type.
9276 Given
9277 int (*ptr_to_array)[4];
9278 int (*ptr_to_func)(int);
9280 varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
9281 ptr_to_func but not ptr_to_array.
9283 Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>&gt;
9284 </pre></td></tr>
9287 <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>
9288 <tr><td colspan="4" class="doc" id="hasPointeeLoc0"><pre>Matches pointer `TypeLoc`s that have a pointee `TypeLoc` matching
9289 `PointeeMatcher`.
9291 Given
9292 int* x;
9293 pointerTypeLoc(hasPointeeLoc(loc(asString("int"))))
9294 matches `int*`.
9295 </pre></td></tr>
9298 <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>
9299 <tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the
9300 pointee matches a given matcher.
9302 Given
9303 int *a;
9304 int const *b;
9305 float const *f;
9306 pointerType(pointee(isConstQualified(), isInteger()))
9307 matches "int const *b"
9309 Usable 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;,
9310 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;
9311 </pre></td></tr>
9314 <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>
9315 <tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher.
9317 Given:
9318 typedef int &amp;int_ref;
9319 int a;
9320 int_ref b = a;
9322 varDecl(hasType(qualType(referenceType()))))) will not match the
9323 declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does.
9324 </pre></td></tr>
9327 <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>
9328 <tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node
9329 matches the given matcher.
9331 The associated declaration is:
9332 - for type nodes, the declaration of the underlying type
9333 - for CallExpr, the declaration of the callee
9334 - for MemberExpr, the declaration of the referenced member
9335 - for CXXConstructExpr, the declaration of the constructor
9336 - for CXXNewExpr, the declaration of the operator new
9337 - for ObjCIvarExpr, the declaration of the ivar
9339 For type nodes, hasDeclaration will generally match the declaration of the
9340 sugared type. Given
9341 class X {};
9342 typedef X Y;
9343 Y y;
9344 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9345 typedefDecl. A common use case is to match the underlying, desugared type.
9346 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9347 varDecl(hasType(hasUnqualifiedDesugaredType(
9348 recordType(hasDeclaration(decl())))))
9349 In this matcher, the decl will match the CXXRecordDecl of class X.
9351 Usable 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;,
9352 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;,
9353 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;,
9354 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;,
9355 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;,
9356 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;,
9357 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9358 </pre></td></tr>
9361 <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>
9362 <tr><td colspan="4" class="doc" id="ignoringParens0"><pre>Matches types that match InnerMatcher after any parens are stripped.
9364 Given
9365 void (*fp)(void);
9366 The matcher
9367 varDecl(hasType(pointerType(pointee(ignoringParens(functionType())))))
9368 would match the declaration for fp.
9369 </pre></td></tr>
9372 <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>
9373 <tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration.
9374 </pre></td></tr>
9377 <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>
9378 <tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type
9379 matches the specified matcher.
9381 Example matches y-&gt;x()
9382 (matcher = cxxMemberCallExpr(on(hasType(pointsTo
9383 cxxRecordDecl(hasName("Y")))))))
9384 class Y { public: void x(); };
9385 void z() { Y *y; y-&gt;x(); }
9386 </pre></td></tr>
9389 <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>
9390 <tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration.
9391 </pre></td></tr>
9394 <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>
9395 <tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced
9396 type matches the specified matcher.
9398 Example matches X &amp;x and const X &amp;y
9399 (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X"))))))
9400 class X {
9401 void a(X b) {
9402 X &amp;x = b;
9403 const X &amp;y = b;
9406 </pre></td></tr>
9409 <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>
9410 <tr><td colspan="4" class="doc" id="hasUnqualifiedLoc0"><pre>Matches `QualifiedTypeLoc`s that have an unqualified `TypeLoc` matching
9411 `InnerMatcher`.
9413 Given
9414 int* const x;
9415 const int y;
9416 qualifiedTypeLoc(hasUnqualifiedLoc(pointerTypeLoc()))
9417 matches the `TypeLoc` of the variable declaration of `x`, but not `y`.
9418 </pre></td></tr>
9421 <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>
9422 <tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node
9423 matches the given matcher.
9425 The associated declaration is:
9426 - for type nodes, the declaration of the underlying type
9427 - for CallExpr, the declaration of the callee
9428 - for MemberExpr, the declaration of the referenced member
9429 - for CXXConstructExpr, the declaration of the constructor
9430 - for CXXNewExpr, the declaration of the operator new
9431 - for ObjCIvarExpr, the declaration of the ivar
9433 For type nodes, hasDeclaration will generally match the declaration of the
9434 sugared type. Given
9435 class X {};
9436 typedef X Y;
9437 Y y;
9438 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9439 typedefDecl. A common use case is to match the underlying, desugared type.
9440 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9441 varDecl(hasType(hasUnqualifiedDesugaredType(
9442 recordType(hasDeclaration(decl())))))
9443 In this matcher, the decl will match the CXXRecordDecl of class X.
9445 Usable 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;,
9446 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;,
9447 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;,
9448 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;,
9449 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;,
9450 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;,
9451 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9452 </pre></td></tr>
9455 <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>
9456 <tr><td colspan="4" class="doc" id="hasReferentLoc0"><pre>Matches reference `TypeLoc`s that have a referent `TypeLoc` matching
9457 `ReferentMatcher`.
9459 Given
9460 int x = 3;
9461 int&amp; xx = x;
9462 referenceTypeLoc(hasReferentLoc(loc(asString("int"))))
9463 matches `int&amp;`.
9464 </pre></td></tr>
9467 <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>
9468 <tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the
9469 pointee matches a given matcher.
9471 Given
9472 int *a;
9473 int const *b;
9474 float const *f;
9475 pointerType(pointee(isConstQualified(), isInteger()))
9476 matches "int const *b"
9478 Usable 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;,
9479 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;
9480 </pre></td></tr>
9483 <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>
9484 <tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement
9486 Given
9487 return a + b;
9488 hasReturnValue(binaryOperator())
9489 matches 'return a + b'
9490 with binaryOperator()
9491 matching 'a + b'
9492 </pre></td></tr>
9495 <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>
9496 <tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches
9497 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
9499 Given
9500 { {}; 1+2; }
9501 hasAnySubstatement(compoundStmt())
9502 matches '{ {}; 1+2; }'
9503 with compoundStmt()
9504 matching '{}'
9505 </pre></td></tr>
9508 <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>
9509 <tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
9510 alignof.
9511 </pre></td></tr>
9514 <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>
9515 <tr><td colspan="4" class="doc" id="forCallable0"><pre>Matches declaration of the function, method, or block the statement
9516 belongs to.
9518 Given:
9519 F&amp; operator=(const F&amp; o) {
9520 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v &gt; 0; });
9521 return *this;
9523 returnStmt(forCallable(functionDecl(hasName("operator="))))
9524 matches 'return *this'
9525 but does not match 'return v &gt; 0'
9527 Given:
9528 -(void) foo {
9529 int x = 1;
9530 dispatch_sync(queue, ^{ int y = 2; });
9532 declStmt(forCallable(objcMethodDecl()))
9533 matches 'int x = 1'
9534 but does not match 'int y = 2'.
9535 whereas declStmt(forCallable(blockDecl()))
9536 matches 'int y = 2'
9537 but does not match 'int x = 1'.
9538 </pre></td></tr>
9541 <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>
9542 <tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statement belongs to.
9544 Deprecated. Use forCallable() to correctly handle the situation when
9545 the declaration is not a function (but a block or an Objective-C method).
9546 forFunction() not only fails to take non-functions into account but also
9547 may match the wrong declaration in their presence.
9549 Given:
9550 F&amp; operator=(const F&amp; o) {
9551 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v &gt; 0; });
9552 return *this;
9554 returnStmt(forFunction(hasName("operator=")))
9555 matches 'return *this'
9556 but does not match 'return v &gt; 0'
9557 </pre></td></tr>
9560 <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>
9561 <tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
9562 sizeof.
9563 </pre></td></tr>
9566 <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>
9567 <tr><td colspan="4" class="doc" id="hasReplacementType0"><pre>Matches template type parameter substitutions that have a replacement
9568 type that matches the provided matcher.
9570 Given
9571 template &lt;typename T&gt;
9572 double F(T t);
9573 int i;
9574 double j = F(i);
9576 substTemplateTypeParmType(hasReplacementType(type())) matches int
9577 </pre></td></tr>
9580 <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>
9581 <tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch
9582 statement. This matcher may produce multiple matches.
9584 Given
9585 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }
9586 switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s")
9587 matches four times, with "c" binding each of "case 1:", "case 2:",
9588 "case 3:" and "case 4:", and "s" respectively binding "switch (1)",
9589 "switch (1)", "switch (2)" and "switch (2)".
9590 </pre></td></tr>
9593 <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>
9594 <tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop,
9595 switch statement or conditional operator.
9597 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
9598 if (true) {}
9599 </pre></td></tr>
9602 <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>
9603 <tr><td colspan="4" class="doc" id="hasInitStatement1"><pre>Matches selection statements with initializer.
9605 Given:
9606 void foo() {
9607 if (int i = foobar(); i &gt; 0) {}
9608 switch (int i = foobar(); i) {}
9609 for (auto&amp; a = get_range(); auto&amp; x : a) {}
9611 void bar() {
9612 if (foobar() &gt; 0) {}
9613 switch (foobar()) {}
9614 for (auto&amp; x : get_range()) {}
9616 ifStmt(hasInitStatement(anything()))
9617 matches the if statement in foo but not in bar.
9618 switchStmt(hasInitStatement(anything()))
9619 matches the switch statement in foo but not in bar.
9620 cxxForRangeStmt(hasInitStatement(anything()))
9621 matches the range for statement in foo but not in bar.
9622 </pre></td></tr>
9625 <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>
9626 <tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node
9627 matches the given matcher.
9629 The associated declaration is:
9630 - for type nodes, the declaration of the underlying type
9631 - for CallExpr, the declaration of the callee
9632 - for MemberExpr, the declaration of the referenced member
9633 - for CXXConstructExpr, the declaration of the constructor
9634 - for CXXNewExpr, the declaration of the operator new
9635 - for ObjCIvarExpr, the declaration of the ivar
9637 For type nodes, hasDeclaration will generally match the declaration of the
9638 sugared type. Given
9639 class X {};
9640 typedef X Y;
9641 Y y;
9642 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9643 typedefDecl. A common use case is to match the underlying, desugared type.
9644 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9645 varDecl(hasType(hasUnqualifiedDesugaredType(
9646 recordType(hasDeclaration(decl())))))
9647 In this matcher, the decl will match the CXXRecordDecl of class X.
9649 Usable 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;,
9650 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;,
9651 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;,
9652 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;,
9653 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;,
9654 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;,
9655 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9656 </pre></td></tr>
9659 <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>
9660 <tr><td colspan="4" class="doc" id="hasTypeLoc12"><pre>Matches if the type location of a node matches the inner matcher.
9662 Examples:
9663 int x;
9664 declaratorDecl(hasTypeLoc(loc(asString("int"))))
9665 matches int x
9667 auto x = int(3);
9668 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
9669 matches int(3)
9671 struct Foo { Foo(int, int); };
9672 auto x = Foo(1, 2);
9673 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
9674 matches Foo(1, 2)
9676 Usable 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;,
9677 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;,
9678 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;,
9679 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
9680 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;,
9681 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;,
9682 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;,
9683 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
9684 </pre></td></tr>
9687 <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>
9688 <tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression.
9690 Given
9691 struct B { int next; };
9692 template&lt;int(B::*next_ptr)&gt; struct A {};
9693 A&lt;&amp;B::next&gt; a;
9694 templateSpecializationType(hasAnyTemplateArgument(
9695 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next"))))))))
9696 matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
9697 B::next
9698 </pre></td></tr>
9701 <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>
9702 <tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain
9703 declaration.
9705 Given
9706 struct B { int next; };
9707 template&lt;int(B::*next_ptr)&gt; struct A {};
9708 A&lt;&amp;B::next&gt; a;
9709 classTemplateSpecializationDecl(hasAnyTemplateArgument(
9710 refersToDeclaration(fieldDecl(hasName("next")))))
9711 matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
9712 B::next
9713 </pre></td></tr>
9716 <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>
9717 <tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that refers to an integral type.
9719 Given
9720 template&lt;int T&gt; struct C {};
9721 C&lt;42&gt; c;
9722 classTemplateSpecializationDecl(
9723 hasAnyTemplateArgument(refersToIntegralType(asString("int"))))
9724 matches the implicit instantiation of C in C&lt;42&gt;.
9725 </pre></td></tr>
9728 <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>
9729 <tr><td colspan="4" class="doc" id="refersToTemplate0"><pre>Matches a TemplateArgument that refers to a certain template.
9731 Given
9732 template&lt;template &lt;typename&gt; class S&gt; class X {};
9733 template&lt;typename T&gt; class Y {};
9734 X&lt;Y&gt; xi;
9735 classTemplateSpecializationDecl(hasAnyTemplateArgument(
9736 refersToTemplate(templateName())))
9737 matches the specialization X&lt;Y&gt;
9738 </pre></td></tr>
9741 <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>
9742 <tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type.
9744 Given
9745 struct X {};
9746 template&lt;typename T&gt; struct A {};
9747 A&lt;X&gt; a;
9748 classTemplateSpecializationDecl(hasAnyTemplateArgument(refersToType(
9749 recordType(hasDeclaration(recordDecl(hasName("X")))))))
9750 matches the specialization of struct A generated by A&lt;X&gt;.
9751 </pre></td></tr>
9754 <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>
9755 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgumentLoc0"><pre>Matches template specialization `TypeLoc`s that have at least one
9756 `TemplateArgumentLoc` matching the given `InnerMatcher`.
9758 Given
9759 template&lt;typename T&gt; class A {};
9760 A&lt;int&gt; a;
9761 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc(
9762 hasTypeLoc(loc(asString("int")))))))
9763 matches `A&lt;int&gt; a`.
9764 </pre></td></tr>
9767 <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>
9768 <tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc1"><pre>Matches template specialization `TypeLoc`s where the n'th
9769 `TemplateArgumentLoc` matches the given `InnerMatcher`.
9771 Given
9772 template&lt;typename T, typename U&gt; class A {};
9773 A&lt;double, int&gt; b;
9774 A&lt;int, double&gt; c;
9775 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
9776 hasTypeLoc(loc(asString("double")))))))
9777 matches `A&lt;double, int&gt; b`, but not `A&lt;int, double&gt; c`.
9778 </pre></td></tr>
9781 <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>
9782 <tr><td colspan="4" class="doc" id="forEachTemplateArgument1"><pre>Matches classTemplateSpecialization, templateSpecializationType and
9783 functionDecl nodes where the template argument matches the inner matcher.
9784 This matcher may produce multiple matches.
9786 Given
9787 template &lt;typename T, unsigned N, unsigned M&gt;
9788 struct Matrix {};
9790 constexpr unsigned R = 2;
9791 Matrix&lt;int, R * 2, R * 4&gt; M;
9793 template &lt;typename T, typename U&gt;
9794 void f(T&amp;&amp; t, U&amp;&amp; u) {}
9796 bool B = false;
9797 f(R, B);
9798 templateSpecializationType(forEachTemplateArgument(isExpr(expr())))
9799 matches twice, with expr() matching 'R * 2' and 'R * 4'
9800 functionDecl(forEachTemplateArgument(refersToType(builtinType())))
9801 matches the specialization f&lt;unsigned, bool&gt; twice, for 'unsigned'
9802 and 'bool'
9803 </pre></td></tr>
9806 <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>
9807 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and
9808 functionDecl that have at least one TemplateArgument matching the given
9809 InnerMatcher.
9811 Given
9812 template&lt;typename T&gt; class A {};
9813 template&lt;&gt; class A&lt;double&gt; {};
9814 A&lt;int&gt; a;
9816 template&lt;typename T&gt; f() {};
9817 void func() { f&lt;int&gt;(); };
9819 classTemplateSpecializationDecl(hasAnyTemplateArgument(
9820 refersToType(asString("int"))))
9821 matches the specialization A&lt;int&gt;
9823 functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
9824 matches the specialization f&lt;int&gt;
9825 </pre></td></tr>
9828 <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>
9829 <tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node
9830 matches the given matcher.
9832 The associated declaration is:
9833 - for type nodes, the declaration of the underlying type
9834 - for CallExpr, the declaration of the callee
9835 - for MemberExpr, the declaration of the referenced member
9836 - for CXXConstructExpr, the declaration of the constructor
9837 - for CXXNewExpr, the declaration of the operator new
9838 - for ObjCIvarExpr, the declaration of the ivar
9840 For type nodes, hasDeclaration will generally match the declaration of the
9841 sugared type. Given
9842 class X {};
9843 typedef X Y;
9844 Y y;
9845 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9846 typedefDecl. A common use case is to match the underlying, desugared type.
9847 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9848 varDecl(hasType(hasUnqualifiedDesugaredType(
9849 recordType(hasDeclaration(decl())))))
9850 In this matcher, the decl will match the CXXRecordDecl of class X.
9852 Usable 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;,
9853 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;,
9854 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;,
9855 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;,
9856 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;,
9857 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;,
9858 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9859 </pre></td></tr>
9862 <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>
9863 <tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and
9864 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
9866 Given
9867 template&lt;typename T, typename U&gt; class A {};
9868 A&lt;bool, int&gt; b;
9869 A&lt;int, bool&gt; c;
9871 template&lt;typename T&gt; void f() {}
9872 void func() { f&lt;int&gt;(); };
9873 classTemplateSpecializationDecl(hasTemplateArgument(
9874 1, refersToType(asString("int"))))
9875 matches the specialization A&lt;bool, int&gt;
9877 functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
9878 matches the specialization f&lt;int&gt;
9879 </pre></td></tr>
9882 <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>
9883 <tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node
9884 matches the given matcher.
9886 The associated declaration is:
9887 - for type nodes, the declaration of the underlying type
9888 - for CallExpr, the declaration of the callee
9889 - for MemberExpr, the declaration of the referenced member
9890 - for CXXConstructExpr, the declaration of the constructor
9891 - for CXXNewExpr, the declaration of the operator new
9892 - for ObjCIvarExpr, the declaration of the ivar
9894 For type nodes, hasDeclaration will generally match the declaration of the
9895 sugared type. Given
9896 class X {};
9897 typedef X Y;
9898 Y y;
9899 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9900 typedefDecl. A common use case is to match the underlying, desugared type.
9901 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9902 varDecl(hasType(hasUnqualifiedDesugaredType(
9903 recordType(hasDeclaration(decl())))))
9904 In this matcher, the decl will match the CXXRecordDecl of class X.
9906 Usable 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;,
9907 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;,
9908 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;,
9909 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;,
9910 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;,
9911 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;,
9912 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9913 </pre></td></tr>
9916 <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>
9917 <tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner
9918 QualType-matcher matches.
9919 </pre></td></tr>
9922 <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>
9923 <tr><td colspan="4" class="doc" id="hasTypeLoc13"><pre>Matches if the type location of a node matches the inner matcher.
9925 Examples:
9926 int x;
9927 declaratorDecl(hasTypeLoc(loc(asString("int"))))
9928 matches int x
9930 auto x = int(3);
9931 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
9932 matches int(3)
9934 struct Foo { Foo(int, int); };
9935 auto x = Foo(1, 2);
9936 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
9937 matches Foo(1, 2)
9939 Usable 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;,
9940 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;,
9941 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;,
9942 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
9943 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;,
9944 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;,
9945 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;,
9946 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
9947 </pre></td></tr>
9950 <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>
9951 <tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type
9952 matcher.
9954 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
9955 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
9956 and U (matcher = typedefDecl(hasType(asString("int")))
9957 and friend class X (matcher = friendDecl(hasType("X"))
9958 and public virtual X (matcher = cxxBaseSpecifier(hasType(
9959 asString("class X")))
9960 class X {};
9961 void y(X &amp;x) { x; X z; }
9962 typedef int U;
9963 class Y { friend class X; };
9964 class Z : public virtual X {};
9965 </pre></td></tr>
9968 <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>
9969 <tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node
9970 matches the given matcher.
9972 The associated declaration is:
9973 - for type nodes, the declaration of the underlying type
9974 - for CallExpr, the declaration of the callee
9975 - for MemberExpr, the declaration of the referenced member
9976 - for CXXConstructExpr, the declaration of the constructor
9977 - for CXXNewExpr, the declaration of the operator new
9978 - for ObjCIvarExpr, the declaration of the ivar
9980 For type nodes, hasDeclaration will generally match the declaration of the
9981 sugared type. Given
9982 class X {};
9983 typedef X Y;
9984 Y y;
9985 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9986 typedefDecl. A common use case is to match the underlying, desugared type.
9987 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9988 varDecl(hasType(hasUnqualifiedDesugaredType(
9989 recordType(hasDeclaration(decl())))))
9990 In this matcher, the decl will match the CXXRecordDecl of class X.
9992 Usable 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;,
9993 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;,
9994 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;,
9995 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;,
9996 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;,
9997 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;,
9998 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9999 </pre></td></tr>
10002 <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>
10003 <tr><td colspan="4" class="doc" id="hasUnqualifiedDesugaredType0"><pre>Matches if the matched type matches the unqualified desugared
10004 type of the matched node.
10006 For example, in:
10007 class A {};
10008 using B = A;
10009 The matcher type(hasUnqualifiedDesugaredType(recordType())) matches
10010 both B and A.
10011 </pre></td></tr>
10014 <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>
10015 <tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument.
10017 Given
10018 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
10019 unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
10020 matches sizeof(a) and alignof(c)
10021 </pre></td></tr>
10024 <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>
10025 <tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches.
10027 Example matches true (matcher = hasUnaryOperand(
10028 cxxBoolLiteral(equals(true))))
10029 !true
10030 </pre></td></tr>
10033 <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>
10034 <tr><td colspan="4" class="doc" id="hasObjectExpression1"><pre>Matches a member expression where the object expression is matched by a
10035 given matcher. Implicit object expressions are included; that is, it matches
10036 use of implicit `this`.
10038 Given
10039 struct X {
10040 int m;
10041 int f(X x) { x.m; return m; }
10043 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))
10044 matches `x.m`, but not `m`; however,
10045 memberExpr(hasObjectExpression(hasType(pointsTo(
10046 cxxRecordDecl(hasName("X"))))))
10047 matches `m` (aka. `this-&gt;m`), but not `x.m`.
10048 </pre></td></tr>
10051 <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>
10052 <tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node
10053 matches the given matcher.
10055 The associated declaration is:
10056 - for type nodes, the declaration of the underlying type
10057 - for CallExpr, the declaration of the callee
10058 - for MemberExpr, the declaration of the referenced member
10059 - for CXXConstructExpr, the declaration of the constructor
10060 - for CXXNewExpr, the declaration of the operator new
10061 - for ObjCIvarExpr, the declaration of the ivar
10063 For type nodes, hasDeclaration will generally match the declaration of the
10064 sugared type. Given
10065 class X {};
10066 typedef X Y;
10067 Y y;
10068 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
10069 typedefDecl. A common use case is to match the underlying, desugared type.
10070 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
10071 varDecl(hasType(hasUnqualifiedDesugaredType(
10072 recordType(hasDeclaration(decl())))))
10073 In this matcher, the decl will match the CXXRecordDecl of class X.
10075 Usable 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;,
10076 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;,
10077 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;,
10078 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;,
10079 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;,
10080 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;,
10081 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
10082 </pre></td></tr>
10085 <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>
10086 <tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is
10087 matched by the given matcher.
10089 Given
10090 namespace X { int a; void b(); }
10091 using X::a;
10092 using X::b;
10093 usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
10094 matches using X::b but not using X::a </pre></td></tr>
10097 <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>
10098 <tr><td colspan="4" class="doc" id="hasUnderlyingType1"><pre>Matches DecltypeType or UsingType nodes to find the underlying type.
10100 Given
10101 decltype(1) a = 1;
10102 decltype(2.0) b = 2.0;
10103 decltypeType(hasUnderlyingType(isInteger()))
10104 matches the type of "a"
10106 Usable 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;
10107 </pre></td></tr>
10110 <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>
10111 <tr><td colspan="4" class="doc" id="throughUsingDecl1"><pre>Matches if a node refers to a declaration through a specific
10112 using shadow declaration.
10114 Examples:
10115 namespace a { int f(); }
10116 using a::f;
10117 int x = f();
10118 declRefExpr(throughUsingDecl(anything()))
10119 matches f
10121 namespace a { class X{}; }
10122 using a::X;
10123 X x;
10124 typeLoc(loc(usingType(throughUsingDecl(anything()))))
10125 matches X
10127 Usable 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;
10128 </pre></td></tr>
10131 <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>
10132 <tr><td colspan="4" class="doc" id="hasType7"><pre>Overloaded to match the declaration of the expression's or value
10133 declaration's type.
10135 In case of a value declaration (for example a variable declaration),
10136 this resolves one layer of indirection. For example, in the value
10137 declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
10138 X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
10139 declaration of x.
10141 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
10142 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
10143 and friend class X (matcher = friendDecl(hasType("X"))
10144 and public virtual X (matcher = cxxBaseSpecifier(hasType(
10145 cxxRecordDecl(hasName("X"))))
10146 class X {};
10147 void y(X &amp;x) { x; X z; }
10148 class Y { friend class X; };
10149 class Z : public virtual X {};
10151 Example matches class Derived
10152 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
10153 class Base {};
10154 class Derived : Base {};
10156 Usable 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;,
10157 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
10158 </pre></td></tr>
10161 <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>
10162 <tr><td colspan="4" class="doc" id="hasType3"><pre>Matches if the expression's or declaration's type matches a type
10163 matcher.
10165 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
10166 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
10167 and U (matcher = typedefDecl(hasType(asString("int")))
10168 and friend class X (matcher = friendDecl(hasType("X"))
10169 and public virtual X (matcher = cxxBaseSpecifier(hasType(
10170 asString("class X")))
10171 class X {};
10172 void y(X &amp;x) { x; X z; }
10173 typedef int U;
10174 class Y { friend class X; };
10175 class Z : public virtual X {};
10176 </pre></td></tr>
10179 <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>
10180 <tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression
10181 that matches the given matcher.
10183 Example matches x (matcher = varDecl(hasInitializer(callExpr())))
10184 bool y() { return true; }
10185 bool x = y();
10186 </pre></td></tr>
10189 <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>
10190 <tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size
10191 expression.
10193 Given
10194 void f(int b) {
10195 int a[b];
10197 variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
10198 varDecl(hasName("b")))))))
10199 matches "int a[b]"
10200 </pre></td></tr>
10203 <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>
10204 <tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
10205 definition that has a given body. Note that in case of functions or
10206 coroutines this matcher only matches the definition itself and not the
10207 other declarations of the same function or coroutine.
10209 Given
10210 for (;;) {}
10211 forStmt(hasBody(compoundStmt()))
10212 matches 'for (;;) {}'
10213 with compoundStmt()
10214 matching '{}'
10216 Given
10217 void f();
10218 void f() {}
10219 functionDecl(hasBody(compoundStmt()))
10220 matches 'void f() {}'
10221 with compoundStmt()
10222 matching '{}'
10223 but does not match 'void f();'
10224 </pre></td></tr>
10227 <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>
10228 <tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop,
10229 switch statement or conditional operator.
10231 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
10232 if (true) {}
10233 </pre></td></tr>
10235 <!--END_TRAVERSAL_MATCHERS -->
10236 </table>
10238 </div>
10239 </body>
10240 </html>