[docs] Fix build-docs.sh
[llvm-project.git] / clang / docs / LibASTMatchersReference.html
blob4ac9ab0090cd4d7c447295e72f9046808e66b076
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(hasReturnArgument(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('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>
686 <tr><td colspan="4" class="doc" id="cxxConstructorDecl0"><pre>Matches C++ constructor declarations.
688 Example matches Foo::Foo() and Foo::Foo(int)
689 class Foo {
690 public:
691 Foo();
692 Foo(int);
693 int DoSomething();
695 </pre></td></tr>
698 <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>
699 <tr><td colspan="4" class="doc" id="cxxConversionDecl0"><pre>Matches conversion operator declarations.
701 Example matches the operator.
702 class X { operator int() const; };
703 </pre></td></tr>
706 <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>
707 <tr><td colspan="4" class="doc" id="cxxDeductionGuideDecl0"><pre>Matches user-defined and implicitly generated deduction guide.
709 Example matches the deduction guide.
710 template&lt;typename T&gt;
711 class X { X(int) };
712 X(int) -&gt; X&lt;int&gt;;
713 </pre></td></tr>
716 <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>
717 <tr><td colspan="4" class="doc" id="cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations.
719 Example matches Foo::~Foo()
720 class Foo {
721 public:
722 virtual ~Foo();
724 </pre></td></tr>
727 <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>
728 <tr><td colspan="4" class="doc" id="cxxMethodDecl0"><pre>Matches method declarations.
730 Example matches y
731 class X { void y(); };
732 </pre></td></tr>
735 <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>
736 <tr><td colspan="4" class="doc" id="cxxRecordDecl0"><pre>Matches C++ class declarations.
738 Example matches X, Z
739 class X;
740 template&lt;class T&gt; class Z {};
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('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>
745 <tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations.
747 Examples matches X, C, and the friend declaration inside C;
748 void X();
749 class C {
750 friend X;
752 </pre></td></tr>
755 <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>
756 <tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function
757 and non-type template parameter declarations).
759 Given
760 class X { int y; };
761 declaratorDecl()
762 matches int y.
763 </pre></td></tr>
766 <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>
767 <tr><td colspan="4" class="doc" id="decompositionDecl0"><pre>Matches decomposition-declarations.
769 Examples matches the declaration node with foo and bar, but not
770 number.
771 (matcher = declStmt(has(decompositionDecl())))
773 int number = 42;
774 auto [foo, bar] = std::make_pair{42, 42};
775 </pre></td></tr>
778 <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>
779 <tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants.
781 Example matches A, B, C
782 enum X {
783 A, B, C
785 </pre></td></tr>
788 <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>
789 <tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations.
791 Example matches X
792 enum X {
793 A, B, C
795 </pre></td></tr>
798 <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>
799 <tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations.
801 Given
802 class X { int m; };
803 fieldDecl()
804 matches 'm'.
805 </pre></td></tr>
808 <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>
809 <tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations.
811 Given
812 class X { friend void foo(); };
813 friendDecl()
814 matches 'friend void foo()'.
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('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>
819 <tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations.
821 Example matches f
822 void f();
823 </pre></td></tr>
826 <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>
827 <tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations.
829 Example matches f
830 template&lt;class T&gt; void f(T t) {}
831 </pre></td></tr>
834 <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>
835 <tr><td colspan="4" class="doc" id="indirectFieldDecl0"><pre>Matches indirect field declarations.
837 Given
838 struct X { struct { int a; }; };
839 indirectFieldDecl()
840 matches 'a'.
841 </pre></td></tr>
844 <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>
845 <tr><td colspan="4" class="doc" id="labelDecl0"><pre>Matches a declaration of label.
847 Given
848 goto FOO;
849 FOO: bar();
850 labelDecl()
851 matches 'FOO:'
852 </pre></td></tr>
855 <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>
856 <tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification.
858 Given
859 extern "C" {}
860 linkageSpecDecl()
861 matches "extern "C" {}"
862 </pre></td></tr>
865 <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>
866 <tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name.
868 Example matches X, S, the anonymous union type, i, and U;
869 typedef int X;
870 struct S {
871 union {
872 int i;
873 } U;
875 </pre></td></tr>
878 <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>
879 <tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias.
881 Given
882 namespace test {}
883 namespace alias = ::test;
884 namespaceAliasDecl()
885 matches "namespace alias" but not "namespace test"
886 </pre></td></tr>
889 <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>
890 <tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace.
892 Given
893 namespace {}
894 namespace test {}
895 namespaceDecl()
896 matches "namespace {}" and "namespace test {}"
897 </pre></td></tr>
900 <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>
901 <tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations.
903 Given
904 template &lt;typename T, int N&gt; struct C {};
905 nonTypeTemplateParmDecl()
906 matches 'N', but not 'T'.
907 </pre></td></tr>
910 <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>
911 <tr><td colspan="4" class="doc" id="objcCategoryDecl0"><pre>Matches Objective-C category declarations.
913 Example matches Foo (Additions)
914 @interface Foo (Additions)
915 @end
916 </pre></td></tr>
919 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('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>
920 <tr><td colspan="4" class="doc" id="objcCategoryImplDecl0"><pre>Matches Objective-C category definitions.
922 Example matches Foo (Additions)
923 @implementation Foo (Additions)
924 @end
925 </pre></td></tr>
928 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('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>
929 <tr><td colspan="4" class="doc" id="objcImplementationDecl0"><pre>Matches Objective-C implementation declarations.
931 Example matches Foo
932 @implementation Foo
933 @end
934 </pre></td></tr>
937 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('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>
938 <tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations.
940 Example matches Foo
941 @interface Foo
942 @end
943 </pre></td></tr>
946 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('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>
947 <tr><td colspan="4" class="doc" id="objcIvarDecl0"><pre>Matches Objective-C instance variable declarations.
949 Example matches _enabled
950 @implementation Foo {
951 BOOL _enabled;
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('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>
958 <tr><td colspan="4" class="doc" id="objcMethodDecl0"><pre>Matches Objective-C method declarations.
960 Example matches both declaration and definition of -[Foo method]
961 @interface Foo
962 - (void)method;
963 @end
965 @implementation Foo
966 - (void)method {}
967 @end
968 </pre></td></tr>
971 <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>
972 <tr><td colspan="4" class="doc" id="objcPropertyDecl0"><pre>Matches Objective-C property declarations.
974 Example matches enabled
975 @interface Foo
976 @property BOOL enabled;
977 @end
978 </pre></td></tr>
981 <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>
982 <tr><td colspan="4" class="doc" id="objcProtocolDecl0"><pre>Matches Objective-C protocol declarations.
984 Example matches FooDelegate
985 @protocol FooDelegate
986 @end
987 </pre></td></tr>
990 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('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>
991 <tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations.
993 Given
994 void f(int x);
995 parmVarDecl()
996 matches int x.
997 </pre></td></tr>
1000 <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>
1001 <tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations.
1003 Example matches X, Z, U, and S
1004 class X;
1005 template&lt;class T&gt; class Z {};
1006 struct S {};
1007 union U {};
1008 </pre></td></tr>
1011 <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>
1012 <tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration.
1014 Example:
1015 staticAssertDecl()
1016 matches
1017 static_assert(sizeof(S) == sizeof(int))
1019 struct S {
1020 int x;
1022 static_assert(sizeof(S) == sizeof(int));
1023 </pre></td></tr>
1026 <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>
1027 <tr><td colspan="4" class="doc" id="tagDecl0"><pre>Matches tag declarations.
1029 Example matches X, Z, U, S, E
1030 class X;
1031 template&lt;class T&gt; class Z {};
1032 struct S {};
1033 union U {};
1034 enum E {
1035 A, B, C
1037 </pre></td></tr>
1040 <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>
1041 <tr><td colspan="4" class="doc" id="templateTemplateParmDecl0"><pre>Matches template template parameter declarations.
1043 Given
1044 template &lt;template &lt;typename&gt; class Z, int N&gt; struct C {};
1045 templateTypeParmDecl()
1046 matches 'Z', but not 'N'.
1047 </pre></td></tr>
1050 <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>
1051 <tr><td colspan="4" class="doc" id="templateTypeParmDecl0"><pre>Matches template type parameter declarations.
1053 Given
1054 template &lt;typename T, int N&gt; struct C {};
1055 templateTypeParmDecl()
1056 matches 'T', but not 'N'.
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('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>
1061 <tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context.
1063 Given
1064 int X;
1065 namespace NS {
1066 int Y;
1067 } // namespace NS
1068 decl(hasDeclContext(translationUnitDecl()))
1069 matches "int X", but not "int Y".
1070 </pre></td></tr>
1073 <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>
1074 <tr><td colspan="4" class="doc" id="typeAliasDecl0"><pre>Matches type alias declarations.
1076 Given
1077 typedef int X;
1078 using Y = int;
1079 typeAliasDecl()
1080 matches "using Y = int", but not "typedef int X"
1081 </pre></td></tr>
1084 <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>
1085 <tr><td colspan="4" class="doc" id="typeAliasTemplateDecl0"><pre>Matches type alias template declarations.
1087 typeAliasTemplateDecl() matches
1088 template &lt;typename T&gt;
1089 using Y = X&lt;T&gt;;
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('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>
1094 <tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations.
1096 Given
1097 typedef int X;
1098 using Y = int;
1099 typedefDecl()
1100 matches "typedef int X", but not "using Y = int"
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('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>
1105 <tr><td colspan="4" class="doc" id="typedefNameDecl0"><pre>Matches typedef name declarations.
1107 Given
1108 typedef int X;
1109 using Y = int;
1110 typedefNameDecl()
1111 matches "typedef int X" and "using Y = int"
1112 </pre></td></tr>
1115 <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>
1116 <tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the
1117 typename.
1119 Given
1120 template &lt;typename T&gt;
1121 struct Base { typedef T Foo; };
1123 template&lt;typename T&gt;
1124 struct S : private Base&lt;T&gt; {
1125 using typename Base&lt;T&gt;::Foo;
1127 unresolvedUsingTypenameDecl()
1128 matches using Base&lt;T&gt;::Foo </pre></td></tr>
1131 <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>
1132 <tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations.
1134 Given
1135 template&lt;typename X&gt;
1136 class C : private X {
1137 using X::x;
1139 unresolvedUsingValueDecl()
1140 matches using X::x </pre></td></tr>
1143 <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>
1144 <tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations.
1146 Given
1147 namespace X { int x; }
1148 using X::x;
1149 usingDecl()
1150 matches using X::x </pre></td></tr>
1153 <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>
1154 <tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations.
1156 Given
1157 namespace X { int x; }
1158 using namespace X;
1159 usingDirectiveDecl()
1160 matches using namespace 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('usingEnumDecl0')"><a name="usingEnumDecl0Anchor">usingEnumDecl</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingEnumDecl.html">UsingEnumDecl</a>&gt;...</td></tr>
1164 <tr><td colspan="4" class="doc" id="usingEnumDecl0"><pre>Matches using-enum declarations.
1166 Given
1167 namespace X { enum x {...}; }
1168 using enum X::x;
1169 usingEnumDecl()
1170 matches using enum 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('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>
1174 <tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration.
1176 Example matches A, B, C and F
1177 enum X { A, B, C };
1178 void F();
1179 </pre></td></tr>
1182 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('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>
1183 <tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations.
1185 Note: this does not match declarations of member variables, which are
1186 "field" declarations in Clang parlance.
1188 Example matches a
1189 int a;
1190 </pre></td></tr>
1193 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>&gt;</td><td class="name" onclick="toggle('lambdaCapture0')"><a name="lambdaCapture0Anchor">lambdaCapture</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture</a>&gt;...</td></tr>
1194 <tr><td colspan="4" class="doc" id="lambdaCapture0"><pre>Matches lambda captures.
1196 Given
1197 int main() {
1198 int x;
1199 auto f = [x](){};
1200 auto g = [x = 1](){};
1202 In the matcher `lambdaExpr(hasAnyCapture(lambdaCapture()))`,
1203 `lambdaCapture()` matches `x` and `x=1`.
1204 </pre></td></tr>
1207 <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>
1208 <tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
1209 </pre></td></tr>
1212 <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>
1213 <tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers.
1215 Given
1216 namespace ns {
1217 struct A { static void f(); };
1218 void A::f() {}
1219 void g() { A::f(); }
1221 ns::A a;
1222 nestedNameSpecifier()
1223 matches "ns::" and both "A::"
1224 </pre></td></tr>
1227 <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>
1228 <tr><td colspan="4" class="doc" id="ompDefaultClause0"><pre>Matches OpenMP ``default`` clause.
1230 Given
1232 #pragma omp parallel default(none)
1233 #pragma omp parallel default(shared)
1234 #pragma omp parallel default(private)
1235 #pragma omp parallel default(firstprivate)
1236 #pragma omp parallel
1238 ``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``,
1239 `` default(private)`` and ``default(firstprivate)``
1240 </pre></td></tr>
1243 <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>
1244 <tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST.
1245 </pre></td></tr>
1248 <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>
1249 <tr><td colspan="4" class="doc" id="addrLabelExpr0"><pre>Matches address of label statements (GNU extension).
1251 Given
1252 FOO: bar();
1253 void *ptr = &amp;&amp;FOO;
1254 goto *bar;
1255 addrLabelExpr()
1256 matches '&amp;&amp;FOO'
1257 </pre></td></tr>
1260 <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>
1261 <tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions.
1263 Given
1264 int i = a[1];
1265 arraySubscriptExpr()
1266 matches "a[1]"
1267 </pre></td></tr>
1270 <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>
1271 <tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements.
1273 int i = 100;
1274 __asm("mov al, 2");
1275 asmStmt()
1276 matches '__asm("mov al, 2")'
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('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>
1281 <tr><td colspan="4" class="doc" id="atomicExpr0"><pre>Matches atomic builtins.
1282 Example matches __atomic_load_n(ptr, 1)
1283 void foo() { int *ptr; __atomic_load_n(ptr, 1); }
1284 </pre></td></tr>
1287 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1288 <tr><td colspan="4" class="doc" id="autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement.
1290 Given
1291 @autoreleasepool {
1292 int x = 0;
1294 autoreleasePoolStmt(stmt()) matches the declaration of "x"
1295 inside the autorelease pool.
1296 </pre></td></tr>
1299 <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>
1300 <tr><td colspan="4" class="doc" id="binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension).
1302 Example matches a ?: b
1303 (a ?: b) + 42;
1304 </pre></td></tr>
1307 <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>
1308 <tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions.
1310 Example matches a || b
1311 !(a || b)
1312 See also the binaryOperation() matcher for more-general matching.
1313 </pre></td></tr>
1316 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1317 <tr><td colspan="4" class="doc" id="blockExpr0"><pre>Matches a reference to a block.
1319 Example: matches "^{}":
1320 void f() { ^{}(); }
1321 </pre></td></tr>
1324 <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>
1325 <tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements.
1327 Given
1328 while (true) { break; }
1329 breakStmt()
1330 matches 'break'
1331 </pre></td></tr>
1334 <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>
1335 <tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression.
1337 Example: Matches (int) 2.2f in
1338 int i = (int) 2.2f;
1339 </pre></td></tr>
1342 <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>
1343 <tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions.
1345 Example matches x.y() and y()
1346 X x;
1347 x.y();
1348 y();
1349 </pre></td></tr>
1352 <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>
1353 <tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements.
1355 Given
1356 switch(a) { case 42: break; default: break; }
1357 caseStmt()
1358 matches 'case 42:'.
1359 </pre></td></tr>
1362 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1363 <tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST.
1365 Example: castExpr() matches each of the following:
1366 (int) 3;
1367 const_cast&lt;Expr *&gt;(SubExpr);
1368 char c = 0;
1369 but does not match
1370 int i = (0);
1371 int k = 0;
1372 </pre></td></tr>
1375 <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>
1376 <tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t).
1378 Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
1379 though.
1381 Example matches 'a', L'a'
1382 char ch = 'a';
1383 wchar_t chw = L'a';
1384 </pre></td></tr>
1387 <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>
1388 <tr><td colspan="4" class="doc" id="chooseExpr0"><pre>Matches GNU __builtin_choose_expr.
1389 </pre></td></tr>
1392 <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>
1393 <tr><td colspan="4" class="doc" id="coawaitExpr0"><pre>Matches co_await expressions.
1395 Given
1396 co_await 1;
1397 coawaitExpr()
1398 matches 'co_await 1'
1399 </pre></td></tr>
1402 <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>
1403 <tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals
1405 Example match: {1}, (1, 2)
1406 int array[4] = {1};
1407 vector int myvec = (vector int)(1, 2);
1408 </pre></td></tr>
1411 <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>
1412 <tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements.
1414 Example matches '{}' and '{{}}' in 'for (;;) {{}}'
1415 for (;;) {{}}
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('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>
1420 <tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions.
1422 Example matches a ? b : c
1423 (a ? b : c) + 42
1424 </pre></td></tr>
1427 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1428 <tr><td colspan="4" class="doc" id="constantExpr0"><pre>Matches a constant expression wrapper.
1430 Example matches the constant in the case statement:
1431 (matcher = constantExpr())
1432 switch (a) {
1433 case 37: break;
1435 </pre></td></tr>
1438 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1439 <tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements.
1441 Given
1442 while (true) { continue; }
1443 continueStmt()
1444 matches 'continue'
1445 </pre></td></tr>
1448 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1449 <tr><td colspan="4" class="doc" id="coreturnStmt0"><pre>Matches co_return statements.
1451 Given
1452 while (true) { co_return; }
1453 coreturnStmt()
1454 matches 'co_return'
1455 </pre></td></tr>
1458 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1459 <tr><td colspan="4" class="doc" id="coyieldExpr0"><pre>Matches co_yield expressions.
1461 Given
1462 co_yield 1;
1463 coyieldExpr()
1464 matches 'co_yield 1'
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('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>
1469 <tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression.
1471 Example matches,
1472 kernel&lt;&lt;&lt;i,j&gt;&gt;&gt;();
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('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>
1477 <tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created.
1479 Example matches FunctionTakesString(GetStringByValue())
1480 (matcher = cxxBindTemporaryExpr())
1481 FunctionTakesString(GetStringByValue());
1482 FunctionTakesStringByPointer(GetStringPointer());
1483 </pre></td></tr>
1486 <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>
1487 <tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals.
1489 Example matches true
1490 true
1491 </pre></td></tr>
1494 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1495 <tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements.
1497 try {} catch(int i) {}
1498 cxxCatchStmt()
1499 matches 'catch(int i)'
1500 </pre></td></tr>
1503 <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>
1504 <tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression.
1506 Example: Matches const_cast&lt;int*&gt;(&amp;r) in
1507 int n = 42;
1508 const int &amp;r(n);
1509 int* p = const_cast&lt;int*&gt;(&amp;r);
1510 </pre></td></tr>
1513 <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>
1514 <tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones).
1516 Example matches string(ptr, n) and ptr within arguments of f
1517 (matcher = cxxConstructExpr())
1518 void f(const string &amp;a, const string &amp;b);
1519 char *ptr;
1520 int n;
1521 f(string(ptr, n), ptr);
1522 </pre></td></tr>
1525 <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>
1526 <tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site.
1528 Example matches the CXXDefaultArgExpr placeholder inserted for the
1529 default value of the second parameter in the call expression f(42)
1530 (matcher = cxxDefaultArgExpr())
1531 void f(int x, int y = 0);
1532 f(42);
1533 </pre></td></tr>
1536 <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>
1537 <tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions.
1539 Given
1540 delete X;
1541 cxxDeleteExpr()
1542 matches 'delete X'.
1543 </pre></td></tr>
1546 <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>
1547 <tr><td colspan="4" class="doc" id="cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be
1548 resolved because the base expression or the member name was dependent.
1550 Given
1551 template &lt;class T&gt; void f() { T t; t.g(); }
1552 cxxDependentScopeMemberExpr()
1553 matches t.g
1554 </pre></td></tr>
1557 <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>
1558 <tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression.
1560 Example:
1561 cxxDynamicCastExpr()
1562 matches
1563 dynamic_cast&lt;D*&gt;(&amp;b);
1565 struct B { virtual ~B() {} }; struct D : B {};
1566 B b;
1567 D* p = dynamic_cast&lt;D*&gt;(&amp;b);
1568 </pre></td></tr>
1571 <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>
1572 <tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements.
1574 cxxForRangeStmt() matches 'for (auto a : i)'
1575 int i[] = {1, 2, 3}; for (auto a : i);
1576 for(int j = 0; j &lt; 5; ++j);
1577 </pre></td></tr>
1580 <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>
1581 <tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions
1583 Example: Matches Foo(bar);
1584 Foo f = bar;
1585 Foo g = (Foo) bar;
1586 Foo h = Foo(bar);
1587 </pre></td></tr>
1590 <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>
1591 <tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions.
1593 Example matches x.y()
1594 X x;
1595 x.y();
1596 </pre></td></tr>
1599 <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>
1600 <tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions.
1602 Given
1603 new X;
1604 cxxNewExpr()
1605 matches 'new X'.
1606 </pre></td></tr>
1609 <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>
1610 <tr><td colspan="4" class="doc" id="cxxNoexceptExpr0"><pre>Matches noexcept expressions.
1612 Given
1613 bool a() noexcept;
1614 bool b() noexcept(true);
1615 bool c() noexcept(false);
1616 bool d() noexcept(noexcept(a()));
1617 bool e = noexcept(b()) || noexcept(c());
1618 cxxNoexceptExpr()
1619 matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`.
1620 doesn't match the noexcept specifier in the declarations a, b, c or d.
1621 </pre></td></tr>
1624 <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>
1625 <tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal.
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('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>
1630 <tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls.
1632 Note that if an operator isn't overloaded, it won't match. Instead, use
1633 binaryOperator matcher.
1634 Currently it does not match operators such as new delete.
1635 FIXME: figure out why these do not match?
1637 Example matches both operator&lt;&lt;((o &lt;&lt; b), c) and operator&lt;&lt;(o, b)
1638 (matcher = cxxOperatorCallExpr())
1639 ostream &amp;operator&lt;&lt; (ostream &amp;out, int i) { };
1640 ostream &amp;o; int b = 1, c = 1;
1641 o &lt;&lt; b &lt;&lt; c;
1642 See also the binaryOperation() matcher for more-general matching of binary
1643 uses of this AST node.
1644 </pre></td></tr>
1647 <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>
1648 <tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression.
1650 Either the source expression or the destination type can be matched
1651 using has(), but hasDestinationType() is more specific and can be
1652 more readable.
1654 Example matches reinterpret_cast&lt;char*&gt;(&amp;p) in
1655 void* p = reinterpret_cast&lt;char*&gt;(&amp;p);
1656 </pre></td></tr>
1659 <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>
1660 <tr><td colspan="4" class="doc" id="cxxRewrittenBinaryOperator0"><pre>Matches rewritten binary operators
1662 Example matches use of "&lt;":
1663 #include &lt;compare&gt;
1664 struct HasSpaceshipMem {
1665 int a;
1666 constexpr auto operator&lt;=&gt;(const HasSpaceshipMem&amp;) const = default;
1668 void compare() {
1669 HasSpaceshipMem hs1, hs2;
1670 if (hs1 &lt; hs2)
1671 return;
1673 See also the binaryOperation() matcher for more-general matching
1674 of this AST node.
1675 </pre></td></tr>
1678 <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>
1679 <tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression.
1681 See also: hasDestinationType
1682 See also: reinterpretCast
1684 Example:
1685 cxxStaticCastExpr()
1686 matches
1687 static_cast&lt;long&gt;(8)
1689 long eight(static_cast&lt;long&gt;(8));
1690 </pre></td></tr>
1693 <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>
1694 <tr><td colspan="4" class="doc" id="cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions.
1696 Given
1697 std::vector&lt;int&gt; a({ 1, 2, 3 });
1698 std::vector&lt;int&gt; b = { 4, 5 };
1699 int c[] = { 6, 7 };
1700 std::pair&lt;int, int&gt; d = { 8, 9 };
1701 cxxStdInitializerListExpr()
1702 matches "{ 1, 2, 3 }" and "{ 4, 5 }"
1703 </pre></td></tr>
1706 <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>
1707 <tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments
1709 Example: Matches Foo(bar, bar)
1710 Foo h = Foo(bar, bar);
1711 </pre></td></tr>
1714 <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>
1715 <tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions.
1717 Example matches the implicit this expression in "return i".
1718 (matcher = cxxThisExpr())
1719 struct foo {
1720 int i;
1721 int f() { return i; }
1723 </pre></td></tr>
1726 <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>
1727 <tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions.
1729 try { throw 5; } catch(int i) {}
1730 cxxThrowExpr()
1731 matches 'throw 5'
1732 </pre></td></tr>
1735 <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>
1736 <tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements.
1738 try {} catch(int i) {}
1739 cxxTryStmt()
1740 matches 'try {}'
1741 </pre></td></tr>
1744 <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>
1745 <tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions.
1747 Example matches T(t) in return statement of f
1748 (matcher = cxxUnresolvedConstructExpr())
1749 template &lt;typename T&gt;
1750 void f(const T&amp; t) { return T(t); }
1751 </pre></td></tr>
1754 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1755 <tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations.
1757 Example matches x in if (x)
1758 bool x;
1759 if (x) {}
1760 </pre></td></tr>
1763 <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>
1764 <tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements.
1766 Given
1767 int a;
1768 declStmt()
1769 matches 'int a'.
1770 </pre></td></tr>
1773 <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>
1774 <tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements.
1776 Given
1777 switch(a) { case 42: break; default: break; }
1778 defaultStmt()
1779 matches 'default:'.
1780 </pre></td></tr>
1783 <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>
1784 <tr><td colspan="4" class="doc" id="dependentCoawaitExpr0"><pre>Matches co_await expressions where the type of the promise is dependent
1785 </pre></td></tr>
1788 <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>
1789 <tr><td colspan="4" class="doc" id="designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99 6.7.8].
1791 Example: Matches { [2].y = 1.0, [0].x = 1.0 }
1792 point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
1793 </pre></td></tr>
1796 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1797 <tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements.
1799 Given
1800 do {} while (true);
1801 doStmt()
1802 matches 'do {} while(true)'
1803 </pre></td></tr>
1806 <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>
1807 <tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions.
1809 Matches any cast expression written in user code, whether it be a
1810 C-style cast, a functional-style cast, or a keyword cast.
1812 Does not match implicit conversions.
1814 Note: the name "explicitCast" is chosen to match Clang's terminology, as
1815 Clang uses the term "cast" to apply to implicit conversions as well as to
1816 actual cast expressions.
1818 See also: hasDestinationType.
1820 Example: matches all five of the casts in
1821 int((int)(reinterpret_cast&lt;int&gt;(static_cast&lt;int&gt;(const_cast&lt;int&gt;(42)))))
1822 but does not match the implicit conversion in
1823 long ell = 42;
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('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>
1828 <tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions.
1830 Example matches x()
1831 void f() { x(); }
1832 </pre></td></tr>
1835 <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>
1836 <tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end
1837 of the sub-expression's evaluation.
1839 Example matches std::string()
1840 const std::string str = std::string();
1841 </pre></td></tr>
1844 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1845 <tr><td colspan="4" class="doc" id="fixedPointLiteral0"><pre>Matches fixed point literals
1846 </pre></td></tr>
1849 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1850 <tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes / encodings, e.g.
1851 1.0, 1.0f, 1.0L and 1e10.
1853 Does not match implicit conversions such as
1854 float a = 10;
1855 </pre></td></tr>
1858 <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>
1859 <tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements.
1861 Example matches 'for (;;) {}'
1862 for (;;) {}
1863 int i[] = {1, 2, 3}; for (auto a : i);
1864 </pre></td></tr>
1867 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1868 <tr><td colspan="4" class="doc" id="genericSelectionExpr0"><pre>Matches C11 _Generic expression.
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('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>
1873 <tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression.
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('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>
1878 <tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements.
1880 Given
1881 goto FOO;
1882 FOO: bar();
1883 gotoStmt()
1884 matches 'goto FOO'
1885 </pre></td></tr>
1888 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1889 <tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements.
1891 Example matches 'if (x) {}'
1892 if (x) {}
1893 </pre></td></tr>
1896 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1897 <tr><td colspan="4" class="doc" id="imaginaryLiteral0"><pre>Matches imaginary literals, which are based on integer and floating
1898 point literals e.g.: 1i, 1.0i
1899 </pre></td></tr>
1902 <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>
1903 <tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST.
1905 This matches many different places, including function call return value
1906 eliding, as well as any type conversions.
1907 </pre></td></tr>
1910 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('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>
1911 <tr><td colspan="4" class="doc" id="implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions.
1913 Given
1914 point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 };
1915 implicitValueInitExpr()
1916 matches "[0].y" (implicitly)
1917 </pre></td></tr>
1920 <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>
1921 <tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions.
1923 Given
1924 int a[] = { 1, 2 };
1925 struct B { int x, y; };
1926 B b = { 5, 6 };
1927 initListExpr()
1928 matches "{ 1, 2 }" and "{ 5, 6 }"
1929 </pre></td></tr>
1932 <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>
1933 <tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes / encodings, e.g.
1934 1, 1L, 0x1 and 1U.
1936 Does not match character-encoded integers such as L'a'.
1937 </pre></td></tr>
1940 <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>
1941 <tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements.
1943 Given
1944 goto FOO;
1945 FOO: bar();
1946 labelStmt()
1947 matches 'FOO:'
1948 </pre></td></tr>
1951 <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>
1952 <tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions.
1954 Example matches [&amp;](){return 5;}
1955 [&amp;](){return 5;}
1956 </pre></td></tr>
1959 <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>
1960 <tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized.
1962 Example: Given
1963 struct T {void func();};
1964 T f();
1965 void g(T);
1966 materializeTemporaryExpr() matches 'f()' in these statements
1967 T u(f());
1968 g(f());
1969 f().func();
1970 but does not match
1971 f();
1972 </pre></td></tr>
1975 <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>
1976 <tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions.
1978 Given
1979 class Y {
1980 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
1981 int a; static int b;
1983 memberExpr()
1984 matches this-&gt;x, x, y.x, a, this-&gt;b
1985 </pre></td></tr>
1988 <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>
1989 <tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements.
1991 foo();;
1992 nullStmt()
1993 matches the second ';'
1994 </pre></td></tr>
1997 <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>
1998 <tr><td colspan="4" class="doc" id="objcCatchStmt0"><pre>Matches Objective-C @catch statements.
2000 Example matches @catch
2001 @try {}
2002 @catch (...) {}
2003 </pre></td></tr>
2006 <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>
2007 <tr><td colspan="4" class="doc" id="objcFinallyStmt0"><pre>Matches Objective-C @finally statements.
2009 Example matches @finally
2010 @try {}
2011 @finally {}
2012 </pre></td></tr>
2015 <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>
2016 <tr><td colspan="4" class="doc" id="objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar.
2018 Example: matches "a" in "init" method:
2019 @implementation A {
2020 NSString *a;
2022 - (void) init {
2023 a = @"hello";
2025 </pre></td></tr>
2028 <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>
2029 <tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions.
2031 The innermost message send invokes the "alloc" class method on the
2032 NSString class, while the outermost message send invokes the
2033 "initWithString" instance method on the object returned from
2034 NSString's "alloc". This matcher should match both message sends.
2035 [[NSString alloc] initWithString:@"Hello"]
2036 </pre></td></tr>
2039 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>&gt;</td><td class="name" onclick="toggle('objcStringLiteral0')"><a name="objcStringLiteral0Anchor">objcStringLiteral</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCStringLiteral.html">ObjCStringLiteral</a>&gt;...</td></tr>
2040 <tr><td colspan="4" class="doc" id="objcStringLiteral0"><pre>Matches ObjectiveC String literal expressions.
2042 Example matches @"abcd"
2043 NSString *s = @"abcd";
2044 </pre></td></tr>
2047 <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>
2048 <tr><td colspan="4" class="doc" id="objcThrowStmt0"><pre>Matches Objective-C statements.
2050 Example matches @throw obj;
2051 </pre></td></tr>
2054 <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>
2055 <tr><td colspan="4" class="doc" id="objcTryStmt0"><pre>Matches Objective-C @try statements.
2057 Example matches @try
2058 @try {}
2059 @catch (...) {}
2060 </pre></td></tr>
2063 <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>
2064 <tr><td colspan="4" class="doc" id="ompExecutableDirective0"><pre>Matches any ``#pragma omp`` executable directive.
2066 Given
2068 #pragma omp parallel
2069 #pragma omp parallel default(none)
2070 #pragma omp taskyield
2072 ``ompExecutableDirective()`` matches ``omp parallel``,
2073 ``omp parallel default(none)`` and ``omp taskyield``.
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('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>
2078 <tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers
2079 to reference another expressions and can be met
2080 in BinaryConditionalOperators, for example.
2082 Example matches 'a'
2083 (a ?: c) + 42;
2084 </pre></td></tr>
2087 <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>
2088 <tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions.
2090 Example matches (foo() + 1)
2091 int foo() { return 1; }
2092 int a = (foo() + 1);
2093 </pre></td></tr>
2096 <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>
2097 <tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions.
2098 ParenListExprs don't have a predefined type and are used for late parsing.
2099 In the final AST, they can be met in template declarations.
2101 Given
2102 template&lt;typename T&gt; class X {
2103 void f() {
2104 X x(*this);
2105 int a = 0, b = 1; int i = (a, b);
2108 parenListExpr() matches "*this" but NOT matches (a, b) because (a, b)
2109 has a predefined type and is a ParenExpr, not a ParenListExpr.
2110 </pre></td></tr>
2113 <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>
2114 <tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2].
2116 Example: Matches __func__
2117 printf("%s", __func__);
2118 </pre></td></tr>
2121 <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>
2122 <tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements.
2124 Given
2125 return 1;
2126 returnStmt()
2127 matches 'return 1'
2128 </pre></td></tr>
2131 <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>
2132 <tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements.
2134 Given
2135 { ++a; }
2136 stmt()
2137 matches both the compound statement '{ ++a; }' and '++a'.
2138 </pre></td></tr>
2141 <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>
2142 <tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension).
2144 Example match: ({ int X = 4; X; })
2145 int C = ({ int X = 4; X; });
2146 </pre></td></tr>
2149 <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>
2150 <tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals).
2152 Example matches "abcd", L"abcd"
2153 char *s = "abcd";
2154 wchar_t *ws = L"abcd";
2155 </pre></td></tr>
2158 <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>
2159 <tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters.
2161 Given
2162 template &lt;int N&gt;
2163 struct A { static const int n = N; };
2164 struct B : public A&lt;42&gt; {};
2165 substNonTypeTemplateParmExpr()
2166 matches "N" in the right-hand side of "static const int n = N;"
2167 </pre></td></tr>
2170 <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>
2171 <tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements.
2173 Given
2174 switch(a) { case 42: break; default: break; }
2175 switchCase()
2176 matches 'case 42:' and 'default:'.
2177 </pre></td></tr>
2180 <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>
2181 <tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements.
2183 Given
2184 switch(a) { case 42: break; default: break; }
2185 switchStmt()
2186 matches 'switch(a)'.
2187 </pre></td></tr>
2190 <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>
2191 <tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL)
2193 Given
2194 Foo x = bar;
2195 int y = sizeof(x) + alignof(x);
2196 unaryExprOrTypeTraitExpr()
2197 matches sizeof(x) and alignof(x)
2198 </pre></td></tr>
2201 <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>
2202 <tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions.
2204 Example matches !a
2205 !a || b
2206 </pre></td></tr>
2209 <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>
2210 <tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing
2211 but could not be resolved to a specific declaration.
2213 Given
2214 template&lt;typename T&gt;
2215 T foo() { T a; return a; }
2216 template&lt;typename T&gt;
2217 void bar() {
2218 foo&lt;T&gt;();
2220 unresolvedLookupExpr()
2221 matches foo&lt;T&gt;() </pre></td></tr>
2224 <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>
2225 <tr><td colspan="4" class="doc" id="unresolvedMemberExpr0"><pre>Matches unresolved member expressions.
2227 Given
2228 struct X {
2229 template &lt;class T&gt; void f();
2230 void g();
2232 template &lt;class T&gt; void h() { X x; x.f&lt;T&gt;(); x.g(); }
2233 unresolvedMemberExpr()
2234 matches x.f&lt;T&gt;
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('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>
2239 <tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call.
2241 Example match: "foo"_suffix
2242 </pre></td></tr>
2245 <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>
2246 <tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements.
2248 Given
2249 while (true) {}
2250 whileStmt()
2251 matches 'while (true) {}'.
2252 </pre></td></tr>
2255 <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>
2256 <tr><td colspan="4" class="doc" id="templateArgumentLoc0"><pre>Matches template arguments (with location info).
2258 Given
2259 template &lt;typename T&gt; struct C {};
2260 C&lt;int&gt; c;
2261 templateArgumentLoc()
2262 matches 'int' in C&lt;int&gt;.
2263 </pre></td></tr>
2266 <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>
2267 <tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments.
2269 Given
2270 template &lt;typename T&gt; struct C {};
2271 C&lt;int&gt; c;
2272 templateArgument()
2273 matches 'int' in C&lt;int&gt;.
2274 </pre></td></tr>
2277 <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>
2278 <tr><td colspan="4" class="doc" id="templateName0"><pre>Matches template name.
2280 Given
2281 template &lt;typename T&gt; class X { };
2282 X&lt;int&gt; xi;
2283 templateName()
2284 matches 'X' in X&lt;int&gt;.
2285 </pre></td></tr>
2288 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('elaboratedTypeLoc0')"><a name="elaboratedTypeLoc0Anchor">elaboratedTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ElaboratedTypeLoc.html">ElaboratedTypeLoc</a>&gt;...</td></tr>
2289 <tr><td colspan="4" class="doc" id="elaboratedTypeLoc0"><pre>Matches C or C++ elaborated `TypeLoc`s.
2291 Given
2292 struct s {};
2293 struct s ss;
2294 elaboratedTypeLoc()
2295 matches the `TypeLoc` of the variable declaration of `ss`.
2296 </pre></td></tr>
2299 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('pointerTypeLoc0')"><a name="pointerTypeLoc0Anchor">pointerTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>&gt;...</td></tr>
2300 <tr><td colspan="4" class="doc" id="pointerTypeLoc0"><pre>Matches pointer `TypeLoc`s.
2302 Given
2303 int* x;
2304 pointerTypeLoc()
2305 matches `int*`.
2306 </pre></td></tr>
2309 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('qualifiedTypeLoc0')"><a name="qualifiedTypeLoc0Anchor">qualifiedTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1QualifiedTypeLoc.html">QualifiedTypeLoc</a>&gt;...</td></tr>
2310 <tr><td colspan="4" class="doc" id="qualifiedTypeLoc0"><pre>Matches `QualifiedTypeLoc`s in the clang AST.
2312 Given
2313 const int x = 0;
2314 qualifiedTypeLoc()
2315 matches `const int`.
2316 </pre></td></tr>
2319 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('referenceTypeLoc0')"><a name="referenceTypeLoc0Anchor">referenceTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>&gt;...</td></tr>
2320 <tr><td colspan="4" class="doc" id="referenceTypeLoc0"><pre>Matches reference `TypeLoc`s.
2322 Given
2323 int x = 3;
2324 int&amp; l = x;
2325 int&amp;&amp; r = 3;
2326 referenceTypeLoc()
2327 matches `int&amp;` and `int&amp;&amp;`.
2328 </pre></td></tr>
2331 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt;</td><td class="name" onclick="toggle('templateSpecializationTypeLoc0')"><a name="templateSpecializationTypeLoc0Anchor">templateSpecializationTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>&gt;...</td></tr>
2332 <tr><td colspan="4" class="doc" id="templateSpecializationTypeLoc0"><pre>Matches template specialization `TypeLoc`s.
2334 Given
2335 template &lt;typename T&gt; class C {};
2336 C&lt;char&gt; var;
2337 varDecl(hasTypeLoc(templateSpecializationTypeLoc(typeLoc())))
2338 matches `C&lt;char&gt; var`.
2339 </pre></td></tr>
2342 <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>
2343 <tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST.
2344 </pre></td></tr>
2347 <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>
2348 <tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays.
2350 Given
2351 int a[] = { 2, 3 };
2352 int b[4];
2353 void f() { int c[a[0]]; }
2354 arrayType()
2355 matches "int a[]", "int b[4]" and "int c[a[0]]";
2356 </pre></td></tr>
2359 <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>
2360 <tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types.
2362 Given
2363 _Atomic(int) i;
2364 atomicType()
2365 matches "_Atomic(int) i"
2366 </pre></td></tr>
2369 <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>
2370 <tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types.
2372 Given:
2373 auto n = 4;
2374 int v[] = { 2, 3 }
2375 for (auto i : v) { }
2376 autoType()
2377 matches "auto n" and "auto i"
2378 </pre></td></tr>
2381 <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>
2382 <tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as
2383 "void (^)(int)".
2385 The pointee is always required to be a FunctionType.
2386 </pre></td></tr>
2389 <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>
2390 <tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types.
2392 Given
2393 struct A {};
2394 A a;
2395 int b;
2396 float c;
2397 bool d;
2398 builtinType()
2399 matches "int b", "float c" and "bool d"
2400 </pre></td></tr>
2403 <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>
2404 <tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types.
2406 Given
2407 _Complex float f;
2408 complexType()
2409 matches "_Complex float f"
2410 </pre></td></tr>
2413 <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>
2414 <tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size.
2416 Given
2417 void() {
2418 int a[2];
2419 int b[] = { 2, 3 };
2420 int c[b[0]];
2422 constantArrayType()
2423 matches "int a[2]"
2424 </pre></td></tr>
2427 <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>
2428 <tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type
2429 Example matches i[] in declaration of f.
2430 (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
2431 Example matches i[1].
2432 (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())))))
2433 void f(int i[]) {
2434 i[1] = 0;
2436 </pre></td></tr>
2439 <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>
2440 <tr><td colspan="4" class="doc" id="decltypeType0"><pre>Matches types nodes representing C++11 decltype(&lt;expr&gt;) types.
2442 Given:
2443 short i = 1;
2444 int j = 42;
2445 decltype(i + j) result = i + j;
2446 decltypeType()
2447 matches "decltype(i + j)"
2448 </pre></td></tr>
2451 <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>
2452 <tr><td colspan="4" class="doc" id="deducedTemplateSpecializationType0"><pre>Matches C++17 deduced template specialization types, e.g. deduced class
2453 template types.
2455 Given
2456 template &lt;typename T&gt;
2457 class C { public: C(T); };
2459 C c(123);
2460 deducedTemplateSpecializationType() matches the type in the declaration
2461 of the variable c.
2462 </pre></td></tr>
2465 <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>
2466 <tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression.
2468 Given
2469 template&lt;typename T, int Size&gt;
2470 class array {
2471 T data[Size];
2473 dependentSizedArrayType
2474 matches "T data[Size]"
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('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>
2479 <tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a
2480 qualified name.
2482 Given
2483 namespace N {
2484 namespace M {
2485 class D {};
2488 class C {};
2490 class C c;
2491 N::M::D d;
2493 elaboratedType() matches the type of the variable declarations of both
2494 c and d.
2495 </pre></td></tr>
2498 <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>
2499 <tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types.
2501 Given
2502 enum C { Green };
2503 enum class S { Red };
2505 C c;
2506 S s;
2508 enumType() matches the type of the variable declarations of both c and
2510 </pre></td></tr>
2513 <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>
2514 <tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes.
2516 Given
2517 int (*f)(int);
2518 void g();
2519 functionProtoType()
2520 matches "int (*f)(int)" and the type of "g" in C++ mode.
2521 In C mode, "g" is not matched because it does not contain a prototype.
2522 </pre></td></tr>
2525 <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>
2526 <tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes.
2528 Given
2529 int (*f)(int);
2530 void g();
2531 functionType()
2532 matches "int (*f)(int)" and the type of "g".
2533 </pre></td></tr>
2536 <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>
2537 <tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size.
2539 Given
2540 int a[] = { 2, 3 };
2541 int b[42];
2542 void f(int c[]) { int d[a[0]]; };
2543 incompleteArrayType()
2544 matches "int a[]" and "int c[]"
2545 </pre></td></tr>
2548 <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>
2549 <tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types.
2551 Example matches S s, but not S&lt;T&gt; s.
2552 (matcher = parmVarDecl(hasType(injectedClassNameType())))
2553 template &lt;typename T&gt; struct S {
2554 void f(S s);
2555 void g(S&lt;T&gt; s);
2557 </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('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>
2561 <tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types.
2563 Given:
2564 int *a;
2565 int &amp;b = *a;
2566 int &amp;&amp;c = 1;
2567 auto &amp;d = b;
2568 auto &amp;&amp;e = c;
2569 auto &amp;&amp;f = 2;
2570 int g = 5;
2572 lValueReferenceType() matches the types of b, d, and e. e is
2573 matched since the type is deduced as int&amp; by reference collapsing rules.
2574 </pre></td></tr>
2577 <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>
2578 <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types.
2579 Given
2580 struct A { int i; }
2581 A::* ptr = A::i;
2582 memberPointerType()
2583 matches "A::* ptr"
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('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>
2588 <tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from
2589 a pointer type, despite being syntactically similar.
2591 Given
2592 int *a;
2594 @interface Foo
2595 @end
2596 Foo *f;
2597 pointerType()
2598 matches "Foo *f", but does not match "int *a".
2599 </pre></td></tr>
2602 <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>
2603 <tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes.
2605 Given
2606 int (*ptr_to_array)[4];
2607 int *array_of_ptrs[4];
2609 varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not
2610 array_of_ptrs.
2611 </pre></td></tr>
2614 <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>
2615 <tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer
2616 types.
2618 Given
2619 int *a;
2620 int &amp;b = *a;
2621 int c = 5;
2623 @interface Foo
2624 @end
2625 Foo *f;
2626 pointerType()
2627 matches "int *a", but does not match "Foo *f".
2628 </pre></td></tr>
2631 <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>
2632 <tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types.
2634 Given:
2635 int *a;
2636 int &amp;b = *a;
2637 int &amp;&amp;c = 1;
2638 auto &amp;d = b;
2639 auto &amp;&amp;e = c;
2640 auto &amp;&amp;f = 2;
2641 int g = 5;
2643 rValueReferenceType() matches the types of c and f. e is not
2644 matched as it is deduced to int&amp; by reference collapsing rules.
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('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>
2649 <tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes).
2651 Given
2652 class C {};
2653 struct S {};
2655 C c;
2656 S s;
2658 recordType() matches the type of the variable declarations of both c
2659 and s.
2660 </pre></td></tr>
2663 <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>
2664 <tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types.
2666 Given
2667 int *a;
2668 int &amp;b = *a;
2669 int &amp;&amp;c = 1;
2670 auto &amp;d = b;
2671 auto &amp;&amp;e = c;
2672 auto &amp;&amp;f = 2;
2673 int g = 5;
2675 referenceType() matches the types of b, c, d, e, and f.
2676 </pre></td></tr>
2679 <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>
2680 <tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a
2681 template type parameter.
2683 Given
2684 template &lt;typename T&gt;
2685 void F(T t) {
2686 int i = 1 + t;
2689 substTemplateTypeParmType() matches the type of 't' but not '1'
2690 </pre></td></tr>
2693 <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>
2694 <tr><td colspan="4" class="doc" id="tagType0"><pre>Matches tag types (record and enum types).
2696 Given
2697 enum E {};
2698 class C {};
2700 E e;
2701 C c;
2703 tagType() matches the type of the variable declarations of both e
2704 and c.
2705 </pre></td></tr>
2708 <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>
2709 <tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types.
2711 Given
2712 template &lt;typename T&gt;
2713 class C { };
2715 template class C&lt;int&gt;; // A
2716 C&lt;char&gt; var; // B
2718 templateSpecializationType() matches the type of the explicit
2719 instantiation in A and the type of the variable declaration in B.
2720 </pre></td></tr>
2723 <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>
2724 <tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types.
2726 Example matches T, but not int.
2727 (matcher = templateTypeParmType())
2728 template &lt;typename T&gt; void f(int i);
2729 </pre></td></tr>
2732 <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>
2733 <tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST.
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('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>
2738 <tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types.
2740 Given
2741 typedef int X;
2742 typedefType()
2743 matches "typedef int X"
2744 </pre></td></tr>
2747 <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>
2748 <tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations.
2750 Given:
2751 typedef __underlying_type(T) type;
2752 unaryTransformType()
2753 matches "__underlying_type(T)"
2754 </pre></td></tr>
2757 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>&gt;</td><td class="name" onclick="toggle('usingType0')"><a name="usingType0Anchor">usingType</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType</a>&gt;...</td></tr>
2758 <tr><td colspan="4" class="doc" id="usingType0"><pre>Matches types specified through a using declaration.
2760 Given
2761 namespace a { struct S {}; }
2762 using a::S;
2763 S s;
2765 usingType() matches the type of the variable declaration of s.
2766 </pre></td></tr>
2769 <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>
2770 <tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an
2771 integer-constant-expression.
2773 Given
2774 void f() {
2775 int a[] = { 2, 3 }
2776 int b[42];
2777 int c[a[0]];
2779 variableArrayType()
2780 matches "int c[a[0]]"
2781 </pre></td></tr>
2783 <!--END_DECL_MATCHERS -->
2784 </table>
2786 <!-- ======================================================================= -->
2787 <h2 id="narrowing-matchers">Narrowing Matchers</h2>
2788 <!-- ======================================================================= -->
2790 <p>Narrowing matchers match certain attributes on the current node, thus
2791 narrowing down the set of nodes of the current type to match on.</p>
2793 <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless)
2794 which allow users to create more powerful match expressions.</p>
2796 <table>
2797 <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
2798 <!-- START_NARROWING_MATCHERS -->
2800 <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>
2801 <tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match.
2803 Usable as: Any Matcher
2804 </pre></td></tr>
2807 <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>
2808 <tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches.
2810 Usable as: Any Matcher
2811 </pre></td></tr>
2814 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr>
2815 <tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node.
2817 Useful when another matcher requires a child matcher, but there's no
2818 additional constraint. This will often be used with an explicit conversion
2819 to an internal::Matcher&lt;&gt; type such as TypeMatcher.
2821 Example: DeclarationMatcher(anything()) matches all declarations, e.g.,
2822 "int* p" and "void f()" in
2823 int* p;
2824 void f();
2826 Usable as: Any Matcher
2827 </pre></td></tr>
2830 <tr><td><em>unspecified</em></td><td class="name" onclick="toggle('mapAnyOf0')"><a name="mapAnyOf0Anchor">mapAnyOf</a></td><td>nodeMatcherFunction...</td></tr>
2831 <tr><td colspan="4" class="doc" id="mapAnyOf0"><pre>Matches any of the NodeMatchers with InnerMatchers nested within
2833 Given
2834 if (true);
2835 for (; true; );
2836 with the matcher
2837 mapAnyOf(ifStmt, forStmt).with(
2838 hasCondition(cxxBoolLiteralExpr(equals(true)))
2839 ).bind("trueCond")
2840 matches the if and the for. It is equivalent to:
2841 auto trueCond = hasCondition(cxxBoolLiteralExpr(equals(true)));
2842 anyOf(
2843 ifStmt(trueCond).bind("trueCond"),
2844 forStmt(trueCond).bind("trueCond")
2847 The with() chain-call accepts zero or more matchers which are combined
2848 as-if with allOf() in each of the node matchers.
2849 Usable as: Any Matcher
2850 </pre></td></tr>
2853 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher&lt;*&gt;</td></tr>
2854 <tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match.
2856 Example matches Y (matcher = cxxRecordDecl(unless(hasName("X"))))
2857 class X {};
2858 class Y {};
2860 Usable as: Any Matcher
2861 </pre></td></tr>
2864 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr</a>&gt;</td><td class="name" onclick="toggle('isImplicit1')"><a name="isImplicit1Anchor">isImplicit</a></td><td></td></tr>
2865 <tr><td colspan="4" class="doc" id="isImplicit1"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
2866 implicit default/copy constructors).
2867 </pre></td></tr>
2870 <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>
2871 <tr><td colspan="4" class="doc" id="hasAnyOperatorName0"><pre>Matches operator expressions (binary or unary) that have any of the
2872 specified names.
2874 hasAnyOperatorName("+", "-")
2875 Is equivalent to
2876 anyOf(hasOperatorName("+"), hasOperatorName("-"))
2877 </pre></td></tr>
2880 <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>
2881 <tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or
2882 unary).
2884 Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
2885 !(a || b)
2886 </pre></td></tr>
2889 <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>
2890 <tr><td colspan="4" class="doc" id="isAssignmentOperator0"><pre>Matches all kinds of assignment operators.
2892 Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
2893 if (a == b)
2894 a += b;
2896 Example 2: matches s1 = s2
2897 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
2898 struct S { S&amp; operator=(const S&amp;); };
2899 void x() { S s1, s2; s1 = s2; }
2900 </pre></td></tr>
2903 <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>
2904 <tr><td colspan="4" class="doc" id="isComparisonOperator0"><pre>Matches comparison operators.
2906 Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
2907 if (a == b)
2908 a += b;
2910 Example 2: matches s1 &lt; s2
2911 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
2912 struct S { bool operator&lt;(const S&amp; other); };
2913 void x(S s1, S s2) { bool b1 = s1 &lt; s2; }
2914 </pre></td></tr>
2917 <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>
2918 <tr><td colspan="4" class="doc" id="isPrivate1"><pre>Matches private C++ declarations and C++ base specifers that specify private
2919 inheritance.
2921 Examples:
2922 class C {
2923 public: int a;
2924 protected: int b;
2925 private: int c; // fieldDecl(isPrivate()) matches 'c'
2928 struct Base {};
2929 struct Derived1 : private Base {}; // matches 'Base'
2930 class Derived2 : Base {}; // matches 'Base'
2931 </pre></td></tr>
2934 <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>
2935 <tr><td colspan="4" class="doc" id="isProtected1"><pre>Matches protected C++ declarations and C++ base specifers that specify
2936 protected inheritance.
2938 Examples:
2939 class C {
2940 public: int a;
2941 protected: int b; // fieldDecl(isProtected()) matches 'b'
2942 private: int c;
2945 class Base {};
2946 class Derived : protected Base {}; // matches 'Base'
2947 </pre></td></tr>
2950 <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>
2951 <tr><td colspan="4" class="doc" id="isPublic1"><pre>Matches public C++ declarations and C++ base specifers that specify public
2952 inheritance.
2954 Examples:
2955 class C {
2956 public: int a; // fieldDecl(isPublic()) matches 'a'
2957 protected: int b;
2958 private: int c;
2961 class Base {};
2962 class Derived1 : public Base {}; // matches 'Base'
2963 struct Derived2 : Base {}; // matches 'Base'
2964 </pre></td></tr>
2967 <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>
2968 <tr><td colspan="4" class="doc" id="isVirtual1"><pre>Matches declarations of virtual methods and C++ base specifers that specify
2969 virtual inheritance.
2971 Example:
2972 class A {
2973 public:
2974 virtual void x(); // matches x
2977 Example:
2978 class Base {};
2979 class DirectlyDerived : virtual Base {}; // matches Base
2980 class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
2982 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;
2983 </pre></td></tr>
2986 <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>
2987 <tr><td colspan="4" class="doc" id="equals5"><pre></pre></td></tr>
2990 <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>
2991 <tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value of type ValueT.
2993 Given
2994 f('false, 3.14, 42);
2995 characterLiteral(equals(0))
2996 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
2997 match false
2998 floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
2999 match 3.14
3000 integerLiteral(equals(42))
3001 matches 42
3003 Note that you cannot directly match a negative numeric literal because the
3004 minus sign is not part of the literal: It is a unary operator whose operand
3005 is the positive numeric literal. Instead, you must use a unaryOperator()
3006 matcher to match the minus sign:
3008 unaryOperator(hasOperatorName("-"),
3009 hasUnaryOperand(integerLiteral(equals(13))))
3011 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;,
3012 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;
3013 </pre></td></tr>
3016 <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>
3017 <tr><td colspan="4" class="doc" id="equals11"><pre></pre></td></tr>
3020 <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>
3021 <tr><td colspan="4" class="doc" id="equals8"><pre></pre></td></tr>
3024 <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>
3025 <tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler.
3027 Given
3028 try {
3029 // ...
3030 } catch (int) {
3031 // ...
3032 } catch (...) {
3033 // ...
3035 cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
3036 </pre></td></tr>
3039 <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>
3040 <tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has
3041 a specific number of arguments (including absent default arguments).
3043 Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
3044 void f(int x, int y);
3045 f(0, 0);
3046 </pre></td></tr>
3049 <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>
3050 <tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization.
3051 </pre></td></tr>
3054 <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>
3055 <tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires
3056 zero initialization.
3058 Given
3059 void foo() {
3060 struct point { double x; double y; };
3061 point pt[2] = { { 1.0, 2.0 } };
3063 initListExpr(has(cxxConstructExpr(requiresZeroInitialization()))
3064 will match the implicit array filler for pt[1].
3065 </pre></td></tr>
3068 <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>
3069 <tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors.
3071 Given
3072 struct S {
3073 S(); // #1
3074 S(const S &amp;); // #2
3075 S(S &amp;&amp;); // #3
3077 cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3.
3078 </pre></td></tr>
3081 <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>
3082 <tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors.
3084 Given
3085 struct S {
3086 S(); // #1
3087 S(const S &amp;); // #2
3088 S(S &amp;&amp;); // #3
3090 cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3.
3091 </pre></td></tr>
3094 <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>
3095 <tr><td colspan="4" class="doc" id="isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor.
3097 Given
3098 struct S {
3099 S(); // #1
3100 S(int) {} // #2
3101 S(S &amp;&amp;) : S() {} // #3
3103 S::S() : S(0) {} // #4
3104 cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not
3105 #1 or #2.
3106 </pre></td></tr>
3109 <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>
3110 <tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor, conversion function, and deduction guide declarations
3111 that have an explicit specifier if this explicit specifier is resolved to
3112 true.
3114 Given
3115 template&lt;bool b&gt;
3116 struct S {
3117 S(int); // #1
3118 explicit S(double); // #2
3119 operator int(); // #3
3120 explicit operator bool(); // #4
3121 explicit(false) S(bool) // # 7
3122 explicit(true) S(char) // # 8
3123 explicit(b) S(S) // # 9
3125 S(int) -&gt; S&lt;true&gt; // #5
3126 explicit S(double) -&gt; S&lt;false&gt; // #6
3127 cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
3128 cxxConversionDecl(isExplicit()) will match #4, but not #3.
3129 cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
3130 </pre></td></tr>
3133 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>&gt;</td><td class="name" onclick="toggle('isInheritingConstructor0')"><a name="isInheritingConstructor0Anchor">isInheritingConstructor</a></td><td></td></tr>
3134 <tr><td colspan="4" class="doc" id="isInheritingConstructor0"><pre></pre></td></tr>
3137 <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>
3138 <tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors.
3140 Given
3141 struct S {
3142 S(); // #1
3143 S(const S &amp;); // #2
3144 S(S &amp;&amp;); // #3
3146 cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2.
3147 </pre></td></tr>
3150 <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>
3151 <tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor, conversion function, and deduction guide declarations
3152 that have an explicit specifier if this explicit specifier is resolved to
3153 true.
3155 Given
3156 template&lt;bool b&gt;
3157 struct S {
3158 S(int); // #1
3159 explicit S(double); // #2
3160 operator int(); // #3
3161 explicit operator bool(); // #4
3162 explicit(false) S(bool) // # 7
3163 explicit(true) S(char) // # 8
3164 explicit(b) S(S) // # 9
3166 S(int) -&gt; S&lt;true&gt; // #5
3167 explicit S(double) -&gt; S&lt;false&gt; // #6
3168 cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
3169 cxxConversionDecl(isExplicit()) will match #4, but not #3.
3170 cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
3171 </pre></td></tr>
3174 <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>
3175 <tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as
3176 opposed to a member.
3178 Given
3179 struct B {};
3180 struct D : B {
3181 int I;
3182 D(int i) : I(i) {}
3184 struct E : B {
3185 E() : B() {}
3187 cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
3188 will match E(), but not match D(int).
3189 </pre></td></tr>
3192 <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>
3193 <tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as
3194 opposed to a base.
3196 Given
3197 struct B {};
3198 struct D : B {
3199 int I;
3200 D(int i) : I(i) {}
3202 struct E : B {
3203 E() : B() {}
3205 cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
3206 will match D(int), but not match E().
3207 </pre></td></tr>
3210 <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>
3211 <tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in
3212 code (as opposed to implicitly added by the compiler).
3214 Given
3215 struct Foo {
3216 Foo() { }
3217 Foo(int) : foo_("A") { }
3218 string foo_;
3220 cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
3221 will match Foo(int), but not Foo()
3222 </pre></td></tr>
3225 <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>
3226 <tr><td colspan="4" class="doc" id="isExplicit2"><pre>Matches constructor, conversion function, and deduction guide declarations
3227 that have an explicit specifier if this explicit specifier is resolved to
3228 true.
3230 Given
3231 template&lt;bool b&gt;
3232 struct S {
3233 S(int); // #1
3234 explicit S(double); // #2
3235 operator int(); // #3
3236 explicit operator bool(); // #4
3237 explicit(false) S(bool) // # 7
3238 explicit(true) S(char) // # 8
3239 explicit(b) S(S) // # 9
3241 S(int) -&gt; S&lt;true&gt; // #5
3242 explicit S(double) -&gt; S&lt;false&gt; // #6
3243 cxxConstructorDecl(isExplicit()) will match #2 and #8, but not #1, #7 or #9.
3244 cxxConversionDecl(isExplicit()) will match #4, but not #3.
3245 cxxDeductionGuideDecl(isExplicit()) will match #6, but not #5.
3246 </pre></td></tr>
3249 <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>
3250 <tr><td colspan="4" class="doc" id="hasMemberName0"><pre>Matches template-dependent, but known, member names.
3252 In template declarations, dependent members are not resolved and so can
3253 not be matched to particular named declarations.
3255 This matcher allows to match on the known name of members.
3257 Given
3258 template &lt;typename T&gt;
3259 struct S {
3260 void mem();
3262 template &lt;typename T&gt;
3263 void x() {
3264 S&lt;T&gt; s;
3265 s.mem();
3267 cxxDependentScopeMemberExpr(hasMemberName("mem")) matches `s.mem()`
3268 </pre></td></tr>
3271 <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>
3272 <tr><td colspan="4" class="doc" id="isArrow2"><pre>Matches member expressions that are called with '-&gt;' as opposed
3273 to '.'.
3275 Member calls on the implicit this pointer match as called with '-&gt;'.
3277 Given
3278 class Y {
3279 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
3280 template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
3281 int a;
3282 static int b;
3284 template &lt;class T&gt;
3285 class Z {
3286 void x() { this-&gt;m; }
3288 memberExpr(isArrow())
3289 matches this-&gt;x, x, y.x, a, this-&gt;b
3290 cxxDependentScopeMemberExpr(isArrow())
3291 matches this-&gt;m
3292 unresolvedMemberExpr(isArrow())
3293 matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
3294 </pre></td></tr>
3297 <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>
3298 <tr><td colspan="4" class="doc" id="memberHasSameNameAsBoundNode0"><pre>Matches template-dependent, but known, member names against an already-bound
3299 node
3301 In template declarations, dependent members are not resolved and so can
3302 not be matched to particular named declarations.
3304 This matcher allows to match on the name of already-bound VarDecl, FieldDecl
3305 and CXXMethodDecl nodes.
3307 Given
3308 template &lt;typename T&gt;
3309 struct S {
3310 void mem();
3312 template &lt;typename T&gt;
3313 void x() {
3314 S&lt;T&gt; s;
3315 s.mem();
3317 The matcher
3318 @code
3319 cxxDependentScopeMemberExpr(
3320 hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
3321 hasDeclaration(classTemplateDecl(has(cxxRecordDecl(has(
3322 cxxMethodDecl(hasName("mem")).bind("templMem")
3323 )))))
3324 )))),
3325 memberHasSameNameAsBoundNode("templMem")
3327 @endcode
3328 first matches and binds the @c mem member of the @c S template, then
3329 compares its name to the usage in @c s.mem() in the @c x function template
3330 </pre></td></tr>
3333 <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>
3334 <tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const.
3336 Given
3337 struct A {
3338 void foo() const;
3339 void bar();
3342 cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
3343 </pre></td></tr>
3346 <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>
3347 <tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment
3348 operator.
3350 Given
3351 struct A {
3352 A &amp;operator=(const A &amp;);
3353 A &amp;operator=(A &amp;&amp;);
3356 cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not
3357 the second one.
3358 </pre></td></tr>
3361 <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>
3362 <tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final.
3364 Given:
3365 class A final {};
3367 struct B {
3368 virtual void f();
3371 struct C : B {
3372 void f() final;
3374 matches A and C::f, but not B, C, or B::f
3375 </pre></td></tr>
3378 <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>
3379 <tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment
3380 operator.
3382 Given
3383 struct A {
3384 A &amp;operator=(const A &amp;);
3385 A &amp;operator=(A &amp;&amp;);
3388 cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not
3389 the first one.
3390 </pre></td></tr>
3393 <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>
3394 <tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method.
3396 Given
3397 class A {
3398 public:
3399 virtual void x();
3401 class B : public A {
3402 public:
3403 virtual void x();
3405 matches B::x
3406 </pre></td></tr>
3409 <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>
3410 <tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure.
3412 Given
3413 class A {
3414 public:
3415 virtual void x() = 0;
3417 matches A::x
3418 </pre></td></tr>
3421 <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>
3422 <tr><td colspan="4" class="doc" id="isUserProvided0"><pre>Matches method declarations that are user-provided.
3424 Given
3425 struct S {
3426 S(); // #1
3427 S(const S &amp;) = default; // #2
3428 S(S &amp;&amp;) = delete; // #3
3430 cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
3431 </pre></td></tr>
3434 <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>
3435 <tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches declarations of virtual methods and C++ base specifers that specify
3436 virtual inheritance.
3438 Example:
3439 class A {
3440 public:
3441 virtual void x(); // matches x
3444 Example:
3445 class Base {};
3446 class DirectlyDerived : virtual Base {}; // matches Base
3447 class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
3449 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;
3450 </pre></td></tr>
3453 <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>
3454 <tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual".
3456 Given
3457 class A {
3458 public:
3459 virtual void x();
3461 class B : public A {
3462 public:
3463 void x();
3465 matches A::x but not B::x
3466 </pre></td></tr>
3469 <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>
3470 <tr><td colspan="4" class="doc" id="isArray0"><pre>Matches array new expressions.
3472 Given:
3473 MyClass *p1 = new MyClass[10];
3474 cxxNewExpr(isArray())
3475 matches the expression 'new MyClass[10]'.
3476 </pre></td></tr>
3479 <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>
3480 <tr><td colspan="4" class="doc" id="hasAnyOperatorName1"><pre>Matches operator expressions (binary or unary) that have any of the
3481 specified names.
3483 hasAnyOperatorName("+", "-")
3484 Is equivalent to
3485 anyOf(hasOperatorName("+"), hasOperatorName("-"))
3486 </pre></td></tr>
3489 <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>
3490 <tr><td colspan="4" class="doc" id="hasAnyOverloadedOperatorName0"><pre>Matches overloaded operator names.
3492 Matches overloaded operator names specified in strings without the
3493 "operator" prefix: e.g. "&lt;&lt;".
3495 hasAnyOverloadedOperatorName("+", "-")
3496 Is equivalent to
3497 anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
3498 </pre></td></tr>
3501 <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>
3502 <tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or
3503 unary).
3505 Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
3506 !(a || b)
3507 </pre></td></tr>
3510 <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>
3511 <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names.
3513 Matches overloaded operator names specified in strings without the
3514 "operator" prefix: e.g. "&lt;&lt;".
3516 Given:
3517 class A { int operator*(); };
3518 const A &amp;operator&lt;&lt;(const A &amp;a, const A &amp;b);
3519 A a;
3520 a &lt;&lt; a; // &lt;-- This matches
3522 cxxOperatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the
3523 specified line and
3524 cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
3525 matches the declaration of A.
3527 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;
3528 </pre></td></tr>
3531 <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>
3532 <tr><td colspan="4" class="doc" id="isAssignmentOperator1"><pre>Matches all kinds of assignment operators.
3534 Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3535 if (a == b)
3536 a += b;
3538 Example 2: matches s1 = s2
3539 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3540 struct S { S&amp; operator=(const S&amp;); };
3541 void x() { S s1, s2; s1 = s2; }
3542 </pre></td></tr>
3545 <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>
3546 <tr><td colspan="4" class="doc" id="isComparisonOperator1"><pre>Matches comparison operators.
3548 Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3549 if (a == b)
3550 a += b;
3552 Example 2: matches s1 &lt; s2
3553 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3554 struct S { bool operator&lt;(const S&amp; other); };
3555 void x(S s1, S s2) { bool b1 = s1 &lt; s2; }
3556 </pre></td></tr>
3559 <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>
3560 <tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined.
3562 Example matches x (matcher = cxxRecordDecl(hasDefinition()))
3563 class x {};
3564 class y;
3565 </pre></td></tr>
3568 <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>
3569 <tr><td colspan="4" class="doc" id="isDerivedFrom2"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
3570 </pre></td></tr>
3573 <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>
3574 <tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom2"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
3575 </pre></td></tr>
3578 <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>
3579 <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or
3580 static member variable template instantiations.
3582 Given
3583 template&lt;typename T&gt; void A(T t) { }
3584 template&lt;&gt; void A(int N) { }
3585 functionDecl(isExplicitTemplateSpecialization())
3586 matches the specialization A&lt;int&gt;().
3588 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;
3589 </pre></td></tr>
3592 <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>
3593 <tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final.
3595 Given:
3596 class A final {};
3598 struct B {
3599 virtual void f();
3602 struct C : B {
3603 void f() final;
3605 matches A and C::f, but not B, C, or B::f
3606 </pre></td></tr>
3609 <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>
3610 <tr><td colspan="4" class="doc" id="isLambda0"><pre>Matches the generated class of lambda expressions.
3612 Given:
3613 auto x = []{};
3615 cxxRecordDecl(isLambda()) matches the implicit class declaration of
3616 decltype(x)
3617 </pre></td></tr>
3620 <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>
3621 <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom2"><pre>Overloaded method as shortcut for
3622 isSameOrDerivedFrom(hasName(...)).
3623 </pre></td></tr>
3626 <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>
3627 <tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static
3628 member variable template instantiations.
3630 Given
3631 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
3633 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
3635 template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
3636 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
3637 matches the template instantiation of X&lt;A&gt;.
3639 But given
3640 template &lt;typename T&gt; class X {}; class A {};
3641 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
3642 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
3643 does not match, as X&lt;A&gt; is an explicit template specialization.
3645 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;
3646 </pre></td></tr>
3649 <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>
3650 <tr><td colspan="4" class="doc" id="hasAnyOperatorName2"><pre>Matches operator expressions (binary or unary) that have any of the
3651 specified names.
3653 hasAnyOperatorName("+", "-")
3654 Is equivalent to
3655 anyOf(hasOperatorName("+"), hasOperatorName("-"))
3656 </pre></td></tr>
3659 <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>
3660 <tr><td colspan="4" class="doc" id="hasOperatorName2"><pre>Matches the operator Name of operator expressions (binary or
3661 unary).
3663 Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
3664 !(a || b)
3665 </pre></td></tr>
3668 <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>
3669 <tr><td colspan="4" class="doc" id="isAssignmentOperator2"><pre>Matches all kinds of assignment operators.
3671 Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3672 if (a == b)
3673 a += b;
3675 Example 2: matches s1 = s2
3676 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3677 struct S { S&amp; operator=(const S&amp;); };
3678 void x() { S s1, s2; s1 = s2; }
3679 </pre></td></tr>
3682 <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>
3683 <tr><td colspan="4" class="doc" id="isComparisonOperator2"><pre>Matches comparison operators.
3685 Example 1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3686 if (a == b)
3687 a += b;
3689 Example 2: matches s1 &lt; s2
3690 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3691 struct S { bool operator&lt;(const S&amp; other); };
3692 void x(S s1, S s2) { bool b1 = s1 &lt; s2; }
3693 </pre></td></tr>
3696 <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>
3697 <tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has
3698 a specific number of arguments (including absent default arguments).
3700 Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
3701 void f(int x, int y);
3702 f(0, 0);
3703 </pre></td></tr>
3706 <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>
3707 <tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has
3708 a specific number of arguments (including absent default arguments).
3710 Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
3711 void f(int x, int y);
3712 f(0, 0);
3713 </pre></td></tr>
3716 <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>
3717 <tr><td colspan="4" class="doc" id="usesADL0"><pre>Matches call expressions which were resolved using ADL.
3719 Example matches y(x) but not y(42) or NS::y(x).
3720 namespace NS {
3721 struct X {};
3722 void y(X);
3725 void y(...);
3727 void test() {
3728 NS::X x;
3729 y(x); // Matches
3730 NS::y(x); // Doesn't match
3731 y(42); // Doesn't match
3732 using NS::y;
3733 y(x); // Found by both unqualified lookup and ADL, doesn't match
3735 </pre></td></tr>
3738 <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>
3739 <tr><td colspan="4" class="doc" id="hasCastKind0"><pre>Matches casts that has a given cast kind.
3741 Example: matches the implicit cast around 0
3742 (matcher = castExpr(hasCastKind(CK_NullToPointer)))
3743 int *p = 0;
3745 If the matcher is use from clang-query, CastKind parameter
3746 should be passed as a quoted string. e.g., hasCastKind("CK_NullToPointer").
3747 </pre></td></tr>
3750 <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>
3751 <tr><td colspan="4" class="doc" id="equals4"><pre></pre></td></tr>
3754 <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>
3755 <tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value of type ValueT.
3757 Given
3758 f('false, 3.14, 42);
3759 characterLiteral(equals(0))
3760 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
3761 match false
3762 floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
3763 match 3.14
3764 integerLiteral(equals(42))
3765 matches 42
3767 Note that you cannot directly match a negative numeric literal because the
3768 minus sign is not part of the literal: It is a unary operator whose operand
3769 is the positive numeric literal. Instead, you must use a unaryOperator()
3770 matcher to match the minus sign:
3772 unaryOperator(hasOperatorName("-"),
3773 hasUnaryOperand(integerLiteral(equals(13))))
3775 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;,
3776 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;
3777 </pre></td></tr>
3780 <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>
3781 <tr><td colspan="4" class="doc" id="equals10"><pre></pre></td></tr>
3784 <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>
3785 <tr><td colspan="4" class="doc" id="equals7"><pre></pre></td></tr>
3788 <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>
3789 <tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N.
3791 Given
3792 template&lt;typename T&gt; struct C {};
3793 C&lt;int&gt; c;
3794 classTemplateSpecializationDecl(templateArgumentCountIs(1))
3795 matches C&lt;int&gt;.
3796 </pre></td></tr>
3799 <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>
3800 <tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of
3801 child statements.
3803 Example: Given
3804 { for (;;) {} }
3805 compoundStmt(statementCountIs(0)))
3806 matches '{}'
3807 but does not match the outer compound statement.
3808 </pre></td></tr>
3811 <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>
3812 <tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches nodes that have the specified size.
3814 Given
3815 int a[42];
3816 int b[2 * 21];
3817 int c[41], d[43];
3818 char *s = "abcd";
3819 wchar_t *ws = L"abcd";
3820 char *w = "a";
3821 constantArrayType(hasSize(42))
3822 matches "int a[42]" and "int b[2 * 21]"
3823 stringLiteral(hasSize(4))
3824 matches "abcd", L"abcd"
3825 </pre></td></tr>
3828 <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>
3829 <tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of
3830 declarations.
3832 Example: Given
3833 int a, b;
3834 int c;
3835 int d = 2, e;
3836 declCountIs(2)
3837 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'.
3838 </pre></td></tr>
3841 <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>
3842 <tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node.
3844 Matches a node if it equals the node previously bound to ID.
3846 Given
3847 class X { int a; int b; };
3848 cxxRecordDecl(
3849 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
3850 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
3851 matches the class X, as a and b have the same type.
3853 Note that when multiple matches are involved via forEach* matchers,
3854 equalsBoundNodes acts as a filter.
3855 For example:
3856 compoundStmt(
3857 forEachDescendant(varDecl().bind("d")),
3858 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
3859 will trigger a match for each combination of variable declaration
3860 and reference to that variable declaration within a compound statement.
3861 </pre></td></tr>
3864 <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>
3865 <tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node.
3867 Decl has pointer identity in the AST.
3868 </pre></td></tr>
3871 <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>
3872 <tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute.
3874 Given
3875 __attribute__((device)) void f() { ... }
3876 decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
3877 f. If the matcher is used from clang-query, attr::Kind parameter should be
3878 passed as a quoted string. e.g., hasAttr("attr::CUDADevice").
3879 </pre></td></tr>
3882 <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>
3883 <tr><td colspan="4" class="doc" id="isExpandedFromMacro0"><pre>Matches statements that are (transitively) expanded from the named macro.
3884 Does not match if only part of the statement is expanded from that macro or
3885 if different parts of the statement are expanded from different
3886 appearances of the macro.
3887 </pre></td></tr>
3890 <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>
3891 <tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is
3892 partially matching a given regex.
3894 Example matches Y but not X
3895 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
3896 #include "ASTMatcher.h"
3897 class X {};
3898 ASTMatcher.h:
3899 class Y {};
3901 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;
3903 If the matcher is used in clang-query, RegexFlags parameter
3904 should be passed as a quoted string. e.g: "NoFlags".
3905 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
3906 </pre></td></tr>
3909 <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>
3910 <tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file.
3912 Example matches X but not Y
3913 (matcher = cxxRecordDecl(isExpansionInMainFile())
3914 #include &lt;Y.h&gt;
3915 class X {};
3916 Y.h:
3917 class Y {};
3919 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;
3920 </pre></td></tr>
3923 <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>
3924 <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files.
3926 Example matches Y but not X
3927 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
3928 #include &lt;SystemHeader.h&gt;
3929 class X {};
3930 SystemHeader.h:
3931 class Y {};
3933 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;
3934 </pre></td></tr>
3937 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;</td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr>
3938 <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
3939 implicit default/copy constructors).
3940 </pre></td></tr>
3943 <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>
3944 <tr><td colspan="4" class="doc" id="isInStdNamespace0"><pre>Matches declarations in the namespace `std`, but not in nested namespaces.
3946 Given
3947 class vector {};
3948 namespace foo {
3949 class vector {};
3950 namespace std {
3951 class vector {};
3954 namespace std {
3955 inline namespace __1 {
3956 class vector {}; // #1
3957 namespace experimental {
3958 class vector {};
3962 cxxRecordDecl(hasName("vector"), isInStdNamespace()) will match only #1.
3963 </pre></td></tr>
3966 <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>
3967 <tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside
3968 template instantiations.
3970 Given
3971 template&lt;typename T&gt; void A(T t) { T i; }
3972 A(0);
3973 A(0U);
3974 functionDecl(isInstantiated())
3975 matches 'A(int) {...};' and 'A(unsigned) {...}'.
3976 </pre></td></tr>
3979 <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>
3980 <tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations and C++ base specifers that specify private
3981 inheritance.
3983 Examples:
3984 class C {
3985 public: int a;
3986 protected: int b;
3987 private: int c; // fieldDecl(isPrivate()) matches 'c'
3990 struct Base {};
3991 struct Derived1 : private Base {}; // matches 'Base'
3992 class Derived2 : Base {}; // matches 'Base'
3993 </pre></td></tr>
3996 <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>
3997 <tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations and C++ base specifers that specify
3998 protected inheritance.
4000 Examples:
4001 class C {
4002 public: int a;
4003 protected: int b; // fieldDecl(isProtected()) matches 'b'
4004 private: int c;
4007 class Base {};
4008 class Derived : protected Base {}; // matches 'Base'
4009 </pre></td></tr>
4012 <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>
4013 <tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations and C++ base specifers that specify public
4014 inheritance.
4016 Examples:
4017 class C {
4018 public: int a; // fieldDecl(isPublic()) matches 'a'
4019 protected: int b;
4020 private: int c;
4023 class Base {};
4024 class Derived1 : public Base {}; // matches 'Base'
4025 struct Derived2 : Base {}; // matches 'Base'
4026 </pre></td></tr>
4029 <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>
4030 <tr><td colspan="4" class="doc" id="designatorCountIs0"><pre>Matches designated initializer expressions that contain
4031 a specific number of designators.
4033 Example: Given
4034 point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 };
4035 point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 };
4036 designatorCountIs(2)
4037 matches '{ [2].y = 1.0, [0].x = 1.0 }',
4038 but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'.
4039 </pre></td></tr>
4042 <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>
4043 <tr><td colspan="4" class="doc" id="isScoped0"><pre>Matches C++11 scoped enum declaration.
4045 Example matches Y (matcher = enumDecl(isScoped()))
4046 enum X {};
4047 enum class Y {};
4048 </pre></td></tr>
4051 <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>
4052 <tr><td colspan="4" class="doc" id="isInstantiationDependent0"><pre>Matches expressions that are instantiation-dependent even if it is
4053 neither type- nor value-dependent.
4055 In the following example, the expression sizeof(sizeof(T() + T()))
4056 is instantiation-dependent (since it involves a template parameter T),
4057 but is neither type- nor value-dependent, since the type of the inner
4058 sizeof is known (std::size_t) and therefore the size of the outer
4059 sizeof is known.
4060 template&lt;typename T&gt;
4061 void f(T x, T y) { sizeof(sizeof(T() + T()); }
4062 expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T())
4063 </pre></td></tr>
4066 <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>
4067 <tr><td colspan="4" class="doc" id="isTypeDependent0"><pre>Matches expressions that are type-dependent because the template type
4068 is not yet instantiated.
4070 For example, the expressions "x" and "x + y" are type-dependent in
4071 the following code, but "y" is not type-dependent:
4072 template&lt;typename T&gt;
4073 void add(T x, int y) {
4074 x + y;
4076 expr(isTypeDependent()) matches x + y
4077 </pre></td></tr>
4080 <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>
4081 <tr><td colspan="4" class="doc" id="isValueDependent0"><pre>Matches expression that are value-dependent because they contain a
4082 non-type template parameter.
4084 For example, the array bound of "Chars" in the following example is
4085 value-dependent.
4086 template&lt;int Size&gt; int f() { return Size; }
4087 expr(isValueDependent()) matches return Size
4088 </pre></td></tr>
4091 <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>
4092 <tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as
4093 GNU's __null, C++11's nullptr, or C's NULL macro.
4095 Given:
4096 void *v1 = NULL;
4097 void *v2 = nullptr;
4098 void *v3 = __null; // GNU extension
4099 char *cp = (char *)0;
4100 int *ip = 0;
4101 int i = 0;
4102 expr(nullPointerConstant())
4103 matches the initializer for v1, v2, v3, cp, and ip. Does not match the
4104 initializer for i.
4105 </pre></td></tr>
4108 <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>
4109 <tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified
4110 bit width.
4112 Given
4113 class C {
4114 int a : 2;
4115 int b : 4;
4116 int c : 2;
4118 fieldDecl(hasBitWidth(2))
4119 matches 'int a;' and 'int c;' but not 'int b;'.
4120 </pre></td></tr>
4123 <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>
4124 <tr><td colspan="4" class="doc" id="isBitField0"><pre>Matches non-static data members that are bit-fields.
4126 Given
4127 class C {
4128 int a : 2;
4129 int b;
4131 fieldDecl(isBitField())
4132 matches 'int a;' but not 'int b;'.
4133 </pre></td></tr>
4136 <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>
4137 <tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value of type ValueT.
4139 Given
4140 f('false, 3.14, 42);
4141 characterLiteral(equals(0))
4142 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
4143 match false
4144 floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
4145 match 3.14
4146 integerLiteral(equals(42))
4147 matches 42
4149 Note that you cannot directly match a negative numeric literal because the
4150 minus sign is not part of the literal: It is a unary operator whose operand
4151 is the positive numeric literal. Instead, you must use a unaryOperator()
4152 matcher to match the minus sign:
4154 unaryOperator(hasOperatorName("-"),
4155 hasUnaryOperand(integerLiteral(equals(13))))
4157 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;,
4158 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;
4159 </pre></td></tr>
4162 <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>
4163 <tr><td colspan="4" class="doc" id="equals12"><pre></pre></td></tr>
4166 <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>
4167 <tr><td colspan="4" class="doc" id="hasAnyOverloadedOperatorName1"><pre>Matches overloaded operator names.
4169 Matches overloaded operator names specified in strings without the
4170 "operator" prefix: e.g. "&lt;&lt;".
4172 hasAnyOverloadedOperatorName("+", "-")
4173 Is equivalent to
4174 anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
4175 </pre></td></tr>
4178 <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>
4179 <tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification.
4181 Given:
4182 void f();
4183 void g() noexcept;
4184 void h() noexcept(true);
4185 void i() noexcept(false);
4186 void j() throw();
4187 void k() throw(int);
4188 void l() throw(...);
4189 functionDecl(hasDynamicExceptionSpec()) and
4190 functionProtoType(hasDynamicExceptionSpec())
4191 match the declarations of j, k, and l, but not f, g, h, or i.
4192 </pre></td></tr>
4195 <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>
4196 <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names.
4198 Matches overloaded operator names specified in strings without the
4199 "operator" prefix: e.g. "&lt;&lt;".
4201 Given:
4202 class A { int operator*(); };
4203 const A &amp;operator&lt;&lt;(const A &amp;a, const A &amp;b);
4204 A a;
4205 a &lt;&lt; a; // &lt;-- This matches
4207 cxxOperatorCallExpr(hasOverloadedOperatorName("&lt;&lt;"))) matches the
4208 specified line and
4209 cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*")))
4210 matches the declaration of A.
4212 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;
4213 </pre></td></tr>
4216 <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>
4217 <tr><td colspan="4" class="doc" id="hasTrailingReturn0"><pre>Matches a function declared with a trailing return type.
4219 Example matches Y (matcher = functionDecl(hasTrailingReturn()))
4220 int X() {}
4221 auto Y() -&gt; int {}
4222 </pre></td></tr>
4225 <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>
4226 <tr><td colspan="4" class="doc" id="isConsteval0"><pre>Matches consteval function declarations and if consteval/if ! consteval
4227 statements.
4229 Given:
4230 consteval int a();
4231 void b() { if consteval {} }
4232 void c() { if ! consteval {} }
4233 void d() { if ! consteval {} else {} }
4234 functionDecl(isConsteval())
4235 matches the declaration of "int a()".
4236 ifStmt(isConsteval())
4237 matches the if statement in "void b()", "void c()", "void d()".
4238 </pre></td></tr>
4241 <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>
4242 <tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations,
4243 and if constexpr.
4245 Given:
4246 constexpr int foo = 42;
4247 constexpr int bar();
4248 void baz() { if constexpr(1 &gt; 0) {} }
4249 varDecl(isConstexpr())
4250 matches the declaration of foo.
4251 functionDecl(isConstexpr())
4252 matches the declaration of bar.
4253 ifStmt(isConstexpr())
4254 matches the if statement in baz.
4255 </pre></td></tr>
4258 <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>
4259 <tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations.
4261 Given:
4262 class A { ~A(); };
4263 class B { ~B() = default; };
4264 functionDecl(isDefaulted())
4265 matches the declaration of ~B, but not ~A.
4266 </pre></td></tr>
4269 <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>
4270 <tr><td colspan="4" class="doc" id="isDefinition3"><pre>Matches if a declaration has a body attached.
4272 Example matches A, va, fa
4273 class A {};
4274 class B; // Doesn't match, as it has no body.
4275 int va;
4276 extern int vb; // Doesn't match, as it doesn't define the variable.
4277 void fa() {}
4278 void fb(); // Doesn't match, as it has no body.
4279 @interface X
4280 - (void)ma; // Doesn't match, interface is declaration.
4281 @end
4282 @implementation X
4283 - (void)ma {}
4284 @end
4286 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;,
4287 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
4288 </pre></td></tr>
4291 <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>
4292 <tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations.
4294 Given:
4295 void Func();
4296 void DeletedFunc() = delete;
4297 functionDecl(isDeleted())
4298 matches the declaration of DeletedFunc, but not Func.
4299 </pre></td></tr>
4302 <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>
4303 <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or
4304 static member variable template instantiations.
4306 Given
4307 template&lt;typename T&gt; void A(T t) { }
4308 template&lt;&gt; void A(int N) { }
4309 functionDecl(isExplicitTemplateSpecialization())
4310 matches the specialization A&lt;int&gt;().
4312 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;
4313 </pre></td></tr>
4316 <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>
4317 <tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function or variable declarations.
4319 Given:
4320 extern "C" void f() {}
4321 extern "C" { void g() {} }
4322 void h() {}
4323 extern "C" int x = 1;
4324 extern "C" int y = 2;
4325 int z = 3;
4326 functionDecl(isExternC())
4327 matches the declaration of f and g, but not the declaration of h.
4328 varDecl(isExternC())
4329 matches the declaration of x and y, but not the declaration of z.
4330 </pre></td></tr>
4333 <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>
4334 <tr><td colspan="4" class="doc" id="isInline1"><pre>Matches functions, variables and namespace declarations that are marked with
4335 the inline keyword.
4337 Given
4338 inline void f();
4339 void g();
4340 namespace n {
4341 inline namespace m {}
4343 inline int Foo = 5;
4344 functionDecl(isInline()) will match ::f().
4345 namespaceDecl(isInline()) will match n::m.
4346 varDecl(isInline()) will match Foo;
4347 </pre></td></tr>
4350 <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>
4351 <tr><td colspan="4" class="doc" id="isMain0"><pre>Determines whether the function is "main", which is the entry point
4352 into an executable program.
4353 </pre></td></tr>
4356 <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>
4357 <tr><td colspan="4" class="doc" id="isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute.
4359 Given
4360 void nope();
4361 [[noreturn]] void a();
4362 __attribute__((noreturn)) void b();
4363 struct c { [[noreturn]] c(); };
4364 functionDecl(isNoReturn())
4365 matches all of those except
4366 void nope();
4367 </pre></td></tr>
4370 <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>
4371 <tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification.
4373 Given:
4374 void f();
4375 void g() noexcept;
4376 void h() throw();
4377 void i() throw(int);
4378 void j() noexcept(false);
4379 functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
4380 match the declarations of g, and h, but not f, i or j.
4381 </pre></td></tr>
4384 <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>
4385 <tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variable/function declarations that have "static" storage
4386 class specifier ("static" keyword) written in the source.
4388 Given:
4389 static void f() {}
4390 static int i = 0;
4391 extern int j;
4392 int k;
4393 functionDecl(isStaticStorageClass())
4394 matches the function declaration f.
4395 varDecl(isStaticStorageClass())
4396 matches the variable declaration i.
4397 </pre></td></tr>
4400 <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>
4401 <tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static
4402 member variable template instantiations.
4404 Given
4405 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
4407 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
4409 template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
4410 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
4411 matches the template instantiation of X&lt;A&gt;.
4413 But given
4414 template &lt;typename T&gt; class X {}; class A {};
4415 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
4416 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
4417 does not match, as X&lt;A&gt; is an explicit template specialization.
4419 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;
4420 </pre></td></tr>
4423 <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>
4424 <tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic.
4426 Example matches f, but not g or h. The function i will not match, even when
4427 compiled in C mode.
4428 void f(...);
4429 void g(int);
4430 template &lt;typename... Ts&gt; void h(Ts...);
4431 void i();
4432 </pre></td></tr>
4435 <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>
4436 <tr><td colspan="4" class="doc" id="isWeak0"><pre>Matches weak function declarations.
4438 Given:
4439 void foo() __attribute__((__weakref__("__foo")));
4440 void bar();
4441 functionDecl(isWeak())
4442 matches the weak declaration "foo", but not "bar".
4443 </pre></td></tr>
4446 <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>
4447 <tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
4448 specific parameter count.
4450 Given
4451 void f(int i) {}
4452 void g(int i, int j) {}
4453 void h(int i, int j);
4454 void j(int i);
4455 void k(int x, int y, int z, ...);
4456 functionDecl(parameterCountIs(2))
4457 matches g and h
4458 functionProtoType(parameterCountIs(2))
4459 matches g and h
4460 functionProtoType(parameterCountIs(3))
4461 matches k
4462 </pre></td></tr>
4465 <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>
4466 <tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification.
4468 Given:
4469 void f();
4470 void g() noexcept;
4471 void h() noexcept(true);
4472 void i() noexcept(false);
4473 void j() throw();
4474 void k() throw(int);
4475 void l() throw(...);
4476 functionDecl(hasDynamicExceptionSpec()) and
4477 functionProtoType(hasDynamicExceptionSpec())
4478 match the declarations of j, k, and l, but not f, g, h, or i.
4479 </pre></td></tr>
4482 <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>
4483 <tr><td colspan="4" class="doc" id="isNoThrow1"><pre>Matches functions that have a non-throwing exception specification.
4485 Given:
4486 void f();
4487 void g() noexcept;
4488 void h() throw();
4489 void i() throw(int);
4490 void j() noexcept(false);
4491 functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
4492 match the declarations of g, and h, but not f, i or j.
4493 </pre></td></tr>
4496 <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>
4497 <tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
4498 specific parameter count.
4500 Given
4501 void f(int i) {}
4502 void g(int i, int j) {}
4503 void h(int i, int j);
4504 void j(int i);
4505 void k(int x, int y, int z, ...);
4506 functionDecl(parameterCountIs(2))
4507 matches g and h
4508 functionProtoType(parameterCountIs(2))
4509 matches g and h
4510 functionProtoType(parameterCountIs(3))
4511 matches k
4512 </pre></td></tr>
4515 <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>
4516 <tr><td colspan="4" class="doc" id="isConsteval1"><pre>Matches consteval function declarations and if consteval/if ! consteval
4517 statements.
4519 Given:
4520 consteval int a();
4521 void b() { if consteval {} }
4522 void c() { if ! consteval {} }
4523 void d() { if ! consteval {} else {} }
4524 functionDecl(isConsteval())
4525 matches the declaration of "int a()".
4526 ifStmt(isConsteval())
4527 matches the if statement in "void b()", "void c()", "void d()".
4528 </pre></td></tr>
4531 <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>
4532 <tr><td colspan="4" class="doc" id="isConstexpr2"><pre>Matches constexpr variable and function declarations,
4533 and if constexpr.
4535 Given:
4536 constexpr int foo = 42;
4537 constexpr int bar();
4538 void baz() { if constexpr(1 &gt; 0) {} }
4539 varDecl(isConstexpr())
4540 matches the declaration of foo.
4541 functionDecl(isConstexpr())
4542 matches the declaration of bar.
4543 ifStmt(isConstexpr())
4544 matches the if statement in baz.
4545 </pre></td></tr>
4548 <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>
4549 <tr><td colspan="4" class="doc" id="equals6"><pre></pre></td></tr>
4552 <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>
4553 <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value of type ValueT.
4555 Given
4556 f('false, 3.14, 42);
4557 characterLiteral(equals(0))
4558 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0))
4559 match false
4560 floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2))
4561 match 3.14
4562 integerLiteral(equals(42))
4563 matches 42
4565 Note that you cannot directly match a negative numeric literal because the
4566 minus sign is not part of the literal: It is a unary operator whose operand
4567 is the positive numeric literal. Instead, you must use a unaryOperator()
4568 matcher to match the minus sign:
4570 unaryOperator(hasOperatorName("-"),
4571 hasUnaryOperand(integerLiteral(equals(13))))
4573 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;,
4574 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;
4575 </pre></td></tr>
4578 <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>
4579 <tr><td colspan="4" class="doc" id="equals13"><pre></pre></td></tr>
4582 <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>
4583 <tr><td colspan="4" class="doc" id="equals9"><pre></pre></td></tr>
4586 <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>
4587 <tr><td colspan="4" class="doc" id="capturesThis0"><pre>Matches a `LambdaCapture` that refers to 'this'.
4589 Given
4590 class C {
4591 int cc;
4592 int f() {
4593 auto l = [this]() { return cc; };
4594 return l();
4597 lambdaExpr(hasAnyCapture(lambdaCapture(capturesThis())))
4598 matches `[this]() { return cc; }`.
4599 </pre></td></tr>
4602 <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>
4603 <tr><td colspan="4" class="doc" id="isImplicit2"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
4604 implicit default/copy constructors).
4605 </pre></td></tr>
4608 <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>
4609 <tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '-&gt;' as opposed
4610 to '.'.
4612 Member calls on the implicit this pointer match as called with '-&gt;'.
4614 Given
4615 class Y {
4616 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
4617 template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
4618 int a;
4619 static int b;
4621 template &lt;class T&gt;
4622 class Z {
4623 void x() { this-&gt;m; }
4625 memberExpr(isArrow())
4626 matches this-&gt;x, x, y.x, a, this-&gt;b
4627 cxxDependentScopeMemberExpr(isArrow())
4628 matches this-&gt;m
4629 unresolvedMemberExpr(isArrow())
4630 matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
4631 </pre></td></tr>
4634 <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>
4635 <tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names.
4637 This matcher is only provided as a performance optimization of hasName.
4638 hasAnyName(a, b, c)
4639 is equivalent to, but faster than
4640 anyOf(hasName(a), hasName(b), hasName(c))
4641 </pre></td></tr>
4644 <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>
4645 <tr><td colspan="4" class="doc" id="hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage.
4647 Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))
4648 void f() {
4649 int x;
4650 static int y;
4652 int z;
4654 Example matches f() because it has external formal linkage despite being
4655 unique to the translation unit as though it has internal likage
4656 (matcher = functionDecl(hasExternalFormalLinkage()))
4658 namespace {
4659 void f() {}
4661 </pre></td></tr>
4664 <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>
4665 <tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name.
4667 Supports specifying enclosing namespaces or classes by prefixing the name
4668 with '&lt;enclosing&gt;::'.
4669 Does not match typedefs of an underlying type with the given name.
4671 Example matches X (Name == "X")
4672 class X;
4674 Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X")
4675 namespace a { namespace b { class X; } }
4676 </pre></td></tr>
4679 <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>
4680 <tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain
4681 a substring matched by the given RegExp.
4683 Supports specifying enclosing namespaces or classes by
4684 prefixing the name with '&lt;enclosing&gt;::'. Does not match typedefs
4685 of an underlying type with the given name.
4687 Example matches X (regexp == "::X")
4688 class X;
4690 Example matches X (regexp is one of "::X", "^foo::.*X", among others)
4691 namespace foo { namespace bar { class X; } }
4693 If the matcher is used in clang-query, RegexFlags parameter
4694 should be passed as a quoted string. e.g: "NoFlags".
4695 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
4696 </pre></td></tr>
4699 <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>
4700 <tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations.
4702 Given
4703 namespace n {
4704 namespace {} // #1
4706 namespaceDecl(isAnonymous()) will match #1 but not ::n.
4707 </pre></td></tr>
4710 <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>
4711 <tr><td colspan="4" class="doc" id="isInline0"><pre>Matches functions, variables and namespace declarations that are marked with
4712 the inline keyword.
4714 Given
4715 inline void f();
4716 void g();
4717 namespace n {
4718 inline namespace m {}
4720 inline int Foo = 5;
4721 functionDecl(isInline()) will match ::f().
4722 namespaceDecl(isInline()) will match n::m.
4723 varDecl(isInline()) will match Foo;
4724 </pre></td></tr>
4727 <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>
4728 <tr><td colspan="4" class="doc" id="isFirstPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``firstprivate`` kind
4729 specified.
4731 Given
4733 #pragma omp parallel
4734 #pragma omp parallel default(none)
4735 #pragma omp parallel default(shared)
4736 #pragma omp parallel default(private)
4737 #pragma omp parallel default(firstprivate)
4739 ``ompDefaultClause(isFirstPrivateKind())`` matches only
4740 ``default(firstprivate)``.
4741 </pre></td></tr>
4744 <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>
4745 <tr><td colspan="4" class="doc" id="isNoneKind0"><pre>Matches if the OpenMP ``default`` clause has ``none`` kind specified.
4747 Given
4749 #pragma omp parallel
4750 #pragma omp parallel default(none)
4751 #pragma omp parallel default(shared)
4752 #pragma omp parallel default(private)
4753 #pragma omp parallel default(firstprivate)
4755 ``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
4756 </pre></td></tr>
4759 <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>
4760 <tr><td colspan="4" class="doc" id="isPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``private`` kind
4761 specified.
4763 Given
4765 #pragma omp parallel
4766 #pragma omp parallel default(none)
4767 #pragma omp parallel default(shared)
4768 #pragma omp parallel default(private)
4769 #pragma omp parallel default(firstprivate)
4771 ``ompDefaultClause(isPrivateKind())`` matches only
4772 ``default(private)``.
4773 </pre></td></tr>
4776 <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>
4777 <tr><td colspan="4" class="doc" id="isSharedKind0"><pre>Matches if the OpenMP ``default`` clause has ``shared`` kind specified.
4779 Given
4781 #pragma omp parallel
4782 #pragma omp parallel default(none)
4783 #pragma omp parallel default(shared)
4784 #pragma omp parallel default(private)
4785 #pragma omp parallel default(firstprivate)
4787 ``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``.
4788 </pre></td></tr>
4791 <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>
4792 <tr><td colspan="4" class="doc" id="isAllowedToContainClauseKind0"><pre>Matches if the OpenMP directive is allowed to contain the specified OpenMP
4793 clause kind.
4795 Given
4797 #pragma omp parallel
4798 #pragma omp parallel for
4799 #pragma omp for
4801 `ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches
4802 ``omp parallel`` and ``omp parallel for``.
4804 If the matcher is use from clang-query, ``OpenMPClauseKind`` parameter
4805 should be passed as a quoted string. e.g.,
4806 ``isAllowedToContainClauseKind("OMPC_default").``
4807 </pre></td></tr>
4810 <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>
4811 <tr><td colspan="4" class="doc" id="isStandaloneDirective0"><pre>Matches standalone OpenMP directives,
4812 i.e., directives that can't have a structured block.
4814 Given
4816 #pragma omp parallel
4818 #pragma omp taskyield
4820 ``ompExecutableDirective(isStandaloneDirective()))`` matches
4821 ``omp taskyield``.
4822 </pre></td></tr>
4825 <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>
4826 <tr><td colspan="4" class="doc" id="isDerivedFrom3"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
4827 </pre></td></tr>
4830 <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>
4831 <tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom3"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
4832 </pre></td></tr>
4835 <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>
4836 <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom3"><pre>Overloaded method as shortcut for
4837 isSameOrDerivedFrom(hasName(...)).
4838 </pre></td></tr>
4841 <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>
4842 <tr><td colspan="4" class="doc" id="argumentCountIs3"><pre>Checks that a call expression or a constructor call expression has
4843 a specific number of arguments (including absent default arguments).
4845 Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2)))
4846 void f(int x, int y);
4847 f(0, 0);
4848 </pre></td></tr>
4851 <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>
4852 <tr><td colspan="4" class="doc" id="hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the
4853 Selector.getAsString()
4855 matcher = objCMessageExpr(hasSelector("methodA:", "methodB:"));
4856 matches both of the expressions below:
4857 [myObj methodA:argA];
4858 [myObj methodB:argB];
4859 </pre></td></tr>
4862 <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>
4863 <tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector
4865 objCMessageExpr(hasKeywordSelector()) matches the generated setFrame
4866 message expression in
4868 UIWebView *webView = ...;
4869 CGRect bodyFrame = webView.frame;
4870 bodyFrame.size.height = self.bodyContentHeight;
4871 webView.frame = bodyFrame;
4872 // ^---- matches here
4873 </pre></td></tr>
4876 <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>
4877 <tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector
4879 Matches only when the selector of the objCMessageExpr is NULL. This may
4880 represent an error condition in the tree!
4881 </pre></td></tr>
4884 <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>
4885 <tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString()
4887 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:"));
4888 matches the outer message expr in the code below, but NOT the message
4889 invocation for self.bodyView.
4890 [self.bodyView loadHTMLString:html baseURL:NULL];
4891 </pre></td></tr>
4894 <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>
4895 <tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector
4897 matcher = objCMessageExpr(matchesSelector(hasUnarySelector());
4898 matches self.bodyView in the code below, but NOT the outer message
4899 invocation of "loadHTMLString:baseURL:".
4900 [self.bodyView loadHTMLString:html baseURL:NULL];
4901 </pre></td></tr>
4904 <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>
4905 <tr><td colspan="4" class="doc" id="isClassMessage0"><pre>Returns true when the Objective-C message is sent to a class.
4907 Example
4908 matcher = objcMessageExpr(isClassMessage())
4909 matches
4910 [NSString stringWithFormat:@"format"];
4911 but not
4912 NSString *x = @"hello";
4913 [x containsString:@"h"];
4914 </pre></td></tr>
4917 <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>
4918 <tr><td colspan="4" class="doc" id="isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance.
4920 Example
4921 matcher = objcMessageExpr(isInstanceMessage())
4922 matches
4923 NSString *x = @"hello";
4924 [x containsString:@"h"];
4925 but not
4926 [NSString stringWithFormat:@"format"];
4927 </pre></td></tr>
4930 <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>
4931 <tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains
4932 a substring matched by the given RegExp.
4933 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message
4934 invocation for self.bodyView.
4935 [self.bodyView loadHTMLString:html baseURL:NULL];
4937 If the matcher is used in clang-query, RegexFlags parameter
4938 should be passed as a quoted string. e.g: "NoFlags".
4939 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
4940 </pre></td></tr>
4943 <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>
4944 <tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments
4946 matcher = objCMessageExpr(numSelectorArgs(0));
4947 matches self.bodyView in the code below
4949 matcher = objCMessageExpr(numSelectorArgs(2));
4950 matches the invocation of "loadHTMLString:baseURL:" but not that
4951 of self.bodyView
4952 [self.bodyView loadHTMLString:html baseURL:NULL];
4953 </pre></td></tr>
4956 <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>
4957 <tr><td colspan="4" class="doc" id="isClassMethod0"><pre>Returns true when the Objective-C method declaration is a class method.
4959 Example
4960 matcher = objcMethodDecl(isClassMethod())
4961 matches
4962 @interface I + (void)foo; @end
4963 but not
4964 @interface I - (void)bar; @end
4965 </pre></td></tr>
4968 <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>
4969 <tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached.
4971 Example matches A, va, fa
4972 class A {};
4973 class B; // Doesn't match, as it has no body.
4974 int va;
4975 extern int vb; // Doesn't match, as it doesn't define the variable.
4976 void fa() {}
4977 void fb(); // Doesn't match, as it has no body.
4978 @interface X
4979 - (void)ma; // Doesn't match, interface is declaration.
4980 @end
4981 @implementation X
4982 - (void)ma {}
4983 @end
4985 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;,
4986 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
4987 </pre></td></tr>
4990 <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>
4991 <tr><td colspan="4" class="doc" id="isInstanceMethod0"><pre>Returns true when the Objective-C method declaration is an instance method.
4993 Example
4994 matcher = objcMethodDecl(isInstanceMethod())
4995 matches
4996 @interface I - (void)bar; @end
4997 but not
4998 @interface I + (void)foo; @end
4999 </pre></td></tr>
5002 <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>
5003 <tr><td colspan="4" class="doc" id="hasDefaultArgument0"><pre>Matches a declaration that has default arguments.
5005 Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
5006 void x(int val) {}
5007 void y(int val = 0) {}
5009 Deprecated. Use hasInitializer() instead to be able to
5010 match on the contents of the default argument. For example:
5012 void x(int val = 7) {}
5013 void y(int val = 42) {}
5014 parmVarDecl(hasInitializer(integerLiteral(equals(42))))
5015 matches the parameter of y
5017 A matcher such as
5018 parmVarDecl(hasInitializer(anything()))
5019 is equivalent to parmVarDecl(hasDefaultArgument()).
5020 </pre></td></tr>
5023 <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>
5024 <tr><td colspan="4" class="doc" id="isAtPosition0"><pre>Matches the ParmVarDecl nodes that are at the N'th position in the parameter
5025 list. The parameter list could be that of either a block, function, or
5026 objc-method.
5029 Given
5031 void f(int a, int b, int c) {
5034 ``parmVarDecl(isAtPosition(0))`` matches ``int a``.
5036 ``parmVarDecl(isAtPosition(1))`` matches ``int b``.
5037 </pre></td></tr>
5040 <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>
5041 <tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string.
5043 Given
5044 class Y { public: void x(); };
5045 void z() { Y* y; y-&gt;x(); }
5046 cxxMemberCallExpr(on(hasType(asString("class Y *"))))
5047 matches y-&gt;x()
5048 </pre></td></tr>
5051 <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>
5052 <tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node.
5054 Matches a node if it equals the node previously bound to ID.
5056 Given
5057 class X { int a; int b; };
5058 cxxRecordDecl(
5059 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
5060 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
5061 matches the class X, as a and b have the same type.
5063 Note that when multiple matches are involved via forEach* matchers,
5064 equalsBoundNodes acts as a filter.
5065 For example:
5066 compoundStmt(
5067 forEachDescendant(varDecl().bind("d")),
5068 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
5069 will trigger a match for each combination of variable declaration
5070 and reference to that variable declaration within a compound statement.
5071 </pre></td></tr>
5074 <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>
5075 <tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to
5076 the node, not hidden within a typedef.
5078 Given
5079 typedef const int const_int;
5080 const_int i;
5081 int *const j;
5082 int *volatile k;
5083 int m;
5084 varDecl(hasType(hasLocalQualifiers())) matches only j and k.
5085 i is const-qualified but the qualifier is not local.
5086 </pre></td></tr>
5089 <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>
5090 <tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type.
5092 Given
5093 void a(char);
5094 void b(wchar_t);
5095 void c(double);
5096 functionDecl(hasAnyParameter(hasType(isAnyCharacter())))
5097 matches "a(char)", "b(wchar_t)", but not "c(double)".
5098 </pre></td></tr>
5101 <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>
5102 <tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type; this includes
5103 the Objective-C object pointer type, which is different despite being
5104 syntactically similar.
5106 Given
5107 int *i = nullptr;
5109 @interface Foo
5110 @end
5111 Foo *f;
5113 int j;
5114 varDecl(hasType(isAnyPointer()))
5115 matches "int *i" and "Foo *f", but not "int j".
5116 </pre></td></tr>
5119 <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>
5120 <tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that
5121 include "top-level" const.
5123 Given
5124 void a(int);
5125 void b(int const);
5126 void c(const int);
5127 void d(const int*);
5128 void e(int const) {};
5129 functionDecl(hasAnyParameter(hasType(isConstQualified())))
5130 matches "void b(int const)", "void c(const int)" and
5131 "void e(int const) {}". It does not match d as there
5132 is no top-level const on the parameter type "const int *".
5133 </pre></td></tr>
5136 <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>
5137 <tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type.
5139 Given
5140 void a(int);
5141 void b(long);
5142 void c(double);
5143 functionDecl(hasAnyParameter(hasType(isInteger())))
5144 matches "a(int)", "b(long)", but not "c(double)".
5145 </pre></td></tr>
5148 <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>
5149 <tr><td colspan="4" class="doc" id="isSignedInteger0"><pre>Matches QualType nodes that are of signed integer type.
5151 Given
5152 void a(int);
5153 void b(unsigned long);
5154 void c(double);
5155 functionDecl(hasAnyParameter(hasType(isSignedInteger())))
5156 matches "a(int)", but not "b(unsigned long)" and "c(double)".
5157 </pre></td></tr>
5160 <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>
5161 <tr><td colspan="4" class="doc" id="isUnsignedInteger0"><pre>Matches QualType nodes that are of unsigned integer type.
5163 Given
5164 void a(int);
5165 void b(unsigned long);
5166 void c(double);
5167 functionDecl(hasAnyParameter(hasType(isUnsignedInteger())))
5168 matches "b(unsigned long)", but not "a(int)" and "c(double)".
5169 </pre></td></tr>
5172 <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>
5173 <tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that
5174 include "top-level" volatile.
5176 Given
5177 void a(int);
5178 void b(int volatile);
5179 void c(volatile int);
5180 void d(volatile int*);
5181 void e(int volatile) {};
5182 functionDecl(hasAnyParameter(hasType(isVolatileQualified())))
5183 matches "void b(int volatile)", "void c(volatile int)" and
5184 "void e(int volatile) {}". It does not match d as there
5185 is no top-level volatile on the parameter type "volatile int *".
5186 </pre></td></tr>
5189 <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>
5190 <tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node.
5192 Matches a node if it equals the node previously bound to ID.
5194 Given
5195 class X { int a; int b; };
5196 cxxRecordDecl(
5197 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
5198 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
5199 matches the class X, as a and b have the same type.
5201 Note that when multiple matches are involved via forEach* matchers,
5202 equalsBoundNodes acts as a filter.
5203 For example:
5204 compoundStmt(
5205 forEachDescendant(varDecl().bind("d")),
5206 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
5207 will trigger a match for each combination of variable declaration
5208 and reference to that variable declaration within a compound statement.
5209 </pre></td></tr>
5212 <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>
5213 <tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node.
5215 Stmt has pointer identity in the AST.
5216 </pre></td></tr>
5219 <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>
5220 <tr><td colspan="4" class="doc" id="isExpandedFromMacro1"><pre>Matches statements that are (transitively) expanded from the named macro.
5221 Does not match if only part of the statement is expanded from that macro or
5222 if different parts of the statement are expanded from different
5223 appearances of the macro.
5224 </pre></td></tr>
5227 <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>
5228 <tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is
5229 partially matching a given regex.
5231 Example matches Y but not X
5232 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
5233 #include "ASTMatcher.h"
5234 class X {};
5235 ASTMatcher.h:
5236 class Y {};
5238 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;
5240 If the matcher is used in clang-query, RegexFlags parameter
5241 should be passed as a quoted string. e.g: "NoFlags".
5242 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
5243 </pre></td></tr>
5246 <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>
5247 <tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file.
5249 Example matches X but not Y
5250 (matcher = cxxRecordDecl(isExpansionInMainFile())
5251 #include &lt;Y.h&gt;
5252 class X {};
5253 Y.h:
5254 class Y {};
5256 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;
5257 </pre></td></tr>
5260 <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>
5261 <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files.
5263 Example matches Y but not X
5264 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
5265 #include &lt;SystemHeader.h&gt;
5266 class X {};
5267 SystemHeader.h:
5268 class Y {};
5270 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;
5271 </pre></td></tr>
5274 <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>
5275 <tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation.
5277 Given
5278 int j;
5279 template&lt;typename T&gt; void A(T t) { T i; j += 42;}
5280 A(0);
5281 A(0U);
5282 declStmt(isInTemplateInstantiation())
5283 matches 'int i;' and 'unsigned i'.
5284 unless(stmt(isInTemplateInstantiation()))
5285 will NOT match j += 42; as it's shared between the template definition and
5286 instantiation.
5287 </pre></td></tr>
5290 <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>
5291 <tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size.
5293 Given
5294 int a[42];
5295 int b[2 * 21];
5296 int c[41], d[43];
5297 char *s = "abcd";
5298 wchar_t *ws = L"abcd";
5299 char *w = "a";
5300 constantArrayType(hasSize(42))
5301 matches "int a[42]" and "int b[2 * 21]"
5302 stringLiteral(hasSize(4))
5303 matches "abcd", L"abcd"
5304 </pre></td></tr>
5307 <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>
5308 <tr><td colspan="4" class="doc" id="isClass0"><pre>Matches TagDecl object that are spelled with "class."
5310 Example matches C, but not S, U or E.
5311 struct S {};
5312 class C {};
5313 union U {};
5314 enum E {};
5315 </pre></td></tr>
5318 <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>
5319 <tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached.
5321 Example matches A, va, fa
5322 class A {};
5323 class B; // Doesn't match, as it has no body.
5324 int va;
5325 extern int vb; // Doesn't match, as it doesn't define the variable.
5326 void fa() {}
5327 void fb(); // Doesn't match, as it has no body.
5328 @interface X
5329 - (void)ma; // Doesn't match, interface is declaration.
5330 @end
5331 @implementation X
5332 - (void)ma {}
5333 @end
5335 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;,
5336 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
5337 </pre></td></tr>
5340 <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>
5341 <tr><td colspan="4" class="doc" id="isEnum0"><pre>Matches TagDecl object that are spelled with "enum."
5343 Example matches E, but not C, S or U.
5344 struct S {};
5345 class C {};
5346 union U {};
5347 enum E {};
5348 </pre></td></tr>
5351 <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>
5352 <tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches TagDecl object that are spelled with "struct."
5354 Example matches S, but not C, U or E.
5355 struct S {};
5356 class C {};
5357 union U {};
5358 enum E {};
5359 </pre></td></tr>
5362 <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>
5363 <tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches TagDecl object that are spelled with "union."
5365 Example matches U, but not C, S or E.
5366 struct S {};
5367 class C {};
5368 union U {};
5369 enum E {};
5370 </pre></td></tr>
5373 <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>
5374 <tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value.
5376 Note that 'Value' is a string as the template argument's value is
5377 an arbitrary precision integer. 'Value' must be euqal to the canonical
5378 representation of that integral value in base 10.
5380 Given
5381 template&lt;int T&gt; struct C {};
5382 C&lt;42&gt; c;
5383 classTemplateSpecializationDecl(
5384 hasAnyTemplateArgument(equalsIntegralValue("42")))
5385 matches the implicit instantiation of C in C&lt;42&gt;.
5386 </pre></td></tr>
5389 <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>
5390 <tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value.
5392 Given
5393 template&lt;int T&gt; struct C {};
5394 C&lt;42&gt; c;
5395 classTemplateSpecializationDecl(
5396 hasAnyTemplateArgument(isIntegral()))
5397 matches the implicit instantiation of C in C&lt;42&gt;
5398 with isIntegral() matching 42.
5399 </pre></td></tr>
5402 <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>
5403 <tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N.
5405 Given
5406 template&lt;typename T&gt; struct C {};
5407 C&lt;int&gt; c;
5408 classTemplateSpecializationDecl(templateArgumentCountIs(1))
5409 matches C&lt;int&gt;.
5410 </pre></td></tr>
5413 <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>
5414 <tr><td colspan="4" class="doc" id="isExpandedFromMacro2"><pre>Matches statements that are (transitively) expanded from the named macro.
5415 Does not match if only part of the statement is expanded from that macro or
5416 if different parts of the statement are expanded from different
5417 appearances of the macro.
5418 </pre></td></tr>
5421 <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>
5422 <tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is
5423 partially matching a given regex.
5425 Example matches Y but not X
5426 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*"))
5427 #include "ASTMatcher.h"
5428 class X {};
5429 ASTMatcher.h:
5430 class Y {};
5432 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;
5434 If the matcher is used in clang-query, RegexFlags parameter
5435 should be passed as a quoted string. e.g: "NoFlags".
5436 Flags can be combined with '|' example "IgnoreCase | BasicRegex"
5437 </pre></td></tr>
5440 <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>
5441 <tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file.
5443 Example matches X but not Y
5444 (matcher = cxxRecordDecl(isExpansionInMainFile())
5445 #include &lt;Y.h&gt;
5446 class X {};
5447 Y.h:
5448 class Y {};
5450 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;
5451 </pre></td></tr>
5454 <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>
5455 <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files.
5457 Example matches Y but not X
5458 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
5459 #include &lt;SystemHeader.h&gt;
5460 class X {};
5461 SystemHeader.h:
5462 class Y {};
5464 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;
5465 </pre></td></tr>
5468 <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>
5469 <tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool.
5471 Given
5472 struct S { bool func(); };
5473 functionDecl(returns(booleanType()))
5474 matches "bool func();"
5475 </pre></td></tr>
5478 <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>
5479 <tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node.
5481 Matches a node if it equals the node previously bound to ID.
5483 Given
5484 class X { int a; int b; };
5485 cxxRecordDecl(
5486 has(fieldDecl(hasName("a"), hasType(type().bind("t")))),
5487 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t"))))))
5488 matches the class X, as a and b have the same type.
5490 Note that when multiple matches are involved via forEach* matchers,
5491 equalsBoundNodes acts as a filter.
5492 For example:
5493 compoundStmt(
5494 forEachDescendant(varDecl().bind("d")),
5495 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d"))))))
5496 will trigger a match for each combination of variable declaration
5497 and reference to that variable declaration within a compound statement.
5498 </pre></td></tr>
5501 <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>
5502 <tr><td colspan="4" class="doc" id="equalsNode2"><pre>Matches if a node equals another node.
5504 Type has pointer identity in the AST.
5505 </pre></td></tr>
5508 <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>
5509 <tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double).
5511 Given
5512 int i;
5513 float f;
5514 realFloatingPointType()
5515 matches "float f" but not "int i"
5516 </pre></td></tr>
5519 <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>
5520 <tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void.
5522 Given
5523 struct S { void func(); };
5524 functionDecl(returns(voidType()))
5525 matches "void func();"
5526 </pre></td></tr>
5529 <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>
5530 <tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind.
5532 Given
5533 int x;
5534 int s = sizeof(x) + alignof(x)
5535 unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
5536 matches sizeof(x)
5538 If the matcher is use from clang-query, UnaryExprOrTypeTrait parameter
5539 should be passed as a quoted string. e.g., ofKind("UETT_SizeOf").
5540 </pre></td></tr>
5543 <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>
5544 <tr><td colspan="4" class="doc" id="hasAnyOperatorName3"><pre>Matches operator expressions (binary or unary) that have any of the
5545 specified names.
5547 hasAnyOperatorName("+", "-")
5548 Is equivalent to
5549 anyOf(hasOperatorName("+"), hasOperatorName("-"))
5550 </pre></td></tr>
5553 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasOperatorName3')"><a name="hasOperatorName3Anchor">hasOperatorName</a></td><td>std::string Name</td></tr>
5554 <tr><td colspan="4" class="doc" id="hasOperatorName3"><pre>Matches the operator Name of operator expressions (binary or
5555 unary).
5557 Example matches a || b (matcher = binaryOperator(hasOperatorName("||")))
5558 !(a || b)
5559 </pre></td></tr>
5562 <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>
5563 <tr><td colspan="4" class="doc" id="isArrow1"><pre>Matches member expressions that are called with '-&gt;' as opposed
5564 to '.'.
5566 Member calls on the implicit this pointer match as called with '-&gt;'.
5568 Given
5569 class Y {
5570 void x() { this-&gt;x(); x(); Y y; y.x(); a; this-&gt;b; Y::b; }
5571 template &lt;class T&gt; void f() { this-&gt;f&lt;T&gt;(); f&lt;T&gt;(); }
5572 int a;
5573 static int b;
5575 template &lt;class T&gt;
5576 class Z {
5577 void x() { this-&gt;m; }
5579 memberExpr(isArrow())
5580 matches this-&gt;x, x, y.x, a, this-&gt;b
5581 cxxDependentScopeMemberExpr(isArrow())
5582 matches this-&gt;m
5583 unresolvedMemberExpr(isArrow())
5584 matches this-&gt;f&lt;T&gt;, f&lt;T&gt;
5585 </pre></td></tr>
5588 <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>
5589 <tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration.
5591 Example matches x, but not y, z, or a.
5592 (matcher = varDecl(hasAutomaticStorageDuration())
5593 void f() {
5594 int x;
5595 static int y;
5596 thread_local int z;
5598 int a;
5599 </pre></td></tr>
5602 <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>
5603 <tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage.
5605 Example matches y and z (matcher = varDecl(hasGlobalStorage())
5606 void f() {
5607 int x;
5608 static int y;
5610 int z;
5611 </pre></td></tr>
5614 <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>
5615 <tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a
5616 non-static local variable.
5618 Example matches x (matcher = varDecl(hasLocalStorage())
5619 void f() {
5620 int x;
5621 static int y;
5623 int z;
5624 </pre></td></tr>
5627 <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>
5628 <tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration.
5629 It includes the variable declared at namespace scope and those declared
5630 with "static" and "extern" storage class specifiers.
5632 void f() {
5633 int x;
5634 static int y;
5635 thread_local int z;
5637 int a;
5638 static int b;
5639 extern int c;
5640 varDecl(hasStaticStorageDuration())
5641 matches the function declaration y, a, b and c.
5642 </pre></td></tr>
5645 <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>
5646 <tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration.
5648 Example matches z, but not x, z, or a.
5649 (matcher = varDecl(hasThreadStorageDuration())
5650 void f() {
5651 int x;
5652 static int y;
5653 thread_local int z;
5655 int a;
5656 </pre></td></tr>
5659 <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>
5660 <tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations,
5661 and if constexpr.
5663 Given:
5664 constexpr int foo = 42;
5665 constexpr int bar();
5666 void baz() { if constexpr(1 &gt; 0) {} }
5667 varDecl(isConstexpr())
5668 matches the declaration of foo.
5669 functionDecl(isConstexpr())
5670 matches the declaration of bar.
5671 ifStmt(isConstexpr())
5672 matches the if statement in baz.
5673 </pre></td></tr>
5676 <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>
5677 <tr><td colspan="4" class="doc" id="isConstinit0"><pre>Matches constinit variable declarations.
5679 Given:
5680 constinit int foo = 42;
5681 constinit const char* bar = "bar";
5682 int baz = 42;
5683 [[clang::require_constant_initialization]] int xyz = 42;
5684 varDecl(isConstinit())
5685 matches the declaration of `foo` and `bar`, but not `baz` and `xyz`.
5686 </pre></td></tr>
5689 <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>
5690 <tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached.
5692 Example matches A, va, fa
5693 class A {};
5694 class B; // Doesn't match, as it has no body.
5695 int va;
5696 extern int vb; // Doesn't match, as it doesn't define the variable.
5697 void fa() {}
5698 void fb(); // Doesn't match, as it has no body.
5699 @interface X
5700 - (void)ma; // Doesn't match, interface is declaration.
5701 @end
5702 @implementation X
5703 - (void)ma {}
5704 @end
5706 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;,
5707 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>&gt;
5708 </pre></td></tr>
5711 <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>
5712 <tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from
5713 a C++ catch block, or an Objective-C statement.
5715 Example matches x (matcher = varDecl(isExceptionVariable())
5716 void f(int y) {
5717 try {
5718 } catch (int x) {
5721 </pre></td></tr>
5724 <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>
5725 <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or
5726 static member variable template instantiations.
5728 Given
5729 template&lt;typename T&gt; void A(T t) { }
5730 template&lt;&gt; void A(int N) { }
5731 functionDecl(isExplicitTemplateSpecialization())
5732 matches the specialization A&lt;int&gt;().
5734 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;
5735 </pre></td></tr>
5738 <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>
5739 <tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function or variable declarations.
5741 Given:
5742 extern "C" void f() {}
5743 extern "C" { void g() {} }
5744 void h() {}
5745 extern "C" int x = 1;
5746 extern "C" int y = 2;
5747 int z = 3;
5748 functionDecl(isExternC())
5749 matches the declaration of f and g, but not the declaration of h.
5750 varDecl(isExternC())
5751 matches the declaration of x and y, but not the declaration of z.
5752 </pre></td></tr>
5755 <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>
5756 <tr><td colspan="4" class="doc" id="isInitCapture0"><pre>Matches a variable serving as the implicit variable for a lambda init-
5757 capture.
5759 Example matches x (matcher = varDecl(isInitCapture()))
5760 auto f = [x=3]() { return x; };
5761 </pre></td></tr>
5764 <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>
5765 <tr><td colspan="4" class="doc" id="isInline2"><pre>Matches functions, variables and namespace declarations that are marked with
5766 the inline keyword.
5768 Given
5769 inline void f();
5770 void g();
5771 namespace n {
5772 inline namespace m {}
5774 inline int Foo = 5;
5775 functionDecl(isInline()) will match ::f().
5776 namespaceDecl(isInline()) will match n::m.
5777 varDecl(isInline()) will match Foo;
5778 </pre></td></tr>
5781 <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>
5782 <tr><td colspan="4" class="doc" id="isStaticLocal0"><pre>Matches a static variable with local scope.
5784 Example matches y (matcher = varDecl(isStaticLocal()))
5785 void f() {
5786 int x;
5787 static int y;
5789 static int z;
5790 </pre></td></tr>
5793 <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>
5794 <tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variable/function declarations that have "static" storage
5795 class specifier ("static" keyword) written in the source.
5797 Given:
5798 static void f() {}
5799 static int i = 0;
5800 extern int j;
5801 int k;
5802 functionDecl(isStaticStorageClass())
5803 matches the function declaration f.
5804 varDecl(isStaticStorageClass())
5805 matches the variable declaration i.
5806 </pre></td></tr>
5809 <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>
5810 <tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static
5811 member variable template instantiations.
5813 Given
5814 template &lt;typename T&gt; class X {}; class A {}; X&lt;A&gt; x;
5816 template &lt;typename T&gt; class X {}; class A {}; template class X&lt;A&gt;;
5818 template &lt;typename T&gt; class X {}; class A {}; extern template class X&lt;A&gt;;
5819 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
5820 matches the template instantiation of X&lt;A&gt;.
5822 But given
5823 template &lt;typename T&gt; class X {}; class A {};
5824 template &lt;&gt; class X&lt;A&gt; {}; X&lt;A&gt; x;
5825 cxxRecordDecl(hasName("::X"), isTemplateInstantiation())
5826 does not match, as X&lt;A&gt; is an explicit template specialization.
5828 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;
5829 </pre></td></tr>
5831 <!--END_NARROWING_MATCHERS -->
5832 </table>
5834 <!-- ======================================================================= -->
5835 <h2 id="traversal-matchers">AST Traversal Matchers</h2>
5836 <!-- ======================================================================= -->
5838 <p>Traversal matchers specify the relationship to other nodes that are
5839 reachable from the current node.</p>
5841 <p>Note that there are special traversal matchers (has, hasDescendant, forEach and
5842 forEachDescendant) which work on all nodes and allow users to write more generic
5843 match expressions.</p>
5845 <table>
5846 <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
5847 <!-- START_TRAVERSAL_MATCHERS -->
5849 <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>
5850 <tr><td colspan="4" class="doc" id="binaryOperation0"><pre>Matches nodes which can be used with binary operators.
5852 The code
5853 var1 != var2;
5854 might be represented in the clang AST as a binaryOperator, a
5855 cxxOperatorCallExpr or a cxxRewrittenBinaryOperator, depending on
5857 * whether the types of var1 and var2 are fundamental (binaryOperator) or at
5858 least one is a class type (cxxOperatorCallExpr)
5859 * whether the code appears in a template declaration, if at least one of the
5860 vars is a dependent-type (binaryOperator)
5861 * whether the code relies on a rewritten binary operator, such as a
5862 spaceship operator or an inverted equality operator
5863 (cxxRewrittenBinaryOperator)
5865 This matcher elides details in places where the matchers for the nodes are
5866 compatible.
5868 Given
5869 binaryOperation(
5870 hasOperatorName("!="),
5871 hasLHS(expr().bind("lhs")),
5872 hasRHS(expr().bind("rhs"))
5874 matches each use of "!=" in:
5875 struct S{
5876 bool operator!=(const S&amp;) const;
5879 void foo()
5881 1 != 2;
5882 S() != S();
5885 template&lt;typename T&gt;
5886 void templ()
5888 1 != 2;
5889 T() != S();
5891 struct HasOpEq
5893 bool operator==(const HasOpEq &amp;) const;
5896 void inverse()
5898 HasOpEq s1;
5899 HasOpEq s2;
5900 if (s1 != s2)
5901 return;
5904 struct HasSpaceship
5906 bool operator&lt;=&gt;(const HasOpEq &amp;) const;
5909 void use_spaceship()
5911 HasSpaceship s1;
5912 HasSpaceship s2;
5913 if (s1 != s2)
5914 return;
5916 </pre></td></tr>
5919 <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>
5920 <tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches.
5922 Unlike anyOf, eachOf will generate a match result for each
5923 matching submatcher.
5925 For example, in:
5926 class A { int a; int b; };
5927 The matcher:
5928 cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")),
5929 has(fieldDecl(hasName("b")).bind("v"))))
5930 will generate two results binding "v", the first of which binds
5931 the field declaration of a, the second the field declaration of
5934 Usable as: Any Matcher
5935 </pre></td></tr>
5938 <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>
5939 <tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches.
5941 Generates results for each match.
5943 For example, in:
5944 class A { class B {}; class C {}; };
5945 The matcher:
5946 cxxRecordDecl(hasName("::A"),
5947 findAll(cxxRecordDecl(isDefinition()).bind("m")))
5948 will generate results for A, B and C.
5950 Usable as: Any Matcher
5951 </pre></td></tr>
5954 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher&lt;*&gt;</td></tr>
5955 <tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
5956 provided matcher.
5958 Example matches X, A, A::X, B, B::C, B::C::X
5959 (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X")))))
5960 class X {};
5961 class A { class X {}; }; // Matches A, because A::X is a class of name
5962 // X inside A.
5963 class B { class C { class X {}; }; };
5965 DescendantT must be an AST base type.
5967 As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
5968 each result that matches instead of only on the first one.
5970 Note: Recursively combined ForEachDescendant can cause many matches:
5971 cxxRecordDecl(forEachDescendant(cxxRecordDecl(
5972 forEachDescendant(cxxRecordDecl())
5974 will match 10 times (plus injected class name matches) on:
5975 class A { class B { class C { class D { class E {}; }; }; }; };
5977 Usable as: Any Matcher
5978 </pre></td></tr>
5981 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher&lt;*&gt;</td></tr>
5982 <tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the
5983 provided matcher.
5985 Example matches X, Y, Y::X, Z::Y, Z::Y::X
5986 (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X")))
5987 class X {};
5988 class Y { class X {}; }; // Matches Y, because Y::X is a class of name X
5989 // inside Y.
5990 class Z { class Y { class X {}; }; }; // Does not match Z.
5992 ChildT must be an AST base type.
5994 As opposed to 'has', 'forEach' will cause a match for each result that
5995 matches instead of only on the first one.
5997 Usable as: Any Matcher
5998 </pre></td></tr>
6001 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher&lt;*&gt;</td></tr>
6002 <tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided
6003 matcher.
6005 Given
6006 void f() { if (true) { int x = 42; } }
6007 void g() { for (;;) { int x = 43; } }
6008 expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.
6010 Usable as: Any Matcher
6011 </pre></td></tr>
6014 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher&lt;*&gt;</td></tr>
6015 <tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the
6016 provided matcher.
6018 Example matches X, Y, Z
6019 (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X")))))
6020 class X {}; // Matches X, because X::X is a class of name X inside X.
6021 class Y { class X {}; };
6022 class Z { class Y { class X {}; }; };
6024 DescendantT must be an AST base type.
6026 Usable as: Any Matcher
6027 </pre></td></tr>
6030 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher&lt;*&gt;</td></tr>
6031 <tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the
6032 provided matcher.
6034 Example matches X, Y
6035 (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X")))
6036 class X {}; // Matches X, because X::X is a class of name X inside X.
6037 class Y { class X {}; };
6038 class Z { class Y { class X {}; }; }; // Does not match Z.
6040 ChildT must be an AST base type.
6042 Usable as: Any Matcher
6043 Note that has is direct matcher, so it also matches things like implicit
6044 casts and paren casts. If you are matching with expr then you should
6045 probably consider using ignoringParenImpCasts like:
6046 has(ignoringParenImpCasts(expr())).
6047 </pre></td></tr>
6050 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher&lt;*&gt;</td></tr>
6051 <tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided
6052 matcher.
6054 Given
6055 void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
6056 compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }".
6058 Usable as: Any Matcher
6059 </pre></td></tr>
6062 <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>
6063 <tr><td colspan="4" class="doc" id="invocation0"><pre>Matches function calls and constructor calls
6065 Because CallExpr and CXXConstructExpr do not share a common
6066 base class with API accessing arguments etc, AST Matchers for code
6067 which should match both are typically duplicated. This matcher
6068 removes the need for duplication.
6070 Given code
6071 struct ConstructorTakesInt
6073 ConstructorTakesInt(int i) {}
6076 void callTakesInt(int i)
6080 void doCall()
6082 callTakesInt(42);
6085 void doConstruct()
6087 ConstructorTakesInt cti(42);
6090 The matcher
6091 invocation(hasArgument(0, integerLiteral(equals(42))))
6092 matches the expression in both doCall and doConstruct
6093 </pre></td></tr>
6096 <tr><td>Matcher&lt;*&gt;</td><td class="name" onclick="toggle('optionally0')"><a name="optionally0Anchor">optionally</a></td><td>Matcher&lt;*&gt;</td></tr>
6097 <tr><td colspan="4" class="doc" id="optionally0"><pre>Matches any node regardless of the submatcher.
6099 However, optionally will retain any bindings generated by the submatcher.
6100 Useful when additional information which may or may not present about a main
6101 matching node is desired.
6103 For example, in:
6104 class Foo {
6105 int bar;
6107 The matcher:
6108 cxxRecordDecl(
6109 optionally(has(
6110 fieldDecl(hasName("bar")).bind("var")
6111 ))).bind("record")
6112 will produce a result binding for both "record" and "var".
6113 The matcher will produce a "record" binding for even if there is no data
6114 member named "bar" in that class.
6116 Usable as: Any Matcher
6117 </pre></td></tr>
6120 <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>
6121 <tr><td colspan="4" class="doc" id="traverse0"><pre>Causes all nested matchers to be matched with the specified traversal kind.
6123 Given
6124 void foo()
6126 int i = 3.0;
6128 The matcher
6129 traverse(TK_IgnoreUnlessSpelledInSource,
6130 varDecl(hasInitializer(floatLiteral().bind("init")))
6132 matches the variable declaration with "init" bound to the "3.0".
6133 </pre></td></tr>
6136 <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>
6137 <tr><td colspan="4" class="doc" id="hasCondition5"><pre>Matches the condition expression of an if statement, for loop,
6138 switch statement or conditional operator.
6140 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
6141 if (true) {}
6142 </pre></td></tr>
6145 <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>
6146 <tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator
6147 (binary or ternary).
6149 Example matches b
6150 condition ? a : b
6151 condition ?: b
6152 </pre></td></tr>
6155 <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>
6156 <tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator.
6158 Example 1 (conditional ternary operator): matches a
6159 condition ? a : b
6161 Example 2 (conditional binary operator): matches opaqueValueExpr(condition)
6162 condition ?: b
6163 </pre></td></tr>
6166 <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>
6167 <tr><td colspan="4" class="doc" id="hasDeclaration15"><pre>Matches a node if the declaration associated with that node
6168 matches the given matcher.
6170 The associated declaration is:
6171 - for type nodes, the declaration of the underlying type
6172 - for CallExpr, the declaration of the callee
6173 - for MemberExpr, the declaration of the referenced member
6174 - for CXXConstructExpr, the declaration of the constructor
6175 - for CXXNewExpr, the declaration of the operator new
6176 - for ObjCIvarExpr, the declaration of the ivar
6178 For type nodes, hasDeclaration will generally match the declaration of the
6179 sugared type. Given
6180 class X {};
6181 typedef X Y;
6182 Y y;
6183 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6184 typedefDecl. A common use case is to match the underlying, desugared type.
6185 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6186 varDecl(hasType(hasUnqualifiedDesugaredType(
6187 recordType(hasDeclaration(decl())))))
6188 In this matcher, the decl will match the CXXRecordDecl of class X.
6190 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;,
6191 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;,
6192 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;,
6193 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;,
6194 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;,
6195 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;,
6196 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6197 </pre></td></tr>
6200 <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>
6201 <tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression.
6203 Given
6204 int i[5];
6205 void f() { i[1] = 42; }
6206 arraySubscriptExpression(hasBase(implicitCastExpr(
6207 hasSourceExpression(declRefExpr()))))
6208 matches i[1] with the declRefExpr() matching i
6209 </pre></td></tr>
6212 <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>
6213 <tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression.
6215 Given
6216 int i[5];
6217 void f() { i[1] = 42; }
6218 arraySubscriptExpression(hasIndex(integerLiteral()))
6219 matches i[1] with the integerLiteral() matching 1
6220 </pre></td></tr>
6223 <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>
6224 <tr><td colspan="4" class="doc" id="hasLHS3"><pre>Matches the left hand side of binary operator expressions.
6226 Example matches a (matcher = binaryOperator(hasLHS()))
6227 a || b
6228 </pre></td></tr>
6231 <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>
6232 <tr><td colspan="4" class="doc" id="hasRHS3"><pre>Matches the right hand side of binary operator expressions.
6234 Example matches b (matcher = binaryOperator(hasRHS()))
6235 a || b
6236 </pre></td></tr>
6239 <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>
6240 <tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element
6241 type.
6243 Given
6244 struct A {};
6245 A a[7];
6246 int b[7];
6247 arrayType(hasElementType(builtinType()))
6248 matches "int b[7]"
6250 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;
6251 </pre></td></tr>
6254 <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>
6255 <tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type.
6257 Given
6258 _Atomic(int) i;
6259 _Atomic(float) f;
6260 atomicType(hasValueType(isInteger()))
6261 matches "_Atomic(int) i"
6263 Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>&gt;
6264 </pre></td></tr>
6267 <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>
6268 <tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type.
6270 Note: There is no TypeLoc for the deduced type and thus no
6271 getDeducedLoc() matcher.
6273 Given
6274 auto a = 1;
6275 auto b = 2.0;
6276 autoType(hasDeducedType(isInteger()))
6277 matches "auto a"
6279 Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>&gt;
6280 </pre></td></tr>
6283 <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>
6284 <tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration.
6286 Given
6287 namespace X { void b(); }
6288 using X::b;
6289 usingDecl(hasAnyUsingShadowDecl(hasName("b"))))
6290 matches using X::b </pre></td></tr>
6293 <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>
6294 <tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a
6295 binary operator matches.
6296 </pre></td></tr>
6299 <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>
6300 <tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions.
6302 Example matches a (matcher = binaryOperator(hasLHS()))
6303 a || b
6304 </pre></td></tr>
6307 <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>
6308 <tr><td colspan="4" class="doc" id="hasOperands0"><pre>Matches if both matchers match with opposite sides of the binary operator.
6310 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
6311 integerLiteral(equals(2)))
6312 1 + 2 // Match
6313 2 + 1 // Match
6314 1 + 1 // No match
6315 2 + 2 // No match
6316 </pre></td></tr>
6319 <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>
6320 <tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions.
6322 Example matches b (matcher = binaryOperator(hasRHS()))
6323 a || b
6324 </pre></td></tr>
6327 <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>
6328 <tr><td colspan="4" class="doc" id="forDecomposition0"><pre>Matches the DecompositionDecl the binding belongs to.
6330 For example, in:
6331 void foo()
6333 int arr[3];
6334 auto &amp;[f, s, t] = arr;
6336 f = 42;
6338 The matcher:
6339 bindingDecl(hasName("f"),
6340 forDecomposition(decompositionDecl())
6341 matches 'f' in 'auto &amp;[f, s, t]'.
6342 </pre></td></tr>
6345 <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>
6346 <tr><td colspan="4" class="doc" id="hasAnyParameter2"><pre>Matches any parameter of a function or an ObjC method declaration or a
6347 block.
6349 Does not match the 'this' parameter of a method.
6351 Given
6352 class X { void f(int x, int y, int z) {} };
6353 cxxMethodDecl(hasAnyParameter(hasName("y")))
6354 matches f(int x, int y, int z) {}
6355 with hasAnyParameter(...)
6356 matching int y
6358 For ObjectiveC, given
6359 @interface I - (void) f:(int) y; @end
6361 the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
6362 matches the declaration of method f with hasParameter
6363 matching y.
6365 For blocks, given
6366 b = ^(int y) { printf("%d", y) };
6368 the matcher blockDecl(hasAnyParameter(hasName("y")))
6369 matches the declaration of the block b with hasParameter
6370 matching y.
6371 </pre></td></tr>
6374 <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>
6375 <tr><td colspan="4" class="doc" id="hasParameter2"><pre>Matches the n'th parameter of a function or an ObjC method
6376 declaration or a block.
6378 Given
6379 class X { void f(int x) {} };
6380 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
6381 matches f(int x) {}
6382 with hasParameter(...)
6383 matching int x
6385 For ObjectiveC, given
6386 @interface I - (void) f:(int) y; @end
6388 the matcher objcMethodDecl(hasParameter(0, hasName("y")))
6389 matches the declaration of method f with hasParameter
6390 matching y.
6391 </pre></td></tr>
6394 <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>
6395 <tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of a node matches the inner matcher.
6397 Examples:
6398 int x;
6399 declaratorDecl(hasTypeLoc(loc(asString("int"))))
6400 matches int x
6402 auto x = int(3);
6403 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6404 matches int(3)
6406 struct Foo { Foo(int, int); };
6407 auto x = Foo(1, 2);
6408 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6409 matches Foo(1, 2)
6411 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;,
6412 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;,
6413 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;,
6414 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6415 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
6416 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;,
6417 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;,
6418 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6419 </pre></td></tr>
6422 <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>
6423 <tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the
6424 pointee matches a given matcher.
6426 Given
6427 int *a;
6428 int const *b;
6429 float const *f;
6430 pointerType(pointee(isConstQualified(), isInteger()))
6431 matches "int const *b"
6433 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;,
6434 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;
6435 </pre></td></tr>
6438 <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>
6439 <tr><td colspan="4" class="doc" id="hasTypeLoc1"><pre>Matches if the type location of a node matches the inner matcher.
6441 Examples:
6442 int x;
6443 declaratorDecl(hasTypeLoc(loc(asString("int"))))
6444 matches int x
6446 auto x = int(3);
6447 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6448 matches int(3)
6450 struct Foo { Foo(int, int); };
6451 auto x = Foo(1, 2);
6452 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6453 matches Foo(1, 2)
6455 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;,
6456 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;,
6457 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;,
6458 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6459 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
6460 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;,
6461 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;,
6462 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6463 </pre></td></tr>
6466 <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>
6467 <tr><td colspan="4" class="doc" id="hasType8"><pre>Overloaded to match the declaration of the expression's or value
6468 declaration's type.
6470 In case of a value declaration (for example a variable declaration),
6471 this resolves one layer of indirection. For example, in the value
6472 declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
6473 X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
6474 declaration of x.
6476 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
6477 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
6478 and friend class X (matcher = friendDecl(hasType("X"))
6479 and public virtual X (matcher = cxxBaseSpecifier(hasType(
6480 cxxRecordDecl(hasName("X"))))
6481 class X {};
6482 void y(X &amp;x) { x; X z; }
6483 class Y { friend class X; };
6484 class Z : public virtual X {};
6486 Example matches class Derived
6487 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
6488 class Base {};
6489 class Derived : Base {};
6491 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;,
6492 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
6493 </pre></td></tr>
6496 <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>
6497 <tr><td colspan="4" class="doc" id="hasType4"><pre>Matches if the expression's or declaration's type matches a type
6498 matcher.
6500 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
6501 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
6502 and U (matcher = typedefDecl(hasType(asString("int")))
6503 and friend class X (matcher = friendDecl(hasType("X"))
6504 and public virtual X (matcher = cxxBaseSpecifier(hasType(
6505 asString("class X")))
6506 class X {};
6507 void y(X &amp;x) { x; X z; }
6508 typedef int U;
6509 class Y { friend class X; };
6510 class Z : public virtual X {};
6511 </pre></td></tr>
6514 <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>
6515 <tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl.
6517 Given
6518 void f(int i);
6519 int y;
6520 f(y);
6521 callExpr(
6522 forEachArgumentWithParam(
6523 declRefExpr(to(varDecl(hasName("y")))),
6524 parmVarDecl(hasType(isInteger()))
6526 matches f(y);
6527 with declRefExpr(...)
6528 matching int y
6529 and parmVarDecl(...)
6530 matching int i
6531 </pre></td></tr>
6534 <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>
6535 <tr><td colspan="4" class="doc" id="forEachArgumentWithParamType1"><pre>Matches all arguments and their respective types for a CallExpr or
6536 CXXConstructExpr. It is very similar to forEachArgumentWithParam but
6537 it works on calls through function pointers as well.
6539 The difference is, that function pointers do not provide access to a
6540 ParmVarDecl, but only the QualType for each argument.
6542 Given
6543 void f(int i);
6544 int y;
6545 f(y);
6546 void (*f_ptr)(int) = f;
6547 f_ptr(y);
6548 callExpr(
6549 forEachArgumentWithParamType(
6550 declRefExpr(to(varDecl(hasName("y")))),
6551 qualType(isInteger()).bind("type)
6553 matches f(y) and f_ptr(y)
6554 with declRefExpr(...)
6555 matching int y
6556 and qualType(...)
6557 matching int
6558 </pre></td></tr>
6561 <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>
6562 <tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call
6563 expression, or an ObjC-message-send expression.
6565 Given
6566 void x(int, int, int) { int y; x(1, y, 42); }
6567 callExpr(hasAnyArgument(declRefExpr()))
6568 matches x(1, y, 42)
6569 with hasAnyArgument(...)
6570 matching y
6572 For ObjectiveC, given
6573 @interface I - (void) f:(int) y; @end
6574 void foo(I *i) { [i f:12]; }
6575 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
6576 matches [i f:12]
6577 </pre></td></tr>
6580 <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>
6581 <tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor
6582 call expression.
6584 Example matches y in x(y)
6585 (matcher = callExpr(hasArgument(0, declRefExpr())))
6586 void x(int) { int y; x(y); }
6587 </pre></td></tr>
6590 <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>
6591 <tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node
6592 matches the given matcher.
6594 The associated declaration is:
6595 - for type nodes, the declaration of the underlying type
6596 - for CallExpr, the declaration of the callee
6597 - for MemberExpr, the declaration of the referenced member
6598 - for CXXConstructExpr, the declaration of the constructor
6599 - for CXXNewExpr, the declaration of the operator new
6600 - for ObjCIvarExpr, the declaration of the ivar
6602 For type nodes, hasDeclaration will generally match the declaration of the
6603 sugared type. Given
6604 class X {};
6605 typedef X Y;
6606 Y y;
6607 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6608 typedefDecl. A common use case is to match the underlying, desugared type.
6609 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6610 varDecl(hasType(hasUnqualifiedDesugaredType(
6611 recordType(hasDeclaration(decl())))))
6612 In this matcher, the decl will match the CXXRecordDecl of class X.
6614 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;,
6615 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;,
6616 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;,
6617 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;,
6618 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;,
6619 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;,
6620 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6621 </pre></td></tr>
6624 <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>
6625 <tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition.
6627 Given
6628 class A { A() : i(42), j(42) {} int i; int j; };
6629 cxxConstructorDecl(forEachConstructorInitializer(
6630 forField(decl().bind("x"))
6632 will trigger two matches, binding for 'i' and 'j' respectively.
6633 </pre></td></tr>
6636 <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>
6637 <tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer.
6639 Given
6640 struct Foo {
6641 Foo() : foo_(1) { }
6642 int foo_;
6644 cxxRecordDecl(has(cxxConstructorDecl(
6645 hasAnyConstructorInitializer(anything())
6647 record matches Foo, hasAnyConstructorInitializer matches foo_(1)
6648 </pre></td></tr>
6651 <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>
6652 <tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer.
6654 Given
6655 struct Foo {
6656 Foo() : foo_(1) { }
6657 int foo_;
6659 cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
6660 forField(hasName("foo_"))))))
6661 matches Foo
6662 with forField matching foo_
6663 </pre></td></tr>
6666 <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>
6667 <tr><td colspan="4" class="doc" id="hasTypeLoc2"><pre>Matches if the type location of a node matches the inner matcher.
6669 Examples:
6670 int x;
6671 declaratorDecl(hasTypeLoc(loc(asString("int"))))
6672 matches int x
6674 auto x = int(3);
6675 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6676 matches int(3)
6678 struct Foo { Foo(int, int); };
6679 auto x = Foo(1, 2);
6680 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6681 matches Foo(1, 2)
6683 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;,
6684 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;,
6685 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;,
6686 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6687 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
6688 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;,
6689 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;,
6690 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6691 </pre></td></tr>
6694 <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>
6695 <tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer.
6697 Given
6698 struct Foo {
6699 Foo() : foo_(1) { }
6700 int foo_;
6702 cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
6703 withInitializer(integerLiteral(equals(1)))))))
6704 matches Foo
6705 with withInitializer matching (1)
6706 </pre></td></tr>
6709 <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>
6710 <tr><td colspan="4" class="doc" id="hasObjectExpression2"><pre>Matches a member expression where the object expression is matched by a
6711 given matcher. Implicit object expressions are included; that is, it matches
6712 use of implicit `this`.
6714 Given
6715 struct X {
6716 int m;
6717 int f(X x) { x.m; return m; }
6719 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))
6720 matches `x.m`, but not `m`; however,
6721 memberExpr(hasObjectExpression(hasType(pointsTo(
6722 cxxRecordDecl(hasName("X"))))))
6723 matches `m` (aka. `this-&gt;m`), but not `x.m`.
6724 </pre></td></tr>
6727 <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>
6728 <tr><td colspan="4" class="doc" id="hasBody3"><pre></pre></td></tr>
6731 <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>
6732 <tr><td colspan="4" class="doc" id="hasInitStatement2"><pre>Matches selection statements with initializer.
6734 Given:
6735 void foo() {
6736 if (int i = foobar(); i &gt; 0) {}
6737 switch (int i = foobar(); i) {}
6738 for (auto&amp; a = get_range(); auto&amp; x : a) {}
6740 void bar() {
6741 if (foobar() &gt; 0) {}
6742 switch (foobar()) {}
6743 for (auto&amp; x : get_range()) {}
6745 ifStmt(hasInitStatement(anything()))
6746 matches the if statement in foo but not in bar.
6747 switchStmt(hasInitStatement(anything()))
6748 matches the switch statement in foo but not in bar.
6749 cxxForRangeStmt(hasInitStatement(anything()))
6750 matches the range for statement in foo but not in bar.
6751 </pre></td></tr>
6754 <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>
6755 <tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop.
6757 Example:
6758 forStmt(hasLoopVariable(anything()))
6759 matches 'int x' in
6760 for (int x : a) { }
6761 </pre></td></tr>
6764 <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>
6765 <tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop.
6767 Example:
6768 forStmt(hasRangeInit(anything()))
6769 matches 'a' in
6770 for (int x : a) { }
6771 </pre></td></tr>
6774 <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>
6775 <tr><td colspan="4" class="doc" id="hasTypeLoc3"><pre>Matches if the type location of a node matches the inner matcher.
6777 Examples:
6778 int x;
6779 declaratorDecl(hasTypeLoc(loc(asString("int"))))
6780 matches int x
6782 auto x = int(3);
6783 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6784 matches int(3)
6786 struct Foo { Foo(int, int); };
6787 auto x = Foo(1, 2);
6788 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6789 matches Foo(1, 2)
6791 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;,
6792 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;,
6793 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;,
6794 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6795 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
6796 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;,
6797 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;,
6798 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6799 </pre></td></tr>
6802 <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>
6803 <tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre>Matches on the implicit object argument of a member call expression. Unlike
6804 `on`, matches the argument directly without stripping away anything.
6806 Given
6807 class Y { public: void m(); };
6808 Y g();
6809 class X : public Y { void g(); };
6810 void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); }
6811 cxxMemberCallExpr(onImplicitObjectArgument(hasType(
6812 cxxRecordDecl(hasName("Y")))))
6813 matches `y.m()`, `x.m()` and (g()).m(), but not `x.g()`.
6814 cxxMemberCallExpr(on(callExpr()))
6815 does not match `(g()).m()`, because the parens are not ignored.
6817 FIXME: Overload to allow directly matching types?
6818 </pre></td></tr>
6821 <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>
6822 <tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression, after
6823 stripping off any parentheses or implicit casts.
6825 Given
6826 class Y { public: void m(); };
6827 Y g();
6828 class X : public Y {};
6829 void z(Y y, X x) { y.m(); (g()).m(); x.m(); }
6830 cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))))
6831 matches `y.m()` and `(g()).m()`.
6832 cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X")))))
6833 matches `x.m()`.
6834 cxxMemberCallExpr(on(callExpr()))
6835 matches `(g()).m()`.
6837 FIXME: Overload to allow directly matching types?
6838 </pre></td></tr>
6841 <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>
6842 <tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration.
6843 </pre></td></tr>
6846 <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>
6847 <tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the type of the expression's implicit object argument either
6848 matches the InnerMatcher, or is a pointer to a type that matches the
6849 InnerMatcher.
6851 Given
6852 class Y { public: void m(); };
6853 class X : public Y { void g(); };
6854 void z() { Y y; y.m(); Y *p; p-&gt;m(); X x; x.m(); x.g(); }
6855 cxxMemberCallExpr(thisPointerType(hasDeclaration(
6856 cxxRecordDecl(hasName("Y")))))
6857 matches `y.m()`, `p-&gt;m()` and `x.m()`.
6858 cxxMemberCallExpr(thisPointerType(hasDeclaration(
6859 cxxRecordDecl(hasName("X")))))
6860 matches `x.g()`.
6861 </pre></td></tr>
6864 <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>
6865 <tr><td colspan="4" class="doc" id="forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may
6866 produce multiple matches.
6868 Given
6869 class A { virtual void f(); };
6870 class B : public A { void f(); };
6871 class C : public B { void f(); };
6872 cxxMethodDecl(ofClass(hasName("C")),
6873 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
6874 matches once, with "b" binding "A::f" and "d" binding "C::f" (Note
6875 that B::f is not overridden by C::f).
6877 The check can produce multiple matches in case of multiple inheritance, e.g.
6878 class A1 { virtual void f(); };
6879 class A2 { virtual void f(); };
6880 class C : public A1, public A2 { void f(); };
6881 cxxMethodDecl(ofClass(hasName("C")),
6882 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d")
6883 matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and
6884 once with "b" binding "A2::f" and "d" binding "C::f".
6885 </pre></td></tr>
6888 <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>
6889 <tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration
6890 belongs to.
6892 FIXME: Generalize this for other kinds of declarations.
6893 FIXME: What other kind of declarations would we need to generalize
6894 this to?
6896 Example matches A() in the last line
6897 (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl(
6898 ofClass(hasName("A"))))))
6899 class A {
6900 public:
6901 A();
6903 A a = A();
6904 </pre></td></tr>
6907 <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>
6908 <tr><td colspan="4" class="doc" id="hasAnyPlacementArg0"><pre>Matches any placement new expression arguments.
6910 Given:
6911 MyClass *p1 = new (Storage) MyClass();
6912 cxxNewExpr(hasAnyPlacementArg(anything()))
6913 matches the expression 'new (Storage, 16) MyClass()'.
6914 </pre></td></tr>
6917 <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>
6918 <tr><td colspan="4" class="doc" id="hasArraySize0"><pre>Matches array new expressions with a given array size.
6920 Given:
6921 MyClass *p1 = new MyClass[10];
6922 cxxNewExpr(hasArraySize(integerLiteral(equals(10))))
6923 matches the expression 'new MyClass[10]'.
6924 </pre></td></tr>
6927 <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>
6928 <tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node
6929 matches the given matcher.
6931 The associated declaration is:
6932 - for type nodes, the declaration of the underlying type
6933 - for CallExpr, the declaration of the callee
6934 - for MemberExpr, the declaration of the referenced member
6935 - for CXXConstructExpr, the declaration of the constructor
6936 - for CXXNewExpr, the declaration of the operator new
6937 - for ObjCIvarExpr, the declaration of the ivar
6939 For type nodes, hasDeclaration will generally match the declaration of the
6940 sugared type. Given
6941 class X {};
6942 typedef X Y;
6943 Y y;
6944 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6945 typedefDecl. A common use case is to match the underlying, desugared type.
6946 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6947 varDecl(hasType(hasUnqualifiedDesugaredType(
6948 recordType(hasDeclaration(decl())))))
6949 In this matcher, the decl will match the CXXRecordDecl of class X.
6951 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;,
6952 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;,
6953 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;,
6954 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;,
6955 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;,
6956 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;,
6957 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
6958 </pre></td></tr>
6961 <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>
6962 <tr><td colspan="4" class="doc" id="hasPlacementArg0"><pre>Matches placement new expression arguments.
6964 Given:
6965 MyClass *p1 = new (Storage, 16) MyClass();
6966 cxxNewExpr(hasPlacementArg(1, integerLiteral(equals(16))))
6967 matches the expression 'new (Storage, 16) MyClass()'.
6968 </pre></td></tr>
6971 <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>
6972 <tr><td colspan="4" class="doc" id="hasTypeLoc4"><pre>Matches if the type location of a node matches the inner matcher.
6974 Examples:
6975 int x;
6976 declaratorDecl(hasTypeLoc(loc(asString("int"))))
6977 matches int x
6979 auto x = int(3);
6980 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
6981 matches int(3)
6983 struct Foo { Foo(int, int); };
6984 auto x = Foo(1, 2);
6985 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
6986 matches Foo(1, 2)
6988 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;,
6989 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;,
6990 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;,
6991 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
6992 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
6993 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;,
6994 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;,
6995 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
6996 </pre></td></tr>
6999 <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>
7000 <tr><td colspan="4" class="doc" id="hasEitherOperand1"><pre>Matches if either the left hand side or the right hand side of a
7001 binary operator matches.
7002 </pre></td></tr>
7005 <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>
7006 <tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions.
7008 Example matches a (matcher = binaryOperator(hasLHS()))
7009 a || b
7010 </pre></td></tr>
7013 <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>
7014 <tr><td colspan="4" class="doc" id="hasOperands1"><pre>Matches if both matchers match with opposite sides of the binary operator.
7016 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
7017 integerLiteral(equals(2)))
7018 1 + 2 // Match
7019 2 + 1 // Match
7020 1 + 1 // No match
7021 2 + 2 // No match
7022 </pre></td></tr>
7025 <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>
7026 <tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions.
7028 Example matches b (matcher = binaryOperator(hasRHS()))
7029 a || b
7030 </pre></td></tr>
7033 <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>
7034 <tr><td colspan="4" class="doc" id="hasUnaryOperand1"><pre>Matches if the operand of a unary operator matches.
7036 Example matches true (matcher = hasUnaryOperand(
7037 cxxBoolLiteral(equals(true))))
7038 !true
7039 </pre></td></tr>
7042 <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>
7043 <tr><td colspan="4" class="doc" id="hasAnyBase0"><pre>Matches C++ classes that have a direct or indirect base matching BaseSpecMatcher.
7045 Example:
7046 matcher hasAnyBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))
7047 class Foo;
7048 class Bar : Foo {};
7049 class Baz : Bar {};
7050 class SpecialBase;
7051 class Proxy : SpecialBase {}; // matches Proxy
7052 class IndirectlyDerived : Proxy {}; //matches IndirectlyDerived
7054 FIXME: Refactor this and isDerivedFrom to reuse implementation.
7055 </pre></td></tr>
7058 <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>
7059 <tr><td colspan="4" class="doc" id="hasDirectBase0"><pre>Matches C++ classes that have a direct base matching BaseSpecMatcher.
7061 Example:
7062 matcher hasDirectBase(hasType(cxxRecordDecl(hasName("SpecialBase"))))
7063 class Foo;
7064 class Bar : Foo {};
7065 class Baz : Bar {};
7066 class SpecialBase;
7067 class Proxy : SpecialBase {}; // matches Proxy
7068 class IndirectlyDerived : Proxy {}; // doesn't match
7069 </pre></td></tr>
7072 <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>
7073 <tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher.
7075 Given:
7076 class A { void func(); };
7077 class B { void member(); };
7079 cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of
7080 A but not B.
7081 </pre></td></tr>
7084 <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>
7085 <tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from a class
7086 matching Base, or Objective-C classes that directly or indirectly
7087 subclass a class matching Base.
7089 Note that a class is not considered to be derived from itself.
7091 Example matches Y, Z, C (Base == hasName("X"))
7092 class X;
7093 class Y : public X {}; // directly derived
7094 class Z : public Y {}; // indirectly derived
7095 typedef X A;
7096 typedef A B;
7097 class C : public B {}; // derived from a typedef of X
7099 In the following example, Bar matches isDerivedFrom(hasName("X")):
7100 class Foo;
7101 typedef Foo X;
7102 class Bar : public Foo {}; // derived from a type that X is a typedef of
7104 In the following example, Bar matches isDerivedFrom(hasName("NSObject"))
7105 @interface NSObject @end
7106 @interface Bar : NSObject @end
7108 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;
7109 </pre></td></tr>
7112 <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>
7113 <tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom0"><pre>Matches C++ or Objective-C classes that are directly derived from a class
7114 matching Base.
7116 Note that a class is not considered to be derived from itself.
7118 Example matches Y, C (Base == hasName("X"))
7119 class X;
7120 class Y : public X {}; // directly derived
7121 class Z : public Y {}; // indirectly derived
7122 typedef X A;
7123 typedef A B;
7124 class C : public B {}; // derived from a typedef of X
7126 In the following example, Bar matches isDerivedFrom(hasName("X")):
7127 class Foo;
7128 typedef Foo X;
7129 class Bar : public Foo {}; // derived from a type that X is a typedef of
7130 </pre></td></tr>
7133 <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>
7134 <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly
7135 match Base.
7136 </pre></td></tr>
7139 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasEitherOperand2')"><a name="hasEitherOperand2Anchor">hasEitherOperand</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
7140 <tr><td colspan="4" class="doc" id="hasEitherOperand2"><pre>Matches if either the left hand side or the right hand side of a
7141 binary operator matches.
7142 </pre></td></tr>
7145 <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>
7146 <tr><td colspan="4" class="doc" id="hasLHS2"><pre>Matches the left hand side of binary operator expressions.
7148 Example matches a (matcher = binaryOperator(hasLHS()))
7149 a || b
7150 </pre></td></tr>
7153 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator</a>&gt;</td><td class="name" onclick="toggle('hasOperands2')"><a name="hasOperands2Anchor">hasOperands</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; Matcher1, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; Matcher2</td></tr>
7154 <tr><td colspan="4" class="doc" id="hasOperands2"><pre>Matches if both matchers match with opposite sides of the binary operator.
7156 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
7157 integerLiteral(equals(2)))
7158 1 + 2 // Match
7159 2 + 1 // Match
7160 1 + 1 // No match
7161 2 + 2 // No match
7162 </pre></td></tr>
7165 <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>
7166 <tr><td colspan="4" class="doc" id="hasRHS2"><pre>Matches the right hand side of binary operator expressions.
7168 Example matches b (matcher = binaryOperator(hasRHS()))
7169 a || b
7170 </pre></td></tr>
7173 <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>
7174 <tr><td colspan="4" class="doc" id="hasTypeLoc5"><pre>Matches if the type location of a node matches the inner matcher.
7176 Examples:
7177 int x;
7178 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7179 matches int x
7181 auto x = int(3);
7182 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7183 matches int(3)
7185 struct Foo { Foo(int, int); };
7186 auto x = Foo(1, 2);
7187 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7188 matches Foo(1, 2)
7190 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;,
7191 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;,
7192 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;,
7193 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7194 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7195 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;,
7196 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;,
7197 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7198 </pre></td></tr>
7201 <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>
7202 <tr><td colspan="4" class="doc" id="hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call
7203 expression, or an ObjC-message-send expression.
7205 Given
7206 void x(int, int, int) { int y; x(1, y, 42); }
7207 callExpr(hasAnyArgument(declRefExpr()))
7208 matches x(1, y, 42)
7209 with hasAnyArgument(...)
7210 matching y
7212 For ObjectiveC, given
7213 @interface I - (void) f:(int) y; @end
7214 void foo(I *i) { [i f:12]; }
7215 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
7216 matches [i f:12]
7217 </pre></td></tr>
7220 <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>
7221 <tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor
7222 call expression.
7224 Example matches y in x(y)
7225 (matcher = callExpr(hasArgument(0, declRefExpr())))
7226 void x(int) { int y; x(y); }
7227 </pre></td></tr>
7230 <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>
7231 <tr><td colspan="4" class="doc" id="hasTypeLoc6"><pre>Matches if the type location of a node matches the inner matcher.
7233 Examples:
7234 int x;
7235 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7236 matches int x
7238 auto x = int(3);
7239 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7240 matches int(3)
7242 struct Foo { Foo(int, int); };
7243 auto x = Foo(1, 2);
7244 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7245 matches Foo(1, 2)
7247 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;,
7248 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;,
7249 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;,
7250 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7251 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7252 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;,
7253 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;,
7254 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7255 </pre></td></tr>
7258 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>&gt;</td><td class="name" onclick="toggle('callee2')"><a name="callee2Anchor">callee</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
7259 <tr><td colspan="4" class="doc" id="callee2"><pre>Matches 1) if the call expression's callee's declaration matches the
7260 given matcher; or 2) if the Obj-C message expression's callee's method
7261 declaration matches the given matcher.
7263 Example matches y.x() (matcher = callExpr(callee(
7264 cxxMethodDecl(hasName("x")))))
7265 class Y { public: void x(); };
7266 void z() { Y y; y.x(); }
7268 Example 2. Matches [I foo] with
7269 objcMessageExpr(callee(objcMethodDecl(hasName("foo"))))
7271 @interface I: NSObject
7272 +(void)foo;
7273 @end
7275 [I foo]
7276 </pre></td></tr>
7279 <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>
7280 <tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches.
7282 Given
7283 class Y { void x() { this-&gt;x(); x(); Y y; y.x(); } };
7284 void f() { f(); }
7285 callExpr(callee(expr()))
7286 matches this-&gt;x(), x(), y.x(), f()
7287 with callee(...)
7288 matching this-&gt;x, x, y.x, f respectively
7290 Note: Callee cannot take the more general internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;
7291 because this introduces ambiguous overloads with calls to Callee taking a
7292 internal::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt;, as the matcher hierarchy is purely
7293 implemented in terms of implicit casts.
7294 </pre></td></tr>
7297 <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>
7298 <tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl.
7300 Given
7301 void f(int i);
7302 int y;
7303 f(y);
7304 callExpr(
7305 forEachArgumentWithParam(
7306 declRefExpr(to(varDecl(hasName("y")))),
7307 parmVarDecl(hasType(isInteger()))
7309 matches f(y);
7310 with declRefExpr(...)
7311 matching int y
7312 and parmVarDecl(...)
7313 matching int i
7314 </pre></td></tr>
7317 <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>
7318 <tr><td colspan="4" class="doc" id="forEachArgumentWithParamType0"><pre>Matches all arguments and their respective types for a CallExpr or
7319 CXXConstructExpr. It is very similar to forEachArgumentWithParam but
7320 it works on calls through function pointers as well.
7322 The difference is, that function pointers do not provide access to a
7323 ParmVarDecl, but only the QualType for each argument.
7325 Given
7326 void f(int i);
7327 int y;
7328 f(y);
7329 void (*f_ptr)(int) = f;
7330 f_ptr(y);
7331 callExpr(
7332 forEachArgumentWithParamType(
7333 declRefExpr(to(varDecl(hasName("y")))),
7334 qualType(isInteger()).bind("type)
7336 matches f(y) and f_ptr(y)
7337 with declRefExpr(...)
7338 matching int y
7339 and qualType(...)
7340 matching int
7341 </pre></td></tr>
7344 <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>
7345 <tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call
7346 expression, or an ObjC-message-send expression.
7348 Given
7349 void x(int, int, int) { int y; x(1, y, 42); }
7350 callExpr(hasAnyArgument(declRefExpr()))
7351 matches x(1, y, 42)
7352 with hasAnyArgument(...)
7353 matching y
7355 For ObjectiveC, given
7356 @interface I - (void) f:(int) y; @end
7357 void foo(I *i) { [i f:12]; }
7358 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
7359 matches [i f:12]
7360 </pre></td></tr>
7363 <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>
7364 <tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor
7365 call expression.
7367 Example matches y in x(y)
7368 (matcher = callExpr(hasArgument(0, declRefExpr())))
7369 void x(int) { int y; x(y); }
7370 </pre></td></tr>
7373 <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>
7374 <tr><td colspan="4" class="doc" id="hasDeclaration14"><pre>Matches a node if the declaration associated with that node
7375 matches the given matcher.
7377 The associated declaration is:
7378 - for type nodes, the declaration of the underlying type
7379 - for CallExpr, the declaration of the callee
7380 - for MemberExpr, the declaration of the referenced member
7381 - for CXXConstructExpr, the declaration of the constructor
7382 - for CXXNewExpr, the declaration of the operator new
7383 - for ObjCIvarExpr, the declaration of the ivar
7385 For type nodes, hasDeclaration will generally match the declaration of the
7386 sugared type. Given
7387 class X {};
7388 typedef X Y;
7389 Y y;
7390 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7391 typedefDecl. A common use case is to match the underlying, desugared type.
7392 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7393 varDecl(hasType(hasUnqualifiedDesugaredType(
7394 recordType(hasDeclaration(decl())))))
7395 In this matcher, the decl will match the CXXRecordDecl of class X.
7397 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;,
7398 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;,
7399 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;,
7400 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;,
7401 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;,
7402 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;,
7403 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
7404 </pre></td></tr>
7407 <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>
7408 <tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range
7409 extension, matches the constant given in the statement.
7411 Given
7412 switch (1) { case 1: case 1+1: case 3 ... 4: ; }
7413 caseStmt(hasCaseConstant(integerLiteral()))
7414 matches "case 1:"
7415 </pre></td></tr>
7418 <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>
7419 <tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression
7420 or opaque value's source expression matches the given matcher.
7422 Example 1: matches "a string"
7423 (matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
7424 class URL { URL(string); };
7425 URL url = "a string";
7427 Example 2: matches 'b' (matcher =
7428 opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
7429 int a = b ?: 1;
7430 </pre></td></tr>
7433 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;</td><td class="name" onclick="toggle('forEachTemplateArgument0')"><a name="forEachTemplateArgument0Anchor">forEachTemplateArgument</a></td><td>clang::ast_matchers::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
7434 <tr><td colspan="4" class="doc" id="forEachTemplateArgument0"><pre>Matches classTemplateSpecialization, templateSpecializationType and
7435 functionDecl nodes where the template argument matches the inner matcher.
7436 This matcher may produce multiple matches.
7438 Given
7439 template &lt;typename T, unsigned N, unsigned M&gt;
7440 struct Matrix {};
7442 constexpr unsigned R = 2;
7443 Matrix&lt;int, R * 2, R * 4&gt; M;
7445 template &lt;typename T, typename U&gt;
7446 void f(T&amp;&amp; t, U&amp;&amp; u) {}
7448 bool B = false;
7449 f(R, B);
7450 templateSpecializationType(forEachTemplateArgument(isExpr(expr())))
7451 matches twice, with expr() matching 'R * 2' and 'R * 4'
7452 functionDecl(forEachTemplateArgument(refersToType(builtinType())))
7453 matches the specialization f&lt;unsigned, bool&gt; twice, for 'unsigned'
7454 and 'bool'
7455 </pre></td></tr>
7458 <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>
7459 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and
7460 functionDecl that have at least one TemplateArgument matching the given
7461 InnerMatcher.
7463 Given
7464 template&lt;typename T&gt; class A {};
7465 template&lt;&gt; class A&lt;double&gt; {};
7466 A&lt;int&gt; a;
7468 template&lt;typename T&gt; f() {};
7469 void func() { f&lt;int&gt;(); };
7471 classTemplateSpecializationDecl(hasAnyTemplateArgument(
7472 refersToType(asString("int"))))
7473 matches the specialization A&lt;int&gt;
7475 functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
7476 matches the specialization f&lt;int&gt;
7477 </pre></td></tr>
7480 <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>
7481 <tr><td colspan="4" class="doc" id="hasSpecializedTemplate0"><pre>Matches the specialized template of a specialization declaration.
7483 Given
7484 template&lt;typename T&gt; class A {}; #1
7485 template&lt;&gt; class A&lt;int&gt; {}; #2
7486 classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl()))
7487 matches '#2' with classTemplateDecl() matching the class template
7488 declaration of 'A' at #1.
7489 </pre></td></tr>
7492 <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>
7493 <tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and
7494 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
7496 Given
7497 template&lt;typename T, typename U&gt; class A {};
7498 A&lt;bool, int&gt; b;
7499 A&lt;int, bool&gt; c;
7501 template&lt;typename T&gt; void f() {}
7502 void func() { f&lt;int&gt;(); };
7503 classTemplateSpecializationDecl(hasTemplateArgument(
7504 1, refersToType(asString("int"))))
7505 matches the specialization A&lt;bool, int&gt;
7507 functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
7508 matches the specialization f&lt;int&gt;
7509 </pre></td></tr>
7512 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc7')"><a name="hasTypeLoc7Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
7513 <tr><td colspan="4" class="doc" id="hasTypeLoc7"><pre>Matches if the type location of a node matches the inner matcher.
7515 Examples:
7516 int x;
7517 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7518 matches int x
7520 auto x = int(3);
7521 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7522 matches int(3)
7524 struct Foo { Foo(int, int); };
7525 auto x = Foo(1, 2);
7526 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7527 matches Foo(1, 2)
7529 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;,
7530 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;,
7531 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;,
7532 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7533 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7534 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;,
7535 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;,
7536 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7537 </pre></td></tr>
7540 <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>
7541 <tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element
7542 type.
7544 Given
7545 struct A {};
7546 A a[7];
7547 int b[7];
7548 arrayType(hasElementType(builtinType()))
7549 matches "int b[7]"
7551 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;
7552 </pre></td></tr>
7555 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc8')"><a name="hasTypeLoc8Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
7556 <tr><td colspan="4" class="doc" id="hasTypeLoc8"><pre>Matches if the type location of a node matches the inner matcher.
7558 Examples:
7559 int x;
7560 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7561 matches int x
7563 auto x = int(3);
7564 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7565 matches int(3)
7567 struct Foo { Foo(int, int); };
7568 auto x = Foo(1, 2);
7569 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7570 matches Foo(1, 2)
7572 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;,
7573 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;,
7574 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;,
7575 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7576 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7577 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;,
7578 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;,
7579 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7580 </pre></td></tr>
7583 <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>
7584 <tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches
7585 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
7587 Given
7588 { {}; 1+2; }
7589 hasAnySubstatement(compoundStmt())
7590 matches '{ {}; 1+2; }'
7591 with compoundStmt()
7592 matching '{}'
7593 </pre></td></tr>
7596 <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>
7597 <tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whoes decayed type matches InnerMatcher
7598 </pre></td></tr>
7601 <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>
7602 <tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node
7603 matches the given matcher.
7605 The associated declaration is:
7606 - for type nodes, the declaration of the underlying type
7607 - for CallExpr, the declaration of the callee
7608 - for MemberExpr, the declaration of the referenced member
7609 - for CXXConstructExpr, the declaration of the constructor
7610 - for CXXNewExpr, the declaration of the operator new
7611 - for ObjCIvarExpr, the declaration of the ivar
7613 For type nodes, hasDeclaration will generally match the declaration of the
7614 sugared type. Given
7615 class X {};
7616 typedef X Y;
7617 Y y;
7618 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7619 typedefDecl. A common use case is to match the underlying, desugared type.
7620 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7621 varDecl(hasType(hasUnqualifiedDesugaredType(
7622 recordType(hasDeclaration(decl())))))
7623 In this matcher, the decl will match the CXXRecordDecl of class X.
7625 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;,
7626 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;,
7627 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;,
7628 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;,
7629 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;,
7630 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;,
7631 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
7632 </pre></td></tr>
7635 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>&gt;</td><td class="name" onclick="toggle('hasTemplateArgumentLoc0')"><a name="hasTemplateArgumentLoc0Anchor">hasTemplateArgumentLoc</a></td><td>unsigned Index, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt; InnerMatcher</td></tr>
7636 <tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc0"><pre>Matches template specialization `TypeLoc`s where the n'th
7637 `TemplateArgumentLoc` matches the given `InnerMatcher`.
7639 Given
7640 template&lt;typename T, typename U&gt; class A {};
7641 A&lt;double, int&gt; b;
7642 A&lt;int, double&gt; c;
7643 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
7644 hasTypeLoc(loc(asString("double")))))))
7645 matches `A&lt;double, int&gt; b`, but not `A&lt;int, double&gt; c`.
7646 </pre></td></tr>
7649 <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>
7650 <tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches if a node refers to a declaration through a specific
7651 using shadow declaration.
7653 Examples:
7654 namespace a { int f(); }
7655 using a::f;
7656 int x = f();
7657 declRefExpr(throughUsingDecl(anything()))
7658 matches f
7660 namespace a { class X{}; }
7661 using a::X;
7662 X x;
7663 typeLoc(loc(usingType(throughUsingDecl(anything()))))
7664 matches X
7666 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;
7667 </pre></td></tr>
7670 <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>
7671 <tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the
7672 specified matcher.
7674 Example matches x in if(x)
7675 (matcher = declRefExpr(to(varDecl(hasName("x")))))
7676 bool x;
7677 if (x) {}
7678 </pre></td></tr>
7681 <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>
7682 <tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement.
7684 Note that this does not work for global declarations because the AST
7685 breaks up multiple-declaration DeclStmt's into multiple single-declaration
7686 DeclStmt's.
7687 Example: Given non-global declarations
7688 int a, b = 0;
7689 int c;
7690 int d = 2, e;
7691 declStmt(containsDeclaration(
7692 0, varDecl(hasInitializer(anything()))))
7693 matches only 'int d = 2, e;', and
7694 declStmt(containsDeclaration(1, varDecl()))
7695 matches 'int a, b = 0' as well as 'int d = 2, e;'
7696 but 'int c;' is not matched.
7697 </pre></td></tr>
7700 <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>
7701 <tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration.
7703 Given
7704 int a, b;
7705 int c;
7706 declStmt(hasSingleDecl(anything()))
7707 matches 'int c;' but not 'int a, b;'.
7708 </pre></td></tr>
7711 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc9')"><a name="hasTypeLoc9Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
7712 <tr><td colspan="4" class="doc" id="hasTypeLoc9"><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_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, 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_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>
7740 <tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a
7741 Decl, matches InnerMatcher.
7743 Given
7744 namespace N {
7745 namespace M {
7746 class D {};
7750 cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the
7751 declaration of class D.
7752 </pre></td></tr>
7755 <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>
7756 <tr><td colspan="4" class="doc" id="hasUnderlyingType0"><pre>Matches DecltypeType or UsingType nodes to find the underlying type.
7758 Given
7759 decltype(1) a = 1;
7760 decltype(2.0) b = 2.0;
7761 decltypeType(hasUnderlyingType(isInteger()))
7762 matches the type of "a"
7764 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;
7765 </pre></td></tr>
7768 <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>
7769 <tr><td colspan="4" class="doc" id="hasAnyBinding0"><pre>Matches any binding of a DecompositionDecl.
7771 For example, in:
7772 void foo()
7774 int arr[3];
7775 auto &amp;[f, s, t] = arr;
7777 f = 42;
7779 The matcher:
7780 decompositionDecl(hasAnyBinding(bindingDecl(hasName("f").bind("fBinding"))))
7781 matches the decomposition decl with 'f' bound to "fBinding".
7782 </pre></td></tr>
7785 <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>
7786 <tr><td colspan="4" class="doc" id="hasBinding0"><pre>Matches the Nth binding of a DecompositionDecl.
7788 For example, in:
7789 void foo()
7791 int arr[3];
7792 auto &amp;[f, s, t] = arr;
7794 f = 42;
7796 The matcher:
7797 decompositionDecl(hasBinding(0,
7798 bindingDecl(hasName("f").bind("fBinding"))))
7799 matches the decomposition decl with 'f' bound to "fBinding".
7800 </pre></td></tr>
7803 <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>
7804 <tr><td colspan="4" class="doc" id="hasBody0"><pre></pre></td></tr>
7807 <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>
7808 <tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop,
7809 switch statement or conditional operator.
7811 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
7812 if (true) {}
7813 </pre></td></tr>
7816 <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>
7817 <tr><td colspan="4" class="doc" id="hasNamedTypeLoc0"><pre>Matches elaborated `TypeLoc`s that have a named `TypeLoc` matching
7818 `InnerMatcher`.
7820 Given
7821 template &lt;typename T&gt;
7822 class C {};
7823 class C&lt;int&gt; c;
7825 class D {};
7826 class D d;
7827 elaboratedTypeLoc(hasNamedTypeLoc(templateSpecializationTypeLoc()));
7828 matches the `TypeLoc` of the variable declaration of `c`, but not `d`.
7829 </pre></td></tr>
7832 <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>
7833 <tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
7834 matches InnerMatcher if the qualifier exists.
7836 Given
7837 namespace N {
7838 namespace M {
7839 class D {};
7842 N::M::D d;
7844 elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N"))))
7845 matches the type of the variable declaration of d.
7846 </pre></td></tr>
7849 <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>
7850 <tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher.
7852 Given
7853 namespace N {
7854 namespace M {
7855 class D {};
7858 N::M::D d;
7860 elaboratedType(namesType(recordType(
7861 hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable
7862 declaration of d.
7863 </pre></td></tr>
7866 <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>
7867 <tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node
7868 matches the given matcher.
7870 The associated declaration is:
7871 - for type nodes, the declaration of the underlying type
7872 - for CallExpr, the declaration of the callee
7873 - for MemberExpr, the declaration of the referenced member
7874 - for CXXConstructExpr, the declaration of the constructor
7875 - for CXXNewExpr, the declaration of the operator new
7876 - for ObjCIvarExpr, the declaration of the ivar
7878 For type nodes, hasDeclaration will generally match the declaration of the
7879 sugared type. Given
7880 class X {};
7881 typedef X Y;
7882 Y y;
7883 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7884 typedefDecl. A common use case is to match the underlying, desugared type.
7885 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7886 varDecl(hasType(hasUnqualifiedDesugaredType(
7887 recordType(hasDeclaration(decl())))))
7888 In this matcher, the decl will match the CXXRecordDecl of class X.
7890 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;,
7891 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;,
7892 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;,
7893 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;,
7894 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;,
7895 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;,
7896 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
7897 </pre></td></tr>
7900 <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>
7901 <tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher.
7903 (Note: Clang's AST refers to other conversions as "casts" too, and calls
7904 actual casts "explicit" casts.)
7905 </pre></td></tr>
7908 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc10')"><a name="hasTypeLoc10Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
7909 <tr><td colspan="4" class="doc" id="hasTypeLoc10"><pre>Matches if the type location of a node matches the inner matcher.
7911 Examples:
7912 int x;
7913 declaratorDecl(hasTypeLoc(loc(asString("int"))))
7914 matches int x
7916 auto x = int(3);
7917 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
7918 matches int(3)
7920 struct Foo { Foo(int, int); };
7921 auto x = Foo(1, 2);
7922 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
7923 matches Foo(1, 2)
7925 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;,
7926 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;,
7927 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;,
7928 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
7929 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
7930 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;,
7931 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;,
7932 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
7933 </pre></td></tr>
7936 <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>
7937 <tr><td colspan="4" class="doc" id="hasType5"><pre>Overloaded to match the declaration of the expression's or value
7938 declaration's type.
7940 In case of a value declaration (for example a variable declaration),
7941 this resolves one layer of indirection. For example, in the value
7942 declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
7943 X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
7944 declaration of x.
7946 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
7947 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
7948 and friend class X (matcher = friendDecl(hasType("X"))
7949 and public virtual X (matcher = cxxBaseSpecifier(hasType(
7950 cxxRecordDecl(hasName("X"))))
7951 class X {};
7952 void y(X &amp;x) { x; X z; }
7953 class Y { friend class X; };
7954 class Z : public virtual X {};
7956 Example matches class Derived
7957 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
7958 class Base {};
7959 class Derived : Base {};
7961 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;,
7962 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
7963 </pre></td></tr>
7966 <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>
7967 <tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type
7968 matcher.
7970 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
7971 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
7972 and U (matcher = typedefDecl(hasType(asString("int")))
7973 and friend class X (matcher = friendDecl(hasType("X"))
7974 and public virtual X (matcher = cxxBaseSpecifier(hasType(
7975 asString("class X")))
7976 class X {};
7977 void y(X &amp;x) { x; X z; }
7978 typedef int U;
7979 class Y { friend class X; };
7980 class Z : public virtual X {};
7981 </pre></td></tr>
7984 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt;</td><td class="name" onclick="toggle('ignoringElidableConstructorCall0')"><a name="ignoringElidableConstructorCall0Anchor">ignoringElidableConstructorCall</a></td><td>ast_matchers::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
7985 <tr><td colspan="4" class="doc" id="ignoringElidableConstructorCall0"><pre>Matches expressions that match InnerMatcher that are possibly wrapped in an
7986 elidable constructor and other corresponding bookkeeping nodes.
7988 In C++17, elidable copy constructors are no longer being generated in the
7989 AST as it is not permitted by the standard. They are, however, part of the
7990 AST in C++14 and earlier. So, a matcher must abstract over these differences
7991 to work in all language modes. This matcher skips elidable constructor-call
7992 AST nodes, `ExprWithCleanups` nodes wrapping elidable constructor-calls and
7993 various implicit nodes inside the constructor calls, all of which will not
7994 appear in the C++17 AST.
7996 Given
7998 struct H {};
7999 H G();
8000 void f() {
8001 H D = G();
8004 ``varDecl(hasInitializer(ignoringElidableConstructorCall(callExpr())))``
8005 matches ``H D = G()`` in C++11 through C++17 (and beyond).
8006 </pre></td></tr>
8009 <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>
8010 <tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts
8011 are stripped off.
8013 Parentheses and explicit casts are not discarded.
8014 Given
8015 int arr[5];
8016 int a = 0;
8017 char b = 0;
8018 const int c = a;
8019 int *d = arr;
8020 long e = (long) 0l;
8021 The matchers
8022 varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
8023 varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
8024 would match the declarations for a, b, c, and d, but not e.
8025 While
8026 varDecl(hasInitializer(integerLiteral()))
8027 varDecl(hasInitializer(declRefExpr()))
8028 only match the declarations for a.
8029 </pre></td></tr>
8032 <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>
8033 <tr><td colspan="4" class="doc" id="ignoringImplicit0"><pre>Matches expressions that match InnerMatcher after any implicit AST
8034 nodes are stripped off.
8036 Parentheses and explicit casts are not discarded.
8037 Given
8038 class C {};
8039 C a = C();
8040 C b;
8041 C c = b;
8042 The matchers
8043 varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr())))
8044 would match the declarations for a, b, and c.
8045 While
8046 varDecl(hasInitializer(cxxConstructExpr()))
8047 only match the declarations for b and c.
8048 </pre></td></tr>
8051 <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>
8052 <tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and
8053 casts are stripped off.
8055 Implicit and non-C Style casts are also discarded.
8056 Given
8057 int a = 0;
8058 char b = (0);
8059 void* c = reinterpret_cast&lt;char*&gt;(0);
8060 char d = char(0);
8061 The matcher
8062 varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
8063 would match the declarations for a, b, c, and d.
8064 while
8065 varDecl(hasInitializer(integerLiteral()))
8066 only match the declaration for a.
8067 </pre></td></tr>
8070 <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>
8071 <tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and
8072 parentheses are stripped off.
8074 Explicit casts are not discarded.
8075 Given
8076 int arr[5];
8077 int a = 0;
8078 char b = (0);
8079 const int c = a;
8080 int *d = (arr);
8081 long e = ((long) 0l);
8082 The matchers
8083 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
8084 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
8085 would match the declarations for a, b, c, and d, but not e.
8086 while
8087 varDecl(hasInitializer(integerLiteral()))
8088 varDecl(hasInitializer(declRefExpr()))
8089 would only match the declaration for a.
8090 </pre></td></tr>
8093 <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>
8094 <tr><td colspan="4" class="doc" id="ignoringParens1"><pre>Overload ignoringParens for Expr.
8096 Given
8097 const char* str = ("my-string");
8098 The matcher
8099 implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral())))
8100 would match the implicit cast resulting from the assignment.
8101 </pre></td></tr>
8104 <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>
8105 <tr><td colspan="4" class="doc" id="hasInClassInitializer0"><pre>Matches non-static data members that have an in-class initializer.
8107 Given
8108 class C {
8109 int a = 2;
8110 int b = 3;
8111 int c;
8113 fieldDecl(hasInClassInitializer(integerLiteral(equals(2))))
8114 matches 'int a;' but not 'int b;'.
8115 fieldDecl(hasInClassInitializer(anything()))
8116 matches 'int a;' and 'int b;' but not 'int c;'.
8117 </pre></td></tr>
8120 <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>
8121 <tr><td colspan="4" class="doc" id="hasBody1"><pre></pre></td></tr>
8124 <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>
8125 <tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop,
8126 switch statement or conditional operator.
8128 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8129 if (true) {}
8130 </pre></td></tr>
8133 <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>
8134 <tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop.
8136 Example:
8137 forStmt(hasIncrement(unaryOperator(hasOperatorName("++"))))
8138 matches '++x' in
8139 for (x; x &lt; N; ++x) { }
8140 </pre></td></tr>
8143 <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>
8144 <tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop.
8146 Example:
8147 forStmt(hasLoopInit(declStmt()))
8148 matches 'int x = 0' in
8149 for (int x = 0; x &lt; N; ++x) { }
8150 </pre></td></tr>
8153 <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>
8154 <tr><td colspan="4" class="doc" id="hasType6"><pre>Overloaded to match the declaration of the expression's or value
8155 declaration's type.
8157 In case of a value declaration (for example a variable declaration),
8158 this resolves one layer of indirection. For example, in the value
8159 declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
8160 X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
8161 declaration of x.
8163 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
8164 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
8165 and friend class X (matcher = friendDecl(hasType("X"))
8166 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8167 cxxRecordDecl(hasName("X"))))
8168 class X {};
8169 void y(X &amp;x) { x; X z; }
8170 class Y { friend class X; };
8171 class Z : public virtual X {};
8173 Example matches class Derived
8174 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
8175 class Base {};
8176 class Derived : Base {};
8178 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;,
8179 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
8180 </pre></td></tr>
8183 <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>
8184 <tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type
8185 matcher.
8187 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
8188 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
8189 and U (matcher = typedefDecl(hasType(asString("int")))
8190 and friend class X (matcher = friendDecl(hasType("X"))
8191 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8192 asString("class X")))
8193 class X {};
8194 void y(X &amp;x) { x; X z; }
8195 typedef int U;
8196 class Y { friend class X; };
8197 class Z : public virtual X {};
8198 </pre></td></tr>
8201 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>&gt;</td><td class="name" onclick="toggle('forEachTemplateArgument2')"><a name="forEachTemplateArgument2Anchor">forEachTemplateArgument</a></td><td>clang::ast_matchers::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
8202 <tr><td colspan="4" class="doc" id="forEachTemplateArgument2"><pre>Matches classTemplateSpecialization, templateSpecializationType and
8203 functionDecl nodes where the template argument matches the inner matcher.
8204 This matcher may produce multiple matches.
8206 Given
8207 template &lt;typename T, unsigned N, unsigned M&gt;
8208 struct Matrix {};
8210 constexpr unsigned R = 2;
8211 Matrix&lt;int, R * 2, R * 4&gt; M;
8213 template &lt;typename T, typename U&gt;
8214 void f(T&amp;&amp; t, U&amp;&amp; u) {}
8216 bool B = false;
8217 f(R, B);
8218 templateSpecializationType(forEachTemplateArgument(isExpr(expr())))
8219 matches twice, with expr() matching 'R * 2' and 'R * 4'
8220 functionDecl(forEachTemplateArgument(refersToType(builtinType())))
8221 matches the specialization f&lt;unsigned, bool&gt; twice, for 'unsigned'
8222 and 'bool'
8223 </pre></td></tr>
8226 <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>
8227 <tr><td colspan="4" class="doc" id="hasAnyBody0"><pre>Matches a function declaration that has a given body present in the AST.
8228 Note that this matcher matches all the declarations of a function whose
8229 body is present in the AST.
8231 Given
8232 void f();
8233 void f() {}
8234 void g();
8235 functionDecl(hasAnyBody(compoundStmt()))
8236 matches both 'void f();'
8237 and 'void f() {}'
8238 with compoundStmt()
8239 matching '{}'
8240 but does not match 'void g();'
8241 </pre></td></tr>
8244 <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>
8245 <tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function or an ObjC method declaration or a
8246 block.
8248 Does not match the 'this' parameter of a method.
8250 Given
8251 class X { void f(int x, int y, int z) {} };
8252 cxxMethodDecl(hasAnyParameter(hasName("y")))
8253 matches f(int x, int y, int z) {}
8254 with hasAnyParameter(...)
8255 matching int y
8257 For ObjectiveC, given
8258 @interface I - (void) f:(int) y; @end
8260 the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
8261 matches the declaration of method f with hasParameter
8262 matching y.
8264 For blocks, given
8265 b = ^(int y) { printf("%d", y) };
8267 the matcher blockDecl(hasAnyParameter(hasName("y")))
8268 matches the declaration of the block b with hasParameter
8269 matching y.
8270 </pre></td></tr>
8273 <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>
8274 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and
8275 functionDecl that have at least one TemplateArgument matching the given
8276 InnerMatcher.
8278 Given
8279 template&lt;typename T&gt; class A {};
8280 template&lt;&gt; class A&lt;double&gt; {};
8281 A&lt;int&gt; a;
8283 template&lt;typename T&gt; f() {};
8284 void func() { f&lt;int&gt;(); };
8286 classTemplateSpecializationDecl(hasAnyTemplateArgument(
8287 refersToType(asString("int"))))
8288 matches the specialization A&lt;int&gt;
8290 functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
8291 matches the specialization f&lt;int&gt;
8292 </pre></td></tr>
8295 <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>
8296 <tr><td colspan="4" class="doc" id="hasBody4"><pre></pre></td></tr>
8299 <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>
8300 <tr><td colspan="4" class="doc" id="hasExplicitSpecifier0"><pre>Matches the expression in an explicit specifier if present in the given
8301 declaration.
8303 Given
8304 template&lt;bool b&gt;
8305 struct S {
8306 S(int); // #1
8307 explicit S(double); // #2
8308 operator int(); // #3
8309 explicit operator bool(); // #4
8310 explicit(false) S(bool) // # 7
8311 explicit(true) S(char) // # 8
8312 explicit(b) S(S) // # 9
8314 S(int) -&gt; S&lt;true&gt; // #5
8315 explicit S(double) -&gt; S&lt;false&gt; // #6
8316 cxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8 and #9, but not #1 or #2.
8317 cxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or #4.
8318 cxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not match #5 or #6.
8319 </pre></td></tr>
8322 <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>
8323 <tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function or an ObjC method
8324 declaration or a block.
8326 Given
8327 class X { void f(int x) {} };
8328 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
8329 matches f(int x) {}
8330 with hasParameter(...)
8331 matching int x
8333 For ObjectiveC, given
8334 @interface I - (void) f:(int) y; @end
8336 the matcher objcMethodDecl(hasParameter(0, hasName("y")))
8337 matches the declaration of method f with hasParameter
8338 matching y.
8339 </pre></td></tr>
8342 <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>
8343 <tr><td colspan="4" class="doc" id="hasReturnTypeLoc0"><pre>Matches a function declared with the specified return `TypeLoc`.
8345 Given
8346 int f() { return 5; }
8347 void g() {}
8348 functionDecl(hasReturnTypeLoc(loc(asString("int"))))
8349 matches the declaration of `f`, but not `g`.
8350 </pre></td></tr>
8353 <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>
8354 <tr><td colspan="4" class="doc" id="hasTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and
8355 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
8357 Given
8358 template&lt;typename T, typename U&gt; class A {};
8359 A&lt;bool, int&gt; b;
8360 A&lt;int, bool&gt; c;
8362 template&lt;typename T&gt; void f() {}
8363 void func() { f&lt;int&gt;(); };
8364 classTemplateSpecializationDecl(hasTemplateArgument(
8365 1, refersToType(asString("int"))))
8366 matches the specialization A&lt;bool, int&gt;
8368 functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
8369 matches the specialization f&lt;int&gt;
8370 </pre></td></tr>
8373 <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>
8374 <tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration.
8376 Given:
8377 class X { int f() { return 1; } };
8378 cxxMethodDecl(returns(asString("int")))
8379 matches int f() { return 1; }
8380 </pre></td></tr>
8383 <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>
8384 <tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop,
8385 switch statement or conditional operator.
8387 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8388 if (true) {}
8389 </pre></td></tr>
8392 <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>
8393 <tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement.
8395 Given
8396 if (A* a = GetAPointer()) {}
8397 hasConditionVariableStatement(...)
8398 matches 'A* a = GetAPointer()'.
8399 </pre></td></tr>
8402 <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>
8403 <tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement.
8405 Examples matches the if statement
8406 (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true)))))
8407 if (false) false; else true;
8408 </pre></td></tr>
8411 <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>
8412 <tr><td colspan="4" class="doc" id="hasInitStatement0"><pre>Matches selection statements with initializer.
8414 Given:
8415 void foo() {
8416 if (int i = foobar(); i &gt; 0) {}
8417 switch (int i = foobar(); i) {}
8418 for (auto&amp; a = get_range(); auto&amp; x : a) {}
8420 void bar() {
8421 if (foobar() &gt; 0) {}
8422 switch (foobar()) {}
8423 for (auto&amp; x : get_range()) {}
8425 ifStmt(hasInitStatement(anything()))
8426 matches the if statement in foo but not in bar.
8427 switchStmt(hasInitStatement(anything()))
8428 matches the switch statement in foo but not in bar.
8429 cxxForRangeStmt(hasInitStatement(anything()))
8430 matches the range for statement in foo but not in bar.
8431 </pre></td></tr>
8434 <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>
8435 <tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement.
8437 Examples matches the if statement
8438 (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true)))))
8439 if (false) true; else false;
8440 </pre></td></tr>
8443 <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>
8444 <tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given
8445 matcher.
8447 FIXME: Unit test this matcher
8448 </pre></td></tr>
8451 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>&gt;</td><td class="name" onclick="toggle('hasInit0')"><a name="hasInit0Anchor">hasInit</a></td><td>unsigned N, ast_matchers::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>&gt; InnerMatcher</td></tr>
8452 <tr><td colspan="4" class="doc" id="hasInit0"><pre>Matches the n'th item of an initializer list expression.
8454 Example matches y.
8455 (matcher = initListExpr(hasInit(0, expr())))
8456 int x{y}.
8457 </pre></td></tr>
8460 <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>
8461 <tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions
8462 (if expression have it).
8463 </pre></td></tr>
8466 <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>
8467 <tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node
8468 matches the given matcher.
8470 The associated declaration is:
8471 - for type nodes, the declaration of the underlying type
8472 - for CallExpr, the declaration of the callee
8473 - for MemberExpr, the declaration of the referenced member
8474 - for CXXConstructExpr, the declaration of the constructor
8475 - for CXXNewExpr, the declaration of the operator new
8476 - for ObjCIvarExpr, the declaration of the ivar
8478 For type nodes, hasDeclaration will generally match the declaration of the
8479 sugared type. Given
8480 class X {};
8481 typedef X Y;
8482 Y y;
8483 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8484 typedefDecl. A common use case is to match the underlying, desugared type.
8485 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8486 varDecl(hasType(hasUnqualifiedDesugaredType(
8487 recordType(hasDeclaration(decl())))))
8488 In this matcher, the decl will match the CXXRecordDecl of class X.
8490 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;,
8491 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;,
8492 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;,
8493 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;,
8494 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;,
8495 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;,
8496 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
8497 </pre></td></tr>
8500 <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>
8501 <tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node
8502 matches the given matcher.
8504 The associated declaration is:
8505 - for type nodes, the declaration of the underlying type
8506 - for CallExpr, the declaration of the callee
8507 - for MemberExpr, the declaration of the referenced member
8508 - for CXXConstructExpr, the declaration of the constructor
8509 - for CXXNewExpr, the declaration of the operator new
8510 - for ObjCIvarExpr, the declaration of the ivar
8512 For type nodes, hasDeclaration will generally match the declaration of the
8513 sugared type. Given
8514 class X {};
8515 typedef X Y;
8516 Y y;
8517 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8518 typedefDecl. A common use case is to match the underlying, desugared type.
8519 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8520 varDecl(hasType(hasUnqualifiedDesugaredType(
8521 recordType(hasDeclaration(decl())))))
8522 In this matcher, the decl will match the CXXRecordDecl of class X.
8524 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;,
8525 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;,
8526 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;,
8527 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;,
8528 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;,
8529 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;,
8530 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
8531 </pre></td></tr>
8534 <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_1VarDecl.html">VarDecl</a>&gt; InnerMatcher</td></tr>
8535 <tr><td colspan="4" class="doc" id="capturesVar0"><pre>Matches a `LambdaCapture` that refers to the specified `VarDecl`. The
8536 `VarDecl` can be a separate variable that is captured by value or
8537 reference, or a synthesized variable if the capture has an initializer.
8539 Given
8540 void foo() {
8541 int x;
8542 auto f = [x](){};
8543 auto g = [x = 1](){};
8545 In the matcher
8546 lambdaExpr(hasAnyCapture(lambdaCapture(capturesVar(hasName("x")))),
8547 capturesVar(hasName("x")) matches `x` and `x = 1`.
8548 </pre></td></tr>
8551 <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>
8552 <tr><td colspan="4" class="doc" id="forEachLambdaCapture0"><pre>Matches each lambda capture in a lambda expression.
8554 Given
8555 int main() {
8556 int x, y;
8557 float z;
8558 auto f = [=]() { return x + y + z; };
8560 lambdaExpr(forEachLambdaCapture(
8561 lambdaCapture(capturesVar(varDecl(hasType(isInteger()))))))
8562 will trigger two matches, binding for 'x' and 'y' respectively.
8563 </pre></td></tr>
8566 <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>
8567 <tr><td colspan="4" class="doc" id="hasAnyCapture0"><pre>Matches any capture in a lambda expression.
8569 Given
8570 void foo() {
8571 int t = 5;
8572 auto f = [=](){ return t; };
8574 lambdaExpr(hasAnyCapture(lambdaCapture())) and
8575 lambdaExpr(hasAnyCapture(lambdaCapture(refersToVarDecl(hasName("t")))))
8576 both match `[=](){ return t; }`.
8577 </pre></td></tr>
8580 <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>
8581 <tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node
8582 matches the given matcher.
8584 The associated declaration is:
8585 - for type nodes, the declaration of the underlying type
8586 - for CallExpr, the declaration of the callee
8587 - for MemberExpr, the declaration of the referenced member
8588 - for CXXConstructExpr, the declaration of the constructor
8589 - for CXXNewExpr, the declaration of the operator new
8590 - for ObjCIvarExpr, the declaration of the ivar
8592 For type nodes, hasDeclaration will generally match the declaration of the
8593 sugared type. Given
8594 class X {};
8595 typedef X Y;
8596 Y y;
8597 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8598 typedefDecl. A common use case is to match the underlying, desugared type.
8599 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8600 varDecl(hasType(hasUnqualifiedDesugaredType(
8601 recordType(hasDeclaration(decl())))))
8602 In this matcher, the decl will match the CXXRecordDecl of class X.
8604 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;,
8605 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;,
8606 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;,
8607 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;,
8608 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;,
8609 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;,
8610 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
8611 </pre></td></tr>
8614 <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>
8615 <tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is matched by a
8616 given matcher. Implicit object expressions are included; that is, it matches
8617 use of implicit `this`.
8619 Given
8620 struct X {
8621 int m;
8622 int f(X x) { x.m; return m; }
8624 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))
8625 matches `x.m`, but not `m`; however,
8626 memberExpr(hasObjectExpression(hasType(pointsTo(
8627 cxxRecordDecl(hasName("X"))))))
8628 matches `m` (aka. `this-&gt;m`), but not `x.m`.
8629 </pre></td></tr>
8632 <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>
8633 <tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a
8634 given matcher.
8636 Given
8637 struct { int first, second; } first, second;
8638 int i(second.first);
8639 int j(first.second);
8640 memberExpr(member(hasName("first")))
8641 matches second.first
8642 but not first.second (because the member name there is "second").
8643 </pre></td></tr>
8646 <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>
8647 <tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the
8648 pointee matches a given matcher.
8650 Given
8651 int *a;
8652 int const *b;
8653 float const *f;
8654 pointerType(pointee(isConstQualified(), isInteger()))
8655 matches "int const *b"
8657 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;,
8658 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;
8659 </pre></td></tr>
8662 <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>
8663 <tr><td colspan="4" class="doc" id="hasUnderlyingDecl0"><pre>Matches a NamedDecl whose underlying declaration matches the given
8664 matcher.
8666 Given
8667 namespace N { template&lt;class T&gt; void f(T t); }
8668 template &lt;class T&gt; void g() { using N::f; f(T()); }
8669 unresolvedLookupExpr(hasAnyDeclaration(
8670 namedDecl(hasUnderlyingDecl(hasName("::N::f")))))
8671 matches the use of f in g() .
8672 </pre></td></tr>
8675 <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>
8676 <tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc.
8678 Given
8679 struct A { struct B { struct C {}; }; };
8680 A::B::C c;
8681 nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A")))))
8682 matches "A::"
8683 </pre></td></tr>
8686 <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>
8687 <tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner
8688 NestedNameSpecifier-matcher matches.
8689 </pre></td></tr>
8692 <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>
8693 <tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the
8694 given TypeLoc.
8696 Given
8697 struct A { struct B { struct C {}; }; };
8698 A::B::C c;
8699 nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
8700 hasDeclaration(cxxRecordDecl(hasName("A")))))))
8701 matches "A::"
8702 </pre></td></tr>
8705 <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>
8706 <tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier.
8708 Given
8709 struct A { struct B { struct C {}; }; };
8710 A::B::C c;
8711 nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and
8712 matches "A::"
8713 </pre></td></tr>
8716 <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>
8717 <tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the
8718 given namespace matcher.
8720 Given
8721 namespace ns { struct A {}; }
8722 ns::A a;
8723 nestedNameSpecifier(specifiesNamespace(hasName("ns")))
8724 matches "ns::"
8725 </pre></td></tr>
8728 <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>
8729 <tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the
8730 given QualType matcher without qualifiers.
8732 Given
8733 struct A { struct B { struct C {}; }; };
8734 A::B::C c;
8735 nestedNameSpecifier(specifiesType(
8736 hasDeclaration(cxxRecordDecl(hasName("A")))
8738 matches "A::"
8739 </pre></td></tr>
8742 <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>
8743 <tr><td colspan="4" class="doc" id="hasAnyClause0"><pre>Matches any clause in an OpenMP directive.
8745 Given
8747 #pragma omp parallel
8748 #pragma omp parallel default(none)
8750 ``ompExecutableDirective(hasAnyClause(anything()))`` matches
8751 ``omp parallel default(none)``.
8752 </pre></td></tr>
8755 <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>
8756 <tr><td colspan="4" class="doc" id="hasStructuredBlock0"><pre>Matches the structured-block of the OpenMP executable directive
8758 Prerequisite: the executable directive must not be standalone directive.
8759 If it is, it will never match.
8761 Given
8763 #pragma omp parallel
8765 #pragma omp parallel
8768 ``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;``
8769 </pre></td></tr>
8772 <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>
8773 <tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Matches C++ classes that are directly or indirectly derived from a class
8774 matching Base, or Objective-C classes that directly or indirectly
8775 subclass a class matching Base.
8777 Note that a class is not considered to be derived from itself.
8779 Example matches Y, Z, C (Base == hasName("X"))
8780 class X;
8781 class Y : public X {}; // directly derived
8782 class Z : public Y {}; // indirectly derived
8783 typedef X A;
8784 typedef A B;
8785 class C : public B {}; // derived from a typedef of X
8787 In the following example, Bar matches isDerivedFrom(hasName("X")):
8788 class Foo;
8789 typedef Foo X;
8790 class Bar : public Foo {}; // derived from a type that X is a typedef of
8792 In the following example, Bar matches isDerivedFrom(hasName("NSObject"))
8793 @interface NSObject @end
8794 @interface Bar : NSObject @end
8796 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;
8797 </pre></td></tr>
8800 <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>
8801 <tr><td colspan="4" class="doc" id="isDirectlyDerivedFrom1"><pre>Matches C++ or Objective-C classes that are directly derived from a class
8802 matching Base.
8804 Note that a class is not considered to be derived from itself.
8806 Example matches Y, C (Base == hasName("X"))
8807 class X;
8808 class Y : public X {}; // directly derived
8809 class Z : public Y {}; // indirectly derived
8810 typedef X A;
8811 typedef A B;
8812 class C : public B {}; // derived from a typedef of X
8814 In the following example, Bar matches isDerivedFrom(hasName("X")):
8815 class Foo;
8816 typedef Foo X;
8817 class Bar : public Foo {}; // derived from a type that X is a typedef of
8818 </pre></td></tr>
8821 <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>
8822 <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Similar to isDerivedFrom(), but also matches classes that directly
8823 match Base.
8824 </pre></td></tr>
8827 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>&gt;</td><td class="name" onclick="toggle('callee1')"><a name="callee1Anchor">callee</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>&gt; InnerMatcher</td></tr>
8828 <tr><td colspan="4" class="doc" id="callee1"><pre>Matches 1) if the call expression's callee's declaration matches the
8829 given matcher; or 2) if the Obj-C message expression's callee's method
8830 declaration matches the given matcher.
8832 Example matches y.x() (matcher = callExpr(callee(
8833 cxxMethodDecl(hasName("x")))))
8834 class Y { public: void x(); };
8835 void z() { Y y; y.x(); }
8837 Example 2. Matches [I foo] with
8838 objcMessageExpr(callee(objcMethodDecl(hasName("foo"))))
8840 @interface I: NSObject
8841 +(void)foo;
8842 @end
8844 [I foo]
8845 </pre></td></tr>
8848 <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>
8849 <tr><td colspan="4" class="doc" id="hasAnyArgument3"><pre>Matches any argument of a call expression or a constructor call
8850 expression, or an ObjC-message-send expression.
8852 Given
8853 void x(int, int, int) { int y; x(1, y, 42); }
8854 callExpr(hasAnyArgument(declRefExpr()))
8855 matches x(1, y, 42)
8856 with hasAnyArgument(...)
8857 matching y
8859 For ObjectiveC, given
8860 @interface I - (void) f:(int) y; @end
8861 void foo(I *i) { [i f:12]; }
8862 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
8863 matches [i f:12]
8864 </pre></td></tr>
8867 <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>
8868 <tr><td colspan="4" class="doc" id="hasArgument3"><pre>Matches the n'th argument of a call expression or a constructor
8869 call expression.
8871 Example matches y in x(y)
8872 (matcher = callExpr(hasArgument(0, declRefExpr())))
8873 void x(int) { int y; x(y); }
8874 </pre></td></tr>
8877 <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>
8878 <tr><td colspan="4" class="doc" id="hasReceiver0"><pre>Matches if the Objective-C message is sent to an instance,
8879 and the inner matcher matches on that instance.
8881 For example the method call in
8882 NSString *x = @"hello";
8883 [x containsString:@"h"];
8884 is matched by
8885 objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x"))))))
8886 </pre></td></tr>
8889 <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>
8890 <tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression.
8892 Example
8893 matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *")));
8894 matches the [webView ...] message invocation.
8895 NSString *webViewJavaScript = ...
8896 UIWebView *webView = ...
8897 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript];
8898 </pre></td></tr>
8901 <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>
8902 <tr><td colspan="4" class="doc" id="hasAnyParameter1"><pre>Matches any parameter of a function or an ObjC method declaration or a
8903 block.
8905 Does not match the 'this' parameter of a method.
8907 Given
8908 class X { void f(int x, int y, int z) {} };
8909 cxxMethodDecl(hasAnyParameter(hasName("y")))
8910 matches f(int x, int y, int z) {}
8911 with hasAnyParameter(...)
8912 matching int y
8914 For ObjectiveC, given
8915 @interface I - (void) f:(int) y; @end
8917 the matcher objcMethodDecl(hasAnyParameter(hasName("y")))
8918 matches the declaration of method f with hasParameter
8919 matching y.
8921 For blocks, given
8922 b = ^(int y) { printf("%d", y) };
8924 the matcher blockDecl(hasAnyParameter(hasName("y")))
8925 matches the declaration of the block b with hasParameter
8926 matching y.
8927 </pre></td></tr>
8930 <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>
8931 <tr><td colspan="4" class="doc" id="hasParameter1"><pre>Matches the n'th parameter of a function or an ObjC method
8932 declaration or a block.
8934 Given
8935 class X { void f(int x) {} };
8936 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
8937 matches f(int x) {}
8938 with hasParameter(...)
8939 matching int x
8941 For ObjectiveC, given
8942 @interface I - (void) f:(int) y; @end
8944 the matcher objcMethodDecl(hasParameter(0, hasName("y")))
8945 matches the declaration of method f with hasParameter
8946 matching y.
8947 </pre></td></tr>
8950 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc11')"><a name="hasTypeLoc11Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
8951 <tr><td colspan="4" class="doc" id="hasTypeLoc11"><pre>Matches if the type location of a node matches the inner matcher.
8953 Examples:
8954 int x;
8955 declaratorDecl(hasTypeLoc(loc(asString("int"))))
8956 matches int x
8958 auto x = int(3);
8959 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
8960 matches int(3)
8962 struct Foo { Foo(int, int); };
8963 auto x = Foo(1, 2);
8964 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
8965 matches Foo(1, 2)
8967 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;,
8968 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;,
8969 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;,
8970 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
8971 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
8972 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;,
8973 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;,
8974 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
8975 </pre></td></tr>
8978 <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>
8979 <tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre>Matches if the cast's source expression
8980 or opaque value's source expression matches the given matcher.
8982 Example 1: matches "a string"
8983 (matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
8984 class URL { URL(string); };
8985 URL url = "a string";
8987 Example 2: matches 'b' (matcher =
8988 opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
8989 int a = b ?: 1;
8990 </pre></td></tr>
8993 <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>
8994 <tr><td colspan="4" class="doc" id="hasAnyDeclaration0"><pre>Matches an OverloadExpr if any of the declarations in the set of
8995 overloads matches the given matcher.
8997 Given
8998 template &lt;typename T&gt; void foo(T);
8999 template &lt;typename T&gt; void bar(T);
9000 template &lt;typename T&gt; void baz(T t) {
9001 foo(t);
9002 bar(t);
9004 unresolvedLookupExpr(hasAnyDeclaration(
9005 functionTemplateDecl(hasName("foo"))))
9006 matches foo in foo(t); but not bar in bar(t);
9007 </pre></td></tr>
9010 <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>
9011 <tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type.
9013 Given
9014 int (*ptr_to_array)[4];
9015 int (*ptr_to_func)(int);
9017 varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
9018 ptr_to_func but not ptr_to_array.
9020 Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>&gt;
9021 </pre></td></tr>
9024 <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>
9025 <tr><td colspan="4" class="doc" id="hasPointeeLoc0"><pre>Matches pointer `TypeLoc`s that have a pointee `TypeLoc` matching
9026 `PointeeMatcher`.
9028 Given
9029 int* x;
9030 pointerTypeLoc(hasPointeeLoc(loc(asString("int"))))
9031 matches `int*`.
9032 </pre></td></tr>
9035 <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>
9036 <tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the
9037 pointee matches a given matcher.
9039 Given
9040 int *a;
9041 int const *b;
9042 float const *f;
9043 pointerType(pointee(isConstQualified(), isInteger()))
9044 matches "int const *b"
9046 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;,
9047 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;
9048 </pre></td></tr>
9051 <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>
9052 <tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher.
9054 Given:
9055 typedef int &amp;int_ref;
9056 int a;
9057 int_ref b = a;
9059 varDecl(hasType(qualType(referenceType()))))) will not match the
9060 declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does.
9061 </pre></td></tr>
9064 <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>
9065 <tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node
9066 matches the given matcher.
9068 The associated declaration is:
9069 - for type nodes, the declaration of the underlying type
9070 - for CallExpr, the declaration of the callee
9071 - for MemberExpr, the declaration of the referenced member
9072 - for CXXConstructExpr, the declaration of the constructor
9073 - for CXXNewExpr, the declaration of the operator new
9074 - for ObjCIvarExpr, the declaration of the ivar
9076 For type nodes, hasDeclaration will generally match the declaration of the
9077 sugared type. Given
9078 class X {};
9079 typedef X Y;
9080 Y y;
9081 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9082 typedefDecl. A common use case is to match the underlying, desugared type.
9083 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9084 varDecl(hasType(hasUnqualifiedDesugaredType(
9085 recordType(hasDeclaration(decl())))))
9086 In this matcher, the decl will match the CXXRecordDecl of class X.
9088 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;,
9089 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;,
9090 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;,
9091 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;,
9092 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;,
9093 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;,
9094 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9095 </pre></td></tr>
9098 <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>
9099 <tr><td colspan="4" class="doc" id="ignoringParens0"><pre>Matches types that match InnerMatcher after any parens are stripped.
9101 Given
9102 void (*fp)(void);
9103 The matcher
9104 varDecl(hasType(pointerType(pointee(ignoringParens(functionType())))))
9105 would match the declaration for fp.
9106 </pre></td></tr>
9109 <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>
9110 <tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration.
9111 </pre></td></tr>
9114 <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>
9115 <tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type
9116 matches the specified matcher.
9118 Example matches y-&gt;x()
9119 (matcher = cxxMemberCallExpr(on(hasType(pointsTo
9120 cxxRecordDecl(hasName("Y")))))))
9121 class Y { public: void x(); };
9122 void z() { Y *y; y-&gt;x(); }
9123 </pre></td></tr>
9126 <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>
9127 <tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration.
9128 </pre></td></tr>
9131 <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>
9132 <tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced
9133 type matches the specified matcher.
9135 Example matches X &amp;x and const X &amp;y
9136 (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X"))))))
9137 class X {
9138 void a(X b) {
9139 X &amp;x = b;
9140 const X &amp;y = b;
9143 </pre></td></tr>
9146 <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>
9147 <tr><td colspan="4" class="doc" id="hasUnqualifiedLoc0"><pre>Matches `QualifiedTypeLoc`s that have an unqualified `TypeLoc` matching
9148 `InnerMatcher`.
9150 Given
9151 int* const x;
9152 const int y;
9153 qualifiedTypeLoc(hasUnqualifiedLoc(pointerTypeLoc()))
9154 matches the `TypeLoc` of the variable declaration of `x`, but not `y`.
9155 </pre></td></tr>
9158 <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>
9159 <tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node
9160 matches the given matcher.
9162 The associated declaration is:
9163 - for type nodes, the declaration of the underlying type
9164 - for CallExpr, the declaration of the callee
9165 - for MemberExpr, the declaration of the referenced member
9166 - for CXXConstructExpr, the declaration of the constructor
9167 - for CXXNewExpr, the declaration of the operator new
9168 - for ObjCIvarExpr, the declaration of the ivar
9170 For type nodes, hasDeclaration will generally match the declaration of the
9171 sugared type. Given
9172 class X {};
9173 typedef X Y;
9174 Y y;
9175 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9176 typedefDecl. A common use case is to match the underlying, desugared type.
9177 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9178 varDecl(hasType(hasUnqualifiedDesugaredType(
9179 recordType(hasDeclaration(decl())))))
9180 In this matcher, the decl will match the CXXRecordDecl of class X.
9182 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;,
9183 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;,
9184 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;,
9185 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;,
9186 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;,
9187 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;,
9188 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9189 </pre></td></tr>
9192 <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>
9193 <tr><td colspan="4" class="doc" id="hasReferentLoc0"><pre>Matches reference `TypeLoc`s that have a referent `TypeLoc` matching
9194 `ReferentMatcher`.
9196 Given
9197 int x = 3;
9198 int&amp; xx = x;
9199 referenceTypeLoc(hasReferentLoc(loc(asString("int"))))
9200 matches `int&amp;`.
9201 </pre></td></tr>
9204 <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>
9205 <tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the
9206 pointee matches a given matcher.
9208 Given
9209 int *a;
9210 int const *b;
9211 float const *f;
9212 pointerType(pointee(isConstQualified(), isInteger()))
9213 matches "int const *b"
9215 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;,
9216 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;
9217 </pre></td></tr>
9220 <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>
9221 <tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement
9223 Given
9224 return a + b;
9225 hasReturnValue(binaryOperator())
9226 matches 'return a + b'
9227 with binaryOperator()
9228 matching 'a + b'
9229 </pre></td></tr>
9232 <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>
9233 <tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches
9234 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
9236 Given
9237 { {}; 1+2; }
9238 hasAnySubstatement(compoundStmt())
9239 matches '{ {}; 1+2; }'
9240 with compoundStmt()
9241 matching '{}'
9242 </pre></td></tr>
9245 <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>
9246 <tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
9247 alignof.
9248 </pre></td></tr>
9251 <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>
9252 <tr><td colspan="4" class="doc" id="forCallable0"><pre>Matches declaration of the function, method, or block the statement
9253 belongs to.
9255 Given:
9256 F&amp; operator=(const F&amp; o) {
9257 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v &gt; 0; });
9258 return *this;
9260 returnStmt(forCallable(functionDecl(hasName("operator="))))
9261 matches 'return *this'
9262 but does not match 'return v &gt; 0'
9264 Given:
9265 -(void) foo {
9266 int x = 1;
9267 dispatch_sync(queue, ^{ int y = 2; });
9269 declStmt(forCallable(objcMethodDecl()))
9270 matches 'int x = 1'
9271 but does not match 'int y = 2'.
9272 whereas declStmt(forCallable(blockDecl()))
9273 matches 'int y = 2'
9274 but does not match 'int x = 1'.
9275 </pre></td></tr>
9278 <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>
9279 <tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statement belongs to.
9281 Deprecated. Use forCallable() to correctly handle the situation when
9282 the declaration is not a function (but a block or an Objective-C method).
9283 forFunction() not only fails to take non-functions into account but also
9284 may match the wrong declaration in their presence.
9286 Given:
9287 F&amp; operator=(const F&amp; o) {
9288 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v &gt; 0; });
9289 return *this;
9291 returnStmt(forFunction(hasName("operator=")))
9292 matches 'return *this'
9293 but does not match 'return v &gt; 0'
9294 </pre></td></tr>
9297 <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>
9298 <tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
9299 sizeof.
9300 </pre></td></tr>
9303 <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>
9304 <tr><td colspan="4" class="doc" id="hasReplacementType0"><pre>Matches template type parameter substitutions that have a replacement
9305 type that matches the provided matcher.
9307 Given
9308 template &lt;typename T&gt;
9309 double F(T t);
9310 int i;
9311 double j = F(i);
9313 substTemplateTypeParmType(hasReplacementType(type())) matches int
9314 </pre></td></tr>
9317 <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>
9318 <tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch
9319 statement. This matcher may produce multiple matches.
9321 Given
9322 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }
9323 switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s")
9324 matches four times, with "c" binding each of "case 1:", "case 2:",
9325 "case 3:" and "case 4:", and "s" respectively binding "switch (1)",
9326 "switch (1)", "switch (2)" and "switch (2)".
9327 </pre></td></tr>
9330 <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>
9331 <tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop,
9332 switch statement or conditional operator.
9334 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
9335 if (true) {}
9336 </pre></td></tr>
9339 <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>
9340 <tr><td colspan="4" class="doc" id="hasInitStatement1"><pre>Matches selection statements with initializer.
9342 Given:
9343 void foo() {
9344 if (int i = foobar(); i &gt; 0) {}
9345 switch (int i = foobar(); i) {}
9346 for (auto&amp; a = get_range(); auto&amp; x : a) {}
9348 void bar() {
9349 if (foobar() &gt; 0) {}
9350 switch (foobar()) {}
9351 for (auto&amp; x : get_range()) {}
9353 ifStmt(hasInitStatement(anything()))
9354 matches the if statement in foo but not in bar.
9355 switchStmt(hasInitStatement(anything()))
9356 matches the switch statement in foo but not in bar.
9357 cxxForRangeStmt(hasInitStatement(anything()))
9358 matches the range for statement in foo but not in bar.
9359 </pre></td></tr>
9362 <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>
9363 <tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node
9364 matches the given matcher.
9366 The associated declaration is:
9367 - for type nodes, the declaration of the underlying type
9368 - for CallExpr, the declaration of the callee
9369 - for MemberExpr, the declaration of the referenced member
9370 - for CXXConstructExpr, the declaration of the constructor
9371 - for CXXNewExpr, the declaration of the operator new
9372 - for ObjCIvarExpr, the declaration of the ivar
9374 For type nodes, hasDeclaration will generally match the declaration of the
9375 sugared type. Given
9376 class X {};
9377 typedef X Y;
9378 Y y;
9379 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9380 typedefDecl. A common use case is to match the underlying, desugared type.
9381 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9382 varDecl(hasType(hasUnqualifiedDesugaredType(
9383 recordType(hasDeclaration(decl())))))
9384 In this matcher, the decl will match the CXXRecordDecl of class X.
9386 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;,
9387 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;,
9388 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;,
9389 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;,
9390 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;,
9391 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;,
9392 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9393 </pre></td></tr>
9396 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc12')"><a name="hasTypeLoc12Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
9397 <tr><td colspan="4" class="doc" id="hasTypeLoc12"><pre>Matches if the type location of a node matches the inner matcher.
9399 Examples:
9400 int x;
9401 declaratorDecl(hasTypeLoc(loc(asString("int"))))
9402 matches int x
9404 auto x = int(3);
9405 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
9406 matches int(3)
9408 struct Foo { Foo(int, int); };
9409 auto x = Foo(1, 2);
9410 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
9411 matches Foo(1, 2)
9413 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;,
9414 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;,
9415 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;,
9416 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
9417 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
9418 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;,
9419 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;,
9420 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
9421 </pre></td></tr>
9424 <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>
9425 <tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression.
9427 Given
9428 struct B { int next; };
9429 template&lt;int(B::*next_ptr)&gt; struct A {};
9430 A&lt;&amp;B::next&gt; a;
9431 templateSpecializationType(hasAnyTemplateArgument(
9432 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next"))))))))
9433 matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
9434 B::next
9435 </pre></td></tr>
9438 <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>
9439 <tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain
9440 declaration.
9442 Given
9443 struct B { int next; };
9444 template&lt;int(B::*next_ptr)&gt; struct A {};
9445 A&lt;&amp;B::next&gt; a;
9446 classTemplateSpecializationDecl(hasAnyTemplateArgument(
9447 refersToDeclaration(fieldDecl(hasName("next")))))
9448 matches the specialization A&lt;&amp;B::next&gt; with fieldDecl(...) matching
9449 B::next
9450 </pre></td></tr>
9453 <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>
9454 <tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that refers to an integral type.
9456 Given
9457 template&lt;int T&gt; struct C {};
9458 C&lt;42&gt; c;
9459 classTemplateSpecializationDecl(
9460 hasAnyTemplateArgument(refersToIntegralType(asString("int"))))
9461 matches the implicit instantiation of C in C&lt;42&gt;.
9462 </pre></td></tr>
9465 <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>
9466 <tr><td colspan="4" class="doc" id="refersToTemplate0"><pre>Matches a TemplateArgument that refers to a certain template.
9468 Given
9469 template&lt;template &lt;typename&gt; class S&gt; class X {};
9470 template&lt;typename T&gt; class Y {};
9471 X&lt;Y&gt; xi;
9472 classTemplateSpecializationDecl(hasAnyTemplateArgument(
9473 refersToTemplate(templateName())))
9474 matches the specialization X&lt;Y&gt;
9475 </pre></td></tr>
9478 <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>
9479 <tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type.
9481 Given
9482 struct X {};
9483 template&lt;typename T&gt; struct A {};
9484 A&lt;X&gt; a;
9485 classTemplateSpecializationDecl(hasAnyTemplateArgument(
9486 refersToType(class(hasName("X")))))
9487 matches the specialization A&lt;X&gt;
9488 </pre></td></tr>
9491 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>&gt;</td><td class="name" onclick="toggle('hasAnyTemplateArgumentLoc0')"><a name="hasAnyTemplateArgumentLoc0Anchor">hasAnyTemplateArgumentLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt; InnerMatcher</td></tr>
9492 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgumentLoc0"><pre>Matches template specialization `TypeLoc`s that have at least one
9493 `TemplateArgumentLoc` matching the given `InnerMatcher`.
9495 Given
9496 template&lt;typename T&gt; class A {};
9497 A&lt;int&gt; a;
9498 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc(
9499 hasTypeLoc(loc(asString("int")))))))
9500 matches `A&lt;int&gt; a`.
9501 </pre></td></tr>
9504 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc</a>&gt;</td><td class="name" onclick="toggle('hasTemplateArgumentLoc1')"><a name="hasTemplateArgumentLoc1Anchor">hasTemplateArgumentLoc</a></td><td>unsigned Index, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt; InnerMatcher</td></tr>
9505 <tr><td colspan="4" class="doc" id="hasTemplateArgumentLoc1"><pre>Matches template specialization `TypeLoc`s where the n'th
9506 `TemplateArgumentLoc` matches the given `InnerMatcher`.
9508 Given
9509 template&lt;typename T, typename U&gt; class A {};
9510 A&lt;double, int&gt; b;
9511 A&lt;int, double&gt; c;
9512 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
9513 hasTypeLoc(loc(asString("double")))))))
9514 matches `A&lt;double, int&gt; b`, but not `A&lt;int, double&gt; c`.
9515 </pre></td></tr>
9518 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('forEachTemplateArgument1')"><a name="forEachTemplateArgument1Anchor">forEachTemplateArgument</a></td><td>clang::ast_matchers::Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
9519 <tr><td colspan="4" class="doc" id="forEachTemplateArgument1"><pre>Matches classTemplateSpecialization, templateSpecializationType and
9520 functionDecl nodes where the template argument matches the inner matcher.
9521 This matcher may produce multiple matches.
9523 Given
9524 template &lt;typename T, unsigned N, unsigned M&gt;
9525 struct Matrix {};
9527 constexpr unsigned R = 2;
9528 Matrix&lt;int, R * 2, R * 4&gt; M;
9530 template &lt;typename T, typename U&gt;
9531 void f(T&amp;&amp; t, U&amp;&amp; u) {}
9533 bool B = false;
9534 f(R, B);
9535 templateSpecializationType(forEachTemplateArgument(isExpr(expr())))
9536 matches twice, with expr() matching 'R * 2' and 'R * 4'
9537 functionDecl(forEachTemplateArgument(refersToType(builtinType())))
9538 matches the specialization f&lt;unsigned, bool&gt; twice, for 'unsigned'
9539 and 'bool'
9540 </pre></td></tr>
9543 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('hasAnyTemplateArgument1')"><a name="hasAnyTemplateArgument1Anchor">hasAnyTemplateArgument</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
9544 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and
9545 functionDecl that have at least one TemplateArgument matching the given
9546 InnerMatcher.
9548 Given
9549 template&lt;typename T&gt; class A {};
9550 template&lt;&gt; class A&lt;double&gt; {};
9551 A&lt;int&gt; a;
9553 template&lt;typename T&gt; f() {};
9554 void func() { f&lt;int&gt;(); };
9556 classTemplateSpecializationDecl(hasAnyTemplateArgument(
9557 refersToType(asString("int"))))
9558 matches the specialization A&lt;int&gt;
9560 functionDecl(hasAnyTemplateArgument(refersToType(asString("int"))))
9561 matches the specialization f&lt;int&gt;
9562 </pre></td></tr>
9565 <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>
9566 <tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node
9567 matches the given matcher.
9569 The associated declaration is:
9570 - for type nodes, the declaration of the underlying type
9571 - for CallExpr, the declaration of the callee
9572 - for MemberExpr, the declaration of the referenced member
9573 - for CXXConstructExpr, the declaration of the constructor
9574 - for CXXNewExpr, the declaration of the operator new
9575 - for ObjCIvarExpr, the declaration of the ivar
9577 For type nodes, hasDeclaration will generally match the declaration of the
9578 sugared type. Given
9579 class X {};
9580 typedef X Y;
9581 Y y;
9582 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9583 typedefDecl. A common use case is to match the underlying, desugared type.
9584 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9585 varDecl(hasType(hasUnqualifiedDesugaredType(
9586 recordType(hasDeclaration(decl())))))
9587 In this matcher, the decl will match the CXXRecordDecl of class X.
9589 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;,
9590 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;,
9591 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;,
9592 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;,
9593 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;,
9594 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;,
9595 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9596 </pre></td></tr>
9599 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>&gt;</td><td class="name" onclick="toggle('hasTemplateArgument1')"><a name="hasTemplateArgument1Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>&gt; InnerMatcher</td></tr>
9600 <tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and
9601 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
9603 Given
9604 template&lt;typename T, typename U&gt; class A {};
9605 A&lt;bool, int&gt; b;
9606 A&lt;int, bool&gt; c;
9608 template&lt;typename T&gt; void f() {}
9609 void func() { f&lt;int&gt;(); };
9610 classTemplateSpecializationDecl(hasTemplateArgument(
9611 1, refersToType(asString("int"))))
9612 matches the specialization A&lt;bool, int&gt;
9614 functionDecl(hasTemplateArgument(0, refersToType(asString("int"))))
9615 matches the specialization f&lt;int&gt;
9616 </pre></td></tr>
9619 <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>
9620 <tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node
9621 matches the given matcher.
9623 The associated declaration is:
9624 - for type nodes, the declaration of the underlying type
9625 - for CallExpr, the declaration of the callee
9626 - for MemberExpr, the declaration of the referenced member
9627 - for CXXConstructExpr, the declaration of the constructor
9628 - for CXXNewExpr, the declaration of the operator new
9629 - for ObjCIvarExpr, the declaration of the ivar
9631 For type nodes, hasDeclaration will generally match the declaration of the
9632 sugared type. Given
9633 class X {};
9634 typedef X Y;
9635 Y y;
9636 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9637 typedefDecl. A common use case is to match the underlying, desugared type.
9638 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9639 varDecl(hasType(hasUnqualifiedDesugaredType(
9640 recordType(hasDeclaration(decl())))))
9641 In this matcher, the decl will match the CXXRecordDecl of class X.
9643 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;,
9644 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;,
9645 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;,
9646 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;,
9647 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;,
9648 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;,
9649 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9650 </pre></td></tr>
9653 <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>
9654 <tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner
9655 QualType-matcher matches.
9656 </pre></td></tr>
9659 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;</td><td class="name" onclick="toggle('hasTypeLoc13')"><a name="hasTypeLoc13Anchor">hasTypeLoc</a></td><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>&gt; Inner</td></tr>
9660 <tr><td colspan="4" class="doc" id="hasTypeLoc13"><pre>Matches if the type location of a node matches the inner matcher.
9662 Examples:
9663 int x;
9664 declaratorDecl(hasTypeLoc(loc(asString("int"))))
9665 matches int x
9667 auto x = int(3);
9668 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int"))))
9669 matches int(3)
9671 struct Foo { Foo(int, int); };
9672 auto x = Foo(1, 2);
9673 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo"))))
9674 matches Foo(1, 2)
9676 Usable as: Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;,
9677 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>&gt;,
9678 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>&gt;,
9679 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>&gt;,
9680 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>&gt;,
9681 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>&gt;,
9682 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>&gt;, Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc</a>&gt;,
9683 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>&gt;
9684 </pre></td></tr>
9687 <tr><td>Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_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>
9688 <tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type
9689 matcher.
9691 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
9692 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
9693 and U (matcher = typedefDecl(hasType(asString("int")))
9694 and friend class X (matcher = friendDecl(hasType("X"))
9695 and public virtual X (matcher = cxxBaseSpecifier(hasType(
9696 asString("class X")))
9697 class X {};
9698 void y(X &amp;x) { x; X z; }
9699 typedef int U;
9700 class Y { friend class X; };
9701 class Z : public virtual X {};
9702 </pre></td></tr>
9705 <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>
9706 <tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node
9707 matches the given matcher.
9709 The associated declaration is:
9710 - for type nodes, the declaration of the underlying type
9711 - for CallExpr, the declaration of the callee
9712 - for MemberExpr, the declaration of the referenced member
9713 - for CXXConstructExpr, the declaration of the constructor
9714 - for CXXNewExpr, the declaration of the operator new
9715 - for ObjCIvarExpr, the declaration of the ivar
9717 For type nodes, hasDeclaration will generally match the declaration of the
9718 sugared type. Given
9719 class X {};
9720 typedef X Y;
9721 Y y;
9722 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9723 typedefDecl. A common use case is to match the underlying, desugared type.
9724 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9725 varDecl(hasType(hasUnqualifiedDesugaredType(
9726 recordType(hasDeclaration(decl())))))
9727 In this matcher, the decl will match the CXXRecordDecl of class X.
9729 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;,
9730 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;,
9731 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;,
9732 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;,
9733 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;,
9734 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;,
9735 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>&gt;
9736 </pre></td></tr>
9739 <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>
9740 <tr><td colspan="4" class="doc" id="hasUnqualifiedDesugaredType0"><pre>Matches if the matched type matches the unqualified desugared
9741 type of the matched node.
9743 For example, in:
9744 class A {};
9745 using B = A;
9746 The matcher type(hasUnqualifiedDesugaredType(recordType())) matches
9747 both B and A.
9748 </pre></td></tr>
9751 <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>
9752 <tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument.
9754 Given
9755 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
9756 unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int"))
9757 matches sizeof(a) and alignof(c)
9758 </pre></td></tr>
9761 <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>
9762 <tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches.
9764 Example matches true (matcher = hasUnaryOperand(
9765 cxxBoolLiteral(equals(true))))
9766 !true
9767 </pre></td></tr>
9770 <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>
9771 <tr><td colspan="4" class="doc" id="hasObjectExpression1"><pre>Matches a member expression where the object expression is matched by a
9772 given matcher. Implicit object expressions are included; that is, it matches
9773 use of implicit `this`.
9775 Given
9776 struct X {
9777 int m;
9778 int f(X x) { x.m; return m; }
9780 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X")))))
9781 matches `x.m`, but not `m`; however,
9782 memberExpr(hasObjectExpression(hasType(pointsTo(
9783 cxxRecordDecl(hasName("X"))))))
9784 matches `m` (aka. `this-&gt;m`), but not `x.m`.
9785 </pre></td></tr>
9788 <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>
9789 <tr><td colspan="4" class="doc" id="hasDeclaration0"><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_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>
9823 <tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is
9824 matched by the given matcher.
9826 Given
9827 namespace X { int a; void b(); }
9828 using X::a;
9829 using X::b;
9830 usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
9831 matches using X::b but not using X::a </pre></td></tr>
9834 <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>
9835 <tr><td colspan="4" class="doc" id="hasUnderlyingType1"><pre>Matches DecltypeType or UsingType nodes to find the underlying type.
9837 Given
9838 decltype(1) a = 1;
9839 decltype(2.0) b = 2.0;
9840 decltypeType(hasUnderlyingType(isInteger()))
9841 matches the type of "a"
9843 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;
9844 </pre></td></tr>
9847 <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>
9848 <tr><td colspan="4" class="doc" id="throughUsingDecl1"><pre>Matches if a node refers to a declaration through a specific
9849 using shadow declaration.
9851 Examples:
9852 namespace a { int f(); }
9853 using a::f;
9854 int x = f();
9855 declRefExpr(throughUsingDecl(anything()))
9856 matches f
9858 namespace a { class X{}; }
9859 using a::X;
9860 X x;
9861 typeLoc(loc(usingType(throughUsingDecl(anything()))))
9862 matches X
9864 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;
9865 </pre></td></tr>
9868 <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>
9869 <tr><td colspan="4" class="doc" id="hasType7"><pre>Overloaded to match the declaration of the expression's or value
9870 declaration's type.
9872 In case of a value declaration (for example a variable declaration),
9873 this resolves one layer of indirection. For example, in the value
9874 declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of
9875 X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the
9876 declaration of x.
9878 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
9879 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
9880 and friend class X (matcher = friendDecl(hasType("X"))
9881 and public virtual X (matcher = cxxBaseSpecifier(hasType(
9882 cxxRecordDecl(hasName("X"))))
9883 class X {};
9884 void y(X &amp;x) { x; X z; }
9885 class Y { friend class X; };
9886 class Z : public virtual X {};
9888 Example matches class Derived
9889 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base"))))))
9890 class Base {};
9891 class Derived : Base {};
9893 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;,
9894 Matcher&lt;<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier</a>&gt;
9895 </pre></td></tr>
9898 <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>
9899 <tr><td colspan="4" class="doc" id="hasType3"><pre>Matches if the expression's or declaration's type matches a type
9900 matcher.
9902 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X")))))
9903 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X")))))
9904 and U (matcher = typedefDecl(hasType(asString("int")))
9905 and friend class X (matcher = friendDecl(hasType("X"))
9906 and public virtual X (matcher = cxxBaseSpecifier(hasType(
9907 asString("class X")))
9908 class X {};
9909 void y(X &amp;x) { x; X z; }
9910 typedef int U;
9911 class Y { friend class X; };
9912 class Z : public virtual X {};
9913 </pre></td></tr>
9916 <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>
9917 <tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression
9918 that matches the given matcher.
9920 Example matches x (matcher = varDecl(hasInitializer(callExpr())))
9921 bool y() { return true; }
9922 bool x = y();
9923 </pre></td></tr>
9926 <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>
9927 <tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size
9928 expression.
9930 Given
9931 void f(int b) {
9932 int a[b];
9934 variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
9935 varDecl(hasName("b")))))))
9936 matches "int a[b]"
9937 </pre></td></tr>
9940 <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>
9941 <tr><td colspan="4" class="doc" id="hasBody2"><pre></pre></td></tr>
9944 <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>
9945 <tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop,
9946 switch statement or conditional operator.
9948 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
9949 if (true) {}
9950 </pre></td></tr>
9952 <!--END_TRAVERSAL_MATCHERS -->
9953 </table>
9955 </div>
9956 </body>
9957 </html>