[IRBuilder] Refactor FMF interface (#121657)
[llvm-project.git] / clang / docs / LibASTMatchersReference.html
blob18f9e7d6c0ea06ceb650d847d4e418bb80ab3c3e
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('exportDecl0')"><a name="exportDecl0Anchor">exportDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExportDecl.html">ExportDecl</a>&gt;...</td></tr>
808 <tr><td colspan="4" class="doc" id="exportDecl0"><pre>Matches any export declaration.
810 Example matches following declarations.
811 export void foo();
812 export { void foo(); }
813 export namespace { void foo(); }
814 export int v;
815 </pre></td></tr>
818 <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>
819 <tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations.
821 Given
822 class X { int m; };
823 fieldDecl()
824 matches 'm'.
825 </pre></td></tr>
828 <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>
829 <tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations.
831 Given
832 class X { friend void foo(); };
833 friendDecl()
834 matches 'friend void foo()'.
835 </pre></td></tr>
838 <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>
839 <tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations.
841 Example matches f
842 void f();
843 </pre></td></tr>
846 <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>
847 <tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations.
849 Example matches f
850 template&lt;class T&gt; void f(T t) {}
851 </pre></td></tr>
854 <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>
855 <tr><td colspan="4" class="doc" id="indirectFieldDecl0"><pre>Matches indirect field declarations.
857 Given
858 struct X { struct { int a; }; };
859 indirectFieldDecl()
860 matches 'a'.
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('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>
865 <tr><td colspan="4" class="doc" id="labelDecl0"><pre>Matches a declaration of label.
867 Given
868 goto FOO;
869 FOO: bar();
870 labelDecl()
871 matches 'FOO:'
872 </pre></td></tr>
875 <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>
876 <tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification.
878 Given
879 extern "C" {}
880 linkageSpecDecl()
881 matches "extern "C" {}"
882 </pre></td></tr>
885 <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>
886 <tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name.
888 Example matches X, S, the anonymous union type, i, and U;
889 typedef int X;
890 struct S {
891 union {
892 int i;
893 } U;
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('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>
899 <tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias.
901 Given
902 namespace test {}
903 namespace alias = ::test;
904 namespaceAliasDecl()
905 matches "namespace alias" but not "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('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>
910 <tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace.
912 Given
913 namespace {}
914 namespace test {}
915 namespaceDecl()
916 matches "namespace {}" and "namespace test {}"
917 </pre></td></tr>
920 <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>
921 <tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations.
923 Given
924 template &lt;typename T, int N&gt; struct C {};
925 nonTypeTemplateParmDecl()
926 matches 'N', but not 'T'.
927 </pre></td></tr>
930 <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>
931 <tr><td colspan="4" class="doc" id="objcCategoryDecl0"><pre>Matches Objective-C category declarations.
933 Example matches Foo (Additions)
934 @interface Foo (Additions)
935 @end
936 </pre></td></tr>
939 <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>
940 <tr><td colspan="4" class="doc" id="objcCategoryImplDecl0"><pre>Matches Objective-C category definitions.
942 Example matches Foo (Additions)
943 @implementation Foo (Additions)
944 @end
945 </pre></td></tr>
948 <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>
949 <tr><td colspan="4" class="doc" id="objcImplementationDecl0"><pre>Matches Objective-C implementation declarations.
951 Example matches Foo
952 @implementation Foo
953 @end
954 </pre></td></tr>
957 <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>
958 <tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations.
960 Example matches Foo
961 @interface Foo
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('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>
967 <tr><td colspan="4" class="doc" id="objcIvarDecl0"><pre>Matches Objective-C instance variable declarations.
969 Example matches _enabled
970 @implementation Foo {
971 BOOL _enabled;
973 @end
974 </pre></td></tr>
977 <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>
978 <tr><td colspan="4" class="doc" id="objcMethodDecl0"><pre>Matches Objective-C method declarations.
980 Example matches both declaration and definition of -[Foo method]
981 @interface Foo
982 - (void)method;
983 @end
985 @implementation Foo
986 - (void)method {}
987 @end
988 </pre></td></tr>
991 <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>
992 <tr><td colspan="4" class="doc" id="objcPropertyDecl0"><pre>Matches Objective-C property declarations.
994 Example matches enabled
995 @interface Foo
996 @property BOOL enabled;
997 @end
998 </pre></td></tr>
1001 <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>
1002 <tr><td colspan="4" class="doc" id="objcProtocolDecl0"><pre>Matches Objective-C protocol declarations.
1004 Example matches FooDelegate
1005 @protocol FooDelegate
1006 @end
1007 </pre></td></tr>
1010 <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>
1011 <tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations.
1013 Given
1014 void f(int x);
1015 parmVarDecl()
1016 matches int x.
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('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>
1021 <tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations.
1023 Example matches X, Z, U, and S
1024 class X;
1025 template&lt;class T&gt; class Z {};
1026 struct S {};
1027 union U {};
1028 </pre></td></tr>
1031 <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>
1032 <tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration.
1034 Example:
1035 staticAssertDecl()
1036 matches
1037 static_assert(sizeof(S) == sizeof(int))
1039 struct S {
1040 int x;
1042 static_assert(sizeof(S) == sizeof(int));
1043 </pre></td></tr>
1046 <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>
1047 <tr><td colspan="4" class="doc" id="tagDecl0"><pre>Matches tag declarations.
1049 Example matches X, Z, U, S, E
1050 class X;
1051 template&lt;class T&gt; class Z {};
1052 struct S {};
1053 union U {};
1054 enum E {
1055 A, B, C
1057 </pre></td></tr>
1060 <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>
1061 <tr><td colspan="4" class="doc" id="templateTemplateParmDecl0"><pre>Matches template template parameter declarations.
1063 Given
1064 template &lt;template &lt;typename&gt; class Z, int N&gt; struct C {};
1065 templateTypeParmDecl()
1066 matches 'Z', but not 'N'.
1067 </pre></td></tr>
1070 <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>
1071 <tr><td colspan="4" class="doc" id="templateTypeParmDecl0"><pre>Matches template type parameter declarations.
1073 Given
1074 template &lt;typename T, int N&gt; struct C {};
1075 templateTypeParmDecl()
1076 matches 'T', but not 'N'.
1077 </pre></td></tr>
1080 <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>
1081 <tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context.
1083 Given
1084 int X;
1085 namespace NS {
1086 int Y;
1087 } // namespace NS
1088 decl(hasDeclContext(translationUnitDecl()))
1089 matches "int X", but not "int Y".
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('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>
1094 <tr><td colspan="4" class="doc" id="typeAliasDecl0"><pre>Matches type alias declarations.
1096 Given
1097 typedef int X;
1098 using Y = int;
1099 typeAliasDecl()
1100 matches "using Y = int", but not "typedef int X"
1101 </pre></td></tr>
1104 <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>
1105 <tr><td colspan="4" class="doc" id="typeAliasTemplateDecl0"><pre>Matches type alias template declarations.
1107 typeAliasTemplateDecl() matches
1108 template &lt;typename T&gt;
1109 using Y = X&lt;T&gt;;
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('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>
1114 <tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations.
1116 Given
1117 typedef int X;
1118 using Y = int;
1119 typedefDecl()
1120 matches "typedef int X", but not "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('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>
1125 <tr><td colspan="4" class="doc" id="typedefNameDecl0"><pre>Matches typedef name declarations.
1127 Given
1128 typedef int X;
1129 using Y = int;
1130 typedefNameDecl()
1131 matches "typedef int X" and "using Y = int"
1132 </pre></td></tr>
1135 <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>
1136 <tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the
1137 typename.
1139 Given
1140 template &lt;typename T&gt;
1141 struct Base { typedef T Foo; };
1143 template&lt;typename T&gt;
1144 struct S : private Base&lt;T&gt; {
1145 using typename Base&lt;T&gt;::Foo;
1147 unresolvedUsingTypenameDecl()
1148 matches using Base&lt;T&gt;::Foo </pre></td></tr>
1151 <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>
1152 <tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations.
1154 Given
1155 template&lt;typename X&gt;
1156 class C : private X {
1157 using X::x;
1159 unresolvedUsingValueDecl()
1160 matches using X::x </pre></td></tr>
1163 <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>
1164 <tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations.
1166 Given
1167 namespace X { int x; }
1168 using X::x;
1169 usingDecl()
1170 matches using X::x </pre></td></tr>
1173 <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>
1174 <tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations.
1176 Given
1177 namespace X { int x; }
1178 using namespace X;
1179 usingDirectiveDecl()
1180 matches using namespace X </pre></td></tr>
1183 <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>
1184 <tr><td colspan="4" class="doc" id="usingEnumDecl0"><pre>Matches using-enum declarations.
1186 Given
1187 namespace X { enum x {...}; }
1188 using enum X::x;
1189 usingEnumDecl()
1190 matches using enum X::x </pre></td></tr>
1193 <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>
1194 <tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration.
1196 Example matches A, B, C and F
1197 enum X { A, B, C };
1198 void F();
1199 </pre></td></tr>
1202 <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>
1203 <tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations.
1205 Note: this does not match declarations of member variables, which are
1206 "field" declarations in Clang parlance.
1208 Example matches a
1209 int a;
1210 </pre></td></tr>
1213 <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>
1214 <tr><td colspan="4" class="doc" id="lambdaCapture0"><pre>Matches lambda captures.
1216 Given
1217 int main() {
1218 int x;
1219 auto f = [x](){};
1220 auto g = [x = 1](){};
1222 In the matcher `lambdaExpr(hasAnyCapture(lambdaCapture()))`,
1223 `lambdaCapture()` matches `x` and `x=1`.
1224 </pre></td></tr>
1227 <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>
1228 <tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
1229 </pre></td></tr>
1232 <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>
1233 <tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers.
1235 Given
1236 namespace ns {
1237 struct A { static void f(); };
1238 void A::f() {}
1239 void g() { A::f(); }
1241 ns::A a;
1242 nestedNameSpecifier()
1243 matches "ns::" and both "A::"
1244 </pre></td></tr>
1247 <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>
1248 <tr><td colspan="4" class="doc" id="ompDefaultClause0"><pre>Matches OpenMP ``default`` clause.
1250 Given
1252 #pragma omp parallel default(none)
1253 #pragma omp parallel default(shared)
1254 #pragma omp parallel default(private)
1255 #pragma omp parallel default(firstprivate)
1256 #pragma omp parallel
1258 ``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``,
1259 `` default(private)`` and ``default(firstprivate)``
1260 </pre></td></tr>
1263 <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>
1264 <tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST.
1265 </pre></td></tr>
1268 <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>
1269 <tr><td colspan="4" class="doc" id="addrLabelExpr0"><pre>Matches address of label statements (GNU extension).
1271 Given
1272 FOO: bar();
1273 void *ptr = &amp;&amp;FOO;
1274 goto *bar;
1275 addrLabelExpr()
1276 matches '&amp;&amp;FOO'
1277 </pre></td></tr>
1280 <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>
1281 <tr><td colspan="4" class="doc" id="arrayInitIndexExpr0"><pre>The arrayInitIndexExpr consists of two subexpressions: a common expression
1282 (the source array) that is evaluated once up-front, and a per-element initializer
1283 that runs once for each array element. Within the per-element initializer,
1284 the current index may be obtained via an ArrayInitIndexExpr.
1286 Given
1287 void testStructBinding() {
1288 int a[2] = {1, 2};
1289 auto [x, y] = a;
1291 arrayInitIndexExpr() matches the array index that implicitly iterates
1292 over the array `a` to copy each element to the anonymous array
1293 that backs the structured binding `[x, y]` elements of which are
1294 referred to by their aliases `x` and `y`.
1295 </pre></td></tr>
1298 <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>
1299 <tr><td colspan="4" class="doc" id="arrayInitLoopExpr0"><pre>Matches a loop initializing the elements of an array in a number of contexts:
1300 * in the implicit copy/move constructor for a class with an array member
1301 * when a lambda-expression captures an array by value
1302 * when a decomposition declaration decomposes an array
1304 Given
1305 void testLambdaCapture() {
1306 int a[10];
1307 auto Lam1 = [a]() {
1308 return;
1311 arrayInitLoopExpr() matches the implicit loop that initializes each element of
1312 the implicit array field inside the lambda object, that represents the array `a`
1313 captured by value.
1314 </pre></td></tr>
1317 <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>
1318 <tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions.
1320 Given
1321 int i = a[1];
1322 arraySubscriptExpr()
1323 matches "a[1]"
1324 </pre></td></tr>
1327 <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>
1328 <tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements.
1330 int i = 100;
1331 __asm("mov al, 2");
1332 asmStmt()
1333 matches '__asm("mov al, 2")'
1334 </pre></td></tr>
1337 <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>
1338 <tr><td colspan="4" class="doc" id="atomicExpr0"><pre>Matches atomic builtins.
1339 Example matches __atomic_load_n(ptr, 1)
1340 void foo() { int *ptr; __atomic_load_n(ptr, 1); }
1341 </pre></td></tr>
1344 <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>
1345 <tr><td colspan="4" class="doc" id="autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement.
1347 Given
1348 @autoreleasepool {
1349 int x = 0;
1351 autoreleasePoolStmt(stmt()) matches the declaration of "x"
1352 inside the autorelease pool.
1353 </pre></td></tr>
1356 <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>
1357 <tr><td colspan="4" class="doc" id="binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension).
1359 Example matches a ?: b
1360 (a ?: b) + 42;
1361 </pre></td></tr>
1364 <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>
1365 <tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions.
1367 Example matches a || b
1368 !(a || b)
1369 See also the binaryOperation() matcher for more-general matching.
1370 </pre></td></tr>
1373 <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>
1374 <tr><td colspan="4" class="doc" id="blockExpr0"><pre>Matches a reference to a block.
1376 Example: matches "^{}":
1377 void f() { ^{}(); }
1378 </pre></td></tr>
1381 <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>
1382 <tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements.
1384 Given
1385 while (true) { break; }
1386 breakStmt()
1387 matches 'break'
1388 </pre></td></tr>
1391 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1392 <tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression.
1394 Example: Matches (int) 2.2f in
1395 int i = (int) 2.2f;
1396 </pre></td></tr>
1399 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1400 <tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions.
1402 Example matches x.y() and y()
1403 X x;
1404 x.y();
1405 y();
1406 </pre></td></tr>
1409 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1410 <tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements.
1412 Given
1413 switch(a) { case 42: break; default: break; }
1414 caseStmt()
1415 matches 'case 42:'.
1416 </pre></td></tr>
1419 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1420 <tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST.
1422 Example: castExpr() matches each of the following:
1423 (int) 3;
1424 const_cast&lt;Expr *&gt;(SubExpr);
1425 char c = 0;
1426 but does not match
1427 int i = (0);
1428 int k = 0;
1429 </pre></td></tr>
1432 <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>
1433 <tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t).
1435 Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
1436 though.
1438 Example matches 'a', L'a'
1439 char ch = 'a';
1440 wchar_t chw = L'a';
1441 </pre></td></tr>
1444 <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>
1445 <tr><td colspan="4" class="doc" id="chooseExpr0"><pre>Matches GNU __builtin_choose_expr.
1446 </pre></td></tr>
1449 <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>
1450 <tr><td colspan="4" class="doc" id="coawaitExpr0"><pre>Matches co_await expressions.
1452 Given
1453 co_await 1;
1454 coawaitExpr()
1455 matches 'co_await 1'
1456 </pre></td></tr>
1459 <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>
1460 <tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals
1462 Example match: {1}, (1, 2)
1463 int array[4] = {1};
1464 vector int myvec = (vector int)(1, 2);
1465 </pre></td></tr>
1468 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1469 <tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements.
1471 Example matches '{}' and '{{}}' in 'for (;;) {{}}'
1472 for (;;) {{}}
1473 </pre></td></tr>
1476 <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>
1477 <tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions.
1479 Example matches a ? b : c
1480 (a ? b : c) + 42
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('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>
1485 <tr><td colspan="4" class="doc" id="constantExpr0"><pre>Matches a constant expression wrapper.
1487 Example matches the constant in the case statement:
1488 (matcher = constantExpr())
1489 switch (a) {
1490 case 37: break;
1492 </pre></td></tr>
1495 <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>
1496 <tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements.
1498 Given
1499 while (true) { continue; }
1500 continueStmt()
1501 matches 'continue'
1502 </pre></td></tr>
1505 <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>
1506 <tr><td colspan="4" class="doc" id="convertVectorExpr0"><pre>Matches builtin function __builtin_convertvector.
1507 </pre></td></tr>
1510 <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>
1511 <tr><td colspan="4" class="doc" id="coreturnStmt0"><pre>Matches co_return statements.
1513 Given
1514 while (true) { co_return; }
1515 coreturnStmt()
1516 matches 'co_return'
1517 </pre></td></tr>
1520 <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>
1521 <tr><td colspan="4" class="doc" id="coroutineBodyStmt0"><pre>Matches coroutine body statements.
1523 coroutineBodyStmt() matches the coroutine below
1524 generator&lt;int&gt; gen() {
1525 co_return;
1527 </pre></td></tr>
1530 <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>
1531 <tr><td colspan="4" class="doc" id="coyieldExpr0"><pre>Matches co_yield expressions.
1533 Given
1534 co_yield 1;
1535 coyieldExpr()
1536 matches 'co_yield 1'
1537 </pre></td></tr>
1540 <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>
1541 <tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression.
1543 Example matches,
1544 kernel&lt;&lt;&lt;i,j&gt;&gt;&gt;();
1545 </pre></td></tr>
1548 <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>
1549 <tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created.
1551 Example matches FunctionTakesString(GetStringByValue())
1552 (matcher = cxxBindTemporaryExpr())
1553 FunctionTakesString(GetStringByValue());
1554 FunctionTakesStringByPointer(GetStringPointer());
1555 </pre></td></tr>
1558 <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>
1559 <tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals.
1561 Example matches true
1562 true
1563 </pre></td></tr>
1566 <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>
1567 <tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements.
1569 try {} catch(int i) {}
1570 cxxCatchStmt()
1571 matches 'catch(int i)'
1572 </pre></td></tr>
1575 <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>
1576 <tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression.
1578 Example: Matches const_cast&lt;int*&gt;(&amp;r) in
1579 int n = 42;
1580 const int &amp;r(n);
1581 int* p = const_cast&lt;int*&gt;(&amp;r);
1582 </pre></td></tr>
1585 <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>
1586 <tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones).
1588 Example matches string(ptr, n) and ptr within arguments of f
1589 (matcher = cxxConstructExpr())
1590 void f(const string &amp;a, const string &amp;b);
1591 char *ptr;
1592 int n;
1593 f(string(ptr, n), ptr);
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('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>
1598 <tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site.
1600 Example matches the CXXDefaultArgExpr placeholder inserted for the
1601 default value of the second parameter in the call expression f(42)
1602 (matcher = cxxDefaultArgExpr())
1603 void f(int x, int y = 0);
1604 f(42);
1605 </pre></td></tr>
1608 <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>
1609 <tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions.
1611 Given
1612 delete X;
1613 cxxDeleteExpr()
1614 matches 'delete X'.
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('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>
1619 <tr><td colspan="4" class="doc" id="cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be
1620 resolved because the base expression or the member name was dependent.
1622 Given
1623 template &lt;class T&gt; void f() { T t; t.g(); }
1624 cxxDependentScopeMemberExpr()
1625 matches t.g
1626 </pre></td></tr>
1629 <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>
1630 <tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression.
1632 Example:
1633 cxxDynamicCastExpr()
1634 matches
1635 dynamic_cast&lt;D*&gt;(&amp;b);
1637 struct B { virtual ~B() {} }; struct D : B {};
1638 B b;
1639 D* p = dynamic_cast&lt;D*&gt;(&amp;b);
1640 </pre></td></tr>
1643 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('cxxFoldExpr0')"><a name="cxxFoldExpr0Anchor">cxxFoldExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>&gt;...</td></tr>
1644 <tr><td colspan="4" class="doc" id="cxxFoldExpr0"><pre>Matches C++17 fold expressions.
1646 Example matches `(0 + ... + args)`:
1647 template &lt;typename... Args&gt;
1648 auto sum(Args... args) {
1649 return (0 + ... + args);
1651 </pre></td></tr>
1654 <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>
1655 <tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements.
1657 cxxForRangeStmt() matches 'for (auto a : i)'
1658 int i[] = {1, 2, 3}; for (auto a : i);
1659 for(int j = 0; j &lt; 5; ++j);
1660 </pre></td></tr>
1663 <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>
1664 <tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions
1666 Example: Matches Foo(bar);
1667 Foo f = bar;
1668 Foo g = (Foo) bar;
1669 Foo h = Foo(bar);
1670 </pre></td></tr>
1673 <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>
1674 <tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions.
1676 Example matches x.y()
1677 X x;
1678 x.y();
1679 </pre></td></tr>
1682 <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>
1683 <tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions.
1685 Given
1686 new X;
1687 cxxNewExpr()
1688 matches 'new X'.
1689 </pre></td></tr>
1692 <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>
1693 <tr><td colspan="4" class="doc" id="cxxNoexceptExpr0"><pre>Matches noexcept expressions.
1695 Given
1696 bool a() noexcept;
1697 bool b() noexcept(true);
1698 bool c() noexcept(false);
1699 bool d() noexcept(noexcept(a()));
1700 bool e = noexcept(b()) || noexcept(c());
1701 cxxNoexceptExpr()
1702 matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`.
1703 doesn't match the noexcept specifier in the declarations a, b, c or d.
1704 </pre></td></tr>
1707 <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>
1708 <tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal.
1709 </pre></td></tr>
1712 <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>
1713 <tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls.
1715 Note that if an operator isn't overloaded, it won't match. Instead, use
1716 binaryOperator matcher.
1717 Currently it does not match operators such as new delete.
1718 FIXME: figure out why these do not match?
1720 Example matches both operator&lt;&lt;((o &lt;&lt; b), c) and operator&lt;&lt;(o, b)
1721 (matcher = cxxOperatorCallExpr())
1722 ostream &amp;operator&lt;&lt; (ostream &amp;out, int i) { };
1723 ostream &amp;o; int b = 1, c = 1;
1724 o &lt;&lt; b &lt;&lt; c;
1725 See also the binaryOperation() matcher for more-general matching of binary
1726 uses of this AST node.
1727 </pre></td></tr>
1730 <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>
1731 <tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression.
1733 Either the source expression or the destination type can be matched
1734 using has(), but hasDestinationType() is more specific and can be
1735 more readable.
1737 Example matches reinterpret_cast&lt;char*&gt;(&amp;p) in
1738 void* p = reinterpret_cast&lt;char*&gt;(&amp;p);
1739 </pre></td></tr>
1742 <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>
1743 <tr><td colspan="4" class="doc" id="cxxRewrittenBinaryOperator0"><pre>Matches rewritten binary operators
1745 Example matches use of "&lt;":
1746 #include &lt;compare&gt;
1747 struct HasSpaceshipMem {
1748 int a;
1749 constexpr auto operator&lt;=&gt;(const HasSpaceshipMem&amp;) const = default;
1751 void compare() {
1752 HasSpaceshipMem hs1, hs2;
1753 if (hs1 &lt; hs2)
1754 return;
1756 See also the binaryOperation() matcher for more-general matching
1757 of this AST node.
1758 </pre></td></tr>
1761 <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>
1762 <tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression.
1764 See also: hasDestinationType
1765 See also: reinterpretCast
1767 Example:
1768 cxxStaticCastExpr()
1769 matches
1770 static_cast&lt;long&gt;(8)
1772 long eight(static_cast&lt;long&gt;(8));
1773 </pre></td></tr>
1776 <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>
1777 <tr><td colspan="4" class="doc" id="cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions.
1779 Given
1780 std::vector&lt;int&gt; a({ 1, 2, 3 });
1781 std::vector&lt;int&gt; b = { 4, 5 };
1782 int c[] = { 6, 7 };
1783 std::pair&lt;int, int&gt; d = { 8, 9 };
1784 cxxStdInitializerListExpr()
1785 matches "{ 1, 2, 3 }" and "{ 4, 5 }"
1786 </pre></td></tr>
1789 <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>
1790 <tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments
1792 Example: Matches Foo(bar, bar)
1793 Foo h = Foo(bar, bar);
1794 </pre></td></tr>
1797 <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>
1798 <tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions.
1800 Example matches the implicit this expression in "return i".
1801 (matcher = cxxThisExpr())
1802 struct foo {
1803 int i;
1804 int f() { return i; }
1806 </pre></td></tr>
1809 <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>
1810 <tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions.
1812 try { throw 5; } catch(int i) {}
1813 cxxThrowExpr()
1814 matches 'throw 5'
1815 </pre></td></tr>
1818 <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>
1819 <tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements.
1821 try {} catch(int i) {}
1822 cxxTryStmt()
1823 matches 'try {}'
1824 </pre></td></tr>
1827 <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>
1828 <tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions.
1830 Example matches T(t) in return statement of f
1831 (matcher = cxxUnresolvedConstructExpr())
1832 template &lt;typename T&gt;
1833 void f(const T&amp; t) { return T(t); }
1834 </pre></td></tr>
1837 <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>
1838 <tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations.
1840 Example matches x in if (x)
1841 bool x;
1842 if (x) {}
1843 </pre></td></tr>
1845 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('dependentScopeDeclRefExpr0')"><a name="dependentScopeDeclRefExpr0Anchor">dependentScopeDeclRefExpr</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentScopeDeclRefExpr.html">DependentScopeDeclRefExpr</a>&gt;...</td></tr>
1846 <tr><td colspan="4" class="doc" id="dependentScopeDeclRefExpr0"><pre>Matches expressions that refer to dependent scope declarations.
1848 Example matches T::v
1849 template <class T> class X : T { void f() { T::v; } };
1850 </pre></td></tr>
1852 <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>
1853 <tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements.
1855 Given
1856 int a;
1857 declStmt()
1858 matches 'int a'.
1859 </pre></td></tr>
1862 <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>
1863 <tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements.
1865 Given
1866 switch(a) { case 42: break; default: break; }
1867 defaultStmt()
1868 matches 'default:'.
1869 </pre></td></tr>
1872 <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>
1873 <tr><td colspan="4" class="doc" id="dependentCoawaitExpr0"><pre>Matches co_await expressions where the type of the promise is dependent
1874 </pre></td></tr>
1877 <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>
1878 <tr><td colspan="4" class="doc" id="designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99 6.7.8].
1880 Example: Matches { [2].y = 1.0, [0].x = 1.0 }
1881 point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
1882 </pre></td></tr>
1885 <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>
1886 <tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements.
1888 Given
1889 do {} while (true);
1890 doStmt()
1891 matches 'do {} while(true)'
1892 </pre></td></tr>
1895 <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>
1896 <tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions.
1898 Matches any cast expression written in user code, whether it be a
1899 C-style cast, a functional-style cast, or a keyword cast.
1901 Does not match implicit conversions.
1903 Note: the name "explicitCast" is chosen to match Clang's terminology, as
1904 Clang uses the term "cast" to apply to implicit conversions as well as to
1905 actual cast expressions.
1907 See also: hasDestinationType.
1909 Example: matches all five of the casts in
1910 int((int)(reinterpret_cast&lt;int&gt;(static_cast&lt;int&gt;(const_cast&lt;int&gt;(42)))))
1911 but does not match the implicit conversion in
1912 long ell = 42;
1913 </pre></td></tr>
1916 <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>
1917 <tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions.
1919 Example matches x()
1920 void f() { x(); }
1921 </pre></td></tr>
1924 <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>
1925 <tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end
1926 of the sub-expression's evaluation.
1928 Example matches std::string()
1929 const std::string str = std::string();
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('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>
1934 <tr><td colspan="4" class="doc" id="fixedPointLiteral0"><pre>Matches fixed point literals
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('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>
1939 <tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes / encodings, e.g.
1940 1.0, 1.0f, 1.0L and 1e10.
1942 Does not match implicit conversions such as
1943 float a = 10;
1944 </pre></td></tr>
1947 <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>
1948 <tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements.
1950 Example matches 'for (;;) {}'
1951 for (;;) {}
1952 int i[] = {1, 2, 3}; for (auto a : i);
1953 </pre></td></tr>
1956 <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>
1957 <tr><td colspan="4" class="doc" id="genericSelectionExpr0"><pre>Matches C11 _Generic expression.
1958 </pre></td></tr>
1961 <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>
1962 <tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression.
1963 </pre></td></tr>
1966 <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>
1967 <tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements.
1969 Given
1970 goto FOO;
1971 FOO: bar();
1972 gotoStmt()
1973 matches 'goto FOO'
1974 </pre></td></tr>
1977 <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>
1978 <tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements.
1980 Example matches 'if (x) {}'
1981 if (x) {}
1982 </pre></td></tr>
1985 <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>
1986 <tr><td colspan="4" class="doc" id="imaginaryLiteral0"><pre>Matches imaginary literals, which are based on integer and floating
1987 point literals e.g.: 1i, 1.0i
1988 </pre></td></tr>
1991 <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>
1992 <tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST.
1994 This matches many different places, including function call return value
1995 eliding, as well as any type conversions.
1996 </pre></td></tr>
1999 <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>
2000 <tr><td colspan="4" class="doc" id="implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions.
2002 Given
2003 point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 };
2004 implicitValueInitExpr()
2005 matches "[0].y" (implicitly)
2006 </pre></td></tr>
2009 <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>
2010 <tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions.
2012 Given
2013 int a[] = { 1, 2 };
2014 struct B { int x, y; };
2015 B b = { 5, 6 };
2016 initListExpr()
2017 matches "{ 1, 2 }" and "{ 5, 6 }"
2018 </pre></td></tr>
2021 <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>
2022 <tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes / encodings, e.g.
2023 1, 1L, 0x1 and 1U.
2025 Does not match character-encoded integers such as L'a'.
2026 </pre></td></tr>
2029 <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>
2030 <tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements.
2032 Given
2033 goto FOO;
2034 FOO: bar();
2035 labelStmt()
2036 matches 'FOO:'
2037 </pre></td></tr>
2040 <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>
2041 <tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions.
2043 Example matches [&amp;](){return 5;}
2044 [&amp;](){return 5;}
2045 </pre></td></tr>
2048 <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>
2049 <tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized.
2051 Example: Given
2052 struct T {void func();};
2053 T f();
2054 void g(T);
2055 materializeTemporaryExpr() matches 'f()' in these statements
2056 T u(f());
2057 g(f());
2058 f().func();
2059 but does not match
2060 f();
2061 </pre></td></tr>
2064 <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>
2065 <tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions.
2067 Given
2068 class Y {
2069 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
2070 int a; static int b;
2072 memberExpr()
2073 matches this-&gt;x, x, y.x, a, this-&gt;b
2074 </pre></td></tr>
2077 <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>
2078 <tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements.
2080 foo();;
2081 nullStmt()
2082 matches the second ';'
2083 </pre></td></tr>
2086 <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>
2087 <tr><td colspan="4" class="doc" id="objcCatchStmt0"><pre>Matches Objective-C @catch statements.
2089 Example matches @catch
2090 @try {}
2091 @catch (...) {}
2092 </pre></td></tr>
2095 <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>
2096 <tr><td colspan="4" class="doc" id="objcFinallyStmt0"><pre>Matches Objective-C @finally statements.
2098 Example matches @finally
2099 @try {}
2100 @finally {}
2101 </pre></td></tr>
2104 <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>
2105 <tr><td colspan="4" class="doc" id="objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar.
2107 Example: matches "a" in "init" method:
2108 @implementation A {
2109 NSString *a;
2111 - (void) init {
2112 a = @"hello";
2114 </pre></td></tr>
2117 <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>
2118 <tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions.
2120 The innermost message send invokes the "alloc" class method on the
2121 NSString class, while the outermost message send invokes the
2122 "initWithString" instance method on the object returned from
2123 NSString's "alloc". This matcher should match both message sends.
2124 [[NSString alloc] initWithString:@"Hello"]
2125 </pre></td></tr>
2128 <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>
2129 <tr><td colspan="4" class="doc" id="objcStringLiteral0"><pre>Matches ObjectiveC String literal expressions.
2131 Example matches @"abcd"
2132 NSString *s = @"abcd";
2133 </pre></td></tr>
2136 <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>
2137 <tr><td colspan="4" class="doc" id="objcThrowStmt0"><pre>Matches Objective-C statements.
2139 Example matches @throw obj;
2140 </pre></td></tr>
2143 <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>
2144 <tr><td colspan="4" class="doc" id="objcTryStmt0"><pre>Matches Objective-C @try statements.
2146 Example matches @try
2147 @try {}
2148 @catch (...) {}
2149 </pre></td></tr>
2152 <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>
2153 <tr><td colspan="4" class="doc" id="ompExecutableDirective0"><pre>Matches any ``#pragma omp`` executable directive.
2155 Given
2157 #pragma omp parallel
2158 #pragma omp parallel default(none)
2159 #pragma omp taskyield
2161 ``ompExecutableDirective()`` matches ``omp parallel``,
2162 ``omp parallel default(none)`` and ``omp taskyield``.
2163 </pre></td></tr>
2166 <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>
2167 <tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers
2168 to reference another expressions and can be met
2169 in BinaryConditionalOperators, for example.
2171 Example matches 'a'
2172 (a ?: c) + 42;
2173 </pre></td></tr>
2176 <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>
2177 <tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions.
2179 Example matches (foo() + 1)
2180 int foo() { return 1; }
2181 int a = (foo() + 1);
2182 </pre></td></tr>
2185 <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>
2186 <tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions.
2187 ParenListExprs don't have a predefined type and are used for late parsing.
2188 In the final AST, they can be met in template declarations.
2190 Given
2191 template&lt;typename T&gt; class X {
2192 void f() {
2193 X x(*this);
2194 int a = 0, b = 1; int i = (a, b);
2197 parenListExpr() matches "*this" but NOT matches (a, b) because (a, b)
2198 has a predefined type and is a ParenExpr, not a ParenListExpr.
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('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>
2203 <tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2].
2205 Example: Matches __func__
2206 printf("%s", __func__);
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('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>
2211 <tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements.
2213 Given
2214 return 1;
2215 returnStmt()
2216 matches 'return 1'
2217 </pre></td></tr>
2220 <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>
2221 <tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements.
2223 Given
2224 { ++a; }
2225 stmt()
2226 matches both the compound statement '{ ++a; }' and '++a'.
2227 </pre></td></tr>
2230 <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>
2231 <tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension).
2233 Example match: ({ int X = 4; X; })
2234 int C = ({ int X = 4; X; });
2235 </pre></td></tr>
2238 <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>
2239 <tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals).
2241 Example matches "abcd", L"abcd"
2242 char *s = "abcd";
2243 wchar_t *ws = L"abcd";
2244 </pre></td></tr>
2247 <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>
2248 <tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters.
2250 Given
2251 template &lt;int N&gt;
2252 struct A { static const int n = N; };
2253 struct B : public A&lt;42&gt; {};
2254 substNonTypeTemplateParmExpr()
2255 matches "N" in the right-hand side of "static const int n = N;"
2256 </pre></td></tr>
2259 <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>
2260 <tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements.
2262 Given
2263 switch(a) { case 42: break; default: break; }
2264 switchCase()
2265 matches 'case 42:' and 'default:'.
2266 </pre></td></tr>
2269 <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>
2270 <tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements.
2272 Given
2273 switch(a) { case 42: break; default: break; }
2274 switchStmt()
2275 matches 'switch(a)'.
2276 </pre></td></tr>
2279 <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>
2280 <tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
2282 Given
2283 Foo x = bar;
2284 int y = sizeof(x) + alignof(x);
2285 unaryExprOrTypeTraitExpr()
2286 matches sizeof(x) and alignof(x)
2287 </pre></td></tr>
2290 <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>
2291 <tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions.
2293 Example matches !a
2294 !a || b
2295 </pre></td></tr>
2298 <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>
2299 <tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing
2300 but could not be resolved to a specific declaration.
2302 Given
2303 template&lt;typename T&gt;
2304 T foo() { T a; return a; }
2305 template&lt;typename T&gt;
2306 void bar() {
2307 foo&lt;T&gt;();
2309 unresolvedLookupExpr()
2310 matches foo&lt;T&gt;() </pre></td></tr>
2313 <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>
2314 <tr><td colspan="4" class="doc" id="unresolvedMemberExpr0"><pre>Matches unresolved member expressions.
2316 Given
2317 struct X {
2318 template &lt;class T&gt; void f();
2319 void g();
2321 template &lt;class T&gt; void h() { X x; x.f&lt;T&gt;(); x.g(); }
2322 unresolvedMemberExpr()
2323 matches x.f&lt;T&gt;
2324 </pre></td></tr>
2327 <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>
2328 <tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call.
2330 Example match: "foo"_suffix
2331 </pre></td></tr>
2334 <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>
2335 <tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements.
2337 Given
2338 while (true) {}
2339 whileStmt()
2340 matches 'while (true) {}'.
2341 </pre></td></tr>
2344 <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>
2345 <tr><td colspan="4" class="doc" id="templateArgumentLoc0"><pre>Matches template arguments (with location info).
2347 Given
2348 template &lt;typename T&gt; struct C {};
2349 C&lt;int&gt; c;
2350 templateArgumentLoc()
2351 matches 'int' in C&lt;int&gt;.
2352 </pre></td></tr>
2355 <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>
2356 <tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments.
2358 Given
2359 template &lt;typename T&gt; struct C {};
2360 C&lt;int&gt; c;
2361 templateArgument()
2362 matches 'int' in C&lt;int&gt;.
2363 </pre></td></tr>
2366 <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>
2367 <tr><td colspan="4" class="doc" id="templateName0"><pre>Matches template name.
2369 Given
2370 template &lt;typename T&gt; class X { };
2371 X&lt;int&gt; xi;
2372 templateName()
2373 matches 'X' in X&lt;int&gt;.
2374 </pre></td></tr>
2377 <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>
2378 <tr><td colspan="4" class="doc" id="elaboratedTypeLoc0"><pre>Matches C or C++ elaborated `TypeLoc`s.
2380 Given
2381 struct s {};
2382 struct s ss;
2383 elaboratedTypeLoc()
2384 matches the `TypeLoc` of the variable declaration of `ss`.
2385 </pre></td></tr>
2388 <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>
2389 <tr><td colspan="4" class="doc" id="pointerTypeLoc0"><pre>Matches pointer `TypeLoc`s.
2391 Given
2392 int* x;
2393 pointerTypeLoc()
2394 matches `int*`.
2395 </pre></td></tr>
2398 <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>
2399 <tr><td colspan="4" class="doc" id="qualifiedTypeLoc0"><pre>Matches `QualifiedTypeLoc`s in the clang AST.
2401 Given
2402 const int x = 0;
2403 qualifiedTypeLoc()
2404 matches `const int`.
2405 </pre></td></tr>
2408 <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>
2409 <tr><td colspan="4" class="doc" id="referenceTypeLoc0"><pre>Matches reference `TypeLoc`s.
2411 Given
2412 int x = 3;
2413 int&amp; l = x;
2414 int&amp;&amp; r = 3;
2415 referenceTypeLoc()
2416 matches `int&amp;` and `int&amp;&amp;`.
2417 </pre></td></tr>
2420 <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>
2421 <tr><td colspan="4" class="doc" id="templateSpecializationTypeLoc0"><pre>Matches template specialization `TypeLoc`s.
2423 Given
2424 template &lt;typename T&gt; class C {};
2425 C&lt;char&gt; var;
2426 varDecl(hasTypeLoc(templateSpecializationTypeLoc(typeLoc())))
2427 matches `C&lt;char&gt; var`.
2428 </pre></td></tr>
2431 <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>
2432 <tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST.
2433 </pre></td></tr>
2436 <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>
2437 <tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays.
2439 Given
2440 int a[] = { 2, 3 };
2441 int b[4];
2442 void f() { int c[a[0]]; }
2443 arrayType()
2444 matches "int a[]", "int b[4]" and "int c[a[0]]";
2445 </pre></td></tr>
2448 <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>
2449 <tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types.
2451 Given
2452 _Atomic(int) i;
2453 atomicType()
2454 matches "_Atomic(int) i"
2455 </pre></td></tr>
2458 <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>
2459 <tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types.
2461 Given:
2462 auto n = 4;
2463 int v[] = { 2, 3 }
2464 for (auto i : v) { }
2465 autoType()
2466 matches "auto n" and "auto i"
2467 </pre></td></tr>
2470 <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>
2471 <tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as
2472 "void (^)(int)".
2474 The pointee is always required to be a FunctionType.
2475 </pre></td></tr>
2478 <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>
2479 <tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types.
2481 Given
2482 struct A {};
2483 A a;
2484 int b;
2485 float c;
2486 bool d;
2487 builtinType()
2488 matches "int b", "float c" and "bool d"
2489 </pre></td></tr>
2492 <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>
2493 <tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types.
2495 Given
2496 _Complex float f;
2497 complexType()
2498 matches "_Complex float f"
2499 </pre></td></tr>
2502 <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>
2503 <tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size.
2505 Given
2506 void() {
2507 int a[2];
2508 int b[] = { 2, 3 };
2509 int c[b[0]];
2511 constantArrayType()
2512 matches "int a[2]"
2513 </pre></td></tr>
2516 <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>
2517 <tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type
2518 Example matches i[] in declaration of f.
2519 (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
2520 Example matches i[1].
2521 (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())))))
2522 void f(int i[]) {
2523 i[1] = 0;
2525 </pre></td></tr>
2528 <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>
2529 <tr><td colspan="4" class="doc" id="decltypeType0"><pre>Matches types nodes representing C++11 decltype(&lt;expr&gt;) types.
2531 Given:
2532 short i = 1;
2533 int j = 42;
2534 decltype(i + j) result = i + j;
2535 decltypeType()
2536 matches "decltype(i + j)"
2537 </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('dependentNameType0')"><a name="dependentNameType0Anchor">dependentNameType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentNameType.html">DependentNameType</a>&gt;...</td></tr>
2540 <tr><td colspan="4" class="doc" id="dependentNameType0"><pre>Matches a dependent name type.
2542 Example matches T::type
2544 template <typename T> struct declToImport {
2545 typedef typename T::type dependent_name;
2547 </pre></td></tr>
2549 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('dependentTemplateSpecializationType0')"><a name="dependentTemplateSpecializationType0Anchor">dependentTemplateSpecializationType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentTemplateSpecializationType.html">DependentTemplateSpecializationType</a>&gt;...</td></tr>
2550 <tr><td colspan="4" class="doc" id="dependentTemplateSpecializationType0"><pre>Matches a dependent template specialization type.
2552 Example matches A<T>::template B<T>
2554 template<typename T> struct A;
2555 template<typename T> struct declToImport {
2556 typename A<T>::template B<T> a;
2558 </pre></td></tr>
2560 <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>
2561 <tr><td colspan="4" class="doc" id="deducedTemplateSpecializationType0"><pre>Matches C++17 deduced template specialization types, e.g. deduced class
2562 template types.
2564 Given
2565 template &lt;typename T&gt;
2566 class C { public: C(T); };
2568 C c(123);
2569 deducedTemplateSpecializationType() matches the type in the declaration
2570 of the variable c.
2571 </pre></td></tr>
2574 <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>
2575 <tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression.
2577 Given
2578 template&lt;typename T, int Size&gt;
2579 class array {
2580 T data[Size];
2582 dependentSizedArrayType()
2583 matches "T data[Size]"
2584 </pre></td></tr>
2587 <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>
2588 <tr><td colspan="4" class="doc" id="dependentSizedExtVectorType0"><pre>Matches C++ extended vector type where either the type or size is
2589 dependent.
2591 Given
2592 template&lt;typename T, int Size&gt;
2593 class vector {
2594 typedef T __attribute__((ext_vector_type(Size))) type;
2596 dependentSizedExtVectorType()
2597 matches "T __attribute__((ext_vector_type(Size)))"
2598 </pre></td></tr>
2601 <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>
2602 <tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a
2603 qualified name.
2605 Given
2606 namespace N {
2607 namespace M {
2608 class D {};
2611 class C {};
2613 class C c;
2614 N::M::D d;
2616 elaboratedType() matches the type of the variable declarations of both
2617 c and d.
2618 </pre></td></tr>
2621 <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>
2622 <tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types.
2624 Given
2625 enum C { Green };
2626 enum class S { Red };
2628 C c;
2629 S s;
2631 enumType() matches the type of the variable declarations of both c and
2633 </pre></td></tr>
2636 <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>
2637 <tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes.
2639 Given
2640 int (*f)(int);
2641 void g();
2642 functionProtoType()
2643 matches "int (*f)(int)" and the type of "g" in C++ mode.
2644 In C mode, "g" is not matched because it does not contain a prototype.
2645 </pre></td></tr>
2648 <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>
2649 <tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes.
2651 Given
2652 int (*f)(int);
2653 void g();
2654 functionType()
2655 matches "int (*f)(int)" and the type of "g".
2656 </pre></td></tr>
2659 <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>
2660 <tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size.
2662 Given
2663 int a[] = { 2, 3 };
2664 int b[42];
2665 void f(int c[]) { int d[a[0]]; };
2666 incompleteArrayType()
2667 matches "int a[]" and "int c[]"
2668 </pre></td></tr>
2671 <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>
2672 <tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types.
2674 Example matches S s, but not S&lt;T&gt; s.
2675 (matcher = parmVarDecl(hasType(injectedClassNameType())))
2676 template &lt;typename T&gt; struct S {
2677 void f(S s);
2678 void g(S&lt;T&gt; s);
2680 </pre></td></tr>
2683 <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>
2684 <tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types.
2686 Given:
2687 int *a;
2688 int &amp;b = *a;
2689 int &amp;&amp;c = 1;
2690 auto &amp;d = b;
2691 auto &amp;&amp;e = c;
2692 auto &amp;&amp;f = 2;
2693 int g = 5;
2695 lValueReferenceType() matches the types of b, d, and e. e is
2696 matched since the type is deduced as int&amp; by reference collapsing rules.
2697 </pre></td></tr>
2700 <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>
2701 <tr><td colspan="4" class="doc" id="macroQualifiedType0"><pre>Matches qualified types when the qualifier is applied via a macro.
2703 Given
2704 #define CDECL __attribute__((cdecl))
2705 typedef void (CDECL *X)();
2706 typedef void (__attribute__((cdecl)) *Y)();
2707 macroQualifiedType()
2708 matches the type of the typedef declaration of X but not Y.
2709 </pre></td></tr>
2712 <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>
2713 <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types.
2714 Given
2715 struct A { int i; }
2716 A::* ptr = A::i;
2717 memberPointerType()
2718 matches "A::* ptr"
2719 </pre></td></tr>
2722 <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>
2723 <tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from
2724 a pointer type, despite being syntactically similar.
2726 Given
2727 int *a;
2729 @interface Foo
2730 @end
2731 Foo *f;
2732 pointerType()
2733 matches "Foo *f", but does not match "int *a".
2734 </pre></td></tr>
2737 <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>
2738 <tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes.
2740 Given
2741 int (*ptr_to_array)[4];
2742 int *array_of_ptrs[4];
2744 varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not
2745 array_of_ptrs.
2746 </pre></td></tr>
2749 <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>
2750 <tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer
2751 types.
2753 Given
2754 int *a;
2755 int &amp;b = *a;
2756 int c = 5;
2758 @interface Foo
2759 @end
2760 Foo *f;
2761 pointerType()
2762 matches "int *a", but does not match "Foo *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('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>
2767 <tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types.
2769 Given:
2770 int *a;
2771 int &amp;b = *a;
2772 int &amp;&amp;c = 1;
2773 auto &amp;d = b;
2774 auto &amp;&amp;e = c;
2775 auto &amp;&amp;f = 2;
2776 int g = 5;
2778 rValueReferenceType() matches the types of c and f. e is not
2779 matched as it is deduced to int&amp; by reference collapsing rules.
2780 </pre></td></tr>
2783 <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>
2784 <tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes).
2786 Given
2787 class C {};
2788 struct S {};
2790 C c;
2791 S s;
2793 recordType() matches the type of the variable declarations of both c
2794 and s.
2795 </pre></td></tr>
2798 <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>
2799 <tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types.
2801 Given
2802 int *a;
2803 int &amp;b = *a;
2804 int &amp;&amp;c = 1;
2805 auto &amp;d = b;
2806 auto &amp;&amp;e = c;
2807 auto &amp;&amp;f = 2;
2808 int g = 5;
2810 referenceType() matches the types of b, c, d, e, and f.
2811 </pre></td></tr>
2814 <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>
2815 <tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a
2816 template type parameter.
2818 Given
2819 template &lt;typename T&gt;
2820 void F(T t) {
2821 int i = 1 + t;
2824 substTemplateTypeParmType() matches the type of 't' but not '1'
2825 </pre></td></tr>
2828 <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>
2829 <tr><td colspan="4" class="doc" id="tagType0"><pre>Matches tag types (record and enum types).
2831 Given
2832 enum E {};
2833 class C {};
2835 E e;
2836 C c;
2838 tagType() matches the type of the variable declarations of both e
2839 and c.
2840 </pre></td></tr>
2843 <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>
2844 <tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types.
2846 Given
2847 template &lt;typename T&gt;
2848 class C { };
2850 template class C&lt;int&gt;; // A
2851 C&lt;char&gt; var; // B
2853 templateSpecializationType() matches the type of the explicit
2854 instantiation in A and the type of the variable declaration in B.
2855 </pre></td></tr>
2858 <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>
2859 <tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types.
2861 Example matches T, but not int.
2862 (matcher = templateTypeParmType())
2863 template &lt;typename T&gt; void f(int i);
2864 </pre></td></tr>
2867 <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>
2868 <tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST.
2869 </pre></td></tr>
2872 <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>
2873 <tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types.
2875 Given
2876 typedef int X;
2877 typedefType()
2878 matches "typedef int X"
2879 </pre></td></tr>
2882 <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>
2883 <tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations.
2885 Given:
2886 typedef __underlying_type(T) type;
2887 unaryTransformType()
2888 matches "__underlying_type(T)"
2889 </pre></td></tr>
2892 <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>
2893 <tr><td colspan="4" class="doc" id="usingType0"><pre>Matches types specified through a using declaration.
2895 Given
2896 namespace a { struct S {}; }
2897 using a::S;
2898 S s;
2900 usingType() matches the type of the variable declaration of s.
2901 </pre></td></tr>
2904 <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>
2905 <tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an
2906 integer-constant-expression.
2908 Given
2909 void f() {
2910 int a[] = { 2, 3 }
2911 int b[42];
2912 int c[a[0]];
2914 variableArrayType()
2915 matches "int c[a[0]]"
2916 </pre></td></tr>
2918 <!--END_DECL_MATCHERS -->
2919 </table>
2921 <!-- ======================================================================= -->
2922 <h2 id="narrowing-matchers">Narrowing Matchers</h2>
2923 <!-- ======================================================================= -->
2925 <p>Narrowing matchers match certain attributes on the current node, thus
2926 narrowing down the set of nodes of the current type to match on.</p>
2928 <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless)
2929 which allow users to create more powerful match expressions.</p>
2931 <table>
2932 <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
2933 <!-- START_NARROWING_MATCHERS -->
2935 <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>
2936 <tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match.
2938 Usable as: Any Matcher
2939 </pre></td></tr>
2942 <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>
2943 <tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches.
2945 Usable as: Any Matcher
2946 </pre></td></tr>
2949 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr>
2950 <tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node.
2952 Useful when another matcher requires a child matcher, but there's no
2953 additional constraint. This will often be used with an explicit conversion
2954 to an internal::Matcher&lt;&gt; type such as TypeMatcher.
2956 Example: DeclarationMatcher(anything()) matches all declarations, e.g.,
2957 "int* p" and "void f()" in
2958 int* p;
2959 void f();
2961 Usable as: Any Matcher
2962 </pre></td></tr>
2965 <tr><td><em>unspecified</em></td><td class="name" onclick="toggle('mapAnyOf0')"><a name="mapAnyOf0Anchor">mapAnyOf</a></td><td>nodeMatcherFunction...</td></tr>
2966 <tr><td colspan="4" class="doc" id="mapAnyOf0"><pre>Matches any of the NodeMatchers with InnerMatchers nested within
2968 Given
2969 if (true);
2970 for (; true; );
2971 with the matcher
2972 mapAnyOf(ifStmt, forStmt).with(
2973 hasCondition(cxxBoolLiteralExpr(equals(true)))
2974 ).bind("trueCond")
2975 matches the if and the for. It is equivalent to:
2976 auto trueCond = hasCondition(cxxBoolLiteralExpr(equals(true)));
2977 anyOf(
2978 ifStmt(trueCond).bind("trueCond"),
2979 forStmt(trueCond).bind("trueCond")
2982 The with() chain-call accepts zero or more matchers which are combined
2983 as-if with allOf() in each of the node matchers.
2984 Usable as: Any Matcher
2985 </pre></td></tr>
2988 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher&lt;*&gt;</td></tr>
2989 <tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match.
2991 Example matches Y (matcher = cxxRecordDecl(unless(hasName("X"))))
2992 class X {};
2993 class Y {};
2995 Usable as: Any Matcher
2996 </pre></td></tr>
2999 <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>
3000 <tr><td colspan="4" class="doc" id="isImplicit1"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
3001 implicit default/copy constructors).
3002 </pre></td></tr>
3005 <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>
3006 <tr><td colspan="4" class="doc" id="hasAnyOperatorName0"><pre>Matches operator expressions (binary or unary) that have any of the
3007 specified names.
3009 hasAnyOperatorName("+", "-")
3010 Is equivalent to
3011 anyOf(hasOperatorName("+"), hasOperatorName("-"))
3012 </pre></td></tr>
3015 <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>
3016 <tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions and fold expressions
3017 (binary or unary).
3019 Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
3020 !(a || b)
3022 Example matches `(0 + ... + args)`
3023 (matcher = cxxFoldExpr(hasOperatorName("+")))
3024 template &lt;typename... Args&gt;
3025 auto sum(Args... args) {
3026 return (0 + ... + args);
3028 </pre></td></tr>
3031 <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>
3032 <tr><td colspan="4" class="doc" id="isAssignmentOperator0"><pre>Matches all kinds of assignment operators.
3034 Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3035 if (a == b)
3036 a += b;
3038 Example 2: matches s1 = s2
3039 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3040 struct S { S&amp; operator=(const S&amp;); };
3041 void x() { S s1, s2; s1 = s2; }
3042 </pre></td></tr>
3045 <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>
3046 <tr><td colspan="4" class="doc" id="isComparisonOperator0"><pre>Matches comparison operators.
3048 Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3049 if (a == b)
3050 a += b;
3052 Example 2: matches s1 &lt; s2
3053 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3054 struct S { bool operator&lt;(const S&amp; other); };
3055 void x(S s1, S s2) { bool b1 = s1 &lt; s2; }
3056 </pre></td></tr>
3059 <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>
3060 <tr><td colspan="4" class="doc" id="isPrivate1"><pre>Matches private C++ declarations and C++ base specifers that specify private
3061 inheritance.
3063 Examples:
3064 class C {
3065 public: int a;
3066 protected: int b;
3067 private: int c; // fieldDecl(isPrivate()) matches 'c'
3070 struct Base {};
3071 struct Derived1 : private Base {}; // matches 'Base'
3072 class Derived2 : Base {}; // matches 'Base'
3073 </pre></td></tr>
3076 <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>
3077 <tr><td colspan="4" class="doc" id="isProtected1"><pre>Matches protected C++ declarations and C++ base specifers that specify
3078 protected inheritance.
3080 Examples:
3081 class C {
3082 public: int a;
3083 protected: int b; // fieldDecl(isProtected()) matches 'b'
3084 private: int c;
3087 class Base {};
3088 class Derived : protected Base {}; // matches 'Base'
3089 </pre></td></tr>
3092 <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>
3093 <tr><td colspan="4" class="doc" id="isPublic1"><pre>Matches public C++ declarations and C++ base specifers that specify public
3094 inheritance.
3096 Examples:
3097 class C {
3098 public: int a; // fieldDecl(isPublic()) matches 'a'
3099 protected: int b;
3100 private: int c;
3103 class Base {};
3104 class Derived1 : public Base {}; // matches 'Base'
3105 struct Derived2 : Base {}; // matches 'Base'
3106 </pre></td></tr>
3109 <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>
3110 <tr><td colspan="4" class="doc" id="isVirtual1"><pre>Matches declarations of virtual methods and C++ base specifers that specify
3111 virtual inheritance.
3113 Example:
3114 class A {
3115 public:
3116 virtual void x(); // matches x
3119 Example:
3120 class Base {};
3121 class DirectlyDerived : virtual Base {}; // matches Base
3122 class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
3124 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;
3125 </pre></td></tr>
3128 <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>
3129 <tr><td colspan="4" class="doc" id="equals5"><pre></pre></td></tr>
3132 <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>
3133 <tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value of type ValueT.
3135 Given
3136 f('false, 3.14, 42);
3137 characterLiteral(equals(0))
3138 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
3139 match false
3140 floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
3141 match 3.14
3142 integerLiteral(equals(42))
3143 matches 42
3145 Note that you cannot directly match a negative numeric literal because the
3146 minus sign is not part of the literal: It is a unary operator whose operand
3147 is the positive numeric literal. Instead, you must use a unaryOperator()
3148 matcher to match the minus sign:
3150 unaryOperator(hasOperatorName("-"),
3151 hasUnaryOperand(integerLiteral(equals(13))))
3153 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;,
3154 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;
3155 </pre></td></tr>
3158 <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>
3159 <tr><td colspan="4" class="doc" id="equals11"><pre></pre></td></tr>
3162 <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>
3163 <tr><td colspan="4" class="doc" id="equals8"><pre></pre></td></tr>
3166 <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>
3167 <tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler.
3169 Given
3170 try {
3171 // ...
3172 } catch (int) {
3173 // ...
3174 } catch (...) {
3175 // ...
3177 cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
3178 </pre></td></tr>
3181 <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>
3182 <tr><td colspan="4" class="doc" id="argumentCountAtLeast1"><pre>Checks that a call expression or a constructor call expression has at least
3183 the specified number of arguments (including absent default arguments).
3185 Example matches f(0, 0) and g(0, 0, 0)
3186 (matcher = callExpr(argumentCountAtLeast(2)))
3187 void f(int x, int y);
3188 void g(int x, int y, int z);
3189 f(0, 0);
3190 g(0, 0, 0);
3191 </pre></td></tr>
3194 <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>
3195 <tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has
3196 a specific number of arguments (including absent default arguments).
3198 Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
3199 void f(int x, int y);
3200 f(0, 0);
3201 </pre></td></tr>
3204 <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>
3205 <tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization.
3206 </pre></td></tr>
3209 <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>
3210 <tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires
3211 zero initialization.
3213 Given
3214 void foo() {
3215 struct point { double x; double y; };
3216 point pt[2] = { { 1.0, 2.0 } };
3218 initListExpr(has(cxxConstructExpr(requiresZeroInitialization()))
3219 will match the implicit array filler for pt[1].
3220 </pre></td></tr>
3223 <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>
3224 <tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors.
3226 Given
3227 struct S {
3228 S(); // #1
3229 S(const S &amp;); // #2
3230 S(S &amp;&amp;); // #3
3232 cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
3233 </pre></td></tr>
3236 <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>
3237 <tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors.
3239 Given
3240 struct S {
3241 S(); // #1
3242 S(const S &amp;); // #2
3243 S(S &amp;&amp;); // #3
3245 cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
3246 </pre></td></tr>
3249 <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>
3250 <tr><td colspan="4" class="doc" id="isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor.
3252 Given
3253 struct S {
3254 S(); // #1
3255 S(int) {} // #2
3256 S(S &amp;&amp;) : S() {} // #3
3258 S::S() : S(0) {} // #4
3259 cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not
3260 #1 or #2.
3261 </pre></td></tr>
3264 <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>
3265 <tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor, conversion function, and deduction guide declarations
3266 that have an explicit specifier if this explicit specifier is resolved to
3267 true.
3269 Given
3270 template&lt;bool b&gt;
3271 struct S {
3272 S(int); // #1
3273 explicit S(double); // #2
3274 operator int(); // #3
3275 explicit operator bool(); // #4
3276 explicit(false) S(bool) // # 7
3277 explicit(true) S(char) // # 8
3278 explicit(b) S(S) // # 9
3280 S(int) -&gt; S&lt;true&gt; // #5
3281 explicit S(double) -&gt; S&lt;false&gt; // #6
3282 cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
3283 cxxConversionDecl(isExplicit()) will match #4, but not #3.
3284 cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
3285 </pre></td></tr>
3288 <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>
3289 <tr><td colspan="4" class="doc" id="isInheritingConstructor0"><pre></pre></td></tr>
3292 <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>
3293 <tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors.
3295 Given
3296 struct S {
3297 S(); // #1
3298 S(const S &amp;); // #2
3299 S(S &amp;&amp;); // #3
3301 cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
3302 </pre></td></tr>
3305 <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>
3306 <tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor, conversion function, and deduction guide declarations
3307 that have an explicit specifier if this explicit specifier is resolved to
3308 true.
3310 Given
3311 template&lt;bool b&gt;
3312 struct S {
3313 S(int); // #1
3314 explicit S(double); // #2
3315 operator int(); // #3
3316 explicit operator bool(); // #4
3317 explicit(false) S(bool) // # 7
3318 explicit(true) S(char) // # 8
3319 explicit(b) S(S) // # 9
3321 S(int) -&gt; S&lt;true&gt; // #5
3322 explicit S(double) -&gt; S&lt;false&gt; // #6
3323 cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
3324 cxxConversionDecl(isExplicit()) will match #4, but not #3.
3325 cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
3326 </pre></td></tr>
3329 <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>
3330 <tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as
3331 opposed to a member.
3333 Given
3334 struct B {};
3335 struct D : B {
3336 int I;
3337 D(int i) : I(i) {}
3339 struct E : B {
3340 E() : B() {}
3342 cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
3343 will match E(), but not match D(int).
3344 </pre></td></tr>
3347 <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>
3348 <tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as
3349 opposed to a base.
3351 Given
3352 struct B {};
3353 struct D : B {
3354 int I;
3355 D(int i) : I(i) {}
3357 struct E : B {
3358 E() : B() {}
3360 cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
3361 will match D(int), but not match E().
3362 </pre></td></tr>
3365 <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>
3366 <tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in
3367 code (as opposed to implicitly added by the compiler).
3369 Given
3370 struct Foo {
3371 Foo() { }
3372 Foo(int) : foo_("A") { }
3373 string foo_;
3375 cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
3376 will match Foo(int), but not Foo()
3377 </pre></td></tr>
3380 <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>
3381 <tr><td colspan="4" class="doc" id="isExplicit2"><pre>Matches constructor, conversion function, and deduction guide declarations
3382 that have an explicit specifier if this explicit specifier is resolved to
3383 true.
3385 Given
3386 template&lt;bool b&gt;
3387 struct S {
3388 S(int); // #1
3389 explicit S(double); // #2
3390 operator int(); // #3
3391 explicit operator bool(); // #4
3392 explicit(false) S(bool) // # 7
3393 explicit(true) S(char) // # 8
3394 explicit(b) S(S) // # 9
3396 S(int) -&gt; S&lt;true&gt; // #5
3397 explicit S(double) -&gt; S&lt;false&gt; // #6
3398 cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
3399 cxxConversionDecl(isExplicit()) will match #4, but not #3.
3400 cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
3401 </pre></td></tr>
3404 <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>
3405 <tr><td colspan="4" class="doc" id="hasMemberName0"><pre>Matches template-dependent, but known, member names.
3407 In template declarations, dependent members are not resolved and so can
3408 not be matched to particular named declarations.
3410 This matcher allows to match on the known name of members.
3412 Given
3413 template &lt;typename T&gt;
3414 struct S {
3415 void mem();
3417 template &lt;typename T&gt;
3418 void x() {
3419 S&lt;T&gt; s;
3420 s.mem();
3422 cxxDependentScopeMemberExpr(hasMemberName("mem")) matches `s.mem()`
3423 </pre></td></tr>
3426 <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>
3427 <tr><td colspan="4" class="doc" id="isArrow2"><pre>Matches member expressions that are called with '-&gt;' as opposed
3428 to '.'.
3430 Member calls on the implicit this pointer match as called with '-&gt;'.
3432 Given
3433 class Y {
3434 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
3435 template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
3436 int a;
3437 static int b;
3439 template &lt;class T&gt;
3440 class Z {
3441 void x() { this-&gt;m; }
3443 memberExpr(isArrow())
3444 matches this-&gt;x, x, y.x, a, this-&gt;b
3445 cxxDependentScopeMemberExpr(isArrow())
3446 matches this-&gt;m
3447 unresolvedMemberExpr(isArrow())
3448 matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
3449 </pre></td></tr>
3452 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DependentScopeDeclRefExpr.html">DependentScopeDeclRefExpr</a>&gt;</td><td class="name" onclick="toggle('hasDependentName0')"><a name="hasDependentName0Anchor">hasDependentName</a></td><td>std::string N</td></tr>
3453 <tr><td colspan="4" class="doc" id="hasDependentName0"><pre>Matches the dependent name of a DependentScopeDeclRefExpr.
3455 Matches the dependent name of a DependentScopeDeclRefExpr
3457 Given:
3459 template &lt;class T&lt; class X : T { void f() { T::v; } };
3461 dependentScopeDeclRefExpr(hasDependentName("v")) matches `T::v`
3462 </pre></td></tr>
3465 <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>
3466 <tr><td colspan="4" class="doc" id="memberHasSameNameAsBoundNode0"><pre>Matches template-dependent, but known, member names against an already-bound
3467 node
3469 In template declarations, dependent members are not resolved and so can
3470 not be matched to particular named declarations.
3472 This matcher allows to match on the name of already-bound VarDecl, FieldDecl
3473 and CXXMethodDecl nodes.
3475 Given
3476 template &lt;typename T&gt;
3477 struct S {
3478 void mem();
3480 template &lt;typename T&gt;
3481 void x() {
3482 S&lt;T&gt; s;
3483 s.mem();
3485 The matcher
3486 @code
3487 cxxDependentScopeMemberExpr(
3488 hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
3489 hasDeclaration(classTemplateDecl(has(cxxRecordDecl(has(
3490 cxxMethodDecl(hasName("mem")).bind("templMem")
3491 )))))
3492 )))),
3493 memberHasSameNameAsBoundNode("templMem")
3495 @endcode
3496 first matches and binds the @c mem member of the @c S template, then
3497 compares its name to the usage in @c s.mem() in the @c x function template
3498 </pre></td></tr>
3501 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>&gt;</td><td class="name" onclick="toggle('hasOperatorName3')"><a name="hasOperatorName3Anchor">hasOperatorName</a></td><td>std::string Name</td></tr>
3502 <tr><td colspan="4" class="doc" id="hasOperatorName3"><pre>Matches the operator Name of operator expressions and fold expressions
3503 (binary or unary).
3505 Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
3506 !(a || b)
3508 Example matches `(0 + ... + args)`
3509 (matcher = cxxFoldExpr(hasOperatorName("+")))
3510 template &lt;typename... Args&gt;
3511 auto sum(Args... args) {
3512 return (0 + ... + args);
3514 </pre></td></tr>
3517 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>&gt;</td><td class="name" onclick="toggle('isBinaryFold0')"><a name="isBinaryFold0Anchor">isBinaryFold</a></td><td></td></tr>
3518 <tr><td colspan="4" class="doc" id="isBinaryFold0"><pre>Matches binary fold expressions, i.e. fold expressions with an initializer.
3520 Example matches `(0 + ... + args)`
3521 (matcher = cxxFoldExpr(isBinaryFold()))
3522 template &lt;typename... Args&gt;
3523 auto sum(Args... args) {
3524 return (0 + ... + args);
3527 template &lt;typename... Args&gt;
3528 auto multiply(Args... args) {
3529 return (args * ...);
3531 </pre></td></tr>
3534 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>&gt;</td><td class="name" onclick="toggle('isLeftFold0')"><a name="isLeftFold0Anchor">isLeftFold</a></td><td></td></tr>
3535 <tr><td colspan="4" class="doc" id="isLeftFold0"><pre>Matches left-folding fold expressions.
3537 Example matches `(0 + ... + args)`
3538 (matcher = cxxFoldExpr(isLeftFold()))
3539 template &lt;typename... Args&gt;
3540 auto sum(Args... args) {
3541 return (0 + ... + args);
3544 template &lt;typename... Args&gt;
3545 auto multiply(Args... args) {
3546 return (args * ... * 1);
3548 </pre></td></tr>
3551 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>&gt;</td><td class="name" onclick="toggle('isRightFold0')"><a name="isRightFold0Anchor">isRightFold</a></td><td></td></tr>
3552 <tr><td colspan="4" class="doc" id="isRightFold0"><pre>Matches right-folding fold expressions.
3554 Example matches `(args * ... * 1)`
3555 (matcher = cxxFoldExpr(isRightFold()))
3556 template &lt;typename... Args&gt;
3557 auto sum(Args... args) {
3558 return (0 + ... + args);
3561 template &lt;typename... Args&gt;
3562 auto multiply(Args... args) {
3563 return (args * ... * 1);
3565 </pre></td></tr>
3568 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>&gt;</td><td class="name" onclick="toggle('isUnaryFold0')"><a name="isUnaryFold0Anchor">isUnaryFold</a></td><td></td></tr>
3569 <tr><td colspan="4" class="doc" id="isUnaryFold0"><pre>Matches unary fold expressions, i.e. fold expressions without an
3570 initializer.
3572 Example matches `(args * ...)`
3573 (matcher = cxxFoldExpr(isUnaryFold()))
3574 template &lt;typename... Args&gt;
3575 auto sum(Args... args) {
3576 return (0 + ... + args);
3579 template &lt;typename... Args&gt;
3580 auto multiply(Args... args) {
3581 return (args * ...);
3583 </pre></td></tr>
3586 <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>
3587 <tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const.
3589 Given
3590 struct A {
3591 void foo() const;
3592 void bar();
3595 cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
3596 </pre></td></tr>
3599 <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>
3600 <tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment
3601 operator.
3603 Given
3604 struct A {
3605 A &amp;operator=(const A &amp;);
3606 A &amp;operator=(A &amp;&amp;);
3609 cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not
3610 the second one.
3611 </pre></td></tr>
3614 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>&gt;</td><td class="name" onclick="toggle('isExplicitObjectMemberFunction0')"><a name="isExplicitObjectMemberFunction0Anchor">isExplicitObjectMemberFunction</a></td><td></td></tr>
3615 <tr><td colspan="4" class="doc" id="isExplicitObjectMemberFunction0"><pre>Matches if the given method declaration declares a member function with an
3616 explicit object parameter.
3618 Given
3619 struct A {
3620 int operator-(this A, int);
3621 void fun(this A &amp;&amp;self);
3622 static int operator()(int);
3623 int operator+(int);
3626 cxxMethodDecl(isExplicitObjectMemberFunction()) matches the first two
3627 methods but not the last two.
3628 </pre></td></tr>
3631 <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>
3632 <tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final.
3634 Given:
3635 class A final {};
3637 struct B {
3638 virtual void f();
3641 struct C : B {
3642 void f() final;
3644 matches A and C::f, but not B, C, or B::f
3645 </pre></td></tr>
3648 <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>
3649 <tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment
3650 operator.
3652 Given
3653 struct A {
3654 A &amp;operator=(const A &amp;);
3655 A &amp;operator=(A &amp;&amp;);
3658 cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not
3659 the first one.
3660 </pre></td></tr>
3663 <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>
3664 <tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method.
3666 Given
3667 class A {
3668 public:
3669 virtual void x();
3671 class B : public A {
3672 public:
3673 virtual void x();
3675 matches B::x
3676 </pre></td></tr>
3679 <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>
3680 <tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure.
3682 Given
3683 class A {
3684 public:
3685 virtual void x() = 0;
3687 matches A::x
3688 </pre></td></tr>
3691 <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>
3692 <tr><td colspan="4" class="doc" id="isUserProvided0"><pre>Matches method declarations that are user-provided.
3694 Given
3695 struct S {
3696 S(); // #1
3697 S(const S &amp;) = default; // #2
3698 S(S &amp;&amp;) = delete; // #3
3700 cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
3701 </pre></td></tr>
3704 <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>
3705 <tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches declarations of virtual methods and C++ base specifers that specify
3706 virtual inheritance.
3708 Example:
3709 class A {
3710 public:
3711 virtual void x(); // matches x
3714 Example:
3715 class Base {};
3716 class DirectlyDerived : virtual Base {}; // matches Base
3717 class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
3719 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;
3720 </pre></td></tr>
3723 <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>
3724 <tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual".
3726 Given
3727 class A {
3728 public:
3729 virtual void x();
3731 class B : public A {
3732 public:
3733 void x();
3735 matches A::x but not B::x
3736 </pre></td></tr>
3739 <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>
3740 <tr><td colspan="4" class="doc" id="isArray0"><pre>Matches array new expressions.
3742 Given:
3743 MyClass *p1 = new MyClass[10];
3744 cxxNewExpr(isArray())
3745 matches the expression 'new MyClass[10]'.
3746 </pre></td></tr>
3749 <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>
3750 <tr><td colspan="4" class="doc" id="hasAnyOperatorName1"><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_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnyOverloadedOperatorName0')"><a name="hasAnyOverloadedOperatorName0Anchor">hasAnyOverloadedOperatorName</a></td><td>StringRef, ..., StringRef</td></tr>
3760 <tr><td colspan="4" class="doc" id="hasAnyOverloadedOperatorName0"><pre>Matches overloaded operator names.
3762 Matches overloaded operator names specified in strings without the
3763 "operator" prefix: e.g. "&lt;&lt;".
3765 hasAnyOverloadedOperatorName("+", "-")
3766 Is equivalent to
3767 anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
3768 </pre></td></tr>
3771 <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>
3772 <tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions and fold expressions
3773 (binary or unary).
3775 Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
3776 !(a || b)
3778 Example matches `(0 + ... + args)`
3779 (matcher = cxxFoldExpr(hasOperatorName("+")))
3780 template &lt;typename... Args&gt;
3781 auto sum(Args... args) {
3782 return (0 + ... + args);
3784 </pre></td></tr>
3787 <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>
3788 <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names.
3790 Matches overloaded operator names specified in strings without the
3791 "operator" prefix: e.g. "&lt;&lt;".
3793 Given:
3794 class A { int operator*(); };
3795 const A &amp;operator&lt;&lt;(const A &amp;a, const A &amp;b);
3796 A a;
3797 a &lt;&lt; a; // &lt;-- This matches
3799 cxxOperatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the
3800 specified line and
3801 cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
3802 matches the declaration of A.
3804 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;
3805 </pre></td></tr>
3808 <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>
3809 <tr><td colspan="4" class="doc" id="isAssignmentOperator1"><pre>Matches all kinds of assignment operators.
3811 Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3812 if (a == b)
3813 a += b;
3815 Example 2: matches s1 = s2
3816 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3817 struct S { S&amp; operator=(const S&amp;); };
3818 void x() { S s1, s2; s1 = s2; }
3819 </pre></td></tr>
3822 <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>
3823 <tr><td colspan="4" class="doc" id="isComparisonOperator1"><pre>Matches comparison operators.
3825 Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3826 if (a == b)
3827 a += b;
3829 Example 2: matches s1 &lt; s2
3830 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3831 struct S { bool operator&lt;(const S&amp; other); };
3832 void x(S s1, S s2) { bool b1 = s1 &lt; s2; }
3833 </pre></td></tr>
3836 <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>
3837 <tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined.
3839 Example matches x (matcher = cxxRecordDecl(hasDefinition()))
3840 class x {};
3841 class y;
3842 </pre></td></tr>
3845 <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>
3846 <tr><td colspan="4" class="doc" id="isDerivedFrom2"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
3847 </pre></td></tr>
3850 <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>
3851 <tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom2"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
3852 </pre></td></tr>
3855 <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>
3856 <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or
3857 static member variable template instantiations.
3859 Given
3860 template&lt;typename T&gt; void A(T t) { }
3861 template&lt;&gt; void A(int N) { }
3862 functionDecl(isExplicitTemplateSpecialization())
3863 matches the specialization A&lt;int&gt;().
3865 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;
3866 </pre></td></tr>
3869 <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>
3870 <tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final.
3872 Given:
3873 class A final {};
3875 struct B {
3876 virtual void f();
3879 struct C : B {
3880 void f() final;
3882 matches A and C::f, but not B, C, or B::f
3883 </pre></td></tr>
3886 <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>
3887 <tr><td colspan="4" class="doc" id="isLambda0"><pre>Matches the generated class of lambda expressions.
3889 Given:
3890 auto x = []{};
3892 cxxRecordDecl(isLambda()) matches the implicit class declaration of
3893 decltype(x)
3894 </pre></td></tr>
3897 <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>
3898 <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom2"><pre>Overloaded method as shortcut for
3899 isSameOrDerivedFrom(hasName(...)).
3900 </pre></td></tr>
3903 <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>
3904 <tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static
3905 member variable template instantiations.
3907 Given
3908 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
3910 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
3912 template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
3913 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
3914 matches the template instantiation of X&lt;A&gt;.
3916 But given
3917 template &lt;typename T&gt; class X {}; class A {};
3918 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
3919 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
3920 does not match, as X&lt;A&gt; is an explicit template specialization.
3922 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;
3923 </pre></td></tr>
3926 <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>
3927 <tr><td colspan="4" class="doc" id="hasAnyOperatorName2"><pre>Matches operator expressions (binary or unary) that have any of the
3928 specified names.
3930 hasAnyOperatorName("+", "-")
3931 Is equivalent to
3932 anyOf(hasOperatorName("+"), hasOperatorName("-"))
3933 </pre></td></tr>
3936 <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>
3937 <tr><td colspan="4" class="doc" id="hasOperatorName2"><pre>Matches the operator Name of operator expressions and fold expressions
3938 (binary or unary).
3940 Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
3941 !(a || b)
3943 Example matches `(0 + ... + args)`
3944 (matcher = cxxFoldExpr(hasOperatorName("+")))
3945 template &lt;typename... Args&gt;
3946 auto sum(Args... args) {
3947 return (0 + ... + args);
3949 </pre></td></tr>
3952 <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>
3953 <tr><td colspan="4" class="doc" id="isAssignmentOperator2"><pre>Matches all kinds of assignment operators.
3955 Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3956 if (a == b)
3957 a += b;
3959 Example 2: matches s1 = s2
3960 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3961 struct S { S&amp; operator=(const S&amp;); };
3962 void x() { S s1, s2; s1 = s2; }
3963 </pre></td></tr>
3966 <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>
3967 <tr><td colspan="4" class="doc" id="isComparisonOperator2"><pre>Matches comparison operators.
3969 Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3970 if (a == b)
3971 a += b;
3973 Example 2: matches s1 &lt; s2
3974 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3975 struct S { bool operator&lt;(const S&amp; other); };
3976 void x(S s1, S s2) { bool b1 = s1 &lt; s2; }
3977 </pre></td></tr>
3980 <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>
3981 <tr><td colspan="4" class="doc" id="argumentCountAtLeast2"><pre>Checks that a call expression or a constructor call expression has at least
3982 the specified number of arguments (including absent default arguments).
3984 Example matches f(0, 0) and g(0, 0, 0)
3985 (matcher = callExpr(argumentCountAtLeast(2)))
3986 void f(int x, int y);
3987 void g(int x, int y, int z);
3988 f(0, 0);
3989 g(0, 0, 0);
3990 </pre></td></tr>
3993 <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>
3994 <tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has
3995 a specific number of arguments (including absent default arguments).
3997 Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
3998 void f(int x, int y);
3999 f(0, 0);
4000 </pre></td></tr>
4003 <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>
4004 <tr><td colspan="4" class="doc" id="argumentCountAtLeast0"><pre>Checks that a call expression or a constructor call expression has at least
4005 the specified number of arguments (including absent default arguments).
4007 Example matches f(0, 0) and g(0, 0, 0)
4008 (matcher = callExpr(argumentCountAtLeast(2)))
4009 void f(int x, int y);
4010 void g(int x, int y, int z);
4011 f(0, 0);
4012 g(0, 0, 0);
4013 </pre></td></tr>
4016 <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>
4017 <tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has
4018 a specific number of arguments (including absent default arguments).
4020 Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
4021 void f(int x, int y);
4022 f(0, 0);
4023 </pre></td></tr>
4026 <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>
4027 <tr><td colspan="4" class="doc" id="usesADL0"><pre>Matches call expressions which were resolved using ADL.
4029 Example matches y(x) but not y(42) or NS::y(x).
4030 namespace NS {
4031 struct X {};
4032 void y(X);
4035 void y(...);
4037 void test() {
4038 NS::X x;
4039 y(x); // Matches
4040 NS::y(x); // Doesn't match
4041 y(42); // Doesn't match
4042 using NS::y;
4043 y(x); // Found by both unqualified lookup and ADL, doesn't match
4045 </pre></td></tr>
4048 <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>
4049 <tr><td colspan="4" class="doc" id="hasCastKind0"><pre>Matches casts that has a given cast kind.
4051 Example: matches the implicit cast around 0
4052 (matcher = castExpr(hasCastKind(CK_NullToPointer)))
4053 int *p = 0;
4055 If the matcher is use from clang-query, CastKind parameter
4056 should be passed as a quoted string. e.g., hasCastKind("CK_NullToPointer").
4057 </pre></td></tr>
4060 <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>
4061 <tr><td colspan="4" class="doc" id="equals4"><pre></pre></td></tr>
4064 <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>
4065 <tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value of type ValueT.
4067 Given
4068 f('false, 3.14, 42);
4069 characterLiteral(equals(0))
4070 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
4071 match false
4072 floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
4073 match 3.14
4074 integerLiteral(equals(42))
4075 matches 42
4077 Note that you cannot directly match a negative numeric literal because the
4078 minus sign is not part of the literal: It is a unary operator whose operand
4079 is the positive numeric literal. Instead, you must use a unaryOperator()
4080 matcher to match the minus sign:
4082 unaryOperator(hasOperatorName("-"),
4083 hasUnaryOperand(integerLiteral(equals(13))))
4085 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;,
4086 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;
4087 </pre></td></tr>
4090 <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>
4091 <tr><td colspan="4" class="doc" id="equals10"><pre></pre></td></tr>
4094 <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>
4095 <tr><td colspan="4" class="doc" id="equals7"><pre></pre></td></tr>
4098 <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>
4099 <tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N.
4101 Given
4102 template&lt;typename T&gt; struct C {};
4103 C&lt;int&gt; c;
4104 classTemplateSpecializationDecl(templateArgumentCountIs(1))
4105 matches C&lt;int&gt;.
4106 </pre></td></tr>
4109 <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>
4110 <tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of
4111 child statements.
4113 Example: Given
4114 { for (;;) {} }
4115 compoundStmt(statementCountIs(0)))
4116 matches '{}'
4117 but does not match the outer compound statement.
4118 </pre></td></tr>
4121 <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>
4122 <tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches nodes that have the specified size.
4124 Given
4125 int a[42];
4126 int b[2 * 21];
4127 int c[41], d[43];
4128 char *s = "abcd";
4129 wchar_t *ws = L"abcd";
4130 char *w = "a";
4131 constantArrayType(hasSize(42))
4132 matches "int a[42]" and "int b[2 * 21]"
4133 stringLiteral(hasSize(4))
4134 matches "abcd", L"abcd"
4135 </pre></td></tr>
4138 <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>
4139 <tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of
4140 declarations.
4142 Example: Given
4143 int a, b;
4144 int c;
4145 int d = 2, e;
4146 declCountIs(2)
4147 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.
4148 </pre></td></tr>
4151 <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>
4152 <tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node.
4154 Matches a node if it equals the node previously bound to ID.
4156 Given
4157 class X { int a; int b; };
4158 cxxRecordDecl(
4159 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
4160 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
4161 matches the class X, as a and b have the same type.
4163 Note that when multiple matches are involved via forEach* matchers,
4164 equalsBoundNodes acts as a filter.
4165 For example:
4166 compoundStmt(
4167 forEachDescendant(varDecl().bind("d")),
4168 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
4169 will trigger a match for each combination of variable declaration
4170 and reference to that variable declaration within a compound statement.
4171 </pre></td></tr>
4174 <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>
4175 <tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node.
4177 Decl has pointer identity in the AST.
4178 </pre></td></tr>
4181 <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>
4182 <tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute.
4184 Given
4185 __attribute__((device)) void f() { ... }
4186 decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
4187 f. If the matcher is used from clang-query, attr::Kind parameter should be
4188 passed as a quoted string. e.g., hasAttr("attr::CUDADevice").
4189 </pre></td></tr>
4192 <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>
4193 <tr><td colspan="4" class="doc" id="isExpandedFromMacro0"><pre>Matches statements that are (transitively) expanded from the named macro.
4194 Does not match if only part of the statement is expanded from that macro or
4195 if different parts of the statement are expanded from different
4196 appearances of the macro.
4197 </pre></td></tr>
4200 <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>
4201 <tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is
4202 partially matching a given regex.
4204 Example matches Y but not X
4205 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
4206 #include "ASTMatcher.h"
4207 class X {};
4208 ASTMatcher.h:
4209 class Y {};
4211 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;
4213 If the matcher is used in clang-query, RegexFlags parameter
4214 should be passed as a quoted string. e.g: "NoFlags".
4215 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
4216 </pre></td></tr>
4219 <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>
4220 <tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file.
4222 Example matches X but not Y
4223 (matcher = cxxRecordDecl(isExpansionInMainFile())
4224 #include &lt;Y.h&gt;
4225 class X {};
4226 Y.h:
4227 class Y {};
4229 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;
4230 </pre></td></tr>
4233 <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>
4234 <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files.
4236 Example matches Y but not X
4237 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
4238 #include &lt;SystemHeader.h&gt;
4239 class X {};
4240 SystemHeader.h:
4241 class Y {};
4243 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;
4244 </pre></td></tr>
4247 <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>
4248 <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
4249 implicit default/copy constructors).
4250 </pre></td></tr>
4253 <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>
4254 <tr><td colspan="4" class="doc" id="isInAnonymousNamespace0"><pre>Matches declarations in an anonymous namespace.
4256 Given
4257 class vector {};
4258 namespace foo {
4259 class vector {};
4260 namespace {
4261 class vector {}; // #1
4264 namespace {
4265 class vector {}; // #2
4266 namespace foo {
4267 class vector{}; // #3
4270 cxxRecordDecl(hasName("vector"), isInAnonymousNamespace()) will match
4271 #1, #2 and #3.
4272 </pre></td></tr>
4275 <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>
4276 <tr><td colspan="4" class="doc" id="isInStdNamespace0"><pre>Matches declarations in the namespace `std`, but not in nested namespaces.
4278 Given
4279 class vector {};
4280 namespace foo {
4281 class vector {};
4282 namespace std {
4283 class vector {};
4286 namespace std {
4287 inline namespace __1 {
4288 class vector {}; // #1
4289 namespace experimental {
4290 class vector {};
4294 cxxRecordDecl(hasName("vector"), isInStdNamespace()) will match only #1.
4295 </pre></td></tr>
4298 <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>
4299 <tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside
4300 template instantiations.
4302 Given
4303 template&lt;typename T&gt; void A(T t) { T i; }
4304 A(0);
4305 A(0U);
4306 functionDecl(isInstantiated())
4307 matches 'A(int) {...};' and 'A(unsigned) {...}'.
4308 </pre></td></tr>
4311 <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>
4312 <tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations and C++ base specifers that specify private
4313 inheritance.
4315 Examples:
4316 class C {
4317 public: int a;
4318 protected: int b;
4319 private: int c; // fieldDecl(isPrivate()) matches 'c'
4322 struct Base {};
4323 struct Derived1 : private Base {}; // matches 'Base'
4324 class Derived2 : Base {}; // matches 'Base'
4325 </pre></td></tr>
4328 <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>
4329 <tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations and C++ base specifers that specify
4330 protected inheritance.
4332 Examples:
4333 class C {
4334 public: int a;
4335 protected: int b; // fieldDecl(isProtected()) matches 'b'
4336 private: int c;
4339 class Base {};
4340 class Derived : protected Base {}; // matches 'Base'
4341 </pre></td></tr>
4344 <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>
4345 <tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations and C++ base specifers that specify public
4346 inheritance.
4348 Examples:
4349 class C {
4350 public: int a; // fieldDecl(isPublic()) matches 'a'
4351 protected: int b;
4352 private: int c;
4355 class Base {};
4356 class Derived1 : public Base {}; // matches 'Base'
4357 struct Derived2 : Base {}; // matches 'Base'
4358 </pre></td></tr>
4361 <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>
4362 <tr><td colspan="4" class="doc" id="designatorCountIs0"><pre>Matches designated initializer expressions that contain
4363 a specific number of designators.
4365 Example: Given
4366 point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
4367 point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 };
4368 designatorCountIs(2)
4369 matches '{ [2].y = 1.0, [0].x = 1.0 }',
4370 but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'.
4371 </pre></td></tr>
4374 <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>
4375 <tr><td colspan="4" class="doc" id="isScoped0"><pre>Matches C++11 scoped enum declaration.
4377 Example matches Y (matcher = enumDecl(isScoped()))
4378 enum X {};
4379 enum class Y {};
4380 </pre></td></tr>
4383 <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>
4384 <tr><td colspan="4" class="doc" id="isInstantiationDependent0"><pre>Matches expressions that are instantiation-dependent even if it is
4385 neither type- nor value-dependent.
4387 In the following example, the expression sizeof(sizeof(T() + T()))
4388 is instantiation-dependent (since it involves a template parameter T),
4389 but is neither type- nor value-dependent, since the type of the inner
4390 sizeof is known (std::size_t) and therefore the size of the outer
4391 sizeof is known.
4392 template&lt;typename T&gt;
4393 void f(T x, T y) { sizeof(sizeof(T() + T()); }
4394 expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T())
4395 </pre></td></tr>
4398 <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>
4399 <tr><td colspan="4" class="doc" id="isTypeDependent0"><pre>Matches expressions that are type-dependent because the template type
4400 is not yet instantiated.
4402 For example, the expressions "x" and "x + y" are type-dependent in
4403 the following code, but "y" is not type-dependent:
4404 template&lt;typename T&gt;
4405 void add(T x, int y) {
4406 x + y;
4408 expr(isTypeDependent()) matches x + y
4409 </pre></td></tr>
4412 <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>
4413 <tr><td colspan="4" class="doc" id="isValueDependent0"><pre>Matches expression that are value-dependent because they contain a
4414 non-type template parameter.
4416 For example, the array bound of "Chars" in the following example is
4417 value-dependent.
4418 template&lt;int Size&gt; int f() { return Size; }
4419 expr(isValueDependent()) matches return Size
4420 </pre></td></tr>
4423 <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>
4424 <tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as
4425 GNU's __null, C++11's nullptr, or C's NULL macro.
4427 Given:
4428 void *v1 = NULL;
4429 void *v2 = nullptr;
4430 void *v3 = __null; // GNU extension
4431 char *cp = (char *)0;
4432 int *ip = 0;
4433 int i = 0;
4434 expr(nullPointerConstant())
4435 matches the initializer for v1, v2, v3, cp, and ip. Does not match the
4436 initializer for i.
4437 </pre></td></tr>
4440 <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>
4441 <tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified
4442 bit width.
4444 Given
4445 class C {
4446 int a : 2;
4447 int b : 4;
4448 int c : 2;
4450 fieldDecl(hasBitWidth(2))
4451 matches 'int a;' and 'int c;' but not 'int b;'.
4452 </pre></td></tr>
4455 <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>
4456 <tr><td colspan="4" class="doc" id="isBitField0"><pre>Matches non-static data members that are bit-fields.
4458 Given
4459 class C {
4460 int a : 2;
4461 int b;
4463 fieldDecl(isBitField())
4464 matches 'int a;' but not 'int b;'.
4465 </pre></td></tr>
4468 <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>
4469 <tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value of type ValueT.
4471 Given
4472 f('false, 3.14, 42);
4473 characterLiteral(equals(0))
4474 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
4475 match false
4476 floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
4477 match 3.14
4478 integerLiteral(equals(42))
4479 matches 42
4481 Note that you cannot directly match a negative numeric literal because the
4482 minus sign is not part of the literal: It is a unary operator whose operand
4483 is the positive numeric literal. Instead, you must use a unaryOperator()
4484 matcher to match the minus sign:
4486 unaryOperator(hasOperatorName("-"),
4487 hasUnaryOperand(integerLiteral(equals(13))))
4489 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;,
4490 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;
4491 </pre></td></tr>
4494 <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>
4495 <tr><td colspan="4" class="doc" id="equals12"><pre></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('hasAnyOverloadedOperatorName1')"><a name="hasAnyOverloadedOperatorName1Anchor">hasAnyOverloadedOperatorName</a></td><td>StringRef, ..., StringRef</td></tr>
4499 <tr><td colspan="4" class="doc" id="hasAnyOverloadedOperatorName1"><pre>Matches overloaded operator names.
4501 Matches overloaded operator names specified in strings without the
4502 "operator" prefix: e.g. "&lt;&lt;".
4504 hasAnyOverloadedOperatorName("+", "-")
4505 Is equivalent to
4506 anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
4507 </pre></td></tr>
4510 <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>
4511 <tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification.
4513 Given:
4514 void f();
4515 void g() noexcept;
4516 void h() noexcept(true);
4517 void i() noexcept(false);
4518 void j() throw();
4519 void k() throw(int);
4520 void l() throw(...);
4521 functionDecl(hasDynamicExceptionSpec()) and
4522 functionProtoType(hasDynamicExceptionSpec())
4523 match the declarations of j, k, and l, but not f, g, h, or i.
4524 </pre></td></tr>
4527 <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>
4528 <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names.
4530 Matches overloaded operator names specified in strings without the
4531 "operator" prefix: e.g. "&lt;&lt;".
4533 Given:
4534 class A { int operator*(); };
4535 const A &amp;operator&lt;&lt;(const A &amp;a, const A &amp;b);
4536 A a;
4537 a &lt;&lt; a; // &lt;-- This matches
4539 cxxOperatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the
4540 specified line and
4541 cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
4542 matches the declaration of A.
4544 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;
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('hasTrailingReturn0')"><a name="hasTrailingReturn0Anchor">hasTrailingReturn</a></td><td></td></tr>
4549 <tr><td colspan="4" class="doc" id="hasTrailingReturn0"><pre>Matches a function declared with a trailing return type.
4551 Example matches Y (matcher = functionDecl(hasTrailingReturn()))
4552 int X() {}
4553 auto Y() -&gt; int {}
4554 </pre></td></tr>
4557 <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>
4558 <tr><td colspan="4" class="doc" id="isConsteval0"><pre>Matches consteval function declarations and if consteval/if ! consteval
4559 statements.
4561 Given:
4562 consteval int a();
4563 void b() { if consteval {} }
4564 void c() { if ! consteval {} }
4565 void d() { if ! consteval {} else {} }
4566 functionDecl(isConsteval())
4567 matches the declaration of "int a()".
4568 ifStmt(isConsteval())
4569 matches the if statement in "void b()", "void c()", "void d()".
4570 </pre></td></tr>
4573 <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>
4574 <tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations,
4575 and if constexpr.
4577 Given:
4578 constexpr int foo = 42;
4579 constexpr int bar();
4580 void baz() { if constexpr(1 &gt; 0) {} }
4581 varDecl(isConstexpr())
4582 matches the declaration of foo.
4583 functionDecl(isConstexpr())
4584 matches the declaration of bar.
4585 ifStmt(isConstexpr())
4586 matches the if statement in baz.
4587 </pre></td></tr>
4590 <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>
4591 <tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations.
4593 Given:
4594 class A { ~A(); };
4595 class B { ~B() = default; };
4596 functionDecl(isDefaulted())
4597 matches the declaration of ~B, but not ~A.
4598 </pre></td></tr>
4601 <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>
4602 <tr><td colspan="4" class="doc" id="isDefinition3"><pre>Matches if a declaration has a body attached.
4604 Example matches A, va, fa
4605 class A {};
4606 class B; // Doesn't match, as it has no body.
4607 int va;
4608 extern int vb; // Doesn't match, as it doesn't define the variable.
4609 void fa() {}
4610 void fb(); // Doesn't match, as it has no body.
4611 @interface X
4612 - (void)ma; // Doesn't match, interface is declaration.
4613 @end
4614 @implementation X
4615 - (void)ma {}
4616 @end
4618 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;,
4619 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
4620 </pre></td></tr>
4623 <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>
4624 <tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations.
4626 Given:
4627 void Func();
4628 void DeletedFunc() = delete;
4629 functionDecl(isDeleted())
4630 matches the declaration of DeletedFunc, but not Func.
4631 </pre></td></tr>
4634 <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>
4635 <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or
4636 static member variable template instantiations.
4638 Given
4639 template&lt;typename T&gt; void A(T t) { }
4640 template&lt;&gt; void A(int N) { }
4641 functionDecl(isExplicitTemplateSpecialization())
4642 matches the specialization A&lt;int&gt;().
4644 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;
4645 </pre></td></tr>
4648 <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>
4649 <tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function or variable declarations.
4651 Given:
4652 extern "C" void f() {}
4653 extern "C" { void g() {} }
4654 void h() {}
4655 extern "C" int x = 1;
4656 extern "C" int y = 2;
4657 int z = 3;
4658 functionDecl(isExternC())
4659 matches the declaration of f and g, but not the declaration of h.
4660 varDecl(isExternC())
4661 matches the declaration of x and y, but not the declaration of z.
4662 </pre></td></tr>
4665 <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>
4666 <tr><td colspan="4" class="doc" id="isInline1"><pre>Matches functions, variables and namespace declarations that are marked with
4667 the inline keyword.
4669 Given
4670 inline void f();
4671 void g();
4672 namespace n {
4673 inline namespace m {}
4675 inline int Foo = 5;
4676 functionDecl(isInline()) will match ::f().
4677 namespaceDecl(isInline()) will match n::m.
4678 varDecl(isInline()) will match Foo;
4679 </pre></td></tr>
4682 <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>
4683 <tr><td colspan="4" class="doc" id="isMain0"><pre>Determines whether the function is "main", which is the entry point
4684 into an executable program.
4685 </pre></td></tr>
4688 <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>
4689 <tr><td colspan="4" class="doc" id="isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute.
4691 Given
4692 void nope();
4693 [[noreturn]] void a();
4694 __attribute__((noreturn)) void b();
4695 struct c { [[noreturn]] c(); };
4696 functionDecl(isNoReturn())
4697 matches all of those except
4698 void nope();
4699 </pre></td></tr>
4702 <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>
4703 <tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification.
4705 Given:
4706 void f();
4707 void g() noexcept;
4708 void h() throw();
4709 void i() throw(int);
4710 void j() noexcept(false);
4711 functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
4712 match the declarations of g, and h, but not f, i or j.
4713 </pre></td></tr>
4716 <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>
4717 <tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variable/function declarations that have "static" storage
4718 class specifier ("static" keyword) written in the source.
4720 Given:
4721 static void f() {}
4722 static int i = 0;
4723 extern int j;
4724 int k;
4725 functionDecl(isStaticStorageClass())
4726 matches the function declaration f.
4727 varDecl(isStaticStorageClass())
4728 matches the variable declaration i.
4729 </pre></td></tr>
4732 <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>
4733 <tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static
4734 member variable template instantiations.
4736 Given
4737 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
4739 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
4741 template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
4742 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
4743 matches the template instantiation of X&lt;A&gt;.
4745 But given
4746 template &lt;typename T&gt; class X {}; class A {};
4747 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
4748 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
4749 does not match, as X&lt;A&gt; is an explicit template specialization.
4751 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;
4752 </pre></td></tr>
4755 <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>
4756 <tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic.
4758 Example matches f, but not g or h. The function i will not match, even when
4759 compiled in C mode.
4760 void f(...);
4761 void g(int);
4762 template &lt;typename... Ts&gt; void h(Ts...);
4763 void i();
4764 </pre></td></tr>
4767 <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>
4768 <tr><td colspan="4" class="doc" id="isWeak0"><pre>Matches weak function declarations.
4770 Given:
4771 void foo() __attribute__((__weakref__("__foo")));
4772 void bar();
4773 functionDecl(isWeak())
4774 matches the weak declaration "foo", but not "bar".
4775 </pre></td></tr>
4778 <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>
4779 <tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
4780 specific parameter count.
4782 Given
4783 void f(int i) {}
4784 void g(int i, int j) {}
4785 void h(int i, int j);
4786 void j(int i);
4787 void k(int x, int y, int z, ...);
4788 functionDecl(parameterCountIs(2))
4789 matches g and h
4790 functionProtoType(parameterCountIs(2))
4791 matches g and h
4792 functionProtoType(parameterCountIs(3))
4793 matches k
4794 </pre></td></tr>
4797 <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>
4798 <tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification.
4800 Given:
4801 void f();
4802 void g() noexcept;
4803 void h() noexcept(true);
4804 void i() noexcept(false);
4805 void j() throw();
4806 void k() throw(int);
4807 void l() throw(...);
4808 functionDecl(hasDynamicExceptionSpec()) and
4809 functionProtoType(hasDynamicExceptionSpec())
4810 match the declarations of j, k, and l, but not f, g, h, or i.
4811 </pre></td></tr>
4814 <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>
4815 <tr><td colspan="4" class="doc" id="isNoThrow1"><pre>Matches functions that have a non-throwing exception specification.
4817 Given:
4818 void f();
4819 void g() noexcept;
4820 void h() throw();
4821 void i() throw(int);
4822 void j() noexcept(false);
4823 functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
4824 match the declarations of g, and h, but not f, i or j.
4825 </pre></td></tr>
4828 <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>
4829 <tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
4830 specific parameter count.
4832 Given
4833 void f(int i) {}
4834 void g(int i, int j) {}
4835 void h(int i, int j);
4836 void j(int i);
4837 void k(int x, int y, int z, ...);
4838 functionDecl(parameterCountIs(2))
4839 matches g and h
4840 functionProtoType(parameterCountIs(2))
4841 matches g and h
4842 functionProtoType(parameterCountIs(3))
4843 matches k
4844 </pre></td></tr>
4847 <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>
4848 <tr><td colspan="4" class="doc" id="isConsteval1"><pre>Matches consteval function declarations and if consteval/if ! consteval
4849 statements.
4851 Given:
4852 consteval int a();
4853 void b() { if consteval {} }
4854 void c() { if ! consteval {} }
4855 void d() { if ! consteval {} else {} }
4856 functionDecl(isConsteval())
4857 matches the declaration of "int a()".
4858 ifStmt(isConsteval())
4859 matches the if statement in "void b()", "void c()", "void d()".
4860 </pre></td></tr>
4863 <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>
4864 <tr><td colspan="4" class="doc" id="isConstexpr2"><pre>Matches constexpr variable and function declarations,
4865 and if constexpr.
4867 Given:
4868 constexpr int foo = 42;
4869 constexpr int bar();
4870 void baz() { if constexpr(1 &gt; 0) {} }
4871 varDecl(isConstexpr())
4872 matches the declaration of foo.
4873 functionDecl(isConstexpr())
4874 matches the declaration of bar.
4875 ifStmt(isConstexpr())
4876 matches the if statement in baz.
4877 </pre></td></tr>
4880 <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>
4881 <tr><td colspan="4" class="doc" id="equals6"><pre></pre></td></tr>
4884 <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>
4885 <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value of type ValueT.
4887 Given
4888 f('false, 3.14, 42);
4889 characterLiteral(equals(0))
4890 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
4891 match false
4892 floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
4893 match 3.14
4894 integerLiteral(equals(42))
4895 matches 42
4897 Note that you cannot directly match a negative numeric literal because the
4898 minus sign is not part of the literal: It is a unary operator whose operand
4899 is the positive numeric literal. Instead, you must use a unaryOperator()
4900 matcher to match the minus sign:
4902 unaryOperator(hasOperatorName("-"),
4903 hasUnaryOperand(integerLiteral(equals(13))))
4905 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;,
4906 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;
4907 </pre></td></tr>
4910 <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>
4911 <tr><td colspan="4" class="doc" id="equals13"><pre></pre></td></tr>
4914 <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>
4915 <tr><td colspan="4" class="doc" id="equals9"><pre></pre></td></tr>
4918 <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>
4919 <tr><td colspan="4" class="doc" id="capturesThis0"><pre>Matches a `LambdaCapture` that refers to 'this'.
4921 Given
4922 class C {
4923 int cc;
4924 int f() {
4925 auto l = [this]() { return cc; };
4926 return l();
4929 lambdaExpr(hasAnyCapture(lambdaCapture(capturesThis())))
4930 matches `[this]() { return cc; }`.
4931 </pre></td></tr>
4934 <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>
4935 <tr><td colspan="4" class="doc" id="isImplicit2"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
4936 implicit default/copy constructors).
4937 </pre></td></tr>
4940 <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>
4941 <tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '-&gt;' as opposed
4942 to '.'.
4944 Member calls on the implicit this pointer match as called with '-&gt;'.
4946 Given
4947 class Y {
4948 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
4949 template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
4950 int a;
4951 static int b;
4953 template &lt;class T&gt;
4954 class Z {
4955 void x() { this-&gt;m; }
4957 memberExpr(isArrow())
4958 matches this-&gt;x, x, y.x, a, this-&gt;b
4959 cxxDependentScopeMemberExpr(isArrow())
4960 matches this-&gt;m
4961 unresolvedMemberExpr(isArrow())
4962 matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
4963 </pre></td></tr>
4966 <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>
4967 <tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names.
4969 This matcher is only provided as a performance optimization of hasName.
4970 hasAnyName(a, b, c)
4971 is equivalent to, but faster than
4972 anyOf(hasName(a), hasName(b), hasName(c))
4973 </pre></td></tr>
4976 <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>
4977 <tr><td colspan="4" class="doc" id="hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage.
4979 Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))
4980 void f() {
4981 int x;
4982 static int y;
4984 int z;
4986 Example matches f() because it has external formal linkage despite being
4987 unique to the translation unit as though it has internal likage
4988 (matcher = functionDecl(hasExternalFormalLinkage()))
4990 namespace {
4991 void f() {}
4993 </pre></td></tr>
4996 <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>
4997 <tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name.
4999 Supports specifying enclosing namespaces or classes by prefixing the name
5000 with '&lt;enclosing&gt;::'.
5001 Does not match typedefs of an underlying type with the given name.
5003 Example matches X (Name == "X")
5004 class X;
5006 Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
5007 namespace a { namespace b { class X; } }
5008 </pre></td></tr>
5011 <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>
5012 <tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain
5013 a substring matched by the given RegExp.
5015 Supports specifying enclosing namespaces or classes by
5016 prefixing the name with '&lt;enclosing&gt;::'. Does not match typedefs
5017 of an underlying type with the given name.
5019 Example matches X (regexp == "::X")
5020 class X;
5022 Example matches X (regexp is one of "::X", "^foo::.*X", among others)
5023 namespace foo { namespace bar { class X; } }
5025 If the matcher is used in clang-query, RegexFlags parameter
5026 should be passed as a quoted string. e.g: "NoFlags".
5027 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
5028 </pre></td></tr>
5031 <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>
5032 <tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations.
5034 Given
5035 namespace n {
5036 namespace {} // #1
5038 namespaceDecl(isAnonymous()) will match #1 but not ::n.
5039 </pre></td></tr>
5042 <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>
5043 <tr><td colspan="4" class="doc" id="isInline0"><pre>Matches functions, variables and namespace declarations that are marked with
5044 the inline keyword.
5046 Given
5047 inline void f();
5048 void g();
5049 namespace n {
5050 inline namespace m {}
5052 inline int Foo = 5;
5053 functionDecl(isInline()) will match ::f().
5054 namespaceDecl(isInline()) will match n::m.
5055 varDecl(isInline()) will match Foo;
5056 </pre></td></tr>
5059 <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>
5060 <tr><td colspan="4" class="doc" id="isFirstPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``firstprivate`` kind
5061 specified.
5063 Given
5065 #pragma omp parallel
5066 #pragma omp parallel default(none)
5067 #pragma omp parallel default(shared)
5068 #pragma omp parallel default(private)
5069 #pragma omp parallel default(firstprivate)
5071 ``ompDefaultClause(isFirstPrivateKind())`` matches only
5072 ``default(firstprivate)``.
5073 </pre></td></tr>
5076 <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>
5077 <tr><td colspan="4" class="doc" id="isNoneKind0"><pre>Matches if the OpenMP ``default`` clause has ``none`` kind specified.
5079 Given
5081 #pragma omp parallel
5082 #pragma omp parallel default(none)
5083 #pragma omp parallel default(shared)
5084 #pragma omp parallel default(private)
5085 #pragma omp parallel default(firstprivate)
5087 ``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
5088 </pre></td></tr>
5091 <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>
5092 <tr><td colspan="4" class="doc" id="isPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``private`` kind
5093 specified.
5095 Given
5097 #pragma omp parallel
5098 #pragma omp parallel default(none)
5099 #pragma omp parallel default(shared)
5100 #pragma omp parallel default(private)
5101 #pragma omp parallel default(firstprivate)
5103 ``ompDefaultClause(isPrivateKind())`` matches only
5104 ``default(private)``.
5105 </pre></td></tr>
5108 <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>
5109 <tr><td colspan="4" class="doc" id="isSharedKind0"><pre>Matches if the OpenMP ``default`` clause has ``shared`` kind specified.
5111 Given
5113 #pragma omp parallel
5114 #pragma omp parallel default(none)
5115 #pragma omp parallel default(shared)
5116 #pragma omp parallel default(private)
5117 #pragma omp parallel default(firstprivate)
5119 ``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``.
5120 </pre></td></tr>
5123 <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>
5124 <tr><td colspan="4" class="doc" id="isAllowedToContainClauseKind0"><pre>Matches if the OpenMP directive is allowed to contain the specified OpenMP
5125 clause kind.
5127 Given
5129 #pragma omp parallel
5130 #pragma omp parallel for
5131 #pragma omp for
5133 `ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches
5134 ``omp parallel`` and ``omp parallel for``.
5136 If the matcher is use from clang-query, ``OpenMPClauseKind`` parameter
5137 should be passed as a quoted string. e.g.,
5138 ``isAllowedToContainClauseKind("OMPC_default").``
5139 </pre></td></tr>
5142 <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>
5143 <tr><td colspan="4" class="doc" id="isStandaloneDirective0"><pre>Matches standalone OpenMP directives,
5144 i.e., directives that can't have a structured block.
5146 Given
5148 #pragma omp parallel
5150 #pragma omp taskyield
5152 ``ompExecutableDirective(isStandaloneDirective()))`` matches
5153 ``omp taskyield``.
5154 </pre></td></tr>
5157 <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>
5158 <tr><td colspan="4" class="doc" id="isDerivedFrom3"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
5159 </pre></td></tr>
5162 <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>
5163 <tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom3"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
5164 </pre></td></tr>
5167 <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>
5168 <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom3"><pre>Overloaded method as shortcut for
5169 isSameOrDerivedFrom(hasName(...)).
5170 </pre></td></tr>
5173 <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>
5174 <tr><td colspan="4" class="doc" id="argumentCountAtLeast3"><pre>Checks that a call expression or a constructor call expression has at least
5175 the specified number of arguments (including absent default arguments).
5177 Example matches f(0, 0) and g(0, 0, 0)
5178 (matcher = callExpr(argumentCountAtLeast(2)))
5179 void f(int x, int y);
5180 void g(int x, int y, int z);
5181 f(0, 0);
5182 g(0, 0, 0);
5183 </pre></td></tr>
5186 <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>
5187 <tr><td colspan="4" class="doc" id="argumentCountIs3"><pre>Checks that a call expression or a constructor call expression has
5188 a specific number of arguments (including absent default arguments).
5190 Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
5191 void f(int x, int y);
5192 f(0, 0);
5193 </pre></td></tr>
5196 <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>
5197 <tr><td colspan="4" class="doc" id="hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the
5198 Selector.getAsString()
5200 matcher = objCMessageExpr(hasSelector("methodA:", "methodB:"));
5201 matches both of the expressions below:
5202 [myObj methodA:argA];
5203 [myObj methodB:argB];
5204 </pre></td></tr>
5207 <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>
5208 <tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector
5210 objCMessageExpr(hasKeywordSelector()) matches the generated setFrame
5211 message expression in
5213 UIWebView *webView = ...;
5214 CGRect bodyFrame = webView.frame;
5215 bodyFrame.size.height = self.bodyContentHeight;
5216 webView.frame = bodyFrame;
5217 // ^---- matches here
5218 </pre></td></tr>
5221 <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>
5222 <tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector
5224 Matches only when the selector of the objCMessageExpr is NULL. This may
5225 represent an error condition in the tree!
5226 </pre></td></tr>
5229 <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>
5230 <tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString()
5232 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:"));
5233 matches the outer message expr in the code below, but NOT the message
5234 invocation for self.bodyView.
5235 [self.bodyView loadHTMLString:html baseURL:NULL];
5236 </pre></td></tr>
5239 <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>
5240 <tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector
5242 matcher = objCMessageExpr(matchesSelector(hasUnarySelector());
5243 matches self.bodyView in the code below, but NOT the outer message
5244 invocation of "loadHTMLString:baseURL:".
5245 [self.bodyView loadHTMLString:html baseURL:NULL];
5246 </pre></td></tr>
5249 <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>
5250 <tr><td colspan="4" class="doc" id="isClassMessage0"><pre>Returns true when the Objective-C message is sent to a class.
5252 Example
5253 matcher = objcMessageExpr(isClassMessage())
5254 matches
5255 [NSString stringWithFormat:@"format"];
5256 but not
5257 NSString *x = @"hello";
5258 [x containsString:@"h"];
5259 </pre></td></tr>
5262 <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>
5263 <tr><td colspan="4" class="doc" id="isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance.
5265 Example
5266 matcher = objcMessageExpr(isInstanceMessage())
5267 matches
5268 NSString *x = @"hello";
5269 [x containsString:@"h"];
5270 but not
5271 [NSString stringWithFormat:@"format"];
5272 </pre></td></tr>
5275 <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>
5276 <tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains
5277 a substring matched by the given RegExp.
5278 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message
5279 invocation for self.bodyView.
5280 [self.bodyView loadHTMLString:html baseURL:NULL];
5282 If the matcher is used in clang-query, RegexFlags parameter
5283 should be passed as a quoted string. e.g: "NoFlags".
5284 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
5285 </pre></td></tr>
5288 <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>
5289 <tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments
5291 matcher = objCMessageExpr(numSelectorArgs(0));
5292 matches self.bodyView in the code below
5294 matcher = objCMessageExpr(numSelectorArgs(2));
5295 matches the invocation of "loadHTMLString:baseURL:" but not that
5296 of self.bodyView
5297 [self.bodyView loadHTMLString:html baseURL:NULL];
5298 </pre></td></tr>
5301 <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>
5302 <tr><td colspan="4" class="doc" id="isClassMethod0"><pre>Returns true when the Objective-C method declaration is a class method.
5304 Example
5305 matcher = objcMethodDecl(isClassMethod())
5306 matches
5307 @interface I + (void)foo; @end
5308 but not
5309 @interface I - (void)bar; @end
5310 </pre></td></tr>
5313 <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>
5314 <tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached.
5316 Example matches A, va, fa
5317 class A {};
5318 class B; // Doesn't match, as it has no body.
5319 int va;
5320 extern int vb; // Doesn't match, as it doesn't define the variable.
5321 void fa() {}
5322 void fb(); // Doesn't match, as it has no body.
5323 @interface X
5324 - (void)ma; // Doesn't match, interface is declaration.
5325 @end
5326 @implementation X
5327 - (void)ma {}
5328 @end
5330 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;,
5331 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
5332 </pre></td></tr>
5335 <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>
5336 <tr><td colspan="4" class="doc" id="isInstanceMethod0"><pre>Returns true when the Objective-C method declaration is an instance method.
5338 Example
5339 matcher = objcMethodDecl(isInstanceMethod())
5340 matches
5341 @interface I - (void)bar; @end
5342 but not
5343 @interface I + (void)foo; @end
5344 </pre></td></tr>
5347 <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>
5348 <tr><td colspan="4" class="doc" id="hasDefaultArgument0"><pre>Matches a declaration that has default arguments.
5350 Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
5351 void x(int val) {}
5352 void y(int val = 0) {}
5354 Deprecated. Use hasInitializer() instead to be able to
5355 match on the contents of the default argument. For example:
5357 void x(int val = 7) {}
5358 void y(int val = 42) {}
5359 parmVarDecl(hasInitializer(integerLiteral(equals(42))))
5360 matches the parameter of y
5362 A matcher such as
5363 parmVarDecl(hasInitializer(anything()))
5364 is equivalent to parmVarDecl(hasDefaultArgument()).
5365 </pre></td></tr>
5368 <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>
5369 <tr><td colspan="4" class="doc" id="isAtPosition0"><pre>Matches the ParmVarDecl nodes that are at the N'th position in the parameter
5370 list. The parameter list could be that of either a block, function, or
5371 objc-method.
5374 Given
5376 void f(int a, int b, int c) {
5379 ``parmVarDecl(isAtPosition(0))`` matches ``int a``.
5381 ``parmVarDecl(isAtPosition(1))`` matches ``int b``.
5382 </pre></td></tr>
5385 <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>
5386 <tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string.
5388 Given
5389 class Y { public: void x(); };
5390 void z() { Y* y; y-&gt;x(); }
5391 cxxMemberCallExpr(on(hasType(asString("class Y *"))))
5392 matches y-&gt;x()
5393 </pre></td></tr>
5396 <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>
5397 <tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node.
5399 Matches a node if it equals the node previously bound to ID.
5401 Given
5402 class X { int a; int b; };
5403 cxxRecordDecl(
5404 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
5405 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
5406 matches the class X, as a and b have the same type.
5408 Note that when multiple matches are involved via forEach* matchers,
5409 equalsBoundNodes acts as a filter.
5410 For example:
5411 compoundStmt(
5412 forEachDescendant(varDecl().bind("d")),
5413 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
5414 will trigger a match for each combination of variable declaration
5415 and reference to that variable declaration within a compound statement.
5416 </pre></td></tr>
5419 <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>
5420 <tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to
5421 the node, not hidden within a typedef.
5423 Given
5424 typedef const int const_int;
5425 const_int i;
5426 int *const j;
5427 int *volatile k;
5428 int m;
5429 varDecl(hasType(hasLocalQualifiers())) matches only j and k.
5430 i is const-qualified but the qualifier is not local.
5431 </pre></td></tr>
5434 <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>
5435 <tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type.
5437 Given
5438 void a(char);
5439 void b(wchar_t);
5440 void c(double);
5441 functionDecl(hasAnyParameter(hasType(isAnyCharacter())))
5442 matches "a(char)", "b(wchar_t)", but not "c(double)".
5443 </pre></td></tr>
5446 <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>
5447 <tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type; this includes
5448 the Objective-C object pointer type, which is different despite being
5449 syntactically similar.
5451 Given
5452 int *i = nullptr;
5454 @interface Foo
5455 @end
5456 Foo *f;
5458 int j;
5459 varDecl(hasType(isAnyPointer()))
5460 matches "int *i" and "Foo *f", but not "int j".
5461 </pre></td></tr>
5464 <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>
5465 <tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that
5466 include "top-level" const.
5468 Given
5469 void a(int);
5470 void b(int const);
5471 void c(const int);
5472 void d(const int*);
5473 void e(int const) {};
5474 functionDecl(hasAnyParameter(hasType(isConstQualified())))
5475 matches "void b(int const)", "void c(const int)" and
5476 "void e(int const) {}". It does not match d as there
5477 is no top-level const on the parameter type "const int *".
5478 </pre></td></tr>
5481 <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>
5482 <tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type.
5484 Given
5485 void a(int);
5486 void b(long);
5487 void c(double);
5488 functionDecl(hasAnyParameter(hasType(isInteger())))
5489 matches "a(int)", "b(long)", but not "c(double)".
5490 </pre></td></tr>
5493 <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>
5494 <tr><td colspan="4" class="doc" id="isSignedInteger0"><pre>Matches QualType nodes that are of signed integer type.
5496 Given
5497 void a(int);
5498 void b(unsigned long);
5499 void c(double);
5500 functionDecl(hasAnyParameter(hasType(isSignedInteger())))
5501 matches "a(int)", but not "b(unsigned long)" and "c(double)".
5502 </pre></td></tr>
5505 <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>
5506 <tr><td colspan="4" class="doc" id="isUnsignedInteger0"><pre>Matches QualType nodes that are of unsigned integer type.
5508 Given
5509 void a(int);
5510 void b(unsigned long);
5511 void c(double);
5512 functionDecl(hasAnyParameter(hasType(isUnsignedInteger())))
5513 matches "b(unsigned long)", but not "a(int)" and "c(double)".
5514 </pre></td></tr>
5517 <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>
5518 <tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that
5519 include "top-level" volatile.
5521 Given
5522 void a(int);
5523 void b(int volatile);
5524 void c(volatile int);
5525 void d(volatile int*);
5526 void e(int volatile) {};
5527 functionDecl(hasAnyParameter(hasType(isVolatileQualified())))
5528 matches "void b(int volatile)", "void c(volatile int)" and
5529 "void e(int volatile) {}". It does not match d as there
5530 is no top-level volatile on the parameter type "volatile int *".
5531 </pre></td></tr>
5534 <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>
5535 <tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node.
5537 Matches a node if it equals the node previously bound to ID.
5539 Given
5540 class X { int a; int b; };
5541 cxxRecordDecl(
5542 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
5543 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
5544 matches the class X, as a and b have the same type.
5546 Note that when multiple matches are involved via forEach* matchers,
5547 equalsBoundNodes acts as a filter.
5548 For example:
5549 compoundStmt(
5550 forEachDescendant(varDecl().bind("d")),
5551 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
5552 will trigger a match for each combination of variable declaration
5553 and reference to that variable declaration within a compound statement.
5554 </pre></td></tr>
5557 <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>
5558 <tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node.
5560 Stmt has pointer identity in the AST.
5561 </pre></td></tr>
5564 <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>
5565 <tr><td colspan="4" class="doc" id="isExpandedFromMacro1"><pre>Matches statements that are (transitively) expanded from the named macro.
5566 Does not match if only part of the statement is expanded from that macro or
5567 if different parts of the statement are expanded from different
5568 appearances of the macro.
5569 </pre></td></tr>
5572 <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>
5573 <tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is
5574 partially matching a given regex.
5576 Example matches Y but not X
5577 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
5578 #include "ASTMatcher.h"
5579 class X {};
5580 ASTMatcher.h:
5581 class Y {};
5583 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;
5585 If the matcher is used in clang-query, RegexFlags parameter
5586 should be passed as a quoted string. e.g: "NoFlags".
5587 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
5588 </pre></td></tr>
5591 <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>
5592 <tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file.
5594 Example matches X but not Y
5595 (matcher = cxxRecordDecl(isExpansionInMainFile())
5596 #include &lt;Y.h&gt;
5597 class X {};
5598 Y.h:
5599 class Y {};
5601 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;
5602 </pre></td></tr>
5605 <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>
5606 <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files.
5608 Example matches Y but not X
5609 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
5610 #include &lt;SystemHeader.h&gt;
5611 class X {};
5612 SystemHeader.h:
5613 class Y {};
5615 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;
5616 </pre></td></tr>
5619 <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>
5620 <tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation.
5622 Given
5623 int j;
5624 template&lt;typename T&gt; void A(T t) { T i; j += 42;}
5625 A(0);
5626 A(0U);
5627 declStmt(isInTemplateInstantiation())
5628 matches 'int i;' and 'unsigned i'.
5629 unless(stmt(isInTemplateInstantiation()))
5630 will NOT match j += 42; as it's shared between the template definition and
5631 instantiation.
5632 </pre></td></tr>
5635 <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>
5636 <tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size.
5638 Given
5639 int a[42];
5640 int b[2 * 21];
5641 int c[41], d[43];
5642 char *s = "abcd";
5643 wchar_t *ws = L"abcd";
5644 char *w = "a";
5645 constantArrayType(hasSize(42))
5646 matches "int a[42]" and "int b[2 * 21]"
5647 stringLiteral(hasSize(4))
5648 matches "abcd", L"abcd"
5649 </pre></td></tr>
5652 <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>
5653 <tr><td colspan="4" class="doc" id="isClass0"><pre>Matches TagDecl object that are spelled with "class."
5655 Example matches C, but not S, U or E.
5656 struct S {};
5657 class C {};
5658 union U {};
5659 enum E {};
5660 </pre></td></tr>
5663 <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>
5664 <tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached.
5666 Example matches A, va, fa
5667 class A {};
5668 class B; // Doesn't match, as it has no body.
5669 int va;
5670 extern int vb; // Doesn't match, as it doesn't define the variable.
5671 void fa() {}
5672 void fb(); // Doesn't match, as it has no body.
5673 @interface X
5674 - (void)ma; // Doesn't match, interface is declaration.
5675 @end
5676 @implementation X
5677 - (void)ma {}
5678 @end
5680 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;,
5681 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
5682 </pre></td></tr>
5685 <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>
5686 <tr><td colspan="4" class="doc" id="isEnum0"><pre>Matches TagDecl object that are spelled with "enum."
5688 Example matches E, but not C, S or U.
5689 struct S {};
5690 class C {};
5691 union U {};
5692 enum E {};
5693 </pre></td></tr>
5696 <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>
5697 <tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches TagDecl object that are spelled with "struct."
5699 Example matches S, but not C, U or E.
5700 struct S {};
5701 class C {};
5702 union U {};
5703 enum E {};
5704 </pre></td></tr>
5707 <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>
5708 <tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches TagDecl object that are spelled with "union."
5710 Example matches U, but not C, S or E.
5711 struct S {};
5712 class C {};
5713 union U {};
5714 enum E {};
5715 </pre></td></tr>
5718 <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>
5719 <tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value.
5721 Note that 'Value' is a string as the template argument's value is
5722 an arbitrary precision integer. 'Value' must be euqal to the canonical
5723 representation of that integral value in base 10.
5725 Given
5726 template&lt;int T&gt; struct C {};
5727 C&lt;42&gt; c;
5728 classTemplateSpecializationDecl(
5729 hasAnyTemplateArgument(equalsIntegralValue("42")))
5730 matches the implicit instantiation of C in C&lt;42&gt;.
5731 </pre></td></tr>
5734 <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>
5735 <tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value.
5737 Given
5738 template&lt;int T&gt; struct C {};
5739 C&lt;42&gt; c;
5740 classTemplateSpecializationDecl(
5741 hasAnyTemplateArgument(isIntegral()))
5742 matches the implicit instantiation of C in C&lt;42&gt;
5743 with isIntegral() matching 42.
5744 </pre></td></tr>
5747 <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>
5748 <tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N.
5750 Given
5751 template&lt;typename T&gt; struct C {};
5752 C&lt;int&gt; c;
5753 classTemplateSpecializationDecl(templateArgumentCountIs(1))
5754 matches C&lt;int&gt;.
5755 </pre></td></tr>
5758 <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>
5759 <tr><td colspan="4" class="doc" id="isExpandedFromMacro2"><pre>Matches statements that are (transitively) expanded from the named macro.
5760 Does not match if only part of the statement is expanded from that macro or
5761 if different parts of the statement are expanded from different
5762 appearances of the macro.
5763 </pre></td></tr>
5766 <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>
5767 <tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is
5768 partially matching a given regex.
5770 Example matches Y but not X
5771 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
5772 #include "ASTMatcher.h"
5773 class X {};
5774 ASTMatcher.h:
5775 class Y {};
5777 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;
5779 If the matcher is used in clang-query, RegexFlags parameter
5780 should be passed as a quoted string. e.g: "NoFlags".
5781 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
5782 </pre></td></tr>
5785 <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>
5786 <tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file.
5788 Example matches X but not Y
5789 (matcher = cxxRecordDecl(isExpansionInMainFile())
5790 #include &lt;Y.h&gt;
5791 class X {};
5792 Y.h:
5793 class Y {};
5795 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;
5796 </pre></td></tr>
5799 <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>
5800 <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files.
5802 Example matches Y but not X
5803 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
5804 #include &lt;SystemHeader.h&gt;
5805 class X {};
5806 SystemHeader.h:
5807 class Y {};
5809 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;
5810 </pre></td></tr>
5813 <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>
5814 <tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool.
5816 Given
5817 struct S { bool func(); };
5818 functionDecl(returns(booleanType()))
5819 matches "bool func();"
5820 </pre></td></tr>
5823 <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>
5824 <tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node.
5826 Matches a node if it equals the node previously bound to ID.
5828 Given
5829 class X { int a; int b; };
5830 cxxRecordDecl(
5831 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
5832 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
5833 matches the class X, as a and b have the same type.
5835 Note that when multiple matches are involved via forEach* matchers,
5836 equalsBoundNodes acts as a filter.
5837 For example:
5838 compoundStmt(
5839 forEachDescendant(varDecl().bind("d")),
5840 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
5841 will trigger a match for each combination of variable declaration
5842 and reference to that variable declaration within a compound statement.
5843 </pre></td></tr>
5846 <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>
5847 <tr><td colspan="4" class="doc" id="equalsNode2"><pre>Matches if a node equals another node.
5849 Type has pointer identity in the AST.
5850 </pre></td></tr>
5853 <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>
5854 <tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double).
5856 Given
5857 int i;
5858 float f;
5859 realFloatingPointType()
5860 matches "float f" but not "int i"
5861 </pre></td></tr>
5864 <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>
5865 <tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void.
5867 Given
5868 struct S { void func(); };
5869 functionDecl(returns(voidType()))
5870 matches "void func();"
5871 </pre></td></tr>
5874 <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>
5875 <tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind.
5877 Given
5878 int x;
5879 int s = sizeof(x) + alignof(x)
5880 unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
5881 matches sizeof(x)
5883 If the matcher is use from clang-query, UnaryExprOrTypeTrait parameter
5884 should be passed as a quoted string. e.g., ofKind("UETT_SizeOf").
5885 </pre></td></tr>
5888 <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>
5889 <tr><td colspan="4" class="doc" id="hasAnyOperatorName3"><pre>Matches operator expressions (binary or unary) that have any of the
5890 specified names.
5892 hasAnyOperatorName("+", "-")
5893 Is equivalent to
5894 anyOf(hasOperatorName("+"), hasOperatorName("-"))
5895 </pre></td></tr>
5898 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasOperatorName4')"><a name="hasOperatorName4Anchor">hasOperatorName</a></td><td>std::string Name</td></tr>
5899 <tr><td colspan="4" class="doc" id="hasOperatorName4"><pre>Matches the operator Name of operator expressions and fold expressions
5900 (binary or unary).
5902 Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
5903 !(a || b)
5905 Example matches `(0 + ... + args)`
5906 (matcher = cxxFoldExpr(hasOperatorName("+")))
5907 template &lt;typename... Args&gt;
5908 auto sum(Args... args) {
5909 return (0 + ... + args);
5911 </pre></td></tr>
5914 <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>
5915 <tr><td colspan="4" class="doc" id="isArrow1"><pre>Matches member expressions that are called with '-&gt;' as opposed
5916 to '.'.
5918 Member calls on the implicit this pointer match as called with '-&gt;'.
5920 Given
5921 class Y {
5922 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
5923 template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
5924 int a;
5925 static int b;
5927 template &lt;class T&gt;
5928 class Z {
5929 void x() { this-&gt;m; }
5931 memberExpr(isArrow())
5932 matches this-&gt;x, x, y.x, a, this-&gt;b
5933 cxxDependentScopeMemberExpr(isArrow())
5934 matches this-&gt;m
5935 unresolvedMemberExpr(isArrow())
5936 matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
5937 </pre></td></tr>
5940 <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>
5941 <tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration.
5943 Example matches x, but not y, z, or a.
5944 (matcher = varDecl(hasAutomaticStorageDuration())
5945 void f() {
5946 int x;
5947 static int y;
5948 thread_local int z;
5950 int a;
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('hasGlobalStorage0')"><a name="hasGlobalStorage0Anchor">hasGlobalStorage</a></td><td></td></tr>
5955 <tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage.
5957 Example matches y and z (matcher = varDecl(hasGlobalStorage())
5958 void f() {
5959 int x;
5960 static int y;
5962 int z;
5963 </pre></td></tr>
5966 <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>
5967 <tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a
5968 non-static local variable.
5970 Example matches x (matcher = varDecl(hasLocalStorage())
5971 void f() {
5972 int x;
5973 static int y;
5975 int z;
5976 </pre></td></tr>
5979 <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>
5980 <tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration.
5981 It includes the variable declared at namespace scope and those declared
5982 with "static" and "extern" storage class specifiers.
5984 void f() {
5985 int x;
5986 static int y;
5987 thread_local int z;
5989 int a;
5990 static int b;
5991 extern int c;
5992 varDecl(hasStaticStorageDuration())
5993 matches the function declaration y, a, b and c.
5994 </pre></td></tr>
5997 <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>
5998 <tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration.
6000 Example matches z, but not x, z, or a.
6001 (matcher = varDecl(hasThreadStorageDuration())
6002 void f() {
6003 int x;
6004 static int y;
6005 thread_local int z;
6007 int a;
6008 </pre></td></tr>
6011 <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>
6012 <tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations,
6013 and if constexpr.
6015 Given:
6016 constexpr int foo = 42;
6017 constexpr int bar();
6018 void baz() { if constexpr(1 &gt; 0) {} }
6019 varDecl(isConstexpr())
6020 matches the declaration of foo.
6021 functionDecl(isConstexpr())
6022 matches the declaration of bar.
6023 ifStmt(isConstexpr())
6024 matches the if statement in baz.
6025 </pre></td></tr>
6028 <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>
6029 <tr><td colspan="4" class="doc" id="isConstinit0"><pre>Matches constinit variable declarations.
6031 Given:
6032 constinit int foo = 42;
6033 constinit const char* bar = "bar";
6034 int baz = 42;
6035 [[clang::require_constant_initialization]] int xyz = 42;
6036 varDecl(isConstinit())
6037 matches the declaration of `foo` and `bar`, but not `baz` and `xyz`.
6038 </pre></td></tr>
6041 <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>
6042 <tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached.
6044 Example matches A, va, fa
6045 class A {};
6046 class B; // Doesn't match, as it has no body.
6047 int va;
6048 extern int vb; // Doesn't match, as it doesn't define the variable.
6049 void fa() {}
6050 void fb(); // Doesn't match, as it has no body.
6051 @interface X
6052 - (void)ma; // Doesn't match, interface is declaration.
6053 @end
6054 @implementation X
6055 - (void)ma {}
6056 @end
6058 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;,
6059 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
6060 </pre></td></tr>
6063 <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>
6064 <tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from
6065 a C++ catch block, or an Objective-C statement.
6067 Example matches x (matcher = varDecl(isExceptionVariable())
6068 void f(int y) {
6069 try {
6070 } catch (int x) {
6073 </pre></td></tr>
6076 <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>
6077 <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or
6078 static member variable template instantiations.
6080 Given
6081 template&lt;typename T&gt; void A(T t) { }
6082 template&lt;&gt; void A(int N) { }
6083 functionDecl(isExplicitTemplateSpecialization())
6084 matches the specialization A&lt;int&gt;().
6086 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;
6087 </pre></td></tr>
6090 <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>
6091 <tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function or variable declarations.
6093 Given:
6094 extern "C" void f() {}
6095 extern "C" { void g() {} }
6096 void h() {}
6097 extern "C" int x = 1;
6098 extern "C" int y = 2;
6099 int z = 3;
6100 functionDecl(isExternC())
6101 matches the declaration of f and g, but not the declaration of h.
6102 varDecl(isExternC())
6103 matches the declaration of x and y, but not the declaration of z.
6104 </pre></td></tr>
6107 <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>
6108 <tr><td colspan="4" class="doc" id="isInitCapture0"><pre>Matches a variable serving as the implicit variable for a lambda init-
6109 capture.
6111 Example matches x (matcher = varDecl(isInitCapture()))
6112 auto f = [x=3]() { return x; };
6113 </pre></td></tr>
6116 <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>
6117 <tr><td colspan="4" class="doc" id="isInline2"><pre>Matches functions, variables and namespace declarations that are marked with
6118 the inline keyword.
6120 Given
6121 inline void f();
6122 void g();
6123 namespace n {
6124 inline namespace m {}
6126 inline int Foo = 5;
6127 functionDecl(isInline()) will match ::f().
6128 namespaceDecl(isInline()) will match n::m.
6129 varDecl(isInline()) will match Foo;
6130 </pre></td></tr>
6133 <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>
6134 <tr><td colspan="4" class="doc" id="isStaticLocal0"><pre>Matches a static variable with local scope.
6136 Example matches y (matcher = varDecl(isStaticLocal()))
6137 void f() {
6138 int x;
6139 static int y;
6141 static int z;
6142 </pre></td></tr>
6145 <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>
6146 <tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variable/function declarations that have "static" storage
6147 class specifier ("static" keyword) written in the source.
6149 Given:
6150 static void f() {}
6151 static int i = 0;
6152 extern int j;
6153 int k;
6154 functionDecl(isStaticStorageClass())
6155 matches the function declaration f.
6156 varDecl(isStaticStorageClass())
6157 matches the variable declaration i.
6158 </pre></td></tr>
6161 <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>
6162 <tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static
6163 member variable template instantiations.
6165 Given
6166 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
6168 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
6170 template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
6171 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
6172 matches the template instantiation of X&lt;A&gt;.
6174 But given
6175 template &lt;typename T&gt; class X {}; class A {};
6176 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
6177 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
6178 does not match, as X&lt;A&gt; is an explicit template specialization.
6180 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;
6181 </pre></td></tr>
6183 <!--END_NARROWING_MATCHERS -->
6184 </table>
6186 <!-- ======================================================================= -->
6187 <h2 id="traversal-matchers">AST Traversal Matchers</h2>
6188 <!-- ======================================================================= -->
6190 <p>Traversal matchers specify the relationship to other nodes that are
6191 reachable from the current node.</p>
6193 <p>Note that there are special traversal matchers (has, hasDescendant, forEach and
6194 forEachDescendant) which work on all nodes and allow users to write more generic
6195 match expressions.</p>
6197 <table>
6198 <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
6199 <!-- START_TRAVERSAL_MATCHERS -->
6201 <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>
6202 <tr><td colspan="4" class="doc" id="binaryOperation0"><pre>Matches nodes which can be used with binary operators.
6204 The code
6205 var1 != var2;
6206 might be represented in the clang AST as a binaryOperator, a
6207 cxxOperatorCallExpr or a cxxRewrittenBinaryOperator, depending on
6209 * whether the types of var1 and var2 are fundamental (binaryOperator) or at
6210 least one is a class type (cxxOperatorCallExpr)
6211 * whether the code appears in a template declaration, if at least one of the
6212 vars is a dependent-type (binaryOperator)
6213 * whether the code relies on a rewritten binary operator, such as a
6214 spaceship operator or an inverted equality operator
6215 (cxxRewrittenBinaryOperator)
6217 This matcher elides details in places where the matchers for the nodes are
6218 compatible.
6220 Given
6221 binaryOperation(
6222 hasOperatorName("!="),
6223 hasLHS(expr().bind("lhs")),
6224 hasRHS(expr().bind("rhs"))
6226 matches each use of "!=" in:
6227 struct S{
6228 bool operator!=(const S&amp;) const;
6231 void foo()
6233 1 != 2;
6234 S() != S();
6237 template&lt;typename T&gt;
6238 void templ()
6240 1 != 2;
6241 T() != S();
6243 struct HasOpEq
6245 bool operator==(const HasOpEq &amp;) const;
6248 void inverse()
6250 HasOpEq s1;
6251 HasOpEq s2;
6252 if (s1 != s2)
6253 return;
6256 struct HasSpaceship
6258 bool operator&lt;=&gt;(const HasOpEq &amp;) const;
6261 void use_spaceship()
6263 HasSpaceship s1;
6264 HasSpaceship s2;
6265 if (s1 != s2)
6266 return;
6268 </pre></td></tr>
6271 <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>
6272 <tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches.
6274 Unlike anyOf, eachOf will generate a match result for each
6275 matching submatcher.
6277 For example, in:
6278 class A { int a; int b; };
6279 The matcher:
6280 cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
6281 has(fieldDecl(hasName("b")).bind("v"))))
6282 will generate two results binding "v", the first of which binds
6283 the field declaration of a, the second the field declaration of
6286 Usable as: Any Matcher
6287 </pre></td></tr>
6290 <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>
6291 <tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches.
6293 Generates results for each match.
6295 For example, in:
6296 class A { class B {}; class C {}; };
6297 The matcher:
6298 cxxRecordDecl(hasName("::A"),
6299 findAll(cxxRecordDecl(isDefinition()).bind("m")))
6300 will generate results for A, B and C.
6302 Usable as: Any Matcher
6303 </pre></td></tr>
6306 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher&lt;*&gt;</td></tr>
6307 <tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
6308 provided matcher.
6310 Example matches X, A, A::X, B, B::C, B::C::X
6311 (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))
6312 class X {};
6313 class A { class X {}; }; // Matches A, because A::X is a class of name
6314 // X inside A.
6315 class B { class C { class X {}; }; };
6317 DescendantT must be an AST base type.
6319 As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
6320 each result that matches instead of only on the first one.
6322 Note: Recursively combined ForEachDescendant can cause many matches:
6323 cxxRecordDecl(forEachDescendant(cxxRecordDecl(
6324 forEachDescendant(cxxRecordDecl())
6326 will match 10 times (plus injected class name matches) on:
6327 class A { class B { class C { class D { class E {}; }; }; }; };
6329 Usable as: Any Matcher
6330 </pre></td></tr>
6333 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher&lt;*&gt;</td></tr>
6334 <tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the
6335 provided matcher.
6337 Example matches X, Y, Y::X, Z::Y, Z::Y::X
6338 (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
6339 class X {};
6340 class Y { class X {}; }; // Matches Y, because Y::X is a class of name X
6341 // inside Y.
6342 class Z { class Y { class X {}; }; }; // Does not match Z.
6344 ChildT must be an AST base type.
6346 As opposed to 'has', 'forEach' will cause a match for each result that
6347 matches instead of only on the first one.
6349 Usable as: Any Matcher
6350 </pre></td></tr>
6353 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher&lt;*&gt;</td></tr>
6354 <tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided
6355 matcher.
6357 Given
6358 void f() { if (true) { int x = 42; } }
6359 void g() { for (;;) { int x = 43; } }
6360 expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.
6362 Usable as: Any Matcher
6363 </pre></td></tr>
6366 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher&lt;*&gt;</td></tr>
6367 <tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
6368 provided matcher.
6370 Example matches X, Y, Z
6371 (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X")))))
6372 class X {}; // Matches X, because X::X is a class of name X inside X.
6373 class Y { class X {}; };
6374 class Z { class Y { class X {}; }; };
6376 DescendantT must be an AST base type.
6378 Usable as: Any Matcher
6379 </pre></td></tr>
6382 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher&lt;*&gt;</td></tr>
6383 <tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the
6384 provided matcher.
6386 Example matches X, Y
6387 (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X")))
6388 class X {}; // Matches X, because X::X is a class of name X inside X.
6389 class Y { class X {}; };
6390 class Z { class Y { class X {}; }; }; // Does not match Z.
6392 ChildT must be an AST base type.
6394 Usable as: Any Matcher
6395 Note that has is direct matcher, so it also matches things like implicit
6396 casts and paren casts. If you are matching with expr then you should
6397 probably consider using ignoringParenImpCasts like:
6398 has(ignoringParenImpCasts(expr())).
6399 </pre></td></tr>
6402 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher&lt;*&gt;</td></tr>
6403 <tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided
6404 matcher.
6406 Given
6407 void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
6408 compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".
6410 Usable as: Any Matcher
6411 </pre></td></tr>
6414 <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>
6415 <tr><td colspan="4" class="doc" id="invocation0"><pre>Matches function calls and constructor calls
6417 Because CallExpr and CXXConstructExpr do not share a common
6418 base class with API accessing arguments etc, AST Matchers for code
6419 which should match both are typically duplicated. This matcher
6420 removes the need for duplication.
6422 Given code
6423 struct ConstructorTakesInt
6425 ConstructorTakesInt(int i) {}
6428 void callTakesInt(int i)
6432 void doCall()
6434 callTakesInt(42);
6437 void doConstruct()
6439 ConstructorTakesInt cti(42);
6442 The matcher
6443 invocation(hasArgument(0, integerLiteral(equals(42))))
6444 matches the expression in both doCall and doConstruct
6445 </pre></td></tr>
6448 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('optionally0')"><a name="optionally0Anchor">optionally</a></td><td>Matcher&lt;*&gt;</td></tr>
6449 <tr><td colspan="4" class="doc" id="optionally0"><pre>Matches any node regardless of the submatcher.
6451 However, optionally will retain any bindings generated by the submatcher.
6452 Useful when additional information which may or may not present about a main
6453 matching node is desired.
6455 For example, in:
6456 class Foo {
6457 int bar;
6459 The matcher:
6460 cxxRecordDecl(
6461 optionally(has(
6462 fieldDecl(hasName("bar")).bind("var")
6463 ))).bind("record")
6464 will produce a result binding for both "record" and "var".
6465 The matcher will produce a "record" binding for even if there is no data
6466 member named "bar" in that class.
6468 Usable as: Any Matcher
6469 </pre></td></tr>
6472 <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>
6473 <tr><td colspan="4" class="doc" id="traverse0"><pre>Causes all nested matchers to be matched with the specified traversal kind.
6475 Given
6476 void foo()
6478 int i = 3.0;
6480 The matcher
6481 traverse(TK_IgnoreUnlessSpelledInSource,
6482 varDecl(hasInitializer(floatLiteral().bind("init")))
6484 matches the variable declaration with "init" bound to the "3.0".
6485 </pre></td></tr>
6488 <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>
6489 <tr><td colspan="4" class="doc" id="hasCondition5"><pre>Matches the condition expression of an if statement, for loop,
6490 switch statement or conditional operator.
6492 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
6493 if (true) {}
6494 </pre></td></tr>
6497 <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>
6498 <tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator
6499 (binary or ternary).
6501 Example matches b
6502 condition ? a : b
6503 condition ?: b
6504 </pre></td></tr>
6507 <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>
6508 <tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator.
6510 Example 1 (conditional ternary operator): matches a
6511 condition ? a : b
6513 Example 2 (conditional binary operator): matches opaqueValueExpr(condition)
6514 condition ?: b
6515 </pre></td></tr>
6518 <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>
6519 <tr><td colspan="4" class="doc" id="hasDeclaration15"><pre>Matches a node if the declaration associated with that node
6520 matches the given matcher.
6522 The associated declaration is:
6523 - for type nodes, the declaration of the underlying type
6524 - for CallExpr, the declaration of the callee
6525 - for MemberExpr, the declaration of the referenced member
6526 - for CXXConstructExpr, the declaration of the constructor
6527 - for CXXNewExpr, the declaration of the operator new
6528 - for ObjCIvarExpr, the declaration of the ivar
6530 For type nodes, hasDeclaration will generally match the declaration of the
6531 sugared type. Given
6532 class X {};
6533 typedef X Y;
6534 Y y;
6535 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6536 typedefDecl. A common use case is to match the underlying, desugared type.
6537 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6538 varDecl(hasType(hasUnqualifiedDesugaredType(
6539 recordType(hasDeclaration(decl())))))
6540 In this matcher, the decl will match the CXXRecordDecl of class X.
6542 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;,
6543 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;,
6544 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;,
6545 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;,
6546 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;,
6547 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;,
6548 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6549 </pre></td></tr>
6552 <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>
6553 <tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression.
6555 Given
6556 int i[5];
6557 void f() { i[1] = 42; }
6558 arraySubscriptExpression(hasBase(implicitCastExpr(
6559 hasSourceExpression(declRefExpr()))))
6560 matches i[1] with the declRefExpr() matching i
6561 </pre></td></tr>
6564 <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>
6565 <tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression.
6567 Given
6568 int i[5];
6569 void f() { i[1] = 42; }
6570 arraySubscriptExpression(hasIndex(integerLiteral()))
6571 matches i[1] with the integerLiteral() matching 1
6572 </pre></td></tr>
6575 <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>
6576 <tr><td colspan="4" class="doc" id="hasLHS3"><pre>Matches the left hand side of binary operator expressions.
6578 Example matches a (matcher = binaryOperator(hasLHS()))
6579 a || b
6580 </pre></td></tr>
6583 <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>
6584 <tr><td colspan="4" class="doc" id="hasRHS3"><pre>Matches the right hand side of binary operator expressions.
6586 Example matches b (matcher = binaryOperator(hasRHS()))
6587 a || b
6588 </pre></td></tr>
6591 <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>
6592 <tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element
6593 type.
6595 Given
6596 struct A {};
6597 A a[7];
6598 int b[7];
6599 arrayType(hasElementType(builtinType()))
6600 matches "int b[7]"
6602 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;
6603 </pre></td></tr>
6606 <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>
6607 <tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type.
6609 Given
6610 _Atomic(int) i;
6611 _Atomic(float) f;
6612 atomicType(hasValueType(isInteger()))
6613 matches "_Atomic(int) i"
6615 Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
6616 </pre></td></tr>
6619 <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>
6620 <tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type.
6622 Note: There is no TypeLoc for the deduced type and thus no
6623 getDeducedLoc() matcher.
6625 Given
6626 auto a = 1;
6627 auto b = 2.0;
6628 autoType(hasDeducedType(isInteger()))
6629 matches "auto a"
6631 Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>&gt;
6632 </pre></td></tr>
6635 <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>
6636 <tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration.
6638 Given
6639 namespace X { void b(); }
6640 using X::b;
6641 usingDecl(hasAnyUsingShadowDecl(hasName("b"))))
6642 matches using X::b </pre></td></tr>
6645 <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>
6646 <tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a
6647 binary operator or fold expression matches.
6648 </pre></td></tr>
6651 <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>
6652 <tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions.
6654 Example matches a (matcher = binaryOperator(hasLHS()))
6655 a || b
6656 </pre></td></tr>
6659 <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>
6660 <tr><td colspan="4" class="doc" id="hasOperands0"><pre>Matches if both matchers match with opposite sides of the binary operator
6661 or fold expression.
6663 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
6664 integerLiteral(equals(2)))
6665 1 + 2 // Match
6666 2 + 1 // Match
6667 1 + 1 // No match
6668 2 + 2 // No match
6669 </pre></td></tr>
6672 <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>
6673 <tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions.
6675 Example matches b (matcher = binaryOperator(hasRHS()))
6676 a || b
6677 </pre></td></tr>
6680 <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>
6681 <tr><td colspan="4" class="doc" id="forDecomposition0"><pre>Matches the DecompositionDecl the binding belongs to.
6683 For example, in:
6684 void foo()
6686 int arr[3];
6687 auto &amp;[f, s, t] = arr;
6689 f = 42;
6691 The matcher:
6692 bindingDecl(hasName("f"),
6693 forDecomposition(decompositionDecl())
6694 matches 'f' in 'auto &amp;[f, s, t]'.
6695 </pre></td></tr>
6698 <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>
6699 <tr><td colspan="4" class="doc" id="hasAnyParameter2"><pre>Matches any parameter of a function or an ObjC method declaration or a
6700 block.
6702 Does not match the 'this' parameter of a method.
6704 Given
6705 class X { void f(int x, int y, int z) {} };
6706 cxxMethodDecl(hasAnyParameter(hasName("y")))
6707 matches f(int x, int y, int z) {}
6708 with hasAnyParameter(...)
6709 matching int y
6711 For ObjectiveC, given
6712 @interface I - (void) f:(int) y; @end
6714 the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
6715 matches the declaration of method f with hasParameter
6716 matching y.
6718 For blocks, given
6719 b = ^(int y) { printf("%d", y) };
6721 the matcher blockDecl(hasAnyParameter(hasName("y")))
6722 matches the declaration of the block b with hasParameter
6723 matching y.
6724 </pre></td></tr>
6727 <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>
6728 <tr><td colspan="4" class="doc" id="hasParameter2"><pre>Matches the n'th parameter of a function or an ObjC method
6729 declaration or a block.
6731 Given
6732 class X { void f(int x) {} };
6733 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
6734 matches f(int x) {}
6735 with hasParameter(...)
6736 matching int x
6738 For ObjectiveC, given
6739 @interface I - (void) f:(int) y; @end
6741 the matcher objcMethodDecl(hasParameter(0, hasName("y")))
6742 matches the declaration of method f with hasParameter
6743 matching y.
6744 </pre></td></tr>
6747 <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>
6748 <tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of a node matches the inner matcher.
6750 Examples:
6751 int x;
6752 declaratorDecl(hasTypeLoc(loc(asString("int"))))
6753 matches int x
6755 auto x = int(3);
6756 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6757 matches int(3)
6759 struct Foo { Foo(int, int); };
6760 auto x = Foo(1, 2);
6761 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6762 matches Foo(1, 2)
6764 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;,
6765 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;,
6766 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;,
6767 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6768 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
6769 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;,
6770 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;,
6771 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6772 </pre></td></tr>
6775 <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>
6776 <tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the
6777 pointee matches a given matcher.
6779 Given
6780 int *a;
6781 int const *b;
6782 float const *f;
6783 pointerType(pointee(isConstQualified(), isInteger()))
6784 matches "int const *b"
6786 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;,
6787 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;
6788 </pre></td></tr>
6791 <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>
6792 <tr><td colspan="4" class="doc" id="hasTypeLoc1"><pre>Matches if the type location of a node matches the inner matcher.
6794 Examples:
6795 int x;
6796 declaratorDecl(hasTypeLoc(loc(asString("int"))))
6797 matches int x
6799 auto x = int(3);
6800 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6801 matches int(3)
6803 struct Foo { Foo(int, int); };
6804 auto x = Foo(1, 2);
6805 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6806 matches Foo(1, 2)
6808 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;,
6809 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;,
6810 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;,
6811 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6812 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
6813 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;,
6814 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;,
6815 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6816 </pre></td></tr>
6819 <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>
6820 <tr><td colspan="4" class="doc" id="hasType8"><pre>Overloaded to match the declaration of the expression's or value
6821 declaration's type.
6823 In case of a value declaration (for example a variable declaration),
6824 this resolves one layer of indirection. For example, in the value
6825 declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
6826 X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
6827 declaration of x.
6829 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
6830 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
6831 and friend class X (matcher = friendDecl(hasType("X"))
6832 and public virtual X (matcher = cxxBaseSpecifier(hasType(
6833 cxxRecordDecl(hasName("X"))))
6834 class X {};
6835 void y(X &amp;x) { x; X z; }
6836 class Y { friend class X; };
6837 class Z : public virtual X {};
6839 Example matches class Derived
6840 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
6841 class Base {};
6842 class Derived : Base {};
6844 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;,
6845 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
6846 </pre></td></tr>
6849 <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>
6850 <tr><td colspan="4" class="doc" id="hasType4"><pre>Matches if the expression's or declaration's type matches a type
6851 matcher.
6853 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
6854 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
6855 and U (matcher = typedefDecl(hasType(asString("int")))
6856 and friend class X (matcher = friendDecl(hasType("X"))
6857 and public virtual X (matcher = cxxBaseSpecifier(hasType(
6858 asString("class X")))
6859 class X {};
6860 void y(X &amp;x) { x; X z; }
6861 typedef int U;
6862 class Y { friend class X; };
6863 class Z : public virtual X {};
6864 </pre></td></tr>
6867 <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>
6868 <tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl.
6870 Given
6871 void f(int i);
6872 int y;
6873 f(y);
6874 callExpr(
6875 forEachArgumentWithParam(
6876 declRefExpr(to(varDecl(hasName("y")))),
6877 parmVarDecl(hasType(isInteger()))
6879 matches f(y);
6880 with declRefExpr(...)
6881 matching int y
6882 and parmVarDecl(...)
6883 matching int i
6884 </pre></td></tr>
6887 <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>
6888 <tr><td colspan="4" class="doc" id="forEachArgumentWithParamType1"><pre>Matches all arguments and their respective types for a CallExpr or
6889 CXXConstructExpr. It is very similar to forEachArgumentWithParam but
6890 it works on calls through function pointers as well.
6892 The difference is, that function pointers do not provide access to a
6893 ParmVarDecl, but only the QualType for each argument.
6895 Given
6896 void f(int i);
6897 int y;
6898 f(y);
6899 void (*f_ptr)(int) = f;
6900 f_ptr(y);
6901 callExpr(
6902 forEachArgumentWithParamType(
6903 declRefExpr(to(varDecl(hasName("y")))),
6904 qualType(isInteger()).bind("type)
6906 matches f(y) and f_ptr(y)
6907 with declRefExpr(...)
6908 matching int y
6909 and qualType(...)
6910 matching int
6911 </pre></td></tr>
6914 <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>
6915 <tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call
6916 expression, or an ObjC-message-send expression.
6918 Given
6919 void x(int, int, int) { int y; x(1, y, 42); }
6920 callExpr(hasAnyArgument(declRefExpr()))
6921 matches x(1, y, 42)
6922 with hasAnyArgument(...)
6923 matching y
6925 For ObjectiveC, given
6926 @interface I - (void) f:(int) y; @end
6927 void foo(I *i) { [i f:12]; }
6928 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
6929 matches [i f:12]
6930 </pre></td></tr>
6933 <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>
6934 <tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor
6935 call expression.
6937 Example matches y in x(y)
6938 (matcher = callExpr(hasArgument(0, declRefExpr())))
6939 void x(int) { int y; x(y); }
6940 </pre></td></tr>
6943 <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>
6944 <tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node
6945 matches the given matcher.
6947 The associated declaration is:
6948 - for type nodes, the declaration of the underlying type
6949 - for CallExpr, the declaration of the callee
6950 - for MemberExpr, the declaration of the referenced member
6951 - for CXXConstructExpr, the declaration of the constructor
6952 - for CXXNewExpr, the declaration of the operator new
6953 - for ObjCIvarExpr, the declaration of the ivar
6955 For type nodes, hasDeclaration will generally match the declaration of the
6956 sugared type. Given
6957 class X {};
6958 typedef X Y;
6959 Y y;
6960 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6961 typedefDecl. A common use case is to match the underlying, desugared type.
6962 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6963 varDecl(hasType(hasUnqualifiedDesugaredType(
6964 recordType(hasDeclaration(decl())))))
6965 In this matcher, the decl will match the CXXRecordDecl of class X.
6967 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;,
6968 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;,
6969 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;,
6970 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;,
6971 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;,
6972 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;,
6973 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6974 </pre></td></tr>
6977 <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>
6978 <tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition.
6980 Given
6981 class A { A() : i(42), j(42) {} int i; int j; };
6982 cxxConstructorDecl(forEachConstructorInitializer(
6983 forField(decl().bind("x"))
6985 will trigger two matches, binding for 'i' and 'j' respectively.
6986 </pre></td></tr>
6989 <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>
6990 <tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer.
6992 Given
6993 struct Foo {
6994 Foo() : foo_(1) { }
6995 int foo_;
6997 cxxRecordDecl(has(cxxConstructorDecl(
6998 hasAnyConstructorInitializer(anything())
7000 record matches Foo, hasAnyConstructorInitializer matches foo_(1)
7001 </pre></td></tr>
7004 <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>
7005 <tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer.
7007 Given
7008 struct Foo {
7009 Foo() : foo_(1) { }
7010 int foo_;
7012 cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
7013 forField(hasName("foo_"))))))
7014 matches Foo
7015 with forField matching foo_
7016 </pre></td></tr>
7019 <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>
7020 <tr><td colspan="4" class="doc" id="hasTypeLoc2"><pre>Matches if the type location of a node matches the inner matcher.
7022 Examples:
7023 int x;
7024 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7025 matches int x
7027 auto x = int(3);
7028 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7029 matches int(3)
7031 struct Foo { Foo(int, int); };
7032 auto x = Foo(1, 2);
7033 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7034 matches Foo(1, 2)
7036 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;,
7037 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;,
7038 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;,
7039 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7040 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7041 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;,
7042 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;,
7043 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7044 </pre></td></tr>
7047 <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>
7048 <tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer.
7050 Given
7051 struct Foo {
7052 Foo() : foo_(1) { }
7053 int foo_;
7055 cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
7056 withInitializer(integerLiteral(equals(1)))))))
7057 matches Foo
7058 with withInitializer matching (1)
7059 </pre></td></tr>
7062 <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>
7063 <tr><td colspan="4" class="doc" id="hasObjectExpression2"><pre>Matches a member expression where the object expression is matched by a
7064 given matcher. Implicit object expressions are included; that is, it matches
7065 use of implicit `this`.
7067 Given
7068 struct X {
7069 int m;
7070 int f(X x) { x.m; return m; }
7072 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))
7073 matches `x.m`, but not `m`; however,
7074 memberExpr(hasObjectExpression(hasType(pointsTo(
7075 cxxRecordDecl(hasName("X"))))))
7076 matches `m` (aka. `this-&gt;m`), but not `x.m`.
7077 </pre></td></tr>
7080 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</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_1Stmt.html">Stmt</a>&gt; InnerMatcher</td></tr>
7081 <tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call or fold expression's callee expression matches.
7083 Given
7084 class Y { void x() { this-&gt;x(); x(); Y y; y.x(); } };
7085 void f() { f(); }
7086 callExpr(callee(expr()))
7087 matches this-&gt;x(), x(), y.x(), f()
7088 with callee(...)
7089 matching this-&gt;x, x, y.x, f respectively
7091 Given
7092 template &lt;typename... Args&gt;
7093 auto sum(Args... args) {
7094 return (0 + ... + args);
7097 template &lt;typename... Args&gt;
7098 auto multiply(Args... args) {
7099 return (args * ... * 1);
7101 cxxFoldExpr(callee(expr()))
7102 matches (args * ... * 1)
7103 with callee(...)
7104 matching *
7106 Note: Callee cannot take the more general internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;
7107 because this introduces ambiguous overloads with calls to Callee taking a
7108 internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, as the matcher hierarchy is purely
7109 implemented in terms of implicit casts.
7110 </pre></td></tr>
7113 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</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>
7114 <tr><td colspan="4" class="doc" id="hasEitherOperand2"><pre>Matches if either the left hand side or the right hand side of a
7115 binary operator or fold expression matches.
7116 </pre></td></tr>
7119 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>&gt;</td><td class="name" onclick="toggle('hasFoldInit0')"><a name="hasFoldInit0Anchor">hasFoldInit</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMacher</td></tr>
7120 <tr><td colspan="4" class="doc" id="hasFoldInit0"><pre>Matches the operand that does not contain the parameter pack.
7122 Example matches `(0 + ... + args)` and `(args * ... * 1)`
7123 (matcher = cxxFoldExpr(hasFoldInit(expr())))
7124 with hasFoldInit(...)
7125 matching `0` and `1` respectively
7126 template &lt;typename... Args&gt;
7127 auto sum(Args... args) {
7128 return (0 + ... + args);
7131 template &lt;typename... Args&gt;
7132 auto multiply(Args... args) {
7133 return (args * ... * 1);
7135 </pre></td></tr>
7138 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>&gt;</td><td class="name" onclick="toggle('hasLHS4')"><a name="hasLHS4Anchor">hasLHS</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
7139 <tr><td colspan="4" class="doc" id="hasLHS4"><pre>Matches the left hand side of binary operator expressions.
7141 Example matches a (matcher = binaryOperator(hasLHS()))
7142 a || b
7143 </pre></td></tr>
7146 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</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>
7147 <tr><td colspan="4" class="doc" id="hasOperands2"><pre>Matches if both matchers match with opposite sides of the binary operator
7148 or fold expression.
7150 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
7151 integerLiteral(equals(2)))
7152 1 + 2 // Match
7153 2 + 1 // Match
7154 1 + 1 // No match
7155 2 + 2 // No match
7156 </pre></td></tr>
7159 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>&gt;</td><td class="name" onclick="toggle('hasPattern0')"><a name="hasPattern0Anchor">hasPattern</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMacher</td></tr>
7160 <tr><td colspan="4" class="doc" id="hasPattern0"><pre>Matches the operand that contains the parameter pack.
7162 Example matches `(0 + ... + args)`
7163 (matcher = cxxFoldExpr(hasPattern(expr())))
7164 with hasPattern(...)
7165 matching `args`
7166 template &lt;typename... Args&gt;
7167 auto sum(Args... args) {
7168 return (0 + ... + args);
7171 template &lt;typename... Args&gt;
7172 auto multiply(Args... args) {
7173 return (args * ... * 1);
7175 </pre></td></tr>
7178 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr</a>&gt;</td><td class="name" onclick="toggle('hasRHS4')"><a name="hasRHS4Anchor">hasRHS</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
7179 <tr><td colspan="4" class="doc" id="hasRHS4"><pre>Matches the right hand side of binary operator expressions.
7181 Example matches b (matcher = binaryOperator(hasRHS()))
7182 a || b
7183 </pre></td></tr>
7186 <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>
7187 <tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
7188 definition that has a given body. Note that in case of functions or
7189 coroutines this matcher only matches the definition itself and not the
7190 other declarations of the same function or coroutine.
7192 Given
7193 for (;;) {}
7194 forStmt(hasBody(compoundStmt()))
7195 matches 'for (;;) {}'
7196 with compoundStmt()
7197 matching '{}'
7199 Given
7200 void f();
7201 void f() {}
7202 functionDecl(hasBody(compoundStmt()))
7203 matches 'void f() {}'
7204 with compoundStmt()
7205 matching '{}'
7206 but does not match 'void f();'
7207 </pre></td></tr>
7210 <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>
7211 <tr><td colspan="4" class="doc" id="hasInitStatement2"><pre>Matches selection statements with initializer.
7213 Given:
7214 void foo() {
7215 if (int i = foobar(); i &gt; 0) {}
7216 switch (int i = foobar(); i) {}
7217 for (auto&amp; a = get_range(); auto&amp; x : a) {}
7219 void bar() {
7220 if (foobar() &gt; 0) {}
7221 switch (foobar()) {}
7222 for (auto&amp; x : get_range()) {}
7224 ifStmt(hasInitStatement(anything()))
7225 matches the if statement in foo but not in bar.
7226 switchStmt(hasInitStatement(anything()))
7227 matches the switch statement in foo but not in bar.
7228 cxxForRangeStmt(hasInitStatement(anything()))
7229 matches the range for statement in foo but not in bar.
7230 </pre></td></tr>
7233 <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>
7234 <tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop.
7236 Example:
7237 forStmt(hasLoopVariable(anything()))
7238 matches 'int x' in
7239 for (int x : a) { }
7240 </pre></td></tr>
7243 <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>
7244 <tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop.
7246 Example:
7247 forStmt(hasRangeInit(anything()))
7248 matches 'a' in
7249 for (int x : a) { }
7250 </pre></td></tr>
7253 <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>
7254 <tr><td colspan="4" class="doc" id="hasTypeLoc3"><pre>Matches if the type location of a node matches the inner matcher.
7256 Examples:
7257 int x;
7258 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7259 matches int x
7261 auto x = int(3);
7262 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7263 matches int(3)
7265 struct Foo { Foo(int, int); };
7266 auto x = Foo(1, 2);
7267 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7268 matches Foo(1, 2)
7270 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;,
7271 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;,
7272 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;,
7273 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7274 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7275 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;,
7276 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;,
7277 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7278 </pre></td></tr>
7281 <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>
7282 <tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre>Matches on the implicit object argument of a member call expression. Unlike
7283 `on`, matches the argument directly without stripping away anything.
7285 Given
7286 class Y { public: void m(); };
7287 Y g();
7288 class X : public Y { void g(); };
7289 void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); }
7290 cxxMemberCallExpr(onImplicitObjectArgument(hasType(
7291 cxxRecordDecl(hasName("Y")))))
7292 matches `y.m()`, `x.m()` and (`g()).m()`, but not `x.g()`).
7293 cxxMemberCallExpr(on(callExpr()))
7294 only matches `(g()).m()` (the parens are ignored).
7296 FIXME: Overload to allow directly matching types?
7297 </pre></td></tr>
7300 <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>
7301 <tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression, after
7302 stripping off any parentheses or implicit casts.
7304 Given
7305 class Y { public: void m(); };
7306 Y g();
7307 class X : public Y {};
7308 void z(Y y, X x) { y.m(); (g()).m(); x.m(); }
7309 cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))))
7310 matches `y.m()` and `(g()).m()`.
7311 cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X")))))
7312 matches `x.m()`.
7313 cxxMemberCallExpr(on(callExpr()))
7314 matches `(g()).m()`.
7316 FIXME: Overload to allow directly matching types?
7317 </pre></td></tr>
7320 <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>
7321 <tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration.
7322 </pre></td></tr>
7325 <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>
7326 <tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the type of the expression's implicit object argument either
7327 matches the InnerMatcher, or is a pointer to a type that matches the
7328 InnerMatcher.
7330 Given
7331 class Y { public: void m(); };
7332 class X : public Y { void g(); };
7333 void z() { Y y; y.m(); Y *p; p-&gt;m(); X x; x.m(); x.g(); }
7334 cxxMemberCallExpr(thisPointerType(hasDeclaration(
7335 cxxRecordDecl(hasName("Y")))))
7336 matches `y.m()`, `p-&gt;m()` and `x.m()`.
7337 cxxMemberCallExpr(thisPointerType(hasDeclaration(
7338 cxxRecordDecl(hasName("X")))))
7339 matches `x.g()`.
7340 </pre></td></tr>
7343 <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>
7344 <tr><td colspan="4" class="doc" id="forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may
7345 produce multiple matches.
7347 Given
7348 class A { virtual void f(); };
7349 class B : public A { void f(); };
7350 class C : public B { void f(); };
7351 cxxMethodDecl(ofClass(hasName("C")),
7352 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
7353 matches once, with "b" binding "A::f" and "d" binding "C::f" (Note
7354 that B::f is not overridden by C::f).
7356 The check can produce multiple matches in case of multiple inheritance, e.g.
7357 class A1 { virtual void f(); };
7358 class A2 { virtual void f(); };
7359 class C : public A1, public A2 { void f(); };
7360 cxxMethodDecl(ofClass(hasName("C")),
7361 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
7362 matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and
7363 once with "b" binding "A2::f" and "d" binding "C::f".
7364 </pre></td></tr>
7367 <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>
7368 <tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration
7369 belongs to.
7371 FIXME: Generalize this for other kinds of declarations.
7372 FIXME: What other kind of declarations would we need to generalize
7373 this to?
7375 Example matches A() in the last line
7376 (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl(
7377 ofClass(hasName("A"))))))
7378 class A {
7379 public:
7380 A();
7382 A a = A();
7383 </pre></td></tr>
7386 <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>
7387 <tr><td colspan="4" class="doc" id="hasAnyPlacementArg0"><pre>Matches any placement new expression arguments.
7389 Given:
7390 MyClass *p1 = new (Storage) MyClass();
7391 cxxNewExpr(hasAnyPlacementArg(anything()))
7392 matches the expression 'new (Storage, 16) MyClass()'.
7393 </pre></td></tr>
7396 <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>
7397 <tr><td colspan="4" class="doc" id="hasArraySize0"><pre>Matches array new expressions with a given array size.
7399 Given:
7400 MyClass *p1 = new MyClass[10];
7401 cxxNewExpr(hasArraySize(integerLiteral(equals(10))))
7402 matches the expression 'new MyClass[10]'.
7403 </pre></td></tr>
7406 <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>
7407 <tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node
7408 matches the given matcher.
7410 The associated declaration is:
7411 - for type nodes, the declaration of the underlying type
7412 - for CallExpr, the declaration of the callee
7413 - for MemberExpr, the declaration of the referenced member
7414 - for CXXConstructExpr, the declaration of the constructor
7415 - for CXXNewExpr, the declaration of the operator new
7416 - for ObjCIvarExpr, the declaration of the ivar
7418 For type nodes, hasDeclaration will generally match the declaration of the
7419 sugared type. Given
7420 class X {};
7421 typedef X Y;
7422 Y y;
7423 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7424 typedefDecl. A common use case is to match the underlying, desugared type.
7425 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7426 varDecl(hasType(hasUnqualifiedDesugaredType(
7427 recordType(hasDeclaration(decl())))))
7428 In this matcher, the decl will match the CXXRecordDecl of class X.
7430 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;,
7431 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;,
7432 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;,
7433 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;,
7434 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;,
7435 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;,
7436 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
7437 </pre></td></tr>
7440 <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>
7441 <tr><td colspan="4" class="doc" id="hasPlacementArg0"><pre>Matches placement new expression arguments.
7443 Given:
7444 MyClass *p1 = new (Storage, 16) MyClass();
7445 cxxNewExpr(hasPlacementArg(1, integerLiteral(equals(16))))
7446 matches the expression 'new (Storage, 16) MyClass()'.
7447 </pre></td></tr>
7450 <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>
7451 <tr><td colspan="4" class="doc" id="hasTypeLoc4"><pre>Matches if the type location of a node matches the inner matcher.
7453 Examples:
7454 int x;
7455 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7456 matches int x
7458 auto x = int(3);
7459 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7460 matches int(3)
7462 struct Foo { Foo(int, int); };
7463 auto x = Foo(1, 2);
7464 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7465 matches Foo(1, 2)
7467 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;,
7468 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;,
7469 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;,
7470 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7471 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7472 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;,
7473 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;,
7474 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7475 </pre></td></tr>
7478 <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>
7479 <tr><td colspan="4" class="doc" id="hasEitherOperand1"><pre>Matches if either the left hand side or the right hand side of a
7480 binary operator or fold expression matches.
7481 </pre></td></tr>
7484 <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>
7485 <tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions.
7487 Example matches a (matcher = binaryOperator(hasLHS()))
7488 a || b
7489 </pre></td></tr>
7492 <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>
7493 <tr><td colspan="4" class="doc" id="hasOperands1"><pre>Matches if both matchers match with opposite sides of the binary operator
7494 or fold expression.
7496 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
7497 integerLiteral(equals(2)))
7498 1 + 2 // Match
7499 2 + 1 // Match
7500 1 + 1 // No match
7501 2 + 2 // No match
7502 </pre></td></tr>
7505 <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>
7506 <tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions.
7508 Example matches b (matcher = binaryOperator(hasRHS()))
7509 a || b
7510 </pre></td></tr>
7513 <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>
7514 <tr><td colspan="4" class="doc" id="hasUnaryOperand1"><pre>Matches if the operand of a unary operator matches.
7516 Example matches true (matcher = hasUnaryOperand(
7517 cxxBoolLiteral(equals(true))))
7518 !true
7519 </pre></td></tr>
7522 <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>
7523 <tr><td colspan="4" class="doc" id="hasAnyBase0"><pre>Matches C++ classes that have a direct or indirect base matching BaseSpecMatcher.
7525 Example:
7526 matcher hasAnyBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))
7527 class Foo;
7528 class Bar : Foo {};
7529 class Baz : Bar {};
7530 class SpecialBase;
7531 class Proxy : SpecialBase {}; // matches Proxy
7532 class IndirectlyDerived : Proxy {}; //matches IndirectlyDerived
7534 FIXME: Refactor this and isDerivedFrom to reuse implementation.
7535 </pre></td></tr>
7538 <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>
7539 <tr><td colspan="4" class="doc" id="hasDirectBase0"><pre>Matches C++ classes that have a direct base matching BaseSpecMatcher.
7541 Example:
7542 matcher hasDirectBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))
7543 class Foo;
7544 class Bar : Foo {};
7545 class Baz : Bar {};
7546 class SpecialBase;
7547 class Proxy : SpecialBase {}; // matches Proxy
7548 class IndirectlyDerived : Proxy {}; // doesn't match
7549 </pre></td></tr>
7552 <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>
7553 <tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher.
7555 Given:
7556 class A { void func(); };
7557 class B { void member(); };
7559 cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of
7560 A but not B.
7561 </pre></td></tr>
7564 <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>
7565 <tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from a class
7566 matching Base, or Objective-C classes that directly or indirectly
7567 subclass a class matching Base.
7569 Note that a class is not considered to be derived from itself.
7571 Example matches Y, Z, C (Base == hasName("X"))
7572 class X;
7573 class Y : public X {}; // directly derived
7574 class Z : public Y {}; // indirectly derived
7575 typedef X A;
7576 typedef A B;
7577 class C : public B {}; // derived from a typedef of X
7579 In the following example, Bar matches isDerivedFrom(hasName("X")):
7580 class Foo;
7581 typedef Foo X;
7582 class Bar : public Foo {}; // derived from a type that X is a typedef of
7584 In the following example, Bar matches isDerivedFrom(hasName("NSObject"))
7585 @interface NSObject @end
7586 @interface Bar : NSObject @end
7588 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;
7589 </pre></td></tr>
7592 <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>
7593 <tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom0"><pre>Matches C++ or Objective-C classes that are directly derived from a class
7594 matching Base.
7596 Note that a class is not considered to be derived from itself.
7598 Example matches Y, C (Base == hasName("X"))
7599 class X;
7600 class Y : public X {}; // directly derived
7601 class Z : public Y {}; // indirectly derived
7602 typedef X A;
7603 typedef A B;
7604 class C : public B {}; // derived from a typedef of X
7606 In the following example, Bar matches isDerivedFrom(hasName("X")):
7607 class Foo;
7608 typedef Foo X;
7609 class Bar : public Foo {}; // derived from a type that X is a typedef of
7610 </pre></td></tr>
7613 <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>
7614 <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly
7615 match Base.
7616 </pre></td></tr>
7619 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasEitherOperand3')"><a name="hasEitherOperand3Anchor">hasEitherOperand</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
7620 <tr><td colspan="4" class="doc" id="hasEitherOperand3"><pre>Matches if either the left hand side or the right hand side of a
7621 binary operator or fold expression matches.
7622 </pre></td></tr>
7625 <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>
7626 <tr><td colspan="4" class="doc" id="hasLHS2"><pre>Matches the left hand side of binary operator expressions.
7628 Example matches a (matcher = binaryOperator(hasLHS()))
7629 a || b
7630 </pre></td></tr>
7633 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasOperands3')"><a name="hasOperands3Anchor">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>
7634 <tr><td colspan="4" class="doc" id="hasOperands3"><pre>Matches if both matchers match with opposite sides of the binary operator
7635 or fold expression.
7637 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
7638 integerLiteral(equals(2)))
7639 1 + 2 // Match
7640 2 + 1 // Match
7641 1 + 1 // No match
7642 2 + 2 // No match
7643 </pre></td></tr>
7646 <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>
7647 <tr><td colspan="4" class="doc" id="hasRHS2"><pre>Matches the right hand side of binary operator expressions.
7649 Example matches b (matcher = binaryOperator(hasRHS()))
7650 a || b
7651 </pre></td></tr>
7654 <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>
7655 <tr><td colspan="4" class="doc" id="hasTypeLoc5"><pre>Matches if the type location of a node matches the inner matcher.
7657 Examples:
7658 int x;
7659 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7660 matches int x
7662 auto x = int(3);
7663 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7664 matches int(3)
7666 struct Foo { Foo(int, int); };
7667 auto x = Foo(1, 2);
7668 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7669 matches Foo(1, 2)
7671 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;,
7672 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;,
7673 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;,
7674 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7675 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7676 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;,
7677 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;,
7678 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7679 </pre></td></tr>
7682 <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>
7683 <tr><td colspan="4" class="doc" id="hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call
7684 expression, or an ObjC-message-send expression.
7686 Given
7687 void x(int, int, int) { int y; x(1, y, 42); }
7688 callExpr(hasAnyArgument(declRefExpr()))
7689 matches x(1, y, 42)
7690 with hasAnyArgument(...)
7691 matching y
7693 For ObjectiveC, given
7694 @interface I - (void) f:(int) y; @end
7695 void foo(I *i) { [i f:12]; }
7696 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
7697 matches [i f:12]
7698 </pre></td></tr>
7701 <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>
7702 <tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor
7703 call expression.
7705 Example matches y in x(y)
7706 (matcher = callExpr(hasArgument(0, declRefExpr())))
7707 void x(int) { int y; x(y); }
7708 </pre></td></tr>
7711 <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>
7712 <tr><td colspan="4" class="doc" id="hasTypeLoc6"><pre>Matches if the type location of a node matches the inner matcher.
7714 Examples:
7715 int x;
7716 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7717 matches int x
7719 auto x = int(3);
7720 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7721 matches int(3)
7723 struct Foo { Foo(int, int); };
7724 auto x = Foo(1, 2);
7725 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7726 matches Foo(1, 2)
7728 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;,
7729 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;,
7730 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;,
7731 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7732 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7733 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;,
7734 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;,
7735 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7736 </pre></td></tr>
7739 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('callee3')"><a name="callee3Anchor">callee</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
7740 <tr><td colspan="4" class="doc" id="callee3"><pre>Matches 1) if the call expression's callee's declaration matches the
7741 given matcher; or 2) if the Obj-C message expression's callee's method
7742 declaration matches the given matcher.
7744 Example matches y.x() (matcher = callExpr(callee(
7745 cxxMethodDecl(hasName("x")))))
7746 class Y { public: void x(); };
7747 void z() { Y y; y.x(); }
7749 Example 2. Matches [I foo] with
7750 objcMessageExpr(callee(objcMethodDecl(hasName("foo"))))
7752 @interface I: NSObject
7753 +(void)foo;
7754 @end
7756 [I foo]
7757 </pre></td></tr>
7760 <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>
7761 <tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call or fold expression's callee expression matches.
7763 Given
7764 class Y { void x() { this-&gt;x(); x(); Y y; y.x(); } };
7765 void f() { f(); }
7766 callExpr(callee(expr()))
7767 matches this-&gt;x(), x(), y.x(), f()
7768 with callee(...)
7769 matching this-&gt;x, x, y.x, f respectively
7771 Given
7772 template &lt;typename... Args&gt;
7773 auto sum(Args... args) {
7774 return (0 + ... + args);
7777 template &lt;typename... Args&gt;
7778 auto multiply(Args... args) {
7779 return (args * ... * 1);
7781 cxxFoldExpr(callee(expr()))
7782 matches (args * ... * 1)
7783 with callee(...)
7784 matching *
7786 Note: Callee cannot take the more general internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;
7787 because this introduces ambiguous overloads with calls to Callee taking a
7788 internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, as the matcher hierarchy is purely
7789 implemented in terms of implicit casts.
7790 </pre></td></tr>
7793 <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>
7794 <tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl.
7796 Given
7797 void f(int i);
7798 int y;
7799 f(y);
7800 callExpr(
7801 forEachArgumentWithParam(
7802 declRefExpr(to(varDecl(hasName("y")))),
7803 parmVarDecl(hasType(isInteger()))
7805 matches f(y);
7806 with declRefExpr(...)
7807 matching int y
7808 and parmVarDecl(...)
7809 matching int i
7810 </pre></td></tr>
7813 <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>
7814 <tr><td colspan="4" class="doc" id="forEachArgumentWithParamType0"><pre>Matches all arguments and their respective types for a CallExpr or
7815 CXXConstructExpr. It is very similar to forEachArgumentWithParam but
7816 it works on calls through function pointers as well.
7818 The difference is, that function pointers do not provide access to a
7819 ParmVarDecl, but only the QualType for each argument.
7821 Given
7822 void f(int i);
7823 int y;
7824 f(y);
7825 void (*f_ptr)(int) = f;
7826 f_ptr(y);
7827 callExpr(
7828 forEachArgumentWithParamType(
7829 declRefExpr(to(varDecl(hasName("y")))),
7830 qualType(isInteger()).bind("type)
7832 matches f(y) and f_ptr(y)
7833 with declRefExpr(...)
7834 matching int y
7835 and qualType(...)
7836 matching int
7837 </pre></td></tr>
7840 <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>
7841 <tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call
7842 expression, or an ObjC-message-send expression.
7844 Given
7845 void x(int, int, int) { int y; x(1, y, 42); }
7846 callExpr(hasAnyArgument(declRefExpr()))
7847 matches x(1, y, 42)
7848 with hasAnyArgument(...)
7849 matching y
7851 For ObjectiveC, given
7852 @interface I - (void) f:(int) y; @end
7853 void foo(I *i) { [i f:12]; }
7854 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
7855 matches [i f:12]
7856 </pre></td></tr>
7859 <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>
7860 <tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor
7861 call expression.
7863 Example matches y in x(y)
7864 (matcher = callExpr(hasArgument(0, declRefExpr())))
7865 void x(int) { int y; x(y); }
7866 </pre></td></tr>
7869 <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>
7870 <tr><td colspan="4" class="doc" id="hasDeclaration14"><pre>Matches a node if the declaration associated with that node
7871 matches the given matcher.
7873 The associated declaration is:
7874 - for type nodes, the declaration of the underlying type
7875 - for CallExpr, the declaration of the callee
7876 - for MemberExpr, the declaration of the referenced member
7877 - for CXXConstructExpr, the declaration of the constructor
7878 - for CXXNewExpr, the declaration of the operator new
7879 - for ObjCIvarExpr, the declaration of the ivar
7881 For type nodes, hasDeclaration will generally match the declaration of the
7882 sugared type. Given
7883 class X {};
7884 typedef X Y;
7885 Y y;
7886 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7887 typedefDecl. A common use case is to match the underlying, desugared type.
7888 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7889 varDecl(hasType(hasUnqualifiedDesugaredType(
7890 recordType(hasDeclaration(decl())))))
7891 In this matcher, the decl will match the CXXRecordDecl of class X.
7893 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;,
7894 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;,
7895 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;,
7896 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;,
7897 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;,
7898 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;,
7899 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
7900 </pre></td></tr>
7903 <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>
7904 <tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range
7905 extension, matches the constant given in the statement.
7907 Given
7908 switch (1) { case 1: case 1+1: case 3 ... 4: ; }
7909 caseStmt(hasCaseConstant(integerLiteral()))
7910 matches "case 1:"
7911 </pre></td></tr>
7914 <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>
7915 <tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression
7916 or opaque value's source expression matches the given matcher.
7918 Example 1: matches "a string"
7919 (matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
7920 class URL { URL(string); };
7921 URL url = "a string";
7923 Example 2: matches 'b' (matcher =
7924 opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
7925 int a = b ?: 1;
7926 </pre></td></tr>
7929 <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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
7930 <tr><td colspan="4" class="doc" id="forEachTemplateArgument0"><pre>Matches templateSpecializationType, class template specialization,
7931 variable template specialization, and function template specialization
7932 nodes where the template argument matches the inner matcher. This matcher
7933 may produce multiple matches.
7935 Given
7936 template &lt;typename T, unsigned N, unsigned M&gt;
7937 struct Matrix {};
7939 constexpr unsigned R = 2;
7940 Matrix&lt;int, R * 2, R * 4&gt; M;
7942 template &lt;typename T, typename U&gt;
7943 void f(T&amp;&amp; t, U&amp;&amp; u) {}
7945 bool B = false;
7946 f(R, B);
7947 templateSpecializationType(forEachTemplateArgument(isExpr(expr())))
7948 matches twice, with expr() matching 'R * 2' and 'R * 4'
7949 functionDecl(forEachTemplateArgument(refersToType(builtinType())))
7950 matches the specialization f&lt;unsigned, bool&gt; twice, for 'unsigned'
7951 and 'bool'
7952 </pre></td></tr>
7955 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</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>
7956 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgumentLoc0"><pre>Matches template specialization `TypeLoc`s, class template specializations,
7957 variable template specializations, and function template specializations
7958 that have at least one `TemplateArgumentLoc` matching the given
7959 `InnerMatcher`.
7961 Given
7962 template&lt;typename T&gt; class A {};
7963 A&lt;int&gt; a;
7964 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc(
7965 hasTypeLoc(loc(asString("int")))))))
7966 matches `A&lt;int&gt; a`.
7967 </pre></td></tr>
7970 <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>
7971 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches templateSpecializationTypes, class template specializations,
7972 variable template specializations, and function template specializations
7973 that have at least one TemplateArgument matching the given InnerMatcher.
7975 Given
7976 template&lt;typename T&gt; class A {};
7977 template&lt;&gt; class A&lt;double&gt; {};
7978 A&lt;int&gt; a;
7980 template&lt;typename T&gt; f() {};
7981 void func() { f&lt;int&gt;(); };
7983 classTemplateSpecializationDecl(hasAnyTemplateArgument(
7984 refersToType(asString("int"))))
7985 matches the specialization A&lt;int&gt;
7987 functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
7988 matches the specialization f&lt;int&gt;
7989 </pre></td></tr>
7992 <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>
7993 <tr><td colspan="4" class="doc" id="hasSpecializedTemplate0"><pre>Matches the specialized template of a specialization declaration.
7995 Given
7996 template&lt;typename T&gt; class A {}; #1
7997 template&lt;&gt; class A&lt;int&gt; {}; #2
7998 classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl()))
7999 matches '#2' with classTemplateDecl() matching the class template
8000 declaration of 'A' at #1.
8001 </pre></td></tr>
8004 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</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>
8005 <tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc0"><pre>Matches template specialization `TypeLoc`s, class template specializations,
8006 variable template specializations, and function template specializations
8007 where the n'th `TemplateArgumentLoc` matches the given `InnerMatcher`.
8009 Given
8010 template&lt;typename T, typename U&gt; class A {};
8011 A&lt;double, int&gt; b;
8012 A&lt;int, double&gt; c;
8013 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
8014 hasTypeLoc(loc(asString("double")))))))
8015 matches `A&lt;double, int&gt; b`, but not `A&lt;int, double&gt; c`.
8016 </pre></td></tr>
8019 <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>
8020 <tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches templateSpecializationType, class template specializations,
8021 variable template specializations, and function template specializations
8022 where the n'th TemplateArgument matches the given InnerMatcher.
8024 Given
8025 template&lt;typename T, typename U&gt; class A {};
8026 A&lt;bool, int&gt; b;
8027 A&lt;int, bool&gt; c;
8029 template&lt;typename T&gt; void f() {}
8030 void func() { f&lt;int&gt;(); };
8031 classTemplateSpecializationDecl(hasTemplateArgument(
8032 1, refersToType(asString("int"))))
8033 matches the specialization A&lt;bool, int&gt;
8035 functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
8036 matches the specialization f&lt;int&gt;
8037 </pre></td></tr>
8040 <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>
8041 <tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element
8042 type.
8044 Given
8045 struct A {};
8046 A a[7];
8047 int b[7];
8048 arrayType(hasElementType(builtinType()))
8049 matches "int b[7]"
8051 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;
8052 </pre></td></tr>
8055 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</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>
8056 <tr><td colspan="4" class="doc" id="hasTypeLoc7"><pre>Matches if the type location of a node matches the inner matcher.
8058 Examples:
8059 int x;
8060 declaratorDecl(hasTypeLoc(loc(asString("int"))))
8061 matches int x
8063 auto x = int(3);
8064 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
8065 matches int(3)
8067 struct Foo { Foo(int, int); };
8068 auto x = Foo(1, 2);
8069 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
8070 matches Foo(1, 2)
8072 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;,
8073 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;,
8074 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;,
8075 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
8076 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
8077 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;,
8078 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;,
8079 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
8080 </pre></td></tr>
8083 <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>
8084 <tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches
8085 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
8087 Given
8088 { {}; 1+2; }
8089 hasAnySubstatement(compoundStmt())
8090 matches '{ {}; 1+2; }'
8091 with compoundStmt()
8092 matching '{}'
8093 </pre></td></tr>
8096 <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>
8097 <tr><td colspan="4" class="doc" id="hasBody5"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
8098 definition that has a given body. Note that in case of functions or
8099 coroutines this matcher only matches the definition itself and not the
8100 other declarations of the same function or coroutine.
8102 Given
8103 for (;;) {}
8104 forStmt(hasBody(compoundStmt()))
8105 matches 'for (;;) {}'
8106 with compoundStmt()
8107 matching '{}'
8109 Given
8110 void f();
8111 void f() {}
8112 functionDecl(hasBody(compoundStmt()))
8113 matches 'void f() {}'
8114 with compoundStmt()
8115 matching '{}'
8116 but does not match 'void f();'
8117 </pre></td></tr>
8120 <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>
8121 <tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whoes decayed type matches InnerMatcher
8122 </pre></td></tr>
8125 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;</td><td class="name" onclick="toggle('hasAnyTemplateArgumentLoc3')"><a name="hasAnyTemplateArgumentLoc3Anchor">hasAnyTemplateArgumentLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt; InnerMatcher</td></tr>
8126 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgumentLoc3"><pre>Matches template specialization `TypeLoc`s, class template specializations,
8127 variable template specializations, and function template specializations
8128 that have at least one `TemplateArgumentLoc` matching the given
8129 `InnerMatcher`.
8131 Given
8132 template&lt;typename T&gt; class A {};
8133 A&lt;int&gt; a;
8134 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc(
8135 hasTypeLoc(loc(asString("int")))))))
8136 matches `A&lt;int&gt; a`.
8137 </pre></td></tr>
8140 <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>
8141 <tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node
8142 matches the given matcher.
8144 The associated declaration is:
8145 - for type nodes, the declaration of the underlying type
8146 - for CallExpr, the declaration of the callee
8147 - for MemberExpr, the declaration of the referenced member
8148 - for CXXConstructExpr, the declaration of the constructor
8149 - for CXXNewExpr, the declaration of the operator new
8150 - for ObjCIvarExpr, the declaration of the ivar
8152 For type nodes, hasDeclaration will generally match the declaration of the
8153 sugared type. Given
8154 class X {};
8155 typedef X Y;
8156 Y y;
8157 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8158 typedefDecl. A common use case is to match the underlying, desugared type.
8159 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8160 varDecl(hasType(hasUnqualifiedDesugaredType(
8161 recordType(hasDeclaration(decl())))))
8162 In this matcher, the decl will match the CXXRecordDecl of class X.
8164 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;,
8165 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;,
8166 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;,
8167 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;,
8168 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;,
8169 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;,
8170 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
8171 </pre></td></tr>
8174 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;</td><td class="name" onclick="toggle('hasTemplateArgumentLoc3')"><a name="hasTemplateArgumentLoc3Anchor">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>
8175 <tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc3"><pre>Matches template specialization `TypeLoc`s, class template specializations,
8176 variable template specializations, and function template specializations
8177 where the n'th `TemplateArgumentLoc` matches the given `InnerMatcher`.
8179 Given
8180 template&lt;typename T, typename U&gt; class A {};
8181 A&lt;double, int&gt; b;
8182 A&lt;int, double&gt; c;
8183 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
8184 hasTypeLoc(loc(asString("double")))))))
8185 matches `A&lt;double, int&gt; b`, but not `A&lt;int, double&gt; c`.
8186 </pre></td></tr>
8189 <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>
8190 <tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches if a node refers to a declaration through a specific
8191 using shadow declaration.
8193 Examples:
8194 namespace a { int f(); }
8195 using a::f;
8196 int x = f();
8197 declRefExpr(throughUsingDecl(anything()))
8198 matches f
8200 namespace a { class X{}; }
8201 using a::X;
8202 X x;
8203 typeLoc(loc(usingType(throughUsingDecl(anything()))))
8204 matches X
8206 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;
8207 </pre></td></tr>
8210 <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>
8211 <tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the
8212 specified matcher.
8214 Example matches x in if(x)
8215 (matcher = declRefExpr(to(varDecl(hasName("x")))))
8216 bool x;
8217 if (x) {}
8218 </pre></td></tr>
8221 <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>
8222 <tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement.
8224 Note that this does not work for global declarations because the AST
8225 breaks up multiple-declaration DeclStmt's into multiple single-declaration
8226 DeclStmt's.
8227 Example: Given non-global declarations
8228 int a, b = 0;
8229 int c;
8230 int d = 2, e;
8231 declStmt(containsDeclaration(
8232 0, varDecl(hasInitializer(anything()))))
8233 matches only 'int d = 2, e;', and
8234 declStmt(containsDeclaration(1, varDecl()))
8235 matches 'int a, b = 0' as well as 'int d = 2, e;'
8236 but 'int c;' is not matched.
8237 </pre></td></tr>
8240 <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>
8241 <tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration.
8243 Given
8244 int a, b;
8245 int c;
8246 declStmt(hasSingleDecl(anything()))
8247 matches 'int c;' but not 'int a, b;'.
8248 </pre></td></tr>
8251 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</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>
8252 <tr><td colspan="4" class="doc" id="hasTypeLoc8"><pre>Matches if the type location of a node matches the inner matcher.
8254 Examples:
8255 int x;
8256 declaratorDecl(hasTypeLoc(loc(asString("int"))))
8257 matches int x
8259 auto x = int(3);
8260 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
8261 matches int(3)
8263 struct Foo { Foo(int, int); };
8264 auto x = Foo(1, 2);
8265 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
8266 matches Foo(1, 2)
8268 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;,
8269 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;,
8270 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;,
8271 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
8272 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
8273 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;,
8274 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;,
8275 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
8276 </pre></td></tr>
8279 <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>
8280 <tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a
8281 Decl, matches InnerMatcher.
8283 Given
8284 namespace N {
8285 namespace M {
8286 class D {};
8290 cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
8291 declaration of class D.
8292 </pre></td></tr>
8295 <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>
8296 <tr><td colspan="4" class="doc" id="hasUnderlyingType0"><pre>Matches DecltypeType or UsingType nodes to find the underlying type.
8298 Given
8299 decltype(1) a = 1;
8300 decltype(2.0) b = 2.0;
8301 decltypeType(hasUnderlyingType(isInteger()))
8302 matches the type of "a"
8304 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;
8305 </pre></td></tr>
8308 <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>
8309 <tr><td colspan="4" class="doc" id="hasAnyBinding0"><pre>Matches any binding of a DecompositionDecl.
8311 For example, in:
8312 void foo()
8314 int arr[3];
8315 auto &amp;[f, s, t] = arr;
8317 f = 42;
8319 The matcher:
8320 decompositionDecl(hasAnyBinding(bindingDecl(hasName("f").bind("fBinding"))))
8321 matches the decomposition decl with 'f' bound to "fBinding".
8322 </pre></td></tr>
8325 <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>
8326 <tr><td colspan="4" class="doc" id="hasBinding0"><pre>Matches the Nth binding of a DecompositionDecl.
8328 For example, in:
8329 void foo()
8331 int arr[3];
8332 auto &amp;[f, s, t] = arr;
8334 f = 42;
8336 The matcher:
8337 decompositionDecl(hasBinding(0,
8338 bindingDecl(hasName("f").bind("fBinding"))))
8339 matches the decomposition decl with 'f' bound to "fBinding".
8340 </pre></td></tr>
8343 <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>
8344 <tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
8345 definition that has a given body. Note that in case of functions or
8346 coroutines this matcher only matches the definition itself and not the
8347 other declarations of the same function or coroutine.
8349 Given
8350 for (;;) {}
8351 forStmt(hasBody(compoundStmt()))
8352 matches 'for (;;) {}'
8353 with compoundStmt()
8354 matching '{}'
8356 Given
8357 void f();
8358 void f() {}
8359 functionDecl(hasBody(compoundStmt()))
8360 matches 'void f() {}'
8361 with compoundStmt()
8362 matching '{}'
8363 but does not match 'void f();'
8364 </pre></td></tr>
8367 <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>
8368 <tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop,
8369 switch statement or conditional operator.
8371 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8372 if (true) {}
8373 </pre></td></tr>
8376 <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>
8377 <tr><td colspan="4" class="doc" id="hasNamedTypeLoc0"><pre>Matches elaborated `TypeLoc`s that have a named `TypeLoc` matching
8378 `InnerMatcher`.
8380 Given
8381 template &lt;typename T&gt;
8382 class C {};
8383 class C&lt;int&gt; c;
8385 class D {};
8386 class D d;
8387 elaboratedTypeLoc(hasNamedTypeLoc(templateSpecializationTypeLoc()));
8388 matches the `TypeLoc` of the variable declaration of `c`, but not `d`.
8389 </pre></td></tr>
8392 <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>
8393 <tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
8394 matches InnerMatcher if the qualifier exists.
8396 Given
8397 namespace N {
8398 namespace M {
8399 class D {};
8402 N::M::D d;
8404 elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N"))))
8405 matches the type of the variable declaration of d.
8406 </pre></td></tr>
8409 <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>
8410 <tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher.
8412 Given
8413 namespace N {
8414 namespace M {
8415 class D {};
8418 N::M::D d;
8420 elaboratedType(namesType(recordType(
8421 hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable
8422 declaration of d.
8423 </pre></td></tr>
8426 <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>
8427 <tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node
8428 matches the given matcher.
8430 The associated declaration is:
8431 - for type nodes, the declaration of the underlying type
8432 - for CallExpr, the declaration of the callee
8433 - for MemberExpr, the declaration of the referenced member
8434 - for CXXConstructExpr, the declaration of the constructor
8435 - for CXXNewExpr, the declaration of the operator new
8436 - for ObjCIvarExpr, the declaration of the ivar
8438 For type nodes, hasDeclaration will generally match the declaration of the
8439 sugared type. Given
8440 class X {};
8441 typedef X Y;
8442 Y y;
8443 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8444 typedefDecl. A common use case is to match the underlying, desugared type.
8445 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8446 varDecl(hasType(hasUnqualifiedDesugaredType(
8447 recordType(hasDeclaration(decl())))))
8448 In this matcher, the decl will match the CXXRecordDecl of class X.
8450 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;,
8451 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;,
8452 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;,
8453 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;,
8454 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;,
8455 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;,
8456 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
8457 </pre></td></tr>
8460 <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>
8461 <tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher.
8463 (Note: Clang's AST refers to other conversions as "casts" too, and calls
8464 actual casts "explicit" casts.)
8465 </pre></td></tr>
8468 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</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>
8469 <tr><td colspan="4" class="doc" id="hasTypeLoc9"><pre>Matches if the type location of a node matches the inner matcher.
8471 Examples:
8472 int x;
8473 declaratorDecl(hasTypeLoc(loc(asString("int"))))
8474 matches int x
8476 auto x = int(3);
8477 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
8478 matches int(3)
8480 struct Foo { Foo(int, int); };
8481 auto x = Foo(1, 2);
8482 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
8483 matches Foo(1, 2)
8485 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;,
8486 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;,
8487 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;,
8488 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
8489 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
8490 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;,
8491 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;,
8492 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
8493 </pre></td></tr>
8496 <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>
8497 <tr><td colspan="4" class="doc" id="hasType5"><pre>Overloaded to match the declaration of the expression's or value
8498 declaration's type.
8500 In case of a value declaration (for example a variable declaration),
8501 this resolves one layer of indirection. For example, in the value
8502 declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
8503 X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
8504 declaration of x.
8506 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
8507 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
8508 and friend class X (matcher = friendDecl(hasType("X"))
8509 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8510 cxxRecordDecl(hasName("X"))))
8511 class X {};
8512 void y(X &amp;x) { x; X z; }
8513 class Y { friend class X; };
8514 class Z : public virtual X {};
8516 Example matches class Derived
8517 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
8518 class Base {};
8519 class Derived : Base {};
8521 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;,
8522 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
8523 </pre></td></tr>
8526 <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>
8527 <tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type
8528 matcher.
8530 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
8531 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
8532 and U (matcher = typedefDecl(hasType(asString("int")))
8533 and friend class X (matcher = friendDecl(hasType("X"))
8534 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8535 asString("class X")))
8536 class X {};
8537 void y(X &amp;x) { x; X z; }
8538 typedef int U;
8539 class Y { friend class X; };
8540 class Z : public virtual X {};
8541 </pre></td></tr>
8544 <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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
8545 <tr><td colspan="4" class="doc" id="ignoringElidableConstructorCall0"><pre>Matches expressions that match InnerMatcher that are possibly wrapped in an
8546 elidable constructor and other corresponding bookkeeping nodes.
8548 In C++17, elidable copy constructors are no longer being generated in the
8549 AST as it is not permitted by the standard. They are, however, part of the
8550 AST in C++14 and earlier. So, a matcher must abstract over these differences
8551 to work in all language modes. This matcher skips elidable constructor-call
8552 AST nodes, `ExprWithCleanups` nodes wrapping elidable constructor-calls and
8553 various implicit nodes inside the constructor calls, all of which will not
8554 appear in the C++17 AST.
8556 Given
8558 struct H {};
8559 H G();
8560 void f() {
8561 H D = G();
8564 ``varDecl(hasInitializer(ignoringElidableConstructorCall(callExpr())))``
8565 matches ``H D = G()`` in C++11 through C++17 (and beyond).
8566 </pre></td></tr>
8569 <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>
8570 <tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts
8571 are stripped off.
8573 Parentheses and explicit casts are not discarded.
8574 Given
8575 int arr[5];
8576 int a = 0;
8577 char b = 0;
8578 const int c = a;
8579 int *d = arr;
8580 long e = (long) 0l;
8581 The matchers
8582 varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
8583 varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
8584 would match the declarations for a, b, c, and d, but not e.
8585 While
8586 varDecl(hasInitializer(integerLiteral()))
8587 varDecl(hasInitializer(declRefExpr()))
8588 only match the declarations for a.
8589 </pre></td></tr>
8592 <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>
8593 <tr><td colspan="4" class="doc" id="ignoringImplicit0"><pre>Matches expressions that match InnerMatcher after any implicit AST
8594 nodes are stripped off.
8596 Parentheses and explicit casts are not discarded.
8597 Given
8598 class C {};
8599 C a = C();
8600 C b;
8601 C c = b;
8602 The matchers
8603 varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr())))
8604 would match the declarations for a, b, and c.
8605 While
8606 varDecl(hasInitializer(cxxConstructExpr()))
8607 only match the declarations for b and c.
8608 </pre></td></tr>
8611 <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>
8612 <tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and
8613 casts are stripped off.
8615 Implicit and non-C Style casts are also discarded.
8616 Given
8617 int a = 0;
8618 char b = (0);
8619 void* c = reinterpret_cast&lt;char*&gt;(0);
8620 char d = char(0);
8621 The matcher
8622 varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
8623 would match the declarations for a, b, c, and d.
8624 while
8625 varDecl(hasInitializer(integerLiteral()))
8626 only match the declaration for a.
8627 </pre></td></tr>
8630 <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>
8631 <tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and
8632 parentheses are stripped off.
8634 Explicit casts are not discarded.
8635 Given
8636 int arr[5];
8637 int a = 0;
8638 char b = (0);
8639 const int c = a;
8640 int *d = (arr);
8641 long e = ((long) 0l);
8642 The matchers
8643 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
8644 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
8645 would match the declarations for a, b, c, and d, but not e.
8646 while
8647 varDecl(hasInitializer(integerLiteral()))
8648 varDecl(hasInitializer(declRefExpr()))
8649 would only match the declaration for a.
8650 </pre></td></tr>
8653 <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>
8654 <tr><td colspan="4" class="doc" id="ignoringParens1"><pre>Overload ignoringParens for Expr.
8656 Given
8657 const char* str = ("my-string");
8658 The matcher
8659 implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral())))
8660 would match the implicit cast resulting from the assignment.
8661 </pre></td></tr>
8664 <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>
8665 <tr><td colspan="4" class="doc" id="hasInClassInitializer0"><pre>Matches non-static data members that have an in-class initializer.
8667 Given
8668 class C {
8669 int a = 2;
8670 int b = 3;
8671 int c;
8673 fieldDecl(hasInClassInitializer(integerLiteral(equals(2))))
8674 matches 'int a;' but not 'int b;'.
8675 fieldDecl(hasInClassInitializer(anything()))
8676 matches 'int a;' and 'int b;' but not 'int c;'.
8677 </pre></td></tr>
8680 <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>
8681 <tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
8682 definition that has a given body. Note that in case of functions or
8683 coroutines this matcher only matches the definition itself and not the
8684 other declarations of the same function or coroutine.
8686 Given
8687 for (;;) {}
8688 forStmt(hasBody(compoundStmt()))
8689 matches 'for (;;) {}'
8690 with compoundStmt()
8691 matching '{}'
8693 Given
8694 void f();
8695 void f() {}
8696 functionDecl(hasBody(compoundStmt()))
8697 matches 'void f() {}'
8698 with compoundStmt()
8699 matching '{}'
8700 but does not match 'void f();'
8701 </pre></td></tr>
8704 <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>
8705 <tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop,
8706 switch statement or conditional operator.
8708 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8709 if (true) {}
8710 </pre></td></tr>
8713 <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>
8714 <tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop.
8716 Example:
8717 forStmt(hasIncrement(unaryOperator(hasOperatorName("++"))))
8718 matches '++x' in
8719 for (x; x &lt; N; ++x) { }
8720 </pre></td></tr>
8723 <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>
8724 <tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop.
8726 Example:
8727 forStmt(hasLoopInit(declStmt()))
8728 matches 'int x = 0' in
8729 for (int x = 0; x &lt; N; ++x) { }
8730 </pre></td></tr>
8733 <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>
8734 <tr><td colspan="4" class="doc" id="hasType6"><pre>Overloaded to match the declaration of the expression's or value
8735 declaration's type.
8737 In case of a value declaration (for example a variable declaration),
8738 this resolves one layer of indirection. For example, in the value
8739 declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
8740 X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
8741 declaration of x.
8743 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
8744 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
8745 and friend class X (matcher = friendDecl(hasType("X"))
8746 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8747 cxxRecordDecl(hasName("X"))))
8748 class X {};
8749 void y(X &amp;x) { x; X z; }
8750 class Y { friend class X; };
8751 class Z : public virtual X {};
8753 Example matches class Derived
8754 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
8755 class Base {};
8756 class Derived : Base {};
8758 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;,
8759 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
8760 </pre></td></tr>
8763 <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>
8764 <tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type
8765 matcher.
8767 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
8768 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
8769 and U (matcher = typedefDecl(hasType(asString("int")))
8770 and friend class X (matcher = friendDecl(hasType("X"))
8771 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8772 asString("class X")))
8773 class X {};
8774 void y(X &amp;x) { x; X z; }
8775 typedef int U;
8776 class Y { friend class X; };
8777 class Z : public virtual X {};
8778 </pre></td></tr>
8781 <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>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
8782 <tr><td colspan="4" class="doc" id="forEachTemplateArgument2"><pre>Matches templateSpecializationType, class template specialization,
8783 variable template specialization, and function template specialization
8784 nodes where the template argument matches the inner matcher. This matcher
8785 may produce multiple matches.
8787 Given
8788 template &lt;typename T, unsigned N, unsigned M&gt;
8789 struct Matrix {};
8791 constexpr unsigned R = 2;
8792 Matrix&lt;int, R * 2, R * 4&gt; M;
8794 template &lt;typename T, typename U&gt;
8795 void f(T&amp;&amp; t, U&amp;&amp; u) {}
8797 bool B = false;
8798 f(R, B);
8799 templateSpecializationType(forEachTemplateArgument(isExpr(expr())))
8800 matches twice, with expr() matching 'R * 2' and 'R * 4'
8801 functionDecl(forEachTemplateArgument(refersToType(builtinType())))
8802 matches the specialization f&lt;unsigned, bool&gt; twice, for 'unsigned'
8803 and 'bool'
8804 </pre></td></tr>
8807 <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>
8808 <tr><td colspan="4" class="doc" id="hasAnyBody0"><pre>Matches a function declaration that has a given body present in the AST.
8809 Note that this matcher matches all the declarations of a function whose
8810 body is present in the AST.
8812 Given
8813 void f();
8814 void f() {}
8815 void g();
8816 functionDecl(hasAnyBody(compoundStmt()))
8817 matches both 'void f();'
8818 and 'void f() {}'
8819 with compoundStmt()
8820 matching '{}'
8821 but does not match 'void g();'
8822 </pre></td></tr>
8825 <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>
8826 <tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function or an ObjC method declaration or a
8827 block.
8829 Does not match the 'this' parameter of a method.
8831 Given
8832 class X { void f(int x, int y, int z) {} };
8833 cxxMethodDecl(hasAnyParameter(hasName("y")))
8834 matches f(int x, int y, int z) {}
8835 with hasAnyParameter(...)
8836 matching int y
8838 For ObjectiveC, given
8839 @interface I - (void) f:(int) y; @end
8841 the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
8842 matches the declaration of method f with hasParameter
8843 matching y.
8845 For blocks, given
8846 b = ^(int y) { printf("%d", y) };
8848 the matcher blockDecl(hasAnyParameter(hasName("y")))
8849 matches the declaration of the block b with hasParameter
8850 matching y.
8851 </pre></td></tr>
8854 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyTemplateArgumentLoc2')"><a name="hasAnyTemplateArgumentLoc2Anchor">hasAnyTemplateArgumentLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt; InnerMatcher</td></tr>
8855 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgumentLoc2"><pre>Matches template specialization `TypeLoc`s, class template specializations,
8856 variable template specializations, and function template specializations
8857 that have at least one `TemplateArgumentLoc` matching the given
8858 `InnerMatcher`.
8860 Given
8861 template&lt;typename T&gt; class A {};
8862 A&lt;int&gt; a;
8863 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc(
8864 hasTypeLoc(loc(asString("int")))))))
8865 matches `A&lt;int&gt; a`.
8866 </pre></td></tr>
8869 <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>
8870 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument2"><pre>Matches templateSpecializationTypes, class template specializations,
8871 variable template specializations, and function template specializations
8872 that have at least one TemplateArgument matching the given InnerMatcher.
8874 Given
8875 template&lt;typename T&gt; class A {};
8876 template&lt;&gt; class A&lt;double&gt; {};
8877 A&lt;int&gt; a;
8879 template&lt;typename T&gt; f() {};
8880 void func() { f&lt;int&gt;(); };
8882 classTemplateSpecializationDecl(hasAnyTemplateArgument(
8883 refersToType(asString("int"))))
8884 matches the specialization A&lt;int&gt;
8886 functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
8887 matches the specialization f&lt;int&gt;
8888 </pre></td></tr>
8891 <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>
8892 <tr><td colspan="4" class="doc" id="hasBody4"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
8893 definition that has a given body. Note that in case of functions or
8894 coroutines this matcher only matches the definition itself and not the
8895 other declarations of the same function or coroutine.
8897 Given
8898 for (;;) {}
8899 forStmt(hasBody(compoundStmt()))
8900 matches 'for (;;) {}'
8901 with compoundStmt()
8902 matching '{}'
8904 Given
8905 void f();
8906 void f() {}
8907 functionDecl(hasBody(compoundStmt()))
8908 matches 'void f() {}'
8909 with compoundStmt()
8910 matching '{}'
8911 but does not match 'void f();'
8912 </pre></td></tr>
8915 <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>
8916 <tr><td colspan="4" class="doc" id="hasExplicitSpecifier0"><pre>Matches the expression in an explicit specifier if present in the given
8917 declaration.
8919 Given
8920 template&lt;bool b&gt;
8921 struct S {
8922 S(int); // #1
8923 explicit S(double); // #2
8924 operator int(); // #3
8925 explicit operator bool(); // #4
8926 explicit(false) S(bool) // # 7
8927 explicit(true) S(char) // # 8
8928 explicit(b) S(S) // # 9
8930 S(int) -&gt; S&lt;true&gt; // #5
8931 explicit S(double) -&gt; S&lt;false&gt; // #6
8932 cxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8 and #9, but not #1 or #2.
8933 cxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or #4.
8934 cxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not match #5 or #6.
8935 </pre></td></tr>
8938 <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>
8939 <tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function or an ObjC method
8940 declaration or a block.
8942 Given
8943 class X { void f(int x) {} };
8944 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
8945 matches f(int x) {}
8946 with hasParameter(...)
8947 matching int x
8949 For ObjectiveC, given
8950 @interface I - (void) f:(int) y; @end
8952 the matcher objcMethodDecl(hasParameter(0, hasName("y")))
8953 matches the declaration of method f with hasParameter
8954 matching y.
8955 </pre></td></tr>
8958 <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>
8959 <tr><td colspan="4" class="doc" id="hasReturnTypeLoc0"><pre>Matches a function declared with the specified return `TypeLoc`.
8961 Given
8962 int f() { return 5; }
8963 void g() {}
8964 functionDecl(hasReturnTypeLoc(loc(asString("int"))))
8965 matches the declaration of `f`, but not `g`.
8966 </pre></td></tr>
8969 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('hasTemplateArgumentLoc2')"><a name="hasTemplateArgumentLoc2Anchor">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>
8970 <tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc2"><pre>Matches template specialization `TypeLoc`s, class template specializations,
8971 variable template specializations, and function template specializations
8972 where the n'th `TemplateArgumentLoc` matches the given `InnerMatcher`.
8974 Given
8975 template&lt;typename T, typename U&gt; class A {};
8976 A&lt;double, int&gt; b;
8977 A&lt;int, double&gt; c;
8978 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
8979 hasTypeLoc(loc(asString("double")))))))
8980 matches `A&lt;double, int&gt; b`, but not `A&lt;int, double&gt; c`.
8981 </pre></td></tr>
8984 <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>
8985 <tr><td colspan="4" class="doc" id="hasTemplateArgument2"><pre>Matches templateSpecializationType, class template specializations,
8986 variable template specializations, and function template specializations
8987 where the n'th TemplateArgument matches the given InnerMatcher.
8989 Given
8990 template&lt;typename T, typename U&gt; class A {};
8991 A&lt;bool, int&gt; b;
8992 A&lt;int, bool&gt; c;
8994 template&lt;typename T&gt; void f() {}
8995 void func() { f&lt;int&gt;(); };
8996 classTemplateSpecializationDecl(hasTemplateArgument(
8997 1, refersToType(asString("int"))))
8998 matches the specialization A&lt;bool, int&gt;
9000 functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
9001 matches the specialization f&lt;int&gt;
9002 </pre></td></tr>
9005 <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>
9006 <tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration.
9008 Given:
9009 class X { int f() { return 1; } };
9010 cxxMethodDecl(returns(asString("int")))
9011 matches int f() { return 1; }
9012 </pre></td></tr>
9015 <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>
9016 <tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop,
9017 switch statement or conditional operator.
9019 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
9020 if (true) {}
9021 </pre></td></tr>
9024 <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>
9025 <tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement.
9027 Given
9028 if (A* a = GetAPointer()) {}
9029 hasConditionVariableStatement(...)
9030 matches 'A* a = GetAPointer()'.
9031 </pre></td></tr>
9034 <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>
9035 <tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement.
9037 Examples matches the if statement
9038 (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true)))))
9039 if (false) false; else true;
9040 </pre></td></tr>
9043 <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>
9044 <tr><td colspan="4" class="doc" id="hasInitStatement0"><pre>Matches selection statements with initializer.
9046 Given:
9047 void foo() {
9048 if (int i = foobar(); i &gt; 0) {}
9049 switch (int i = foobar(); i) {}
9050 for (auto&amp; a = get_range(); auto&amp; x : a) {}
9052 void bar() {
9053 if (foobar() &gt; 0) {}
9054 switch (foobar()) {}
9055 for (auto&amp; x : get_range()) {}
9057 ifStmt(hasInitStatement(anything()))
9058 matches the if statement in foo but not in bar.
9059 switchStmt(hasInitStatement(anything()))
9060 matches the switch statement in foo but not in bar.
9061 cxxForRangeStmt(hasInitStatement(anything()))
9062 matches the range for statement in foo but not in bar.
9063 </pre></td></tr>
9066 <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>
9067 <tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement.
9069 Examples matches the if statement
9070 (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true)))))
9071 if (false) true; else false;
9072 </pre></td></tr>
9075 <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>
9076 <tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given
9077 matcher.
9078 </pre></td></tr>
9081 <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, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
9082 <tr><td colspan="4" class="doc" id="hasInit0"><pre>Matches the n'th item of an initializer list expression.
9084 Example matches y.
9085 (matcher = initListExpr(hasInit(0, expr())))
9086 int x{y}.
9087 </pre></td></tr>
9090 <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>
9091 <tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions
9092 (if expression have it).
9093 </pre></td></tr>
9096 <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>
9097 <tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node
9098 matches the given matcher.
9100 The associated declaration is:
9101 - for type nodes, the declaration of the underlying type
9102 - for CallExpr, the declaration of the callee
9103 - for MemberExpr, the declaration of the referenced member
9104 - for CXXConstructExpr, the declaration of the constructor
9105 - for CXXNewExpr, the declaration of the operator new
9106 - for ObjCIvarExpr, the declaration of the ivar
9108 For type nodes, hasDeclaration will generally match the declaration of the
9109 sugared type. Given
9110 class X {};
9111 typedef X Y;
9112 Y y;
9113 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9114 typedefDecl. A common use case is to match the underlying, desugared type.
9115 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9116 varDecl(hasType(hasUnqualifiedDesugaredType(
9117 recordType(hasDeclaration(decl())))))
9118 In this matcher, the decl will match the CXXRecordDecl of class X.
9120 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;,
9121 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;,
9122 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;,
9123 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;,
9124 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;,
9125 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;,
9126 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9127 </pre></td></tr>
9130 <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>
9131 <tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node
9132 matches the given matcher.
9134 The associated declaration is:
9135 - for type nodes, the declaration of the underlying type
9136 - for CallExpr, the declaration of the callee
9137 - for MemberExpr, the declaration of the referenced member
9138 - for CXXConstructExpr, the declaration of the constructor
9139 - for CXXNewExpr, the declaration of the operator new
9140 - for ObjCIvarExpr, the declaration of the ivar
9142 For type nodes, hasDeclaration will generally match the declaration of the
9143 sugared type. Given
9144 class X {};
9145 typedef X Y;
9146 Y y;
9147 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9148 typedefDecl. A common use case is to match the underlying, desugared type.
9149 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9150 varDecl(hasType(hasUnqualifiedDesugaredType(
9151 recordType(hasDeclaration(decl())))))
9152 In this matcher, the decl will match the CXXRecordDecl of class X.
9154 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;,
9155 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;,
9156 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;,
9157 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;,
9158 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;,
9159 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;,
9160 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9161 </pre></td></tr>
9164 <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>
9165 <tr><td colspan="4" class="doc" id="capturesVar0"><pre>Matches a `LambdaCapture` that refers to the specified `VarDecl`. The
9166 `VarDecl` can be a separate variable that is captured by value or
9167 reference, or a synthesized variable if the capture has an initializer.
9169 Given
9170 void foo() {
9171 int x;
9172 auto f = [x](){};
9173 auto g = [x = 1](){};
9175 In the matcher
9176 lambdaExpr(hasAnyCapture(lambdaCapture(capturesVar(hasName("x")))),
9177 capturesVar(hasName("x")) matches `x` and `x = 1`.
9178 </pre></td></tr>
9181 <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>
9182 <tr><td colspan="4" class="doc" id="forEachLambdaCapture0"><pre>Matches each lambda capture in a lambda expression.
9184 Given
9185 int main() {
9186 int x, y;
9187 float z;
9188 auto f = [=]() { return x + y + z; };
9190 lambdaExpr(forEachLambdaCapture(
9191 lambdaCapture(capturesVar(varDecl(hasType(isInteger()))))))
9192 will trigger two matches, binding for 'x' and 'y' respectively.
9193 </pre></td></tr>
9196 <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>
9197 <tr><td colspan="4" class="doc" id="hasAnyCapture0"><pre>Matches any capture in a lambda expression.
9199 Given
9200 void foo() {
9201 int t = 5;
9202 auto f = [=](){ return t; };
9204 lambdaExpr(hasAnyCapture(lambdaCapture())) and
9205 lambdaExpr(hasAnyCapture(lambdaCapture(refersToVarDecl(hasName("t")))))
9206 both match `[=](){ return t; }`.
9207 </pre></td></tr>
9210 <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>
9211 <tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node
9212 matches the given matcher.
9214 The associated declaration is:
9215 - for type nodes, the declaration of the underlying type
9216 - for CallExpr, the declaration of the callee
9217 - for MemberExpr, the declaration of the referenced member
9218 - for CXXConstructExpr, the declaration of the constructor
9219 - for CXXNewExpr, the declaration of the operator new
9220 - for ObjCIvarExpr, the declaration of the ivar
9222 For type nodes, hasDeclaration will generally match the declaration of the
9223 sugared type. Given
9224 class X {};
9225 typedef X Y;
9226 Y y;
9227 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9228 typedefDecl. A common use case is to match the underlying, desugared type.
9229 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9230 varDecl(hasType(hasUnqualifiedDesugaredType(
9231 recordType(hasDeclaration(decl())))))
9232 In this matcher, the decl will match the CXXRecordDecl of class X.
9234 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;,
9235 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;,
9236 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;,
9237 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;,
9238 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;,
9239 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;,
9240 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9241 </pre></td></tr>
9244 <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>
9245 <tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is matched by a
9246 given matcher. Implicit object expressions are included; that is, it matches
9247 use of implicit `this`.
9249 Given
9250 struct X {
9251 int m;
9252 int f(X x) { x.m; return m; }
9254 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))
9255 matches `x.m`, but not `m`; however,
9256 memberExpr(hasObjectExpression(hasType(pointsTo(
9257 cxxRecordDecl(hasName("X"))))))
9258 matches `m` (aka. `this-&gt;m`), but not `x.m`.
9259 </pre></td></tr>
9262 <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>
9263 <tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a
9264 given matcher.
9266 Given
9267 struct { int first, second; } first, second;
9268 int i(second.first);
9269 int j(first.second);
9270 memberExpr(member(hasName("first")))
9271 matches second.first
9272 but not first.second (because the member name there is "second").
9273 </pre></td></tr>
9276 <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>
9277 <tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the
9278 pointee matches a given matcher.
9280 Given
9281 int *a;
9282 int const *b;
9283 float const *f;
9284 pointerType(pointee(isConstQualified(), isInteger()))
9285 matches "int const *b"
9287 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;,
9288 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;
9289 </pre></td></tr>
9292 <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>
9293 <tr><td colspan="4" class="doc" id="hasUnderlyingDecl0"><pre>Matches a NamedDecl whose underlying declaration matches the given
9294 matcher.
9296 Given
9297 namespace N { template&lt;class T&gt; void f(T t); }
9298 template &lt;class T&gt; void g() { using N::f; f(T()); }
9299 unresolvedLookupExpr(hasAnyDeclaration(
9300 namedDecl(hasUnderlyingDecl(hasName("::N::f")))))
9301 matches the use of f in g() .
9302 </pre></td></tr>
9305 <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>
9306 <tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc.
9308 Given
9309 struct A { struct B { struct C {}; }; };
9310 A::B::C c;
9311 nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A")))))
9312 matches "A::"
9313 </pre></td></tr>
9316 <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>
9317 <tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner
9318 NestedNameSpecifier-matcher matches.
9319 </pre></td></tr>
9322 <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>
9323 <tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the
9324 given TypeLoc.
9326 Given
9327 struct A { struct B { struct C {}; }; };
9328 A::B::C c;
9329 nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
9330 hasDeclaration(cxxRecordDecl(hasName("A")))))))
9331 matches "A::"
9332 </pre></td></tr>
9335 <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>
9336 <tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier.
9338 Given
9339 struct A { struct B { struct C {}; }; };
9340 A::B::C c;
9341 nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and
9342 matches "A::"
9343 </pre></td></tr>
9346 <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>
9347 <tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the
9348 given namespace matcher.
9350 Given
9351 namespace ns { struct A {}; }
9352 ns::A a;
9353 nestedNameSpecifier(specifiesNamespace(hasName("ns")))
9354 matches "ns::"
9355 </pre></td></tr>
9358 <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>
9359 <tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the
9360 given QualType matcher without qualifiers.
9362 Given
9363 struct A { struct B { struct C {}; }; };
9364 A::B::C c;
9365 nestedNameSpecifier(specifiesType(
9366 hasDeclaration(cxxRecordDecl(hasName("A")))
9368 matches "A::"
9369 </pre></td></tr>
9372 <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>
9373 <tr><td colspan="4" class="doc" id="hasAnyClause0"><pre>Matches any clause in an OpenMP directive.
9375 Given
9377 #pragma omp parallel
9378 #pragma omp parallel default(none)
9380 ``ompExecutableDirective(hasAnyClause(anything()))`` matches
9381 ``omp parallel default(none)``.
9382 </pre></td></tr>
9385 <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>
9386 <tr><td colspan="4" class="doc" id="hasStructuredBlock0"><pre>Matches the structured-block of the OpenMP executable directive
9388 Prerequisite: the executable directive must not be standalone directive.
9389 If it is, it will never match.
9391 Given
9393 #pragma omp parallel
9395 #pragma omp parallel
9398 ``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;``
9399 </pre></td></tr>
9402 <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>
9403 <tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Matches C++ classes that are directly or indirectly derived from a class
9404 matching Base, or Objective-C classes that directly or indirectly
9405 subclass a class matching Base.
9407 Note that a class is not considered to be derived from itself.
9409 Example matches Y, Z, C (Base == hasName("X"))
9410 class X;
9411 class Y : public X {}; // directly derived
9412 class Z : public Y {}; // indirectly derived
9413 typedef X A;
9414 typedef A B;
9415 class C : public B {}; // derived from a typedef of X
9417 In the following example, Bar matches isDerivedFrom(hasName("X")):
9418 class Foo;
9419 typedef Foo X;
9420 class Bar : public Foo {}; // derived from a type that X is a typedef of
9422 In the following example, Bar matches isDerivedFrom(hasName("NSObject"))
9423 @interface NSObject @end
9424 @interface Bar : NSObject @end
9426 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;
9427 </pre></td></tr>
9430 <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>
9431 <tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom1"><pre>Matches C++ or Objective-C classes that are directly derived from a class
9432 matching Base.
9434 Note that a class is not considered to be derived from itself.
9436 Example matches Y, C (Base == hasName("X"))
9437 class X;
9438 class Y : public X {}; // directly derived
9439 class Z : public Y {}; // indirectly derived
9440 typedef X A;
9441 typedef A B;
9442 class C : public B {}; // derived from a typedef of X
9444 In the following example, Bar matches isDerivedFrom(hasName("X")):
9445 class Foo;
9446 typedef Foo X;
9447 class Bar : public Foo {}; // derived from a type that X is a typedef of
9448 </pre></td></tr>
9451 <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>
9452 <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Similar to isDerivedFrom(), but also matches classes that directly
9453 match Base.
9454 </pre></td></tr>
9457 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</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>
9458 <tr><td colspan="4" class="doc" id="callee2"><pre>Matches 1) if the call expression's callee's declaration matches the
9459 given matcher; or 2) if the Obj-C message expression's callee's method
9460 declaration matches the given matcher.
9462 Example matches y.x() (matcher = callExpr(callee(
9463 cxxMethodDecl(hasName("x")))))
9464 class Y { public: void x(); };
9465 void z() { Y y; y.x(); }
9467 Example 2. Matches [I foo] with
9468 objcMessageExpr(callee(objcMethodDecl(hasName("foo"))))
9470 @interface I: NSObject
9471 +(void)foo;
9472 @end
9474 [I foo]
9475 </pre></td></tr>
9478 <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>
9479 <tr><td colspan="4" class="doc" id="hasAnyArgument3"><pre>Matches any argument of a call expression or a constructor call
9480 expression, or an ObjC-message-send expression.
9482 Given
9483 void x(int, int, int) { int y; x(1, y, 42); }
9484 callExpr(hasAnyArgument(declRefExpr()))
9485 matches x(1, y, 42)
9486 with hasAnyArgument(...)
9487 matching y
9489 For ObjectiveC, given
9490 @interface I - (void) f:(int) y; @end
9491 void foo(I *i) { [i f:12]; }
9492 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
9493 matches [i f:12]
9494 </pre></td></tr>
9497 <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>
9498 <tr><td colspan="4" class="doc" id="hasArgument3"><pre>Matches the n'th argument of a call expression or a constructor
9499 call expression.
9501 Example matches y in x(y)
9502 (matcher = callExpr(hasArgument(0, declRefExpr())))
9503 void x(int) { int y; x(y); }
9504 </pre></td></tr>
9507 <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>
9508 <tr><td colspan="4" class="doc" id="hasReceiver0"><pre>Matches if the Objective-C message is sent to an instance,
9509 and the inner matcher matches on that instance.
9511 For example the method call in
9512 NSString *x = @"hello";
9513 [x containsString:@"h"];
9514 is matched by
9515 objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x"))))))
9516 </pre></td></tr>
9519 <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>
9520 <tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression.
9522 Example
9523 matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *")));
9524 matches the [webView ...] message invocation.
9525 NSString *webViewJavaScript = ...
9526 UIWebView *webView = ...
9527 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript];
9528 </pre></td></tr>
9531 <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>
9532 <tr><td colspan="4" class="doc" id="hasAnyParameter1"><pre>Matches any parameter of a function or an ObjC method declaration or a
9533 block.
9535 Does not match the 'this' parameter of a method.
9537 Given
9538 class X { void f(int x, int y, int z) {} };
9539 cxxMethodDecl(hasAnyParameter(hasName("y")))
9540 matches f(int x, int y, int z) {}
9541 with hasAnyParameter(...)
9542 matching int y
9544 For ObjectiveC, given
9545 @interface I - (void) f:(int) y; @end
9547 the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
9548 matches the declaration of method f with hasParameter
9549 matching y.
9551 For blocks, given
9552 b = ^(int y) { printf("%d", y) };
9554 the matcher blockDecl(hasAnyParameter(hasName("y")))
9555 matches the declaration of the block b with hasParameter
9556 matching y.
9557 </pre></td></tr>
9560 <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>
9561 <tr><td colspan="4" class="doc" id="hasParameter1"><pre>Matches the n'th parameter of a function or an ObjC method
9562 declaration or a block.
9564 Given
9565 class X { void f(int x) {} };
9566 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
9567 matches f(int x) {}
9568 with hasParameter(...)
9569 matching int x
9571 For ObjectiveC, given
9572 @interface I - (void) f:(int) y; @end
9574 the matcher objcMethodDecl(hasParameter(0, hasName("y")))
9575 matches the declaration of method f with hasParameter
9576 matching y.
9577 </pre></td></tr>
9580 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</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>
9581 <tr><td colspan="4" class="doc" id="hasTypeLoc10"><pre>Matches if the type location of a node matches the inner matcher.
9583 Examples:
9584 int x;
9585 declaratorDecl(hasTypeLoc(loc(asString("int"))))
9586 matches int x
9588 auto x = int(3);
9589 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
9590 matches int(3)
9592 struct Foo { Foo(int, int); };
9593 auto x = Foo(1, 2);
9594 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
9595 matches Foo(1, 2)
9597 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;,
9598 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;,
9599 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;,
9600 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
9601 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
9602 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;,
9603 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;,
9604 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
9605 </pre></td></tr>
9608 <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>
9609 <tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre>Matches if the cast's source expression
9610 or opaque value's source expression matches the given matcher.
9612 Example 1: matches "a string"
9613 (matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
9614 class URL { URL(string); };
9615 URL url = "a string";
9617 Example 2: matches 'b' (matcher =
9618 opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
9619 int a = b ?: 1;
9620 </pre></td></tr>
9623 <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>
9624 <tr><td colspan="4" class="doc" id="hasAnyDeclaration0"><pre>Matches an OverloadExpr if any of the declarations in the set of
9625 overloads matches the given matcher.
9627 Given
9628 template &lt;typename T&gt; void foo(T);
9629 template &lt;typename T&gt; void bar(T);
9630 template &lt;typename T&gt; void baz(T t) {
9631 foo(t);
9632 bar(t);
9634 unresolvedLookupExpr(hasAnyDeclaration(
9635 functionTemplateDecl(hasName("foo"))))
9636 matches foo in foo(t); but not bar in bar(t);
9637 </pre></td></tr>
9640 <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>
9641 <tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type.
9643 Given
9644 int (*ptr_to_array)[4];
9645 int (*ptr_to_func)(int);
9647 varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
9648 ptr_to_func but not ptr_to_array.
9650 Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>&gt;
9651 </pre></td></tr>
9654 <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>
9655 <tr><td colspan="4" class="doc" id="hasPointeeLoc0"><pre>Matches pointer `TypeLoc`s that have a pointee `TypeLoc` matching
9656 `PointeeMatcher`.
9658 Given
9659 int* x;
9660 pointerTypeLoc(hasPointeeLoc(loc(asString("int"))))
9661 matches `int*`.
9662 </pre></td></tr>
9665 <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>
9666 <tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the
9667 pointee matches a given matcher.
9669 Given
9670 int *a;
9671 int const *b;
9672 float const *f;
9673 pointerType(pointee(isConstQualified(), isInteger()))
9674 matches "int const *b"
9676 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;,
9677 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;
9678 </pre></td></tr>
9681 <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>
9682 <tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher.
9684 Given:
9685 typedef int &amp;int_ref;
9686 int a;
9687 int_ref b = a;
9689 varDecl(hasType(qualType(referenceType()))))) will not match the
9690 declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does.
9691 </pre></td></tr>
9694 <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>
9695 <tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node
9696 matches the given matcher.
9698 The associated declaration is:
9699 - for type nodes, the declaration of the underlying type
9700 - for CallExpr, the declaration of the callee
9701 - for MemberExpr, the declaration of the referenced member
9702 - for CXXConstructExpr, the declaration of the constructor
9703 - for CXXNewExpr, the declaration of the operator new
9704 - for ObjCIvarExpr, the declaration of the ivar
9706 For type nodes, hasDeclaration will generally match the declaration of the
9707 sugared type. Given
9708 class X {};
9709 typedef X Y;
9710 Y y;
9711 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9712 typedefDecl. A common use case is to match the underlying, desugared type.
9713 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9714 varDecl(hasType(hasUnqualifiedDesugaredType(
9715 recordType(hasDeclaration(decl())))))
9716 In this matcher, the decl will match the CXXRecordDecl of class X.
9718 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;,
9719 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;,
9720 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;,
9721 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;,
9722 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;,
9723 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;,
9724 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9725 </pre></td></tr>
9728 <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>
9729 <tr><td colspan="4" class="doc" id="ignoringParens0"><pre>Matches types that match InnerMatcher after any parens are stripped.
9731 Given
9732 void (*fp)(void);
9733 The matcher
9734 varDecl(hasType(pointerType(pointee(ignoringParens(functionType())))))
9735 would match the declaration for fp.
9736 </pre></td></tr>
9739 <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>
9740 <tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration.
9741 </pre></td></tr>
9744 <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>
9745 <tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type
9746 matches the specified matcher.
9748 Example matches y-&gt;x()
9749 (matcher = cxxMemberCallExpr(on(hasType(pointsTo
9750 cxxRecordDecl(hasName("Y")))))))
9751 class Y { public: void x(); };
9752 void z() { Y *y; y-&gt;x(); }
9753 </pre></td></tr>
9756 <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>
9757 <tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration.
9758 </pre></td></tr>
9761 <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>
9762 <tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced
9763 type matches the specified matcher.
9765 Example matches X &amp;x and const X &amp;y
9766 (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X"))))))
9767 class X {
9768 void a(X b) {
9769 X &amp;x = b;
9770 const X &amp;y = b;
9773 </pre></td></tr>
9776 <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>
9777 <tr><td colspan="4" class="doc" id="hasUnqualifiedLoc0"><pre>Matches `QualifiedTypeLoc`s that have an unqualified `TypeLoc` matching
9778 `InnerMatcher`.
9780 Given
9781 int* const x;
9782 const int y;
9783 qualifiedTypeLoc(hasUnqualifiedLoc(pointerTypeLoc()))
9784 matches the `TypeLoc` of the variable declaration of `x`, but not `y`.
9785 </pre></td></tr>
9788 <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>
9789 <tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node
9790 matches the given matcher.
9792 The associated declaration is:
9793 - for type nodes, the declaration of the underlying type
9794 - for CallExpr, the declaration of the callee
9795 - for MemberExpr, the declaration of the referenced member
9796 - for CXXConstructExpr, the declaration of the constructor
9797 - for CXXNewExpr, the declaration of the operator new
9798 - for ObjCIvarExpr, the declaration of the ivar
9800 For type nodes, hasDeclaration will generally match the declaration of the
9801 sugared type. Given
9802 class X {};
9803 typedef X Y;
9804 Y y;
9805 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9806 typedefDecl. A common use case is to match the underlying, desugared type.
9807 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9808 varDecl(hasType(hasUnqualifiedDesugaredType(
9809 recordType(hasDeclaration(decl())))))
9810 In this matcher, the decl will match the CXXRecordDecl of class X.
9812 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;,
9813 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;,
9814 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;,
9815 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;,
9816 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;,
9817 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;,
9818 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9819 </pre></td></tr>
9822 <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>
9823 <tr><td colspan="4" class="doc" id="hasReferentLoc0"><pre>Matches reference `TypeLoc`s that have a referent `TypeLoc` matching
9824 `ReferentMatcher`.
9826 Given
9827 int x = 3;
9828 int&amp; xx = x;
9829 referenceTypeLoc(hasReferentLoc(loc(asString("int"))))
9830 matches `int&amp;`.
9831 </pre></td></tr>
9834 <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>
9835 <tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the
9836 pointee matches a given matcher.
9838 Given
9839 int *a;
9840 int const *b;
9841 float const *f;
9842 pointerType(pointee(isConstQualified(), isInteger()))
9843 matches "int const *b"
9845 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;,
9846 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;
9847 </pre></td></tr>
9850 <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>
9851 <tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement
9853 Given
9854 return a + b;
9855 hasReturnValue(binaryOperator())
9856 matches 'return a + b'
9857 with binaryOperator()
9858 matching 'a + b'
9859 </pre></td></tr>
9862 <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>
9863 <tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches
9864 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
9866 Given
9867 { {}; 1+2; }
9868 hasAnySubstatement(compoundStmt())
9869 matches '{ {}; 1+2; }'
9870 with compoundStmt()
9871 matching '{}'
9872 </pre></td></tr>
9875 <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>
9876 <tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
9877 alignof.
9878 </pre></td></tr>
9881 <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>
9882 <tr><td colspan="4" class="doc" id="forCallable0"><pre>Matches declaration of the function, method, or block the statement
9883 belongs to.
9885 Given:
9886 F&amp; operator=(const F&amp; o) {
9887 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v &gt; 0; });
9888 return *this;
9890 returnStmt(forCallable(functionDecl(hasName("operator="))))
9891 matches 'return *this'
9892 but does not match 'return v &gt; 0'
9894 Given:
9895 -(void) foo {
9896 int x = 1;
9897 dispatch_sync(queue, ^{ int y = 2; });
9899 declStmt(forCallable(objcMethodDecl()))
9900 matches 'int x = 1'
9901 but does not match 'int y = 2'.
9902 whereas declStmt(forCallable(blockDecl()))
9903 matches 'int y = 2'
9904 but does not match 'int x = 1'.
9905 </pre></td></tr>
9908 <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>
9909 <tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statement belongs to.
9911 Deprecated. Use forCallable() to correctly handle the situation when
9912 the declaration is not a function (but a block or an Objective-C method).
9913 forFunction() not only fails to take non-functions into account but also
9914 may match the wrong declaration in their presence.
9916 Given:
9917 F&amp; operator=(const F&amp; o) {
9918 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v &gt; 0; });
9919 return *this;
9921 returnStmt(forFunction(hasName("operator=")))
9922 matches 'return *this'
9923 but does not match 'return v &gt; 0'
9924 </pre></td></tr>
9927 <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>
9928 <tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
9929 sizeof.
9930 </pre></td></tr>
9933 <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>
9934 <tr><td colspan="4" class="doc" id="hasReplacementType0"><pre>Matches template type parameter substitutions that have a replacement
9935 type that matches the provided matcher.
9937 Given
9938 template &lt;typename T&gt;
9939 double F(T t);
9940 int i;
9941 double j = F(i);
9943 substTemplateTypeParmType(hasReplacementType(type())) matches int
9944 </pre></td></tr>
9947 <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>
9948 <tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch
9949 statement. This matcher may produce multiple matches.
9951 Given
9952 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }
9953 switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s")
9954 matches four times, with "c" binding each of "case 1:", "case 2:",
9955 "case 3:" and "case 4:", and "s" respectively binding "switch (1)",
9956 "switch (1)", "switch (2)" and "switch (2)".
9957 </pre></td></tr>
9960 <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>
9961 <tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop,
9962 switch statement or conditional operator.
9964 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
9965 if (true) {}
9966 </pre></td></tr>
9969 <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>
9970 <tr><td colspan="4" class="doc" id="hasInitStatement1"><pre>Matches selection statements with initializer.
9972 Given:
9973 void foo() {
9974 if (int i = foobar(); i &gt; 0) {}
9975 switch (int i = foobar(); i) {}
9976 for (auto&amp; a = get_range(); auto&amp; x : a) {}
9978 void bar() {
9979 if (foobar() &gt; 0) {}
9980 switch (foobar()) {}
9981 for (auto&amp; x : get_range()) {}
9983 ifStmt(hasInitStatement(anything()))
9984 matches the if statement in foo but not in bar.
9985 switchStmt(hasInitStatement(anything()))
9986 matches the switch statement in foo but not in bar.
9987 cxxForRangeStmt(hasInitStatement(anything()))
9988 matches the range for statement in foo but not in bar.
9989 </pre></td></tr>
9992 <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>
9993 <tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node
9994 matches the given matcher.
9996 The associated declaration is:
9997 - for type nodes, the declaration of the underlying type
9998 - for CallExpr, the declaration of the callee
9999 - for MemberExpr, the declaration of the referenced member
10000 - for CXXConstructExpr, the declaration of the constructor
10001 - for CXXNewExpr, the declaration of the operator new
10002 - for ObjCIvarExpr, the declaration of the ivar
10004 For type nodes, hasDeclaration will generally match the declaration of the
10005 sugared type. Given
10006 class X {};
10007 typedef X Y;
10008 Y y;
10009 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
10010 typedefDecl. A common use case is to match the underlying, desugared type.
10011 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
10012 varDecl(hasType(hasUnqualifiedDesugaredType(
10013 recordType(hasDeclaration(decl())))))
10014 In this matcher, the decl will match the CXXRecordDecl of class X.
10016 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;,
10017 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;,
10018 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;,
10019 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;,
10020 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;,
10021 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;,
10022 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
10023 </pre></td></tr>
10026 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</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>
10027 <tr><td colspan="4" class="doc" id="hasTypeLoc11"><pre>Matches if the type location of a node matches the inner matcher.
10029 Examples:
10030 int x;
10031 declaratorDecl(hasTypeLoc(loc(asString("int"))))
10032 matches int x
10034 auto x = int(3);
10035 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
10036 matches int(3)
10038 struct Foo { Foo(int, int); };
10039 auto x = Foo(1, 2);
10040 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
10041 matches Foo(1, 2)
10043 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;,
10044 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;,
10045 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;,
10046 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
10047 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
10048 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;,
10049 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;,
10050 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
10051 </pre></td></tr>
10054 <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>
10055 <tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression.
10057 Given
10058 struct B { int next; };
10059 template&lt;int(B::*next_ptr)&gt; struct A {};
10060 A&lt;&amp;B::next&gt; a;
10061 templateSpecializationType(hasAnyTemplateArgument(
10062 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next"))))))))
10063 matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
10064 B::next
10065 </pre></td></tr>
10068 <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>
10069 <tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain
10070 declaration.
10072 Given
10073 struct B { int next; };
10074 template&lt;int(B::*next_ptr)&gt; struct A {};
10075 A&lt;&amp;B::next&gt; a;
10076 classTemplateSpecializationDecl(hasAnyTemplateArgument(
10077 refersToDeclaration(fieldDecl(hasName("next")))))
10078 matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
10079 B::next
10080 </pre></td></tr>
10083 <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>
10084 <tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that refers to an integral type.
10086 Given
10087 template&lt;int T&gt; struct C {};
10088 C&lt;42&gt; c;
10089 classTemplateSpecializationDecl(
10090 hasAnyTemplateArgument(refersToIntegralType(asString("int"))))
10091 matches the implicit instantiation of C in C&lt;42&gt;.
10092 </pre></td></tr>
10095 <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>
10096 <tr><td colspan="4" class="doc" id="refersToTemplate0"><pre>Matches a TemplateArgument that refers to a certain template.
10098 Given
10099 template&lt;template &lt;typename&gt; class S&gt; class X {};
10100 template&lt;typename T&gt; class Y {};
10101 X&lt;Y&gt; xi;
10102 classTemplateSpecializationDecl(hasAnyTemplateArgument(
10103 refersToTemplate(templateName())))
10104 matches the specialization X&lt;Y&gt;
10105 </pre></td></tr>
10108 <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>
10109 <tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type.
10111 Given
10112 struct X {};
10113 template&lt;typename T&gt; struct A {};
10114 A&lt;X&gt; a;
10115 classTemplateSpecializationDecl(hasAnyTemplateArgument(refersToType(
10116 recordType(hasDeclaration(recordDecl(hasName("X")))))))
10117 matches the specialization of struct A generated by A&lt;X&gt;.
10118 </pre></td></tr>
10121 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>&gt;</td><td class="name" onclick="toggle('hasAnyTemplateArgumentLoc4')"><a name="hasAnyTemplateArgumentLoc4Anchor">hasAnyTemplateArgumentLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt; InnerMatcher</td></tr>
10122 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgumentLoc4"><pre>Matches template specialization `TypeLoc`s, class template specializations,
10123 variable template specializations, and function template specializations
10124 that have at least one `TemplateArgumentLoc` matching the given
10125 `InnerMatcher`.
10127 Given
10128 template&lt;typename T&gt; class A {};
10129 A&lt;int&gt; a;
10130 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc(
10131 hasTypeLoc(loc(asString("int")))))))
10132 matches `A&lt;int&gt; a`.
10133 </pre></td></tr>
10136 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>&gt;</td><td class="name" onclick="toggle('hasTemplateArgumentLoc4')"><a name="hasTemplateArgumentLoc4Anchor">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>
10137 <tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc4"><pre>Matches template specialization `TypeLoc`s, class template specializations,
10138 variable template specializations, and function template specializations
10139 where the n'th `TemplateArgumentLoc` matches the given `InnerMatcher`.
10141 Given
10142 template&lt;typename T, typename U&gt; class A {};
10143 A&lt;double, int&gt; b;
10144 A&lt;int, double&gt; c;
10145 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
10146 hasTypeLoc(loc(asString("double")))))))
10147 matches `A&lt;double, int&gt; b`, but not `A&lt;int, double&gt; c`.
10148 </pre></td></tr>
10151 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('forEachTemplateArgument3')"><a name="forEachTemplateArgument3Anchor">forEachTemplateArgument</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
10152 <tr><td colspan="4" class="doc" id="forEachTemplateArgument3"><pre>Matches templateSpecializationType, class template specialization,
10153 variable template specialization, and function template specialization
10154 nodes where the template argument matches the inner matcher. This matcher
10155 may produce multiple matches.
10157 Given
10158 template &lt;typename T, unsigned N, unsigned M&gt;
10159 struct Matrix {};
10161 constexpr unsigned R = 2;
10162 Matrix&lt;int, R * 2, R * 4&gt; M;
10164 template &lt;typename T, typename U&gt;
10165 void f(T&amp;&amp; t, U&amp;&amp; u) {}
10167 bool B = false;
10168 f(R, B);
10169 templateSpecializationType(forEachTemplateArgument(isExpr(expr())))
10170 matches twice, with expr() matching 'R * 2' and 'R * 4'
10171 functionDecl(forEachTemplateArgument(refersToType(builtinType())))
10172 matches the specialization f&lt;unsigned, bool&gt; twice, for 'unsigned'
10173 and 'bool'
10174 </pre></td></tr>
10177 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('hasAnyTemplateArgument3')"><a name="hasAnyTemplateArgument3Anchor">hasAnyTemplateArgument</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
10178 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument3"><pre>Matches templateSpecializationTypes, class template specializations,
10179 variable template specializations, and function template specializations
10180 that have at least one TemplateArgument matching the given InnerMatcher.
10182 Given
10183 template&lt;typename T&gt; class A {};
10184 template&lt;&gt; class A&lt;double&gt; {};
10185 A&lt;int&gt; a;
10187 template&lt;typename T&gt; f() {};
10188 void func() { f&lt;int&gt;(); };
10190 classTemplateSpecializationDecl(hasAnyTemplateArgument(
10191 refersToType(asString("int"))))
10192 matches the specialization A&lt;int&gt;
10194 functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
10195 matches the specialization f&lt;int&gt;
10196 </pre></td></tr>
10199 <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>
10200 <tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node
10201 matches the given matcher.
10203 The associated declaration is:
10204 - for type nodes, the declaration of the underlying type
10205 - for CallExpr, the declaration of the callee
10206 - for MemberExpr, the declaration of the referenced member
10207 - for CXXConstructExpr, the declaration of the constructor
10208 - for CXXNewExpr, the declaration of the operator new
10209 - for ObjCIvarExpr, the declaration of the ivar
10211 For type nodes, hasDeclaration will generally match the declaration of the
10212 sugared type. Given
10213 class X {};
10214 typedef X Y;
10215 Y y;
10216 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
10217 typedefDecl. A common use case is to match the underlying, desugared type.
10218 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
10219 varDecl(hasType(hasUnqualifiedDesugaredType(
10220 recordType(hasDeclaration(decl())))))
10221 In this matcher, the decl will match the CXXRecordDecl of class X.
10223 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;,
10224 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;,
10225 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;,
10226 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;,
10227 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;,
10228 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;,
10229 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
10230 </pre></td></tr>
10233 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('hasTemplateArgument3')"><a name="hasTemplateArgument3Anchor">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>
10234 <tr><td colspan="4" class="doc" id="hasTemplateArgument3"><pre>Matches templateSpecializationType, class template specializations,
10235 variable template specializations, and function template specializations
10236 where the n'th TemplateArgument matches the given InnerMatcher.
10238 Given
10239 template&lt;typename T, typename U&gt; class A {};
10240 A&lt;bool, int&gt; b;
10241 A&lt;int, bool&gt; c;
10243 template&lt;typename T&gt; void f() {}
10244 void func() { f&lt;int&gt;(); };
10245 classTemplateSpecializationDecl(hasTemplateArgument(
10246 1, refersToType(asString("int"))))
10247 matches the specialization A&lt;bool, int&gt;
10249 functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
10250 matches the specialization f&lt;int&gt;
10251 </pre></td></tr>
10254 <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>
10255 <tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node
10256 matches the given matcher.
10258 The associated declaration is:
10259 - for type nodes, the declaration of the underlying type
10260 - for CallExpr, the declaration of the callee
10261 - for MemberExpr, the declaration of the referenced member
10262 - for CXXConstructExpr, the declaration of the constructor
10263 - for CXXNewExpr, the declaration of the operator new
10264 - for ObjCIvarExpr, the declaration of the ivar
10266 For type nodes, hasDeclaration will generally match the declaration of the
10267 sugared type. Given
10268 class X {};
10269 typedef X Y;
10270 Y y;
10271 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
10272 typedefDecl. A common use case is to match the underlying, desugared type.
10273 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
10274 varDecl(hasType(hasUnqualifiedDesugaredType(
10275 recordType(hasDeclaration(decl())))))
10276 In this matcher, the decl will match the CXXRecordDecl of class X.
10278 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;,
10279 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;,
10280 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;,
10281 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;,
10282 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;,
10283 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;,
10284 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
10285 </pre></td></tr>
10288 <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>
10289 <tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner
10290 QualType-matcher matches.
10291 </pre></td></tr>
10294 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</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>
10295 <tr><td colspan="4" class="doc" id="hasTypeLoc12"><pre>Matches if the type location of a node matches the inner matcher.
10297 Examples:
10298 int x;
10299 declaratorDecl(hasTypeLoc(loc(asString("int"))))
10300 matches int x
10302 auto x = int(3);
10303 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
10304 matches int(3)
10306 struct Foo { Foo(int, int); };
10307 auto x = Foo(1, 2);
10308 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
10309 matches Foo(1, 2)
10311 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;,
10312 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;,
10313 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;,
10314 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
10315 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
10316 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;,
10317 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;,
10318 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
10319 </pre></td></tr>
10322 <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>
10323 <tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type
10324 matcher.
10326 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
10327 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
10328 and U (matcher = typedefDecl(hasType(asString("int")))
10329 and friend class X (matcher = friendDecl(hasType("X"))
10330 and public virtual X (matcher = cxxBaseSpecifier(hasType(
10331 asString("class X")))
10332 class X {};
10333 void y(X &amp;x) { x; X z; }
10334 typedef int U;
10335 class Y { friend class X; };
10336 class Z : public virtual X {};
10337 </pre></td></tr>
10340 <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>
10341 <tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node
10342 matches the given matcher.
10344 The associated declaration is:
10345 - for type nodes, the declaration of the underlying type
10346 - for CallExpr, the declaration of the callee
10347 - for MemberExpr, the declaration of the referenced member
10348 - for CXXConstructExpr, the declaration of the constructor
10349 - for CXXNewExpr, the declaration of the operator new
10350 - for ObjCIvarExpr, the declaration of the ivar
10352 For type nodes, hasDeclaration will generally match the declaration of the
10353 sugared type. Given
10354 class X {};
10355 typedef X Y;
10356 Y y;
10357 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
10358 typedefDecl. A common use case is to match the underlying, desugared type.
10359 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
10360 varDecl(hasType(hasUnqualifiedDesugaredType(
10361 recordType(hasDeclaration(decl())))))
10362 In this matcher, the decl will match the CXXRecordDecl of class X.
10364 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;,
10365 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;,
10366 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;,
10367 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;,
10368 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;,
10369 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;,
10370 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
10371 </pre></td></tr>
10374 <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>
10375 <tr><td colspan="4" class="doc" id="hasUnqualifiedDesugaredType0"><pre>Matches if the matched type matches the unqualified desugared
10376 type of the matched node.
10378 For example, in:
10379 class A {};
10380 using B = A;
10381 The matcher type(hasUnqualifiedDesugaredType(recordType())) matches
10382 both B and A.
10383 </pre></td></tr>
10386 <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>
10387 <tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument.
10389 Given
10390 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
10391 unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
10392 matches sizeof(a) and alignof(c)
10393 </pre></td></tr>
10396 <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>
10397 <tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches.
10399 Example matches true (matcher = hasUnaryOperand(
10400 cxxBoolLiteral(equals(true))))
10401 !true
10402 </pre></td></tr>
10405 <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>
10406 <tr><td colspan="4" class="doc" id="hasObjectExpression1"><pre>Matches a member expression where the object expression is matched by a
10407 given matcher. Implicit object expressions are included; that is, it matches
10408 use of implicit `this`.
10410 Given
10411 struct X {
10412 int m;
10413 int f(X x) { x.m; return m; }
10415 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))
10416 matches `x.m`, but not `m`; however,
10417 memberExpr(hasObjectExpression(hasType(pointsTo(
10418 cxxRecordDecl(hasName("X"))))))
10419 matches `m` (aka. `this-&gt;m`), but not `x.m`.
10420 </pre></td></tr>
10423 <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>
10424 <tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node
10425 matches the given matcher.
10427 The associated declaration is:
10428 - for type nodes, the declaration of the underlying type
10429 - for CallExpr, the declaration of the callee
10430 - for MemberExpr, the declaration of the referenced member
10431 - for CXXConstructExpr, the declaration of the constructor
10432 - for CXXNewExpr, the declaration of the operator new
10433 - for ObjCIvarExpr, the declaration of the ivar
10435 For type nodes, hasDeclaration will generally match the declaration of the
10436 sugared type. Given
10437 class X {};
10438 typedef X Y;
10439 Y y;
10440 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
10441 typedefDecl. A common use case is to match the underlying, desugared type.
10442 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
10443 varDecl(hasType(hasUnqualifiedDesugaredType(
10444 recordType(hasDeclaration(decl())))))
10445 In this matcher, the decl will match the CXXRecordDecl of class X.
10447 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;,
10448 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;,
10449 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;,
10450 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;,
10451 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;,
10452 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;,
10453 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
10454 </pre></td></tr>
10457 <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>
10458 <tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is
10459 matched by the given matcher.
10461 Given
10462 namespace X { int a; void b(); }
10463 using X::a;
10464 using X::b;
10465 usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
10466 matches using X::b but not using X::a </pre></td></tr>
10469 <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>
10470 <tr><td colspan="4" class="doc" id="hasUnderlyingType1"><pre>Matches DecltypeType or UsingType nodes to find the underlying type.
10472 Given
10473 decltype(1) a = 1;
10474 decltype(2.0) b = 2.0;
10475 decltypeType(hasUnderlyingType(isInteger()))
10476 matches the type of "a"
10478 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;
10479 </pre></td></tr>
10482 <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>
10483 <tr><td colspan="4" class="doc" id="throughUsingDecl1"><pre>Matches if a node refers to a declaration through a specific
10484 using shadow declaration.
10486 Examples:
10487 namespace a { int f(); }
10488 using a::f;
10489 int x = f();
10490 declRefExpr(throughUsingDecl(anything()))
10491 matches f
10493 namespace a { class X{}; }
10494 using a::X;
10495 X x;
10496 typeLoc(loc(usingType(throughUsingDecl(anything()))))
10497 matches X
10499 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;
10500 </pre></td></tr>
10503 <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>
10504 <tr><td colspan="4" class="doc" id="hasType7"><pre>Overloaded to match the declaration of the expression's or value
10505 declaration's type.
10507 In case of a value declaration (for example a variable declaration),
10508 this resolves one layer of indirection. For example, in the value
10509 declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
10510 X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
10511 declaration of x.
10513 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
10514 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
10515 and friend class X (matcher = friendDecl(hasType("X"))
10516 and public virtual X (matcher = cxxBaseSpecifier(hasType(
10517 cxxRecordDecl(hasName("X"))))
10518 class X {};
10519 void y(X &amp;x) { x; X z; }
10520 class Y { friend class X; };
10521 class Z : public virtual X {};
10523 Example matches class Derived
10524 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
10525 class Base {};
10526 class Derived : Base {};
10528 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;,
10529 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
10530 </pre></td></tr>
10533 <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>
10534 <tr><td colspan="4" class="doc" id="hasType3"><pre>Matches if the expression's or declaration's type matches a type
10535 matcher.
10537 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
10538 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
10539 and U (matcher = typedefDecl(hasType(asString("int")))
10540 and friend class X (matcher = friendDecl(hasType("X"))
10541 and public virtual X (matcher = cxxBaseSpecifier(hasType(
10542 asString("class X")))
10543 class X {};
10544 void y(X &amp;x) { x; X z; }
10545 typedef int U;
10546 class Y { friend class X; };
10547 class Z : public virtual X {};
10548 </pre></td></tr>
10551 <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>
10552 <tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression
10553 that matches the given matcher.
10555 Example matches x (matcher = varDecl(hasInitializer(callExpr())))
10556 bool y() { return true; }
10557 bool x = y();
10558 </pre></td></tr>
10561 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarTemplateSpecializationDecl.html">VarTemplateSpecializationDecl</a>&gt;</td><td class="name" onclick="toggle('forEachTemplateArgument1')"><a name="forEachTemplateArgument1Anchor">forEachTemplateArgument</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
10562 <tr><td colspan="4" class="doc" id="forEachTemplateArgument1"><pre>Matches templateSpecializationType, class template specialization,
10563 variable template specialization, and function template specialization
10564 nodes where the template argument matches the inner matcher. This matcher
10565 may produce multiple matches.
10567 Given
10568 template &lt;typename T, unsigned N, unsigned M&gt;
10569 struct Matrix {};
10571 constexpr unsigned R = 2;
10572 Matrix&lt;int, R * 2, R * 4&gt; M;
10574 template &lt;typename T, typename U&gt;
10575 void f(T&amp;&amp; t, U&amp;&amp; u) {}
10577 bool B = false;
10578 f(R, B);
10579 templateSpecializationType(forEachTemplateArgument(isExpr(expr())))
10580 matches twice, with expr() matching 'R * 2' and 'R * 4'
10581 functionDecl(forEachTemplateArgument(refersToType(builtinType())))
10582 matches the specialization f&lt;unsigned, bool&gt; twice, for 'unsigned'
10583 and 'bool'
10584 </pre></td></tr>
10587 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarTemplateSpecializationDecl.html">VarTemplateSpecializationDecl</a>&gt;</td><td class="name" onclick="toggle('hasAnyTemplateArgumentLoc1')"><a name="hasAnyTemplateArgumentLoc1Anchor">hasAnyTemplateArgumentLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt; InnerMatcher</td></tr>
10588 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgumentLoc1"><pre>Matches template specialization `TypeLoc`s, class template specializations,
10589 variable template specializations, and function template specializations
10590 that have at least one `TemplateArgumentLoc` matching the given
10591 `InnerMatcher`.
10593 Given
10594 template&lt;typename T&gt; class A {};
10595 A&lt;int&gt; a;
10596 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc(
10597 hasTypeLoc(loc(asString("int")))))))
10598 matches `A&lt;int&gt; a`.
10599 </pre></td></tr>
10602 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarTemplateSpecializationDecl.html">VarTemplateSpecializationDecl</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>
10603 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches templateSpecializationTypes, class template specializations,
10604 variable template specializations, and function template specializations
10605 that have at least one TemplateArgument matching the given InnerMatcher.
10607 Given
10608 template&lt;typename T&gt; class A {};
10609 template&lt;&gt; class A&lt;double&gt; {};
10610 A&lt;int&gt; a;
10612 template&lt;typename T&gt; f() {};
10613 void func() { f&lt;int&gt;(); };
10615 classTemplateSpecializationDecl(hasAnyTemplateArgument(
10616 refersToType(asString("int"))))
10617 matches the specialization A&lt;int&gt;
10619 functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
10620 matches the specialization f&lt;int&gt;
10621 </pre></td></tr>
10624 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarTemplateSpecializationDecl.html">VarTemplateSpecializationDecl</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>
10625 <tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc1"><pre>Matches template specialization `TypeLoc`s, class template specializations,
10626 variable template specializations, and function template specializations
10627 where the n'th `TemplateArgumentLoc` matches the given `InnerMatcher`.
10629 Given
10630 template&lt;typename T, typename U&gt; class A {};
10631 A&lt;double, int&gt; b;
10632 A&lt;int, double&gt; c;
10633 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
10634 hasTypeLoc(loc(asString("double")))))))
10635 matches `A&lt;double, int&gt; b`, but not `A&lt;int, double&gt; c`.
10636 </pre></td></tr>
10639 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1VarTemplateSpecializationDecl.html">VarTemplateSpecializationDecl</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>
10640 <tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches templateSpecializationType, class template specializations,
10641 variable template specializations, and function template specializations
10642 where the n'th TemplateArgument matches the given InnerMatcher.
10644 Given
10645 template&lt;typename T, typename U&gt; class A {};
10646 A&lt;bool, int&gt; b;
10647 A&lt;int, bool&gt; c;
10649 template&lt;typename T&gt; void f() {}
10650 void func() { f&lt;int&gt;(); };
10651 classTemplateSpecializationDecl(hasTemplateArgument(
10652 1, refersToType(asString("int"))))
10653 matches the specialization A&lt;bool, int&gt;
10655 functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
10656 matches the specialization f&lt;int&gt;
10657 </pre></td></tr>
10660 <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>
10661 <tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size
10662 expression.
10664 Given
10665 void f(int b) {
10666 int a[b];
10668 variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
10669 varDecl(hasName("b")))))))
10670 matches "int a[b]"
10671 </pre></td></tr>
10674 <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>
10675 <tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
10676 definition that has a given body. Note that in case of functions or
10677 coroutines this matcher only matches the definition itself and not the
10678 other declarations of the same function or coroutine.
10680 Given
10681 for (;;) {}
10682 forStmt(hasBody(compoundStmt()))
10683 matches 'for (;;) {}'
10684 with compoundStmt()
10685 matching '{}'
10687 Given
10688 void f();
10689 void f() {}
10690 functionDecl(hasBody(compoundStmt()))
10691 matches 'void f() {}'
10692 with compoundStmt()
10693 matching '{}'
10694 but does not match 'void f();'
10695 </pre></td></tr>
10698 <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>
10699 <tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop,
10700 switch statement or conditional operator.
10702 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
10703 if (true) {}
10704 </pre></td></tr>
10706 <!--END_TRAVERSAL_MATCHERS -->
10707 </table>
10709 </div>
10710 </body>
10711 </html>