1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
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">
14 border-bottom: 1px solid black
;
20 span
.mono
{ font-family: monospace
; }
22 .traverse_compare, .traverse_compare td, .traverse_compare th {
23 border: 1px solid black
;
24 border-collapse: collapse
;
27 <script type=
"text/javascript">
30 row
= document
.getElementById(id
);
31 if (row
.style
.display
!= 'table-cell')
32 row
.style
.display
= 'table-cell';
34 row
.style
.display
= 'none';
38 <body onLoad=
"toggle(location.hash.substring(1, location.hash.length - 6))">
40 <!--#include virtual="../menu.html.incl"-->
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:
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>
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
<Stmt
> 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:
71 recordDecl(hasDescendant(
72 ifStmt(hasTrueExpression(
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
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
106 set traversal IgnoreUnlessSpelledInSource
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:
114 Finder-
>addMatcher(traverse(TK_IgnoreUnlessSpelledInSource,
115 returnStmt(hasReturnValue(integerLiteral(equals(
0))))
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">
125 <th><span class=
"mono">AsIs
</span></th>
126 <th><span class=
"mono">IgnoreUnlessSpelledInSource
</span></th>
129 <td>AST dump of
<span class=
"mono">func1
</span>:
135 B func1() { return
42; }
147 `-MaterializeTemporaryExpr
151 `-IntegerLiteral 'int'
42
153 C++
11, C++
14 dialect:
160 `-MaterializeTemporaryExpr
163 `-IntegerLiteral 'int'
42
165 C++
17, C++
20 dialect:
172 `-IntegerLiteral 'int'
42
181 `-IntegerLiteral 'int'
42
186 <td>Matcher for returned
<span class=
"mono">42</span>:
192 B func1() { return
42; }
199 returnStmt(hasReturnValue(
201 ignoringElidableConstructorCall(
203 cxxConstructExpr(hasArgument(
0,
205 integerLiteral().bind(
"returnVal")
216 returnStmt(hasReturnValue(
217 integerLiteral().bind(
"returnVal")
223 <pre>implicitCastExpr()
</pre>
230 B func1() { return
42; }
240 <td>Match result for:
244 ).bind(
"prepend_explicit")
256 Match found. Insertion produces incorrect output:
259 struct explicit Copyable {
266 No match found. Incorrect replacement not possible.
270 <td>Replacement of
<span class=
"mono">begin()
</span>
271 with
<span class=
"mono">cbegin()
</span>:
274 on(ConstContainerExpr),
275 callee(cxxMethodDecl(hasName(
"begin")))
276 ).bind(
"replace_with_cbegin")
290 2 matches found. Replacement produces incorrect output:
296 for (auto i :.cbegin() c) {
302 1 match found. Replacement produces correct output:
315 <td>Replacement of
<span class=
"mono">int
</span> member
316 with
<span class=
"mono">safe_int
</span>:
319 hasType(asString(
"int"))
320 ).bind(
"use_safe_int")
328 template
<typename T
> struct TemplStruct {
336 void instantiate() { TemplStruct
<int
> ti; }
340 2 matches found. Replacement produces incorrect output:
346 template
<typename T
> struct TemplStruct {
354 void instantiate() { TemplStruct
<int
> ti; }
358 1 match found. Replacement produces correct output:
364 template
<typename T
> struct TemplStruct {
372 void instantiate() { TemplStruct
<int
> ti; }
377 <td>Add prefix to member initializer
380 forField(fieldDecl())
396 2 matches found. Replacement produces incorrect output:
401 m_Record() : m_i(
42) {}
409 1 match found. Replacement produces correct output:
414 Record() : m_i(
42) {}
423 <td>Ignored default arguments
427 hasName(
"hasDefaultArg")
434 void hasDefaultArg(int i, int j =
0) {}
435 void callDefaultArg() { hasDefaultArg(
42); }
449 hasType(asString(
"int"))
462 auto l = [a, b = c](int d) { int e = d; };
468 2 matches found. Replacement produces incorrect output:
478 auto l = [safe_a, safe_b = c](int d) { int e = d; };
484 1 match found. Replacement produces correct output:
494 auto l = [a, b = c](int d) { int e = d; };
507 <td>Rewritten binary operators
510 hasOperatorName(
"<"),
511 hasRHS(hasDescendant(integerLiteral(equals(
0))))
516 #include
<compare
>
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) {
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
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:
566 // This binds the CXXRecordDecl to
"id", as the decl() matcher will stay on
568 recordDecl(decl().bind(
"id"), hasName(
"::MyClass"))
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
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr
</a>></td><td class=
"name" onclick=
"toggle('attr0')"><a name=
"attr0Anchor">attr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr
</a>>...
</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.
583 struct [[nodiscard]] Foo{};
584 void bar(int * __attribute__((nonnull)) );
585 __declspec(noinline) void baz();
587 #pragma omp declare simd
590 matches
"nodiscard",
"nonnull",
"noinline", and the whole
"#pragma" line.
594 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>></td><td class=
"name" onclick=
"toggle('cxxBaseSpecifier0')"><a name=
"cxxBaseSpecifier0Anchor">cxxBaseSpecifier
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>>...
</td></tr>
595 <tr><td colspan=
"4" class=
"doc" id=
"cxxBaseSpecifier0"><pre>Matches class bases.
597 Examples matches public virtual B.
599 class C : public virtual B {};
603 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>></td><td class=
"name" onclick=
"toggle('cxxCtorInitializer0')"><a name=
"cxxCtorInitializer0Anchor">cxxCtorInitializer
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>>...
</td></tr>
604 <tr><td colspan=
"4" class=
"doc" id=
"cxxCtorInitializer0"><pre>Matches constructor initializers.
606 Examples matches i(
42).
614 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('accessSpecDecl0')"><a name=
"accessSpecDecl0Anchor">accessSpecDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1AccessSpecDecl.html">AccessSpecDecl
</a>>...
</td></tr>
615 <tr><td colspan=
"4" class=
"doc" id=
"accessSpecDecl0"><pre>Matches C++ access specifier declarations.
627 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('bindingDecl0')"><a name=
"bindingDecl0Anchor">bindingDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BindingDecl.html">BindingDecl
</a>>...
</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};
636 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('blockDecl0')"><a name=
"blockDecl0Anchor">blockDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl
</a>>...
</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
648 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('classTemplateDecl0')"><a name=
"classTemplateDecl0Anchor">classTemplateDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html">ClassTemplateDecl
</a>>...
</td></tr>
649 <tr><td colspan=
"4" class=
"doc" id=
"classTemplateDecl0"><pre>Matches C++ class template declarations.
652 template
<class T
> class Z {};
656 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('classTemplatePartialSpecializationDecl0')"><a name=
"classTemplatePartialSpecializationDecl0Anchor">classTemplatePartialSpecializationDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ClassTemplatePartialSpecializationDecl.html">ClassTemplatePartialSpecializationDecl
</a>>...
</td></tr>
657 <tr><td colspan=
"4" class=
"doc" id=
"classTemplatePartialSpecializationDecl0"><pre>Matches C++ class template partial specializations.
660 template
<class T1, class T2, int I
>
663 template
<class T, int I
>
664 class A
<T, T*, I
> {};
667 class A
<int, int,
1> {};
668 classTemplatePartialSpecializationDecl()
669 matches the specialization A
<T,T*,I
> but not A
<int,int,
1>
673 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('classTemplateSpecializationDecl0')"><a name=
"classTemplateSpecializationDecl0Anchor">classTemplateSpecializationDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl
</a>>...
</td></tr>
674 <tr><td colspan=
"4" class=
"doc" id=
"classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations.
677 template
<typename T
> class A {};
678 template
<> class A
<double
> {};
680 classTemplateSpecializationDecl()
681 matches the specializations A
<int
> and A
<double
>
685 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('conceptDecl0')"><a name=
"conceptDecl0Anchor">conceptDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ConceptDecl.html">ConceptDecl
</a>>...
</td></tr>
686 <tr><td colspan=
"4" class=
"doc" id=
"conceptDecl0"><pre>Matches concept declarations.
688 Example matches integral
689 template
<typename T
>
690 concept integral = std::is_integral_v
<T
>;
694 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('cxxConstructorDecl0')"><a name=
"cxxConstructorDecl0Anchor">cxxConstructorDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl
</a>>...
</td></tr>
695 <tr><td colspan=
"4" class=
"doc" id=
"cxxConstructorDecl0"><pre>Matches C++ constructor declarations.
697 Example matches Foo::Foo() and Foo::Foo(int)
707 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('cxxConversionDecl0')"><a name=
"cxxConversionDecl0Anchor">cxxConversionDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl
</a>>...
</td></tr>
708 <tr><td colspan=
"4" class=
"doc" id=
"cxxConversionDecl0"><pre>Matches conversion operator declarations.
710 Example matches the operator.
711 class X { operator int() const; };
715 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('cxxDeductionGuideDecl0')"><a name=
"cxxDeductionGuideDecl0Anchor">cxxDeductionGuideDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXDeductionGuideDecl.html">CXXDeductionGuideDecl
</a>>...
</td></tr>
716 <tr><td colspan=
"4" class=
"doc" id=
"cxxDeductionGuideDecl0"><pre>Matches user-defined and implicitly generated deduction guide.
718 Example matches the deduction guide.
719 template
<typename T
>
721 X(int) -
> X
<int
>;
725 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('cxxDestructorDecl0')"><a name=
"cxxDestructorDecl0Anchor">cxxDestructorDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl
</a>>...
</td></tr>
726 <tr><td colspan=
"4" class=
"doc" id=
"cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations.
728 Example matches Foo::~Foo()
736 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('cxxMethodDecl0')"><a name=
"cxxMethodDecl0Anchor">cxxMethodDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>>...
</td></tr>
737 <tr><td colspan=
"4" class=
"doc" id=
"cxxMethodDecl0"><pre>Matches method declarations.
740 class X { void y(); };
744 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('cxxRecordDecl0')"><a name=
"cxxRecordDecl0Anchor">cxxRecordDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>>...
</td></tr>
745 <tr><td colspan=
"4" class=
"doc" id=
"cxxRecordDecl0"><pre>Matches C++ class declarations.
749 template
<class T
> class Z {};
753 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('decl0')"><a name=
"decl0Anchor">decl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>>...
</td></tr>
754 <tr><td colspan=
"4" class=
"doc" id=
"decl0"><pre>Matches declarations.
756 Examples matches X, C, and the friend declaration inside C;
764 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('declaratorDecl0')"><a name=
"declaratorDecl0Anchor">declaratorDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl
</a>>...
</td></tr>
765 <tr><td colspan=
"4" class=
"doc" id=
"declaratorDecl0"><pre>Matches declarator declarations (field, variable, function
766 and non-type template parameter declarations).
775 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('decompositionDecl0')"><a name=
"decompositionDecl0Anchor">decompositionDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DecompositionDecl.html">DecompositionDecl
</a>>...
</td></tr>
776 <tr><td colspan=
"4" class=
"doc" id=
"decompositionDecl0"><pre>Matches decomposition-declarations.
778 Examples matches the declaration node with foo and bar, but not
780 (matcher = declStmt(has(decompositionDecl())))
783 auto [foo, bar] = std::make_pair{
42,
42};
787 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('enumConstantDecl0')"><a name=
"enumConstantDecl0Anchor">enumConstantDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1EnumConstantDecl.html">EnumConstantDecl
</a>>...
</td></tr>
788 <tr><td colspan=
"4" class=
"doc" id=
"enumConstantDecl0"><pre>Matches enum constants.
790 Example matches A, B, C
797 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('enumDecl0')"><a name=
"enumDecl0Anchor">enumDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl
</a>>...
</td></tr>
798 <tr><td colspan=
"4" class=
"doc" id=
"enumDecl0"><pre>Matches enum declarations.
807 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('fieldDecl0')"><a name=
"fieldDecl0Anchor">fieldDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl
</a>>...
</td></tr>
808 <tr><td colspan=
"4" class=
"doc" id=
"fieldDecl0"><pre>Matches field declarations.
817 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('friendDecl0')"><a name=
"friendDecl0Anchor">friendDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl
</a>>...
</td></tr>
818 <tr><td colspan=
"4" class=
"doc" id=
"friendDecl0"><pre>Matches friend declarations.
821 class X { friend void foo(); };
823 matches 'friend void foo()'.
827 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('functionDecl0')"><a name=
"functionDecl0Anchor">functionDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>>...
</td></tr>
828 <tr><td colspan=
"4" class=
"doc" id=
"functionDecl0"><pre>Matches function declarations.
835 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('functionTemplateDecl0')"><a name=
"functionTemplateDecl0Anchor">functionTemplateDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionTemplateDecl.html">FunctionTemplateDecl
</a>>...
</td></tr>
836 <tr><td colspan=
"4" class=
"doc" id=
"functionTemplateDecl0"><pre>Matches C++ function template declarations.
839 template
<class T
> void f(T t) {}
843 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('indirectFieldDecl0')"><a name=
"indirectFieldDecl0Anchor">indirectFieldDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1IndirectFieldDecl.html">IndirectFieldDecl
</a>>...
</td></tr>
844 <tr><td colspan=
"4" class=
"doc" id=
"indirectFieldDecl0"><pre>Matches indirect field declarations.
847 struct X { struct { int a; }; };
853 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('labelDecl0')"><a name=
"labelDecl0Anchor">labelDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1LabelDecl.html">LabelDecl
</a>>...
</td></tr>
854 <tr><td colspan=
"4" class=
"doc" id=
"labelDecl0"><pre>Matches a declaration of label.
864 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('linkageSpecDecl0')"><a name=
"linkageSpecDecl0Anchor">linkageSpecDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1LinkageSpecDecl.html">LinkageSpecDecl
</a>>...
</td></tr>
865 <tr><td colspan=
"4" class=
"doc" id=
"linkageSpecDecl0"><pre>Matches a declaration of a linkage specification.
870 matches
"extern "C
" {}"
874 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('namedDecl0')"><a name=
"namedDecl0Anchor">namedDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl
</a>>...
</td></tr>
875 <tr><td colspan=
"4" class=
"doc" id=
"namedDecl0"><pre>Matches a declaration of anything that could have a name.
877 Example matches X, S, the anonymous union type, i, and U;
887 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('namespaceAliasDecl0')"><a name=
"namespaceAliasDecl0Anchor">namespaceAliasDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NamespaceAliasDecl.html">NamespaceAliasDecl
</a>>...
</td></tr>
888 <tr><td colspan=
"4" class=
"doc" id=
"namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias.
892 namespace alias = ::test;
894 matches
"namespace alias" but not
"namespace test"
898 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('namespaceDecl0')"><a name=
"namespaceDecl0Anchor">namespaceDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl
</a>>...
</td></tr>
899 <tr><td colspan=
"4" class=
"doc" id=
"namespaceDecl0"><pre>Matches a declaration of a namespace.
905 matches
"namespace {}" and
"namespace test {}"
909 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('nonTypeTemplateParmDecl0')"><a name=
"nonTypeTemplateParmDecl0Anchor">nonTypeTemplateParmDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NonTypeTemplateParmDecl.html">NonTypeTemplateParmDecl
</a>>...
</td></tr>
910 <tr><td colspan=
"4" class=
"doc" id=
"nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations.
913 template
<typename T, int N
> struct C {};
914 nonTypeTemplateParmDecl()
915 matches 'N', but not 'T'.
919 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('objcCategoryDecl0')"><a name=
"objcCategoryDecl0Anchor">objcCategoryDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryDecl.html">ObjCCategoryDecl
</a>>...
</td></tr>
920 <tr><td colspan=
"4" class=
"doc" id=
"objcCategoryDecl0"><pre>Matches Objective-C category declarations.
922 Example matches Foo (Additions)
923 @interface Foo (Additions)
928 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('objcCategoryImplDecl0')"><a name=
"objcCategoryImplDecl0Anchor">objcCategoryImplDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryImplDecl.html">ObjCCategoryImplDecl
</a>>...
</td></tr>
929 <tr><td colspan=
"4" class=
"doc" id=
"objcCategoryImplDecl0"><pre>Matches Objective-C category definitions.
931 Example matches Foo (Additions)
932 @implementation Foo (Additions)
937 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('objcImplementationDecl0')"><a name=
"objcImplementationDecl0Anchor">objcImplementationDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCImplementationDecl.html">ObjCImplementationDecl
</a>>...
</td></tr>
938 <tr><td colspan=
"4" class=
"doc" id=
"objcImplementationDecl0"><pre>Matches Objective-C implementation declarations.
946 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('objcInterfaceDecl0')"><a name=
"objcInterfaceDecl0Anchor">objcInterfaceDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl
</a>>...
</td></tr>
947 <tr><td colspan=
"4" class=
"doc" id=
"objcInterfaceDecl0"><pre>Matches Objective-C interface declarations.
955 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('objcIvarDecl0')"><a name=
"objcIvarDecl0Anchor">objcIvarDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCIvarDecl.html">ObjCIvarDecl
</a>>...
</td></tr>
956 <tr><td colspan=
"4" class=
"doc" id=
"objcIvarDecl0"><pre>Matches Objective-C instance variable declarations.
958 Example matches _enabled
959 @implementation Foo {
966 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('objcMethodDecl0')"><a name=
"objcMethodDecl0Anchor">objcMethodDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl
</a>>...
</td></tr>
967 <tr><td colspan=
"4" class=
"doc" id=
"objcMethodDecl0"><pre>Matches Objective-C method declarations.
969 Example matches both declaration and definition of -[Foo method]
980 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('objcPropertyDecl0')"><a name=
"objcPropertyDecl0Anchor">objcPropertyDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl
</a>>...
</td></tr>
981 <tr><td colspan=
"4" class=
"doc" id=
"objcPropertyDecl0"><pre>Matches Objective-C property declarations.
983 Example matches enabled
985 @property BOOL enabled;
990 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('objcProtocolDecl0')"><a name=
"objcProtocolDecl0Anchor">objcProtocolDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCProtocolDecl.html">ObjCProtocolDecl
</a>>...
</td></tr>
991 <tr><td colspan=
"4" class=
"doc" id=
"objcProtocolDecl0"><pre>Matches Objective-C protocol declarations.
993 Example matches FooDelegate
994 @protocol FooDelegate
999 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('parmVarDecl0')"><a name=
"parmVarDecl0Anchor">parmVarDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl
</a>>...
</td></tr>
1000 <tr><td colspan=
"4" class=
"doc" id=
"parmVarDecl0"><pre>Matches parameter variable declarations.
1009 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('recordDecl0')"><a name=
"recordDecl0Anchor">recordDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl
</a>>...
</td></tr>
1010 <tr><td colspan=
"4" class=
"doc" id=
"recordDecl0"><pre>Matches class, struct, and union declarations.
1012 Example matches X, Z, U, and S
1014 template
<class T
> class Z {};
1020 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('staticAssertDecl0')"><a name=
"staticAssertDecl0Anchor">staticAssertDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1StaticAssertDecl.html">StaticAssertDecl
</a>>...
</td></tr>
1021 <tr><td colspan=
"4" class=
"doc" id=
"staticAssertDecl0"><pre>Matches a C++ static_assert declaration.
1026 static_assert(sizeof(S) == sizeof(int))
1031 static_assert(sizeof(S) == sizeof(int));
1035 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('tagDecl0')"><a name=
"tagDecl0Anchor">tagDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl
</a>>...
</td></tr>
1036 <tr><td colspan=
"4" class=
"doc" id=
"tagDecl0"><pre>Matches tag declarations.
1038 Example matches X, Z, U, S, E
1040 template
<class T
> class Z {};
1049 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('templateTemplateParmDecl0')"><a name=
"templateTemplateParmDecl0Anchor">templateTemplateParmDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateTemplateParmDecl.html">TemplateTemplateParmDecl
</a>>...
</td></tr>
1050 <tr><td colspan=
"4" class=
"doc" id=
"templateTemplateParmDecl0"><pre>Matches template template parameter declarations.
1053 template
<template
<typename
> class Z, int N
> struct C {};
1054 templateTypeParmDecl()
1055 matches 'Z', but not 'N'.
1059 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('templateTypeParmDecl0')"><a name=
"templateTypeParmDecl0Anchor">templateTypeParmDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmDecl.html">TemplateTypeParmDecl
</a>>...
</td></tr>
1060 <tr><td colspan=
"4" class=
"doc" id=
"templateTypeParmDecl0"><pre>Matches template type parameter declarations.
1063 template
<typename T, int N
> struct C {};
1064 templateTypeParmDecl()
1065 matches 'T', but not 'N'.
1069 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('translationUnitDecl0')"><a name=
"translationUnitDecl0Anchor">translationUnitDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TranslationUnitDecl.html">TranslationUnitDecl
</a>>...
</td></tr>
1070 <tr><td colspan=
"4" class=
"doc" id=
"translationUnitDecl0"><pre>Matches the top declaration context.
1077 decl(hasDeclContext(translationUnitDecl()))
1078 matches
"int X", but not
"int Y".
1082 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('typeAliasDecl0')"><a name=
"typeAliasDecl0Anchor">typeAliasDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeAliasDecl.html">TypeAliasDecl
</a>>...
</td></tr>
1083 <tr><td colspan=
"4" class=
"doc" id=
"typeAliasDecl0"><pre>Matches type alias declarations.
1089 matches
"using Y = int", but not
"typedef int X"
1093 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('typeAliasTemplateDecl0')"><a name=
"typeAliasTemplateDecl0Anchor">typeAliasTemplateDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeAliasTemplateDecl.html">TypeAliasTemplateDecl
</a>>...
</td></tr>
1094 <tr><td colspan=
"4" class=
"doc" id=
"typeAliasTemplateDecl0"><pre>Matches type alias template declarations.
1096 typeAliasTemplateDecl() matches
1097 template
<typename T
>
1098 using Y = X
<T
>;
1102 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('typedefDecl0')"><a name=
"typedefDecl0Anchor">typedefDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html">TypedefDecl
</a>>...
</td></tr>
1103 <tr><td colspan=
"4" class=
"doc" id=
"typedefDecl0"><pre>Matches typedef declarations.
1109 matches
"typedef int X", but not
"using Y = int"
1113 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('typedefNameDecl0')"><a name=
"typedefNameDecl0Anchor">typedefNameDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl
</a>>...
</td></tr>
1114 <tr><td colspan=
"4" class=
"doc" id=
"typedefNameDecl0"><pre>Matches typedef name declarations.
1120 matches
"typedef int X" and
"using Y = int"
1124 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('unresolvedUsingTypenameDecl0')"><a name=
"unresolvedUsingTypenameDecl0Anchor">unresolvedUsingTypenameDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingTypenameDecl.html">UnresolvedUsingTypenameDecl
</a>>...
</td></tr>
1125 <tr><td colspan=
"4" class=
"doc" id=
"unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the
1129 template
<typename T
>
1130 struct Base { typedef T Foo; };
1132 template
<typename T
>
1133 struct S : private Base
<T
> {
1134 using typename Base
<T
>::Foo;
1136 unresolvedUsingTypenameDecl()
1137 matches using Base
<T
>::Foo
</pre></td></tr>
1140 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('unresolvedUsingValueDecl0')"><a name=
"unresolvedUsingValueDecl0Anchor">unresolvedUsingValueDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingValueDecl.html">UnresolvedUsingValueDecl
</a>>...
</td></tr>
1141 <tr><td colspan=
"4" class=
"doc" id=
"unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations.
1144 template
<typename X
>
1145 class C : private X {
1148 unresolvedUsingValueDecl()
1149 matches using X::x
</pre></td></tr>
1152 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('usingDecl0')"><a name=
"usingDecl0Anchor">usingDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html">UsingDecl
</a>>...
</td></tr>
1153 <tr><td colspan=
"4" class=
"doc" id=
"usingDecl0"><pre>Matches using declarations.
1156 namespace X { int x; }
1159 matches using X::x
</pre></td></tr>
1162 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('usingDirectiveDecl0')"><a name=
"usingDirectiveDecl0Anchor">usingDirectiveDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UsingDirectiveDecl.html">UsingDirectiveDecl
</a>>...
</td></tr>
1163 <tr><td colspan=
"4" class=
"doc" id=
"usingDirectiveDecl0"><pre>Matches using namespace declarations.
1166 namespace X { int x; }
1168 usingDirectiveDecl()
1169 matches using namespace X
</pre></td></tr>
1172 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('usingEnumDecl0')"><a name=
"usingEnumDecl0Anchor">usingEnumDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UsingEnumDecl.html">UsingEnumDecl
</a>>...
</td></tr>
1173 <tr><td colspan=
"4" class=
"doc" id=
"usingEnumDecl0"><pre>Matches using-enum declarations.
1176 namespace X { enum x {...}; }
1179 matches using enum X::x
</pre></td></tr>
1182 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('valueDecl0')"><a name=
"valueDecl0Anchor">valueDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl
</a>>...
</td></tr>
1183 <tr><td colspan=
"4" class=
"doc" id=
"valueDecl0"><pre>Matches any value declaration.
1185 Example matches A, B, C and F
1191 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('varDecl0')"><a name=
"varDecl0Anchor">varDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl
</a>>...
</td></tr>
1192 <tr><td colspan=
"4" class=
"doc" id=
"varDecl0"><pre>Matches variable declarations.
1194 Note: this does not match declarations of member variables, which are
1195 "field" declarations in Clang parlance.
1202 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture
</a>></td><td class=
"name" onclick=
"toggle('lambdaCapture0')"><a name=
"lambdaCapture0Anchor">lambdaCapture
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture
</a>>...
</td></tr>
1203 <tr><td colspan=
"4" class=
"doc" id=
"lambdaCapture0"><pre>Matches lambda captures.
1209 auto g = [x =
1](){};
1211 In the matcher `lambdaExpr(hasAnyCapture(lambdaCapture()))`,
1212 `lambdaCapture()` matches `x` and `x=
1`.
1216 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc
</a>></td><td class=
"name" onclick=
"toggle('nestedNameSpecifierLoc0')"><a name=
"nestedNameSpecifierLoc0Anchor">nestedNameSpecifierLoc
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc
</a>>...
</td></tr>
1217 <tr><td colspan=
"4" class=
"doc" id=
"nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
1221 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier
</a>></td><td class=
"name" onclick=
"toggle('nestedNameSpecifier0')"><a name=
"nestedNameSpecifier0Anchor">nestedNameSpecifier
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier
</a>>...
</td></tr>
1222 <tr><td colspan=
"4" class=
"doc" id=
"nestedNameSpecifier0"><pre>Matches nested name specifiers.
1226 struct A { static void f(); };
1228 void g() { A::f(); }
1231 nestedNameSpecifier()
1232 matches
"ns::" and both
"A::"
1236 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1OMPClause.html">OMPClause
</a>></td><td class=
"name" onclick=
"toggle('ompDefaultClause0')"><a name=
"ompDefaultClause0Anchor">ompDefaultClause
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause
</a>>...
</td></tr>
1237 <tr><td colspan=
"4" class=
"doc" id=
"ompDefaultClause0"><pre>Matches OpenMP ``default`` clause.
1241 #pragma omp parallel default(none)
1242 #pragma omp parallel default(shared)
1243 #pragma omp parallel default(private)
1244 #pragma omp parallel default(firstprivate)
1245 #pragma omp parallel
1247 ``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``,
1248 `` default(private)`` and ``default(firstprivate)``
1252 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType
</a>></td><td class=
"name" onclick=
"toggle('qualType0')"><a name=
"qualType0Anchor">qualType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType
</a>>...
</td></tr>
1253 <tr><td colspan=
"4" class=
"doc" id=
"qualType0"><pre>Matches QualTypes in the clang AST.
1257 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('addrLabelExpr0')"><a name=
"addrLabelExpr0Anchor">addrLabelExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr
</a>>...
</td></tr>
1258 <tr><td colspan=
"4" class=
"doc" id=
"addrLabelExpr0"><pre>Matches address of label statements (GNU extension).
1262 void *ptr =
&&FOO;
1265 matches '
&&FOO'
1269 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('arrayInitIndexExpr0')"><a name=
"arrayInitIndexExpr0Anchor">arrayInitIndexExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ArrayInitIndexExpr.html">ArrayInitIndexExpr
</a>>...
</td></tr>
1270 <tr><td colspan=
"4" class=
"doc" id=
"arrayInitIndexExpr0"><pre>The arrayInitIndexExpr consists of two subexpressions: a common expression
1271 (the source array) that is evaluated once up-front, and a per-element initializer
1272 that runs once for each array element. Within the per-element initializer,
1273 the current index may be obtained via an ArrayInitIndexExpr.
1276 void testStructBinding() {
1280 arrayInitIndexExpr() matches the array index that implicitly iterates
1281 over the array `a` to copy each element to the anonymous array
1282 that backs the structured binding `[x, y]` elements of which are
1283 referred to by their aliases `x` and `y`.
1287 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('arrayInitLoopExpr0')"><a name=
"arrayInitLoopExpr0Anchor">arrayInitLoopExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ArrayInitLoopExpr.html">ArrayInitLoopExpr
</a>>...
</td></tr>
1288 <tr><td colspan=
"4" class=
"doc" id=
"arrayInitLoopExpr0"><pre>Matches a loop initializing the elements of an array in a number of contexts:
1289 * in the implicit copy/move constructor for a class with an array member
1290 * when a lambda-expression captures an array by value
1291 * when a decomposition declaration decomposes an array
1294 void testLambdaCapture() {
1300 arrayInitLoopExpr() matches the implicit loop that initializes each element of
1301 the implicit array field inside the lambda object, that represents the array `a`
1306 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('arraySubscriptExpr0')"><a name=
"arraySubscriptExpr0Anchor">arraySubscriptExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr
</a>>...
</td></tr>
1307 <tr><td colspan=
"4" class=
"doc" id=
"arraySubscriptExpr0"><pre>Matches array subscript expressions.
1311 arraySubscriptExpr()
1316 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('asmStmt0')"><a name=
"asmStmt0Anchor">asmStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1AsmStmt.html">AsmStmt
</a>>...
</td></tr>
1317 <tr><td colspan=
"4" class=
"doc" id=
"asmStmt0"><pre>Matches asm statements.
1322 matches '__asm(
"mov al, 2")'
1326 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('atomicExpr0')"><a name=
"atomicExpr0Anchor">atomicExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1AtomicExpr.html">AtomicExpr
</a>>...
</td></tr>
1327 <tr><td colspan=
"4" class=
"doc" id=
"atomicExpr0"><pre>Matches atomic builtins.
1328 Example matches __atomic_load_n(ptr,
1)
1329 void foo() { int *ptr; __atomic_load_n(ptr,
1); }
1333 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('autoreleasePoolStmt0')"><a name=
"autoreleasePoolStmt0Anchor">autoreleasePoolStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCAutoreleasePoolStmt.html">ObjCAutoreleasePoolStmt
</a>>...
</td></tr>
1334 <tr><td colspan=
"4" class=
"doc" id=
"autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement.
1340 autoreleasePoolStmt(stmt()) matches the declaration of
"x"
1341 inside the autorelease pool.
1345 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('binaryConditionalOperator0')"><a name=
"binaryConditionalOperator0Anchor">binaryConditionalOperator
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BinaryConditionalOperator.html">BinaryConditionalOperator
</a>>...
</td></tr>
1346 <tr><td colspan=
"4" class=
"doc" id=
"binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension).
1348 Example matches a ?: b
1353 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('binaryOperator0')"><a name=
"binaryOperator0Anchor">binaryOperator
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator
</a>>...
</td></tr>
1354 <tr><td colspan=
"4" class=
"doc" id=
"binaryOperator0"><pre>Matches binary operator expressions.
1356 Example matches a || b
1358 See also the binaryOperation() matcher for more-general matching.
1362 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('blockExpr0')"><a name=
"blockExpr0Anchor">blockExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BlockExpr.html">BlockExpr
</a>>...
</td></tr>
1363 <tr><td colspan=
"4" class=
"doc" id=
"blockExpr0"><pre>Matches a reference to a block.
1365 Example: matches
"^{}":
1370 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('breakStmt0')"><a name=
"breakStmt0Anchor">breakStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BreakStmt.html">BreakStmt
</a>>...
</td></tr>
1371 <tr><td colspan=
"4" class=
"doc" id=
"breakStmt0"><pre>Matches break statements.
1374 while (true) { break; }
1380 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cStyleCastExpr0')"><a name=
"cStyleCastExpr0Anchor">cStyleCastExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CStyleCastExpr.html">CStyleCastExpr
</a>>...
</td></tr>
1381 <tr><td colspan=
"4" class=
"doc" id=
"cStyleCastExpr0"><pre>Matches a C-style cast expression.
1383 Example: Matches (int)
2.2f in
1388 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('callExpr0')"><a name=
"callExpr0Anchor">callExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr
</a>>...
</td></tr>
1389 <tr><td colspan=
"4" class=
"doc" id=
"callExpr0"><pre>Matches call expressions.
1391 Example matches x.y() and y()
1398 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('caseStmt0')"><a name=
"caseStmt0Anchor">caseStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt
</a>>...
</td></tr>
1399 <tr><td colspan=
"4" class=
"doc" id=
"caseStmt0"><pre>Matches case statements inside switch statements.
1402 switch(a) { case
42: break; default: break; }
1408 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('castExpr0')"><a name=
"castExpr0Anchor">castExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr
</a>>...
</td></tr>
1409 <tr><td colspan=
"4" class=
"doc" id=
"castExpr0"><pre>Matches any cast nodes of Clang's AST.
1411 Example: castExpr() matches each of the following:
1413 const_cast
<Expr *
>(SubExpr);
1421 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('characterLiteral0')"><a name=
"characterLiteral0Anchor">characterLiteral
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral
</a>>...
</td></tr>
1422 <tr><td colspan=
"4" class=
"doc" id=
"characterLiteral0"><pre>Matches character literals (also matches wchar_t).
1424 Not matching Hex-encoded chars (e.g.
0x1234, which is a IntegerLiteral),
1427 Example matches 'a', L'a'
1433 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('chooseExpr0')"><a name=
"chooseExpr0Anchor">chooseExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ChooseExpr.html">ChooseExpr
</a>>...
</td></tr>
1434 <tr><td colspan=
"4" class=
"doc" id=
"chooseExpr0"><pre>Matches GNU __builtin_choose_expr.
1438 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('coawaitExpr0')"><a name=
"coawaitExpr0Anchor">coawaitExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CoawaitExpr.html">CoawaitExpr
</a>>...
</td></tr>
1439 <tr><td colspan=
"4" class=
"doc" id=
"coawaitExpr0"><pre>Matches co_await expressions.
1444 matches 'co_await
1'
1448 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('compoundLiteralExpr0')"><a name=
"compoundLiteralExpr0Anchor">compoundLiteralExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr
</a>>...
</td></tr>
1449 <tr><td colspan=
"4" class=
"doc" id=
"compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals
1451 Example match: {
1}, (
1,
2)
1453 vector int myvec = (vector int)(
1,
2);
1457 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('compoundStmt0')"><a name=
"compoundStmt0Anchor">compoundStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt
</a>>...
</td></tr>
1458 <tr><td colspan=
"4" class=
"doc" id=
"compoundStmt0"><pre>Matches compound statements.
1460 Example matches '{}' and '{{}}' in 'for (;;) {{}}'
1465 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('conditionalOperator0')"><a name=
"conditionalOperator0Anchor">conditionalOperator
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator
</a>>...
</td></tr>
1466 <tr><td colspan=
"4" class=
"doc" id=
"conditionalOperator0"><pre>Matches conditional operator expressions.
1468 Example matches a ? b : c
1473 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('constantExpr0')"><a name=
"constantExpr0Anchor">constantExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ConstantExpr.html">ConstantExpr
</a>>...
</td></tr>
1474 <tr><td colspan=
"4" class=
"doc" id=
"constantExpr0"><pre>Matches a constant expression wrapper.
1476 Example matches the constant in the case statement:
1477 (matcher = constantExpr())
1484 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('continueStmt0')"><a name=
"continueStmt0Anchor">continueStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ContinueStmt.html">ContinueStmt
</a>>...
</td></tr>
1485 <tr><td colspan=
"4" class=
"doc" id=
"continueStmt0"><pre>Matches continue statements.
1488 while (true) { continue; }
1494 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('convertVectorExpr0')"><a name=
"convertVectorExpr0Anchor">convertVectorExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ConvertVectorExpr.html">ConvertVectorExpr
</a>>...
</td></tr>
1495 <tr><td colspan=
"4" class=
"doc" id=
"convertVectorExpr0"><pre>Matches builtin function __builtin_convertvector.
1499 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('coreturnStmt0')"><a name=
"coreturnStmt0Anchor">coreturnStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CoreturnStmt.html">CoreturnStmt
</a>>...
</td></tr>
1500 <tr><td colspan=
"4" class=
"doc" id=
"coreturnStmt0"><pre>Matches co_return statements.
1503 while (true) { co_return; }
1509 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('coroutineBodyStmt0')"><a name=
"coroutineBodyStmt0Anchor">coroutineBodyStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CoroutineBodyStmt.html">CoroutineBodyStmt
</a>>...
</td></tr>
1510 <tr><td colspan=
"4" class=
"doc" id=
"coroutineBodyStmt0"><pre>Matches coroutine body statements.
1512 coroutineBodyStmt() matches the coroutine below
1513 generator
<int
> gen() {
1519 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('coyieldExpr0')"><a name=
"coyieldExpr0Anchor">coyieldExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CoyieldExpr.html">CoyieldExpr
</a>>...
</td></tr>
1520 <tr><td colspan=
"4" class=
"doc" id=
"coyieldExpr0"><pre>Matches co_yield expressions.
1525 matches 'co_yield
1'
1529 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cudaKernelCallExpr0')"><a name=
"cudaKernelCallExpr0Anchor">cudaKernelCallExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html">CUDAKernelCallExpr
</a>>...
</td></tr>
1530 <tr><td colspan=
"4" class=
"doc" id=
"cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression.
1533 kernel
<<<i,j
>>>();
1537 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxBindTemporaryExpr0')"><a name=
"cxxBindTemporaryExpr0Anchor">cxxBindTemporaryExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr
</a>>...
</td></tr>
1538 <tr><td colspan=
"4" class=
"doc" id=
"cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created.
1540 Example matches FunctionTakesString(GetStringByValue())
1541 (matcher = cxxBindTemporaryExpr())
1542 FunctionTakesString(GetStringByValue());
1543 FunctionTakesStringByPointer(GetStringPointer());
1547 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxBoolLiteral0')"><a name=
"cxxBoolLiteral0Anchor">cxxBoolLiteral
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr
</a>>...
</td></tr>
1548 <tr><td colspan=
"4" class=
"doc" id=
"cxxBoolLiteral0"><pre>Matches bool literals.
1550 Example matches true
1555 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxCatchStmt0')"><a name=
"cxxCatchStmt0Anchor">cxxCatchStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt
</a>>...
</td></tr>
1556 <tr><td colspan=
"4" class=
"doc" id=
"cxxCatchStmt0"><pre>Matches catch statements.
1558 try {} catch(int i) {}
1560 matches 'catch(int i)'
1564 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxConstCastExpr0')"><a name=
"cxxConstCastExpr0Anchor">cxxConstCastExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr
</a>>...
</td></tr>
1565 <tr><td colspan=
"4" class=
"doc" id=
"cxxConstCastExpr0"><pre>Matches a const_cast expression.
1567 Example: Matches const_cast
<int*
>(
&r) in
1569 const int
&r(n);
1570 int* p = const_cast
<int*
>(
&r);
1574 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxConstructExpr0')"><a name=
"cxxConstructExpr0Anchor">cxxConstructExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr
</a>>...
</td></tr>
1575 <tr><td colspan=
"4" class=
"doc" id=
"cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones).
1577 Example matches string(ptr, n) and ptr within arguments of f
1578 (matcher = cxxConstructExpr())
1579 void f(const string
&a, const string
&b);
1582 f(string(ptr, n), ptr);
1586 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxDefaultArgExpr0')"><a name=
"cxxDefaultArgExpr0Anchor">cxxDefaultArgExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr
</a>>...
</td></tr>
1587 <tr><td colspan=
"4" class=
"doc" id=
"cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site.
1589 Example matches the CXXDefaultArgExpr placeholder inserted for the
1590 default value of the second parameter in the call expression f(
42)
1591 (matcher = cxxDefaultArgExpr())
1592 void f(int x, int y =
0);
1597 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxDeleteExpr0')"><a name=
"cxxDeleteExpr0Anchor">cxxDeleteExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr
</a>>...
</td></tr>
1598 <tr><td colspan=
"4" class=
"doc" id=
"cxxDeleteExpr0"><pre>Matches delete expressions.
1607 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxDependentScopeMemberExpr0')"><a name=
"cxxDependentScopeMemberExpr0Anchor">cxxDependentScopeMemberExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr
</a>>...
</td></tr>
1608 <tr><td colspan=
"4" class=
"doc" id=
"cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be
1609 resolved because the base expression or the member name was dependent.
1612 template
<class T
> void f() { T t; t.g(); }
1613 cxxDependentScopeMemberExpr()
1618 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxDynamicCastExpr0')"><a name=
"cxxDynamicCastExpr0Anchor">cxxDynamicCastExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr
</a>>...
</td></tr>
1619 <tr><td colspan=
"4" class=
"doc" id=
"cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression.
1622 cxxDynamicCastExpr()
1624 dynamic_cast
<D*
>(
&b);
1626 struct B { virtual ~B() {} }; struct D : B {};
1628 D* p = dynamic_cast
<D*
>(
&b);
1632 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxFoldExpr0')"><a name=
"cxxFoldExpr0Anchor">cxxFoldExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr
</a>>...
</td></tr>
1633 <tr><td colspan=
"4" class=
"doc" id=
"cxxFoldExpr0"><pre>Matches C++
17 fold expressions.
1635 Example matches `(
0 + ... + args)`:
1636 template
<typename... Args
>
1637 auto sum(Args... args) {
1638 return (
0 + ... + args);
1643 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxForRangeStmt0')"><a name=
"cxxForRangeStmt0Anchor">cxxForRangeStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt
</a>>...
</td></tr>
1644 <tr><td colspan=
"4" class=
"doc" id=
"cxxForRangeStmt0"><pre>Matches range-based for statements.
1646 cxxForRangeStmt() matches 'for (auto a : i)'
1647 int i[] = {
1,
2,
3}; for (auto a : i);
1648 for(int j =
0; j
< 5; ++j);
1652 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxFunctionalCastExpr0')"><a name=
"cxxFunctionalCastExpr0Anchor">cxxFunctionalCastExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr
</a>>...
</td></tr>
1653 <tr><td colspan=
"4" class=
"doc" id=
"cxxFunctionalCastExpr0"><pre>Matches functional cast expressions
1655 Example: Matches Foo(bar);
1662 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxMemberCallExpr0')"><a name=
"cxxMemberCallExpr0Anchor">cxxMemberCallExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr
</a>>...
</td></tr>
1663 <tr><td colspan=
"4" class=
"doc" id=
"cxxMemberCallExpr0"><pre>Matches member call expressions.
1665 Example matches x.y()
1671 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxNewExpr0')"><a name=
"cxxNewExpr0Anchor">cxxNewExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr
</a>>...
</td></tr>
1672 <tr><td colspan=
"4" class=
"doc" id=
"cxxNewExpr0"><pre>Matches new expressions.
1681 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxNoexceptExpr0')"><a name=
"cxxNoexceptExpr0Anchor">cxxNoexceptExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNoexceptExpr.html">CXXNoexceptExpr
</a>>...
</td></tr>
1682 <tr><td colspan=
"4" class=
"doc" id=
"cxxNoexceptExpr0"><pre>Matches noexcept expressions.
1686 bool b() noexcept(true);
1687 bool c() noexcept(false);
1688 bool d() noexcept(noexcept(a()));
1689 bool e = noexcept(b()) || noexcept(c());
1691 matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`.
1692 doesn't match the noexcept specifier in the declarations a, b, c or d.
1696 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxNullPtrLiteralExpr0')"><a name=
"cxxNullPtrLiteralExpr0Anchor">cxxNullPtrLiteralExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr
</a>>...
</td></tr>
1697 <tr><td colspan=
"4" class=
"doc" id=
"cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal.
1701 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxOperatorCallExpr0')"><a name=
"cxxOperatorCallExpr0Anchor">cxxOperatorCallExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr
</a>>...
</td></tr>
1702 <tr><td colspan=
"4" class=
"doc" id=
"cxxOperatorCallExpr0"><pre>Matches overloaded operator calls.
1704 Note that if an operator isn't overloaded, it won't match. Instead, use
1705 binaryOperator matcher.
1706 Currently it does not match operators such as new delete.
1707 FIXME: figure out why these do not match?
1709 Example matches both operator
<<((o
<< b), c) and operator
<<(o, b)
1710 (matcher = cxxOperatorCallExpr())
1711 ostream
&operator
<< (ostream
&out, int i) { };
1712 ostream
&o; int b =
1, c =
1;
1713 o
<< b
<< c;
1714 See also the binaryOperation() matcher for more-general matching of binary
1715 uses of this AST node.
1719 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxReinterpretCastExpr0')"><a name=
"cxxReinterpretCastExpr0Anchor">cxxReinterpretCastExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr
</a>>...
</td></tr>
1720 <tr><td colspan=
"4" class=
"doc" id=
"cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression.
1722 Either the source expression or the destination type can be matched
1723 using has(), but hasDestinationType() is more specific and can be
1726 Example matches reinterpret_cast
<char*
>(
&p) in
1727 void* p = reinterpret_cast
<char*
>(
&p);
1731 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxRewrittenBinaryOperator0')"><a name=
"cxxRewrittenBinaryOperator0Anchor">cxxRewrittenBinaryOperator
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator
</a>>...
</td></tr>
1732 <tr><td colspan=
"4" class=
"doc" id=
"cxxRewrittenBinaryOperator0"><pre>Matches rewritten binary operators
1734 Example matches use of
"<":
1735 #include
<compare
>
1736 struct HasSpaceshipMem {
1738 constexpr auto operator
<=
>(const HasSpaceshipMem
&) const = default;
1741 HasSpaceshipMem hs1, hs2;
1745 See also the binaryOperation() matcher for more-general matching
1750 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxStaticCastExpr0')"><a name=
"cxxStaticCastExpr0Anchor">cxxStaticCastExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr
</a>>...
</td></tr>
1751 <tr><td colspan=
"4" class=
"doc" id=
"cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression.
1753 See also: hasDestinationType
1754 See also: reinterpretCast
1759 static_cast
<long
>(
8)
1761 long eight(static_cast
<long
>(
8));
1765 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxStdInitializerListExpr0')"><a name=
"cxxStdInitializerListExpr0Anchor">cxxStdInitializerListExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXStdInitializerListExpr.html">CXXStdInitializerListExpr
</a>>...
</td></tr>
1766 <tr><td colspan=
"4" class=
"doc" id=
"cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions.
1769 std::vector
<int
> a({
1,
2,
3 });
1770 std::vector
<int
> b = {
4,
5 };
1772 std::pair
<int, int
> d = {
8,
9 };
1773 cxxStdInitializerListExpr()
1774 matches
"{ 1, 2, 3 }" and
"{ 4, 5 }"
1778 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxTemporaryObjectExpr0')"><a name=
"cxxTemporaryObjectExpr0Anchor">cxxTemporaryObjectExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr
</a>>...
</td></tr>
1779 <tr><td colspan=
"4" class=
"doc" id=
"cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N !=
1 arguments
1781 Example: Matches Foo(bar, bar)
1782 Foo h = Foo(bar, bar);
1786 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxThisExpr0')"><a name=
"cxxThisExpr0Anchor">cxxThisExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr
</a>>...
</td></tr>
1787 <tr><td colspan=
"4" class=
"doc" id=
"cxxThisExpr0"><pre>Matches implicit and explicit this expressions.
1789 Example matches the implicit this expression in
"return i".
1790 (matcher = cxxThisExpr())
1793 int f() { return i; }
1798 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxThrowExpr0')"><a name=
"cxxThrowExpr0Anchor">cxxThrowExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr
</a>>...
</td></tr>
1799 <tr><td colspan=
"4" class=
"doc" id=
"cxxThrowExpr0"><pre>Matches throw expressions.
1801 try { throw
5; } catch(int i) {}
1807 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxTryStmt0')"><a name=
"cxxTryStmt0Anchor">cxxTryStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt
</a>>...
</td></tr>
1808 <tr><td colspan=
"4" class=
"doc" id=
"cxxTryStmt0"><pre>Matches try statements.
1810 try {} catch(int i) {}
1816 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('cxxUnresolvedConstructExpr0')"><a name=
"cxxUnresolvedConstructExpr0Anchor">cxxUnresolvedConstructExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>>...
</td></tr>
1817 <tr><td colspan=
"4" class=
"doc" id=
"cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions.
1819 Example matches T(t) in return statement of f
1820 (matcher = cxxUnresolvedConstructExpr())
1821 template
<typename T
>
1822 void f(const T
& t) { return T(t); }
1826 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('declRefExpr0')"><a name=
"declRefExpr0Anchor">declRefExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr
</a>>...
</td></tr>
1827 <tr><td colspan=
"4" class=
"doc" id=
"declRefExpr0"><pre>Matches expressions that refer to declarations.
1829 Example matches x in if (x)
1835 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('declStmt0')"><a name=
"declStmt0Anchor">declStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt
</a>>...
</td></tr>
1836 <tr><td colspan=
"4" class=
"doc" id=
"declStmt0"><pre>Matches declaration statements.
1845 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('defaultStmt0')"><a name=
"defaultStmt0Anchor">defaultStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DefaultStmt.html">DefaultStmt
</a>>...
</td></tr>
1846 <tr><td colspan=
"4" class=
"doc" id=
"defaultStmt0"><pre>Matches default statements inside switch statements.
1849 switch(a) { case
42: break; default: break; }
1855 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('dependentCoawaitExpr0')"><a name=
"dependentCoawaitExpr0Anchor">dependentCoawaitExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DependentCoawaitExpr.html">DependentCoawaitExpr
</a>>...
</td></tr>
1856 <tr><td colspan=
"4" class=
"doc" id=
"dependentCoawaitExpr0"><pre>Matches co_await expressions where the type of the promise is dependent
1860 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('designatedInitExpr0')"><a name=
"designatedInitExpr0Anchor">designatedInitExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DesignatedInitExpr.html">DesignatedInitExpr
</a>>...
</td></tr>
1861 <tr><td colspan=
"4" class=
"doc" id=
"designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99
6.7.8].
1863 Example: Matches { [
2].y =
1.0, [
0].x =
1.0 }
1864 point ptarray[
10] = { [
2].y =
1.0, [
0].x =
1.0 };
1868 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('doStmt0')"><a name=
"doStmt0Anchor">doStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt
</a>>...
</td></tr>
1869 <tr><td colspan=
"4" class=
"doc" id=
"doStmt0"><pre>Matches do statements.
1874 matches 'do {} while(true)'
1878 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('explicitCastExpr0')"><a name=
"explicitCastExpr0Anchor">explicitCastExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr
</a>>...
</td></tr>
1879 <tr><td colspan=
"4" class=
"doc" id=
"explicitCastExpr0"><pre>Matches explicit cast expressions.
1881 Matches any cast expression written in user code, whether it be a
1882 C-style cast, a functional-style cast, or a keyword cast.
1884 Does not match implicit conversions.
1886 Note: the name
"explicitCast" is chosen to match Clang's terminology, as
1887 Clang uses the term
"cast" to apply to implicit conversions as well as to
1888 actual cast expressions.
1890 See also: hasDestinationType.
1892 Example: matches all five of the casts in
1893 int((int)(reinterpret_cast
<int
>(static_cast
<int
>(const_cast
<int
>(
42)))))
1894 but does not match the implicit conversion in
1899 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('expr0')"><a name=
"expr0Anchor">expr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>>...
</td></tr>
1900 <tr><td colspan=
"4" class=
"doc" id=
"expr0"><pre>Matches expressions.
1907 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('exprWithCleanups0')"><a name=
"exprWithCleanups0Anchor">exprWithCleanups
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ExprWithCleanups.html">ExprWithCleanups
</a>>...
</td></tr>
1908 <tr><td colspan=
"4" class=
"doc" id=
"exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end
1909 of the sub-expression's evaluation.
1911 Example matches std::string()
1912 const std::string str = std::string();
1916 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('fixedPointLiteral0')"><a name=
"fixedPointLiteral0Anchor">fixedPointLiteral
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FixedPointLiteral.html">FixedPointLiteral
</a>>...
</td></tr>
1917 <tr><td colspan=
"4" class=
"doc" id=
"fixedPointLiteral0"><pre>Matches fixed point literals
1921 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('floatLiteral0')"><a name=
"floatLiteral0Anchor">floatLiteral
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral
</a>>...
</td></tr>
1922 <tr><td colspan=
"4" class=
"doc" id=
"floatLiteral0"><pre>Matches float literals of all sizes / encodings, e.g.
1923 1.0,
1.0f,
1.0L and
1e10.
1925 Does not match implicit conversions such as
1930 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('forStmt0')"><a name=
"forStmt0Anchor">forStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt
</a>>...
</td></tr>
1931 <tr><td colspan=
"4" class=
"doc" id=
"forStmt0"><pre>Matches for statements.
1933 Example matches 'for (;;) {}'
1935 int i[] = {
1,
2,
3}; for (auto a : i);
1939 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('genericSelectionExpr0')"><a name=
"genericSelectionExpr0Anchor">genericSelectionExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1GenericSelectionExpr.html">GenericSelectionExpr
</a>>...
</td></tr>
1940 <tr><td colspan=
"4" class=
"doc" id=
"genericSelectionExpr0"><pre>Matches C11 _Generic expression.
1944 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('gnuNullExpr0')"><a name=
"gnuNullExpr0Anchor">gnuNullExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1GNUNullExpr.html">GNUNullExpr
</a>>...
</td></tr>
1945 <tr><td colspan=
"4" class=
"doc" id=
"gnuNullExpr0"><pre>Matches GNU __null expression.
1949 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('gotoStmt0')"><a name=
"gotoStmt0Anchor">gotoStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1GotoStmt.html">GotoStmt
</a>>...
</td></tr>
1950 <tr><td colspan=
"4" class=
"doc" id=
"gotoStmt0"><pre>Matches goto statements.
1960 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('ifStmt0')"><a name=
"ifStmt0Anchor">ifStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt
</a>>...
</td></tr>
1961 <tr><td colspan=
"4" class=
"doc" id=
"ifStmt0"><pre>Matches if statements.
1963 Example matches 'if (x) {}'
1968 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('imaginaryLiteral0')"><a name=
"imaginaryLiteral0Anchor">imaginaryLiteral
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ImaginaryLiteral.html">ImaginaryLiteral
</a>>...
</td></tr>
1969 <tr><td colspan=
"4" class=
"doc" id=
"imaginaryLiteral0"><pre>Matches imaginary literals, which are based on integer and floating
1970 point literals e.g.:
1i,
1.0i
1974 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('implicitCastExpr0')"><a name=
"implicitCastExpr0Anchor">implicitCastExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ImplicitCastExpr.html">ImplicitCastExpr
</a>>...
</td></tr>
1975 <tr><td colspan=
"4" class=
"doc" id=
"implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST.
1977 This matches many different places, including function call return value
1978 eliding, as well as any type conversions.
1982 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('implicitValueInitExpr0')"><a name=
"implicitValueInitExpr0Anchor">implicitValueInitExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ImplicitValueInitExpr.html">ImplicitValueInitExpr
</a>>...
</td></tr>
1983 <tr><td colspan=
"4" class=
"doc" id=
"implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions.
1986 point ptarray[
10] = { [
2].y =
1.0, [
2].x =
2.0, [
0].x =
1.0 };
1987 implicitValueInitExpr()
1988 matches
"[0].y" (implicitly)
1992 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('initListExpr0')"><a name=
"initListExpr0Anchor">initListExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr
</a>>...
</td></tr>
1993 <tr><td colspan=
"4" class=
"doc" id=
"initListExpr0"><pre>Matches init list expressions.
1997 struct B { int x, y; };
2000 matches
"{ 1, 2 }" and
"{ 5, 6 }"
2004 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('integerLiteral0')"><a name=
"integerLiteral0Anchor">integerLiteral
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral
</a>>...
</td></tr>
2005 <tr><td colspan=
"4" class=
"doc" id=
"integerLiteral0"><pre>Matches integer literals of all sizes / encodings, e.g.
2008 Does not match character-encoded integers such as L'a'.
2012 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('labelStmt0')"><a name=
"labelStmt0Anchor">labelStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt
</a>>...
</td></tr>
2013 <tr><td colspan=
"4" class=
"doc" id=
"labelStmt0"><pre>Matches label statements.
2023 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('lambdaExpr0')"><a name=
"lambdaExpr0Anchor">lambdaExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr
</a>>...
</td></tr>
2024 <tr><td colspan=
"4" class=
"doc" id=
"lambdaExpr0"><pre>Matches lambda expressions.
2026 Example matches [
&](){return
5;}
2027 [
&](){return
5;}
2031 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('materializeTemporaryExpr0')"><a name=
"materializeTemporaryExpr0Anchor">materializeTemporaryExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1MaterializeTemporaryExpr.html">MaterializeTemporaryExpr
</a>>...
</td></tr>
2032 <tr><td colspan=
"4" class=
"doc" id=
"materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized.
2035 struct T {void func();};
2038 materializeTemporaryExpr() matches 'f()' in these statements
2047 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('memberExpr0')"><a name=
"memberExpr0Anchor">memberExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr
</a>>...
</td></tr>
2048 <tr><td colspan=
"4" class=
"doc" id=
"memberExpr0"><pre>Matches member expressions.
2052 void x() { this-
>x(); x(); Y y; y.x(); a; this-
>b; Y::b; }
2053 int a; static int b;
2056 matches this-
>x, x, y.x, a, this-
>b
2060 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('nullStmt0')"><a name=
"nullStmt0Anchor">nullStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NullStmt.html">NullStmt
</a>>...
</td></tr>
2061 <tr><td colspan=
"4" class=
"doc" id=
"nullStmt0"><pre>Matches null statements.
2065 matches the second ';'
2069 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('objcCatchStmt0')"><a name=
"objcCatchStmt0Anchor">objcCatchStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCAtCatchStmt.html">ObjCAtCatchStmt
</a>>...
</td></tr>
2070 <tr><td colspan=
"4" class=
"doc" id=
"objcCatchStmt0"><pre>Matches Objective-C @catch statements.
2072 Example matches @catch
2078 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('objcFinallyStmt0')"><a name=
"objcFinallyStmt0Anchor">objcFinallyStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCAtFinallyStmt.html">ObjCAtFinallyStmt
</a>>...
</td></tr>
2079 <tr><td colspan=
"4" class=
"doc" id=
"objcFinallyStmt0"><pre>Matches Objective-C @finally statements.
2081 Example matches @finally
2087 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('objcIvarRefExpr0')"><a name=
"objcIvarRefExpr0Anchor">objcIvarRefExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCIvarRefExpr.html">ObjCIvarRefExpr
</a>>...
</td></tr>
2088 <tr><td colspan=
"4" class=
"doc" id=
"objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar.
2090 Example: matches
"a" in
"init" method:
2100 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('objcMessageExpr0')"><a name=
"objcMessageExpr0Anchor">objcMessageExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr
</a>>...
</td></tr>
2101 <tr><td colspan=
"4" class=
"doc" id=
"objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions.
2103 The innermost message send invokes the
"alloc" class method on the
2104 NSString class, while the outermost message send invokes the
2105 "initWithString" instance method on the object returned from
2106 NSString's
"alloc". This matcher should match both message sends.
2107 [[NSString alloc] initWithString:@
"Hello"]
2111 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('objcStringLiteral0')"><a name=
"objcStringLiteral0Anchor">objcStringLiteral
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCStringLiteral.html">ObjCStringLiteral
</a>>...
</td></tr>
2112 <tr><td colspan=
"4" class=
"doc" id=
"objcStringLiteral0"><pre>Matches ObjectiveC String literal expressions.
2114 Example matches @
"abcd"
2115 NSString *s = @
"abcd";
2119 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('objcThrowStmt0')"><a name=
"objcThrowStmt0Anchor">objcThrowStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCAtThrowStmt.html">ObjCAtThrowStmt
</a>>...
</td></tr>
2120 <tr><td colspan=
"4" class=
"doc" id=
"objcThrowStmt0"><pre>Matches Objective-C statements.
2122 Example matches @throw obj;
2126 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('objcTryStmt0')"><a name=
"objcTryStmt0Anchor">objcTryStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCAtTryStmt.html">ObjCAtTryStmt
</a>>...
</td></tr>
2127 <tr><td colspan=
"4" class=
"doc" id=
"objcTryStmt0"><pre>Matches Objective-C @try statements.
2129 Example matches @try
2135 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('ompExecutableDirective0')"><a name=
"ompExecutableDirective0Anchor">ompExecutableDirective
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html">OMPExecutableDirective
</a>>...
</td></tr>
2136 <tr><td colspan=
"4" class=
"doc" id=
"ompExecutableDirective0"><pre>Matches any ``#pragma omp`` executable directive.
2140 #pragma omp parallel
2141 #pragma omp parallel default(none)
2142 #pragma omp taskyield
2144 ``ompExecutableDirective()`` matches ``omp parallel``,
2145 ``omp parallel default(none)`` and ``omp taskyield``.
2149 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('opaqueValueExpr0')"><a name=
"opaqueValueExpr0Anchor">opaqueValueExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1OpaqueValueExpr.html">OpaqueValueExpr
</a>>...
</td></tr>
2150 <tr><td colspan=
"4" class=
"doc" id=
"opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers
2151 to reference another expressions and can be met
2152 in BinaryConditionalOperators, for example.
2159 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('parenExpr0')"><a name=
"parenExpr0Anchor">parenExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ParenExpr.html">ParenExpr
</a>>...
</td></tr>
2160 <tr><td colspan=
"4" class=
"doc" id=
"parenExpr0"><pre>Matches parentheses used in expressions.
2162 Example matches (foo() +
1)
2163 int foo() { return
1; }
2164 int a = (foo() +
1);
2168 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('parenListExpr0')"><a name=
"parenListExpr0Anchor">parenListExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ParenListExpr.html">ParenListExpr
</a>>...
</td></tr>
2169 <tr><td colspan=
"4" class=
"doc" id=
"parenListExpr0"><pre>Matches paren list expressions.
2170 ParenListExprs don't have a predefined type and are used for late parsing.
2171 In the final AST, they can be met in template declarations.
2174 template
<typename T
> class X {
2177 int a =
0, b =
1; int i = (a, b);
2180 parenListExpr() matches
"*this" but NOT matches (a, b) because (a, b)
2181 has a predefined type and is a ParenExpr, not a ParenListExpr.
2185 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('predefinedExpr0')"><a name=
"predefinedExpr0Anchor">predefinedExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1PredefinedExpr.html">PredefinedExpr
</a>>...
</td></tr>
2186 <tr><td colspan=
"4" class=
"doc" id=
"predefinedExpr0"><pre>Matches predefined identifier expressions [C99
6.4.2.2].
2188 Example: Matches __func__
2189 printf(
"%s", __func__);
2193 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('returnStmt0')"><a name=
"returnStmt0Anchor">returnStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">ReturnStmt
</a>>...
</td></tr>
2194 <tr><td colspan=
"4" class=
"doc" id=
"returnStmt0"><pre>Matches return statements.
2203 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('stmt0')"><a name=
"stmt0Anchor">stmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>>...
</td></tr>
2204 <tr><td colspan=
"4" class=
"doc" id=
"stmt0"><pre>Matches statements.
2209 matches both the compound statement '{ ++a; }' and '++a'.
2213 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('stmtExpr0')"><a name=
"stmtExpr0Anchor">stmtExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1StmtExpr.html">StmtExpr
</a>>...
</td></tr>
2214 <tr><td colspan=
"4" class=
"doc" id=
"stmtExpr0"><pre>Matches statement expression (GNU extension).
2216 Example match: ({ int X =
4; X; })
2217 int C = ({ int X =
4; X; });
2221 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('stringLiteral0')"><a name=
"stringLiteral0Anchor">stringLiteral
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral
</a>>...
</td></tr>
2222 <tr><td colspan=
"4" class=
"doc" id=
"stringLiteral0"><pre>Matches string literals (also matches wide string literals).
2224 Example matches
"abcd", L
"abcd"
2226 wchar_t *ws = L
"abcd";
2230 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('substNonTypeTemplateParmExpr0')"><a name=
"substNonTypeTemplateParmExpr0Anchor">substNonTypeTemplateParmExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1SubstNonTypeTemplateParmExpr.html">SubstNonTypeTemplateParmExpr
</a>>...
</td></tr>
2231 <tr><td colspan=
"4" class=
"doc" id=
"substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters.
2234 template
<int N
>
2235 struct A { static const int n = N; };
2236 struct B : public A
<42> {};
2237 substNonTypeTemplateParmExpr()
2238 matches
"N" in the right-hand side of
"static const int n = N;"
2242 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('switchCase0')"><a name=
"switchCase0Anchor">switchCase
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase
</a>>...
</td></tr>
2243 <tr><td colspan=
"4" class=
"doc" id=
"switchCase0"><pre>Matches case and default statements inside switch statements.
2246 switch(a) { case
42: break; default: break; }
2248 matches 'case
42:' and 'default:'.
2252 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('switchStmt0')"><a name=
"switchStmt0Anchor">switchStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt
</a>>...
</td></tr>
2253 <tr><td colspan=
"4" class=
"doc" id=
"switchStmt0"><pre>Matches switch statements.
2256 switch(a) { case
42: break; default: break; }
2258 matches 'switch(a)'.
2262 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('unaryExprOrTypeTraitExpr0')"><a name=
"unaryExprOrTypeTraitExpr0Anchor">unaryExprOrTypeTraitExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr
</a>>...
</td></tr>
2263 <tr><td colspan=
"4" class=
"doc" id=
"unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++
11) and vec_step (OpenCL)
2267 int y = sizeof(x) + alignof(x);
2268 unaryExprOrTypeTraitExpr()
2269 matches sizeof(x) and alignof(x)
2273 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('unaryOperator0')"><a name=
"unaryOperator0Anchor">unaryOperator
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator
</a>>...
</td></tr>
2274 <tr><td colspan=
"4" class=
"doc" id=
"unaryOperator0"><pre>Matches unary operator expressions.
2281 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('unresolvedLookupExpr0')"><a name=
"unresolvedLookupExpr0Anchor">unresolvedLookupExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UnresolvedLookupExpr.html">UnresolvedLookupExpr
</a>>...
</td></tr>
2282 <tr><td colspan=
"4" class=
"doc" id=
"unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing
2283 but could not be resolved to a specific declaration.
2286 template
<typename T
>
2287 T foo() { T a; return a; }
2288 template
<typename T
>
2292 unresolvedLookupExpr()
2293 matches foo
<T
>()
</pre></td></tr>
2296 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('unresolvedMemberExpr0')"><a name=
"unresolvedMemberExpr0Anchor">unresolvedMemberExpr
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html">UnresolvedMemberExpr
</a>>...
</td></tr>
2297 <tr><td colspan=
"4" class=
"doc" id=
"unresolvedMemberExpr0"><pre>Matches unresolved member expressions.
2301 template
<class T
> void f();
2304 template
<class T
> void h() { X x; x.f
<T
>(); x.g(); }
2305 unresolvedMemberExpr()
2306 matches x.f
<T
>
2310 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('userDefinedLiteral0')"><a name=
"userDefinedLiteral0Anchor">userDefinedLiteral
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UserDefinedLiteral.html">UserDefinedLiteral
</a>>...
</td></tr>
2311 <tr><td colspan=
"4" class=
"doc" id=
"userDefinedLiteral0"><pre>Matches user defined literal operator call.
2313 Example match:
"foo"_suffix
2317 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>></td><td class=
"name" onclick=
"toggle('whileStmt0')"><a name=
"whileStmt0Anchor">whileStmt
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt
</a>>...
</td></tr>
2318 <tr><td colspan=
"4" class=
"doc" id=
"whileStmt0"><pre>Matches while statements.
2323 matches 'while (true) {}'.
2327 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc
</a>></td><td class=
"name" onclick=
"toggle('templateArgumentLoc0')"><a name=
"templateArgumentLoc0Anchor">templateArgumentLoc
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc
</a>>...
</td></tr>
2328 <tr><td colspan=
"4" class=
"doc" id=
"templateArgumentLoc0"><pre>Matches template arguments (with location info).
2331 template
<typename T
> struct C {};
2333 templateArgumentLoc()
2334 matches 'int' in C
<int
>.
2338 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument
</a>></td><td class=
"name" onclick=
"toggle('templateArgument0')"><a name=
"templateArgument0Anchor">templateArgument
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument
</a>>...
</td></tr>
2339 <tr><td colspan=
"4" class=
"doc" id=
"templateArgument0"><pre>Matches template arguments.
2342 template
<typename T
> struct C {};
2345 matches 'int' in C
<int
>.
2349 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName
</a>></td><td class=
"name" onclick=
"toggle('templateName0')"><a name=
"templateName0Anchor">templateName
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName
</a>>...
</td></tr>
2350 <tr><td colspan=
"4" class=
"doc" id=
"templateName0"><pre>Matches template name.
2353 template
<typename T
> class X { };
2356 matches 'X' in X
<int
>.
2360 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>></td><td class=
"name" onclick=
"toggle('elaboratedTypeLoc0')"><a name=
"elaboratedTypeLoc0Anchor">elaboratedTypeLoc
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ElaboratedTypeLoc.html">ElaboratedTypeLoc
</a>>...
</td></tr>
2361 <tr><td colspan=
"4" class=
"doc" id=
"elaboratedTypeLoc0"><pre>Matches C or C++ elaborated `TypeLoc`s.
2367 matches the `TypeLoc` of the variable declaration of `ss`.
2371 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>></td><td class=
"name" onclick=
"toggle('pointerTypeLoc0')"><a name=
"pointerTypeLoc0Anchor">pointerTypeLoc
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc
</a>>...
</td></tr>
2372 <tr><td colspan=
"4" class=
"doc" id=
"pointerTypeLoc0"><pre>Matches pointer `TypeLoc`s.
2381 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>></td><td class=
"name" onclick=
"toggle('qualifiedTypeLoc0')"><a name=
"qualifiedTypeLoc0Anchor">qualifiedTypeLoc
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1QualifiedTypeLoc.html">QualifiedTypeLoc
</a>>...
</td></tr>
2382 <tr><td colspan=
"4" class=
"doc" id=
"qualifiedTypeLoc0"><pre>Matches `QualifiedTypeLoc`s in the clang AST.
2387 matches `const int`.
2391 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>></td><td class=
"name" onclick=
"toggle('referenceTypeLoc0')"><a name=
"referenceTypeLoc0Anchor">referenceTypeLoc
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc
</a>>...
</td></tr>
2392 <tr><td colspan=
"4" class=
"doc" id=
"referenceTypeLoc0"><pre>Matches reference `TypeLoc`s.
2397 int
&& r =
3;
2399 matches `int
&` and `int
&&`.
2403 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>></td><td class=
"name" onclick=
"toggle('templateSpecializationTypeLoc0')"><a name=
"templateSpecializationTypeLoc0Anchor">templateSpecializationTypeLoc
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html">TemplateSpecializationTypeLoc
</a>>...
</td></tr>
2404 <tr><td colspan=
"4" class=
"doc" id=
"templateSpecializationTypeLoc0"><pre>Matches template specialization `TypeLoc`s.
2407 template
<typename T
> class C {};
2409 varDecl(hasTypeLoc(templateSpecializationTypeLoc(typeLoc())))
2410 matches `C
<char
> var`.
2414 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>></td><td class=
"name" onclick=
"toggle('typeLoc0')"><a name=
"typeLoc0Anchor">typeLoc
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>>...
</td></tr>
2415 <tr><td colspan=
"4" class=
"doc" id=
"typeLoc0"><pre>Matches TypeLocs in the clang AST.
2419 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('arrayType0')"><a name=
"arrayType0Anchor">arrayType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType
</a>>...
</td></tr>
2420 <tr><td colspan=
"4" class=
"doc" id=
"arrayType0"><pre>Matches all kinds of arrays.
2425 void f() { int c[a[
0]]; }
2427 matches
"int a[]",
"int b[4]" and
"int c[a[0]]";
2431 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('atomicType0')"><a name=
"atomicType0Anchor">atomicType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType
</a>>...
</td></tr>
2432 <tr><td colspan=
"4" class=
"doc" id=
"atomicType0"><pre>Matches atomic types.
2437 matches
"_Atomic(int) i"
2441 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('autoType0')"><a name=
"autoType0Anchor">autoType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType
</a>>...
</td></tr>
2442 <tr><td colspan=
"4" class=
"doc" id=
"autoType0"><pre>Matches types nodes representing C++
11 auto types.
2447 for (auto i : v) { }
2449 matches
"auto n" and
"auto i"
2453 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('blockPointerType0')"><a name=
"blockPointerType0Anchor">blockPointerType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType
</a>>...
</td></tr>
2454 <tr><td colspan=
"4" class=
"doc" id=
"blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as
2457 The pointee is always required to be a FunctionType.
2461 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('builtinType0')"><a name=
"builtinType0Anchor">builtinType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BuiltinType.html">BuiltinType
</a>>...
</td></tr>
2462 <tr><td colspan=
"4" class=
"doc" id=
"builtinType0"><pre>Matches builtin Types.
2471 matches
"int b",
"float c" and
"bool d"
2475 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('complexType0')"><a name=
"complexType0Anchor">complexType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType
</a>>...
</td></tr>
2476 <tr><td colspan=
"4" class=
"doc" id=
"complexType0"><pre>Matches C99 complex types.
2481 matches
"_Complex float f"
2485 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('constantArrayType0')"><a name=
"constantArrayType0Anchor">constantArrayType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType
</a>>...
</td></tr>
2486 <tr><td colspan=
"4" class=
"doc" id=
"constantArrayType0"><pre>Matches C arrays with a specified constant size.
2499 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('decayedType0')"><a name=
"decayedType0Anchor">decayedType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DecayedType.html">DecayedType
</a>>...
</td></tr>
2500 <tr><td colspan=
"4" class=
"doc" id=
"decayedType0"><pre>Matches decayed type
2501 Example matches i[] in declaration of f.
2502 (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
2503 Example matches i[
1].
2504 (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())))))
2511 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('decltypeType0')"><a name=
"decltypeType0Anchor">decltypeType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType
</a>>...
</td></tr>
2512 <tr><td colspan=
"4" class=
"doc" id=
"decltypeType0"><pre>Matches types nodes representing C++
11 decltype(
<expr
>) types.
2517 decltype(i + j) result = i + j;
2519 matches
"decltype(i + j)"
2523 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('deducedTemplateSpecializationType0')"><a name=
"deducedTemplateSpecializationType0Anchor">deducedTemplateSpecializationType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DeducedTemplateSpecializationType.html">DeducedTemplateSpecializationType
</a>>...
</td></tr>
2524 <tr><td colspan=
"4" class=
"doc" id=
"deducedTemplateSpecializationType0"><pre>Matches C++
17 deduced template specialization types, e.g. deduced class
2528 template
<typename T
>
2529 class C { public: C(T); };
2532 deducedTemplateSpecializationType() matches the type in the declaration
2537 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('dependentSizedArrayType0')"><a name=
"dependentSizedArrayType0Anchor">dependentSizedArrayType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayType.html">DependentSizedArrayType
</a>>...
</td></tr>
2538 <tr><td colspan=
"4" class=
"doc" id=
"dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression.
2541 template
<typename T, int Size
>
2545 dependentSizedArrayType()
2546 matches
"T data[Size]"
2550 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('dependentSizedExtVectorType0')"><a name=
"dependentSizedExtVectorType0Anchor">dependentSizedExtVectorType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DependentSizedExtVectorType.html">DependentSizedExtVectorType
</a>>...
</td></tr>
2551 <tr><td colspan=
"4" class=
"doc" id=
"dependentSizedExtVectorType0"><pre>Matches C++ extended vector type where either the type or size is
2555 template
<typename T, int Size
>
2557 typedef T __attribute__((ext_vector_type(Size))) type;
2559 dependentSizedExtVectorType()
2560 matches
"T __attribute__((ext_vector_type(Size)))"
2564 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('elaboratedType0')"><a name=
"elaboratedType0Anchor">elaboratedType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType
</a>>...
</td></tr>
2565 <tr><td colspan=
"4" class=
"doc" id=
"elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a
2579 elaboratedType() matches the type of the variable declarations of both
2584 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('enumType0')"><a name=
"enumType0Anchor">enumType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType
</a>>...
</td></tr>
2585 <tr><td colspan=
"4" class=
"doc" id=
"enumType0"><pre>Matches enum types.
2589 enum class S { Red };
2594 enumType() matches the type of the variable declarations of both c and
2599 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('functionProtoType0')"><a name=
"functionProtoType0Anchor">functionProtoType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType
</a>>...
</td></tr>
2600 <tr><td colspan=
"4" class=
"doc" id=
"functionProtoType0"><pre>Matches FunctionProtoType nodes.
2606 matches
"int (*f)(int)" and the type of
"g" in C++ mode.
2607 In C mode,
"g" is not matched because it does not contain a prototype.
2611 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('functionType0')"><a name=
"functionType0Anchor">functionType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionType.html">FunctionType
</a>>...
</td></tr>
2612 <tr><td colspan=
"4" class=
"doc" id=
"functionType0"><pre>Matches FunctionType nodes.
2618 matches
"int (*f)(int)" and the type of
"g".
2622 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('incompleteArrayType0')"><a name=
"incompleteArrayType0Anchor">incompleteArrayType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1IncompleteArrayType.html">IncompleteArrayType
</a>>...
</td></tr>
2623 <tr><td colspan=
"4" class=
"doc" id=
"incompleteArrayType0"><pre>Matches C arrays with unspecified size.
2628 void f(int c[]) { int d[a[
0]]; };
2629 incompleteArrayType()
2630 matches
"int a[]" and
"int c[]"
2634 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('injectedClassNameType0')"><a name=
"injectedClassNameType0Anchor">injectedClassNameType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType
</a>>...
</td></tr>
2635 <tr><td colspan=
"4" class=
"doc" id=
"injectedClassNameType0"><pre>Matches injected class name types.
2637 Example matches S s, but not S
<T
> s.
2638 (matcher = parmVarDecl(hasType(injectedClassNameType())))
2639 template
<typename T
> struct S {
2641 void g(S
<T
> s);
2646 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('lValueReferenceType0')"><a name=
"lValueReferenceType0Anchor">lValueReferenceType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1LValueReferenceType.html">LValueReferenceType
</a>>...
</td></tr>
2647 <tr><td colspan=
"4" class=
"doc" id=
"lValueReferenceType0"><pre>Matches lvalue reference types.
2652 int
&&c =
1;
2654 auto
&&e = c;
2655 auto
&&f =
2;
2658 lValueReferenceType() matches the types of b, d, and e. e is
2659 matched since the type is deduced as int
& by reference collapsing rules.
2663 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('macroQualifiedType0')"><a name=
"macroQualifiedType0Anchor">macroQualifiedType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1MacroQualifiedType.html">MacroQualifiedType
</a>>...
</td></tr>
2664 <tr><td colspan=
"4" class=
"doc" id=
"macroQualifiedType0"><pre>Matches qualified types when the qualifier is applied via a macro.
2667 #define CDECL __attribute__((cdecl))
2668 typedef void (CDECL *X)();
2669 typedef void (__attribute__((cdecl)) *Y)();
2670 macroQualifiedType()
2671 matches the type of the typedef declaration of X but not Y.
2675 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('memberPointerType0')"><a name=
"memberPointerType0Anchor">memberPointerType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType
</a>>...
</td></tr>
2676 <tr><td colspan=
"4" class=
"doc" id=
"memberPointerType0"><pre>Matches member pointer types.
2685 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('objcObjectPointerType0')"><a name=
"objcObjectPointerType0Anchor">objcObjectPointerType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html">ObjCObjectPointerType
</a>>...
</td></tr>
2686 <tr><td colspan=
"4" class=
"doc" id=
"objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from
2687 a pointer type, despite being syntactically similar.
2696 matches
"Foo *f", but does not match
"int *a".
2700 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('parenType0')"><a name=
"parenType0Anchor">parenType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType
</a>>...
</td></tr>
2701 <tr><td colspan=
"4" class=
"doc" id=
"parenType0"><pre>Matches ParenType nodes.
2704 int (*ptr_to_array)[
4];
2705 int *array_of_ptrs[
4];
2707 varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not
2712 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('pointerType0')"><a name=
"pointerType0Anchor">pointerType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType
</a>>...
</td></tr>
2713 <tr><td colspan=
"4" class=
"doc" id=
"pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer
2725 matches
"int *a", but does not match
"Foo *f".
2729 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('rValueReferenceType0')"><a name=
"rValueReferenceType0Anchor">rValueReferenceType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1RValueReferenceType.html">RValueReferenceType
</a>>...
</td></tr>
2730 <tr><td colspan=
"4" class=
"doc" id=
"rValueReferenceType0"><pre>Matches rvalue reference types.
2735 int
&&c =
1;
2737 auto
&&e = c;
2738 auto
&&f =
2;
2741 rValueReferenceType() matches the types of c and f. e is not
2742 matched as it is deduced to int
& by reference collapsing rules.
2746 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('recordType0')"><a name=
"recordType0Anchor">recordType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType
</a>>...
</td></tr>
2747 <tr><td colspan=
"4" class=
"doc" id=
"recordType0"><pre>Matches record types (e.g. structs, classes).
2756 recordType() matches the type of the variable declarations of both c
2761 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('referenceType0')"><a name=
"referenceType0Anchor">referenceType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType
</a>>...
</td></tr>
2762 <tr><td colspan=
"4" class=
"doc" id=
"referenceType0"><pre>Matches both lvalue and rvalue reference types.
2767 int
&&c =
1;
2769 auto
&&e = c;
2770 auto
&&f =
2;
2773 referenceType() matches the types of b, c, d, e, and f.
2777 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('substTemplateTypeParmType0')"><a name=
"substTemplateTypeParmType0Anchor">substTemplateTypeParmType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html">SubstTemplateTypeParmType
</a>>...
</td></tr>
2778 <tr><td colspan=
"4" class=
"doc" id=
"substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a
2779 template type parameter.
2782 template
<typename T
>
2787 substTemplateTypeParmType() matches the type of 't' but not '
1'
2791 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('tagType0')"><a name=
"tagType0Anchor">tagType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType
</a>>...
</td></tr>
2792 <tr><td colspan=
"4" class=
"doc" id=
"tagType0"><pre>Matches tag types (record and enum types).
2801 tagType() matches the type of the variable declarations of both e
2806 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('templateSpecializationType0')"><a name=
"templateSpecializationType0Anchor">templateSpecializationType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType
</a>>...
</td></tr>
2807 <tr><td colspan=
"4" class=
"doc" id=
"templateSpecializationType0"><pre>Matches template specialization types.
2810 template
<typename T
>
2813 template class C
<int
>; // A
2814 C
<char
> var; // B
2816 templateSpecializationType() matches the type of the explicit
2817 instantiation in A and the type of the variable declaration in B.
2821 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('templateTypeParmType0')"><a name=
"templateTypeParmType0Anchor">templateTypeParmType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType
</a>>...
</td></tr>
2822 <tr><td colspan=
"4" class=
"doc" id=
"templateTypeParmType0"><pre>Matches template type parameter types.
2824 Example matches T, but not int.
2825 (matcher = templateTypeParmType())
2826 template
<typename T
> void f(int i);
2830 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('type0')"><a name=
"type0Anchor">type
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>>...
</td></tr>
2831 <tr><td colspan=
"4" class=
"doc" id=
"type0"><pre>Matches Types in the clang AST.
2835 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('typedefType0')"><a name=
"typedefType0Anchor">typedefType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType
</a>>...
</td></tr>
2836 <tr><td colspan=
"4" class=
"doc" id=
"typedefType0"><pre>Matches typedef types.
2841 matches
"typedef int X"
2845 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('unaryTransformType0')"><a name=
"unaryTransformType0Anchor">unaryTransformType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UnaryTransformType.html">UnaryTransformType
</a>>...
</td></tr>
2846 <tr><td colspan=
"4" class=
"doc" id=
"unaryTransformType0"><pre>Matches types nodes representing unary type transformations.
2849 typedef __underlying_type(T) type;
2850 unaryTransformType()
2851 matches
"__underlying_type(T)"
2855 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('usingType0')"><a name=
"usingType0Anchor">usingType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UsingType.html">UsingType
</a>>...
</td></tr>
2856 <tr><td colspan=
"4" class=
"doc" id=
"usingType0"><pre>Matches types specified through a using declaration.
2859 namespace a { struct S {}; }
2863 usingType() matches the type of the variable declaration of s.
2867 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Type.html">Type
</a>></td><td class=
"name" onclick=
"toggle('variableArrayType0')"><a name=
"variableArrayType0Anchor">variableArrayType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1VariableArrayType.html">VariableArrayType
</a>>...
</td></tr>
2868 <tr><td colspan=
"4" class=
"doc" id=
"variableArrayType0"><pre>Matches C arrays with a specified size that is not an
2869 integer-constant-expression.
2878 matches
"int c[a[0]]"
2881 <!--END_DECL_MATCHERS -->
2884 <!-- ======================================================================= -->
2885 <h2 id=
"narrowing-matchers">Narrowing Matchers
</h2>
2886 <!-- ======================================================================= -->
2888 <p>Narrowing matchers match certain attributes on the current node, thus
2889 narrowing down the set of nodes of the current type to match on.
</p>
2891 <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless)
2892 which allow users to create more powerful match expressions.
</p>
2895 <tr style=
"text-align:left"><th>Return type
</th><th>Name
</th><th>Parameters
</th></tr>
2896 <!-- START_NARROWING_MATCHERS -->
2898 <tr><td>Matcher
<*
></td><td class=
"name" onclick=
"toggle('allOf0')"><a name=
"allOf0Anchor">allOf
</a></td><td>Matcher
<*
>, ..., Matcher
<*
></td></tr>
2899 <tr><td colspan=
"4" class=
"doc" id=
"allOf0"><pre>Matches if all given matchers match.
2901 Usable as: Any Matcher
2905 <tr><td>Matcher
<*
></td><td class=
"name" onclick=
"toggle('anyOf0')"><a name=
"anyOf0Anchor">anyOf
</a></td><td>Matcher
<*
>, ..., Matcher
<*
></td></tr>
2906 <tr><td colspan=
"4" class=
"doc" id=
"anyOf0"><pre>Matches if any of the given matchers matches.
2908 Usable as: Any Matcher
2912 <tr><td>Matcher
<*
></td><td class=
"name" onclick=
"toggle('anything0')"><a name=
"anything0Anchor">anything
</a></td><td></td></tr>
2913 <tr><td colspan=
"4" class=
"doc" id=
"anything0"><pre>Matches any node.
2915 Useful when another matcher requires a child matcher, but there's no
2916 additional constraint. This will often be used with an explicit conversion
2917 to an internal::Matcher
<> type such as TypeMatcher.
2919 Example: DeclarationMatcher(anything()) matches all declarations, e.g.,
2920 "int* p" and
"void f()" in
2924 Usable as: Any Matcher
2928 <tr><td><em>unspecified
</em></td><td class=
"name" onclick=
"toggle('mapAnyOf0')"><a name=
"mapAnyOf0Anchor">mapAnyOf
</a></td><td>nodeMatcherFunction...
</td></tr>
2929 <tr><td colspan=
"4" class=
"doc" id=
"mapAnyOf0"><pre>Matches any of the NodeMatchers with InnerMatchers nested within
2935 mapAnyOf(ifStmt, forStmt).with(
2936 hasCondition(cxxBoolLiteralExpr(equals(true)))
2938 matches the if and the for. It is equivalent to:
2939 auto trueCond = hasCondition(cxxBoolLiteralExpr(equals(true)));
2941 ifStmt(trueCond).bind(
"trueCond"),
2942 forStmt(trueCond).bind(
"trueCond")
2945 The with() chain-call accepts zero or more matchers which are combined
2946 as-if with allOf() in each of the node matchers.
2947 Usable as: Any Matcher
2951 <tr><td>Matcher
<*
></td><td class=
"name" onclick=
"toggle('unless0')"><a name=
"unless0Anchor">unless
</a></td><td>Matcher
<*
></td></tr>
2952 <tr><td colspan=
"4" class=
"doc" id=
"unless0"><pre>Matches if the provided matcher does not match.
2954 Example matches Y (matcher = cxxRecordDecl(unless(hasName(
"X"))))
2958 Usable as: Any Matcher
2962 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Attr.html">Attr
</a>></td><td class=
"name" onclick=
"toggle('isImplicit1')"><a name=
"isImplicit1Anchor">isImplicit
</a></td><td></td></tr>
2963 <tr><td colspan=
"4" class=
"doc" id=
"isImplicit1"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
2964 implicit default/copy constructors).
2968 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator
</a>></td><td class=
"name" onclick=
"toggle('hasAnyOperatorName0')"><a name=
"hasAnyOperatorName0Anchor">hasAnyOperatorName
</a></td><td>StringRef, ..., StringRef
</td></tr>
2969 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOperatorName0"><pre>Matches operator expressions (binary or unary) that have any of the
2972 hasAnyOperatorName(
"+",
"-")
2974 anyOf(hasOperatorName(
"+"), hasOperatorName(
"-"))
2978 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator
</a>></td><td class=
"name" onclick=
"toggle('hasOperatorName0')"><a name=
"hasOperatorName0Anchor">hasOperatorName
</a></td><td>std::string Name
</td></tr>
2979 <tr><td colspan=
"4" class=
"doc" id=
"hasOperatorName0"><pre>Matches the operator Name of operator expressions and fold expressions
2982 Example matches a || b (matcher = binaryOperator(hasOperatorName(
"||")))
2985 Example matches `(
0 + ... + args)`
2986 (matcher = cxxFoldExpr(hasOperatorName(
"+")))
2987 template
<typename... Args
>
2988 auto sum(Args... args) {
2989 return (
0 + ... + args);
2994 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator
</a>></td><td class=
"name" onclick=
"toggle('isAssignmentOperator0')"><a name=
"isAssignmentOperator0Anchor">isAssignmentOperator
</a></td><td></td></tr>
2995 <tr><td colspan=
"4" class=
"doc" id=
"isAssignmentOperator0"><pre>Matches all kinds of assignment operators.
2997 Example
1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3001 Example
2: matches s1 = s2
3002 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3003 struct S { S
& operator=(const S
&); };
3004 void x() { S s1, s2; s1 = s2; }
3008 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator
</a>></td><td class=
"name" onclick=
"toggle('isComparisonOperator0')"><a name=
"isComparisonOperator0Anchor">isComparisonOperator
</a></td><td></td></tr>
3009 <tr><td colspan=
"4" class=
"doc" id=
"isComparisonOperator0"><pre>Matches comparison operators.
3011 Example
1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3015 Example
2: matches s1
< s2
3016 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3017 struct S { bool operator
<(const S
& other); };
3018 void x(S s1, S s2) { bool b1 = s1
< s2; }
3022 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>></td><td class=
"name" onclick=
"toggle('isPrivate1')"><a name=
"isPrivate1Anchor">isPrivate
</a></td><td></td></tr>
3023 <tr><td colspan=
"4" class=
"doc" id=
"isPrivate1"><pre>Matches private C++ declarations and C++ base specifers that specify private
3030 private: int c; // fieldDecl(isPrivate()) matches 'c'
3034 struct Derived1 : private Base {}; // matches 'Base'
3035 class Derived2 : Base {}; // matches 'Base'
3039 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>></td><td class=
"name" onclick=
"toggle('isProtected1')"><a name=
"isProtected1Anchor">isProtected
</a></td><td></td></tr>
3040 <tr><td colspan=
"4" class=
"doc" id=
"isProtected1"><pre>Matches protected C++ declarations and C++ base specifers that specify
3041 protected inheritance.
3046 protected: int b; // fieldDecl(isProtected()) matches 'b'
3051 class Derived : protected Base {}; // matches 'Base'
3055 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>></td><td class=
"name" onclick=
"toggle('isPublic1')"><a name=
"isPublic1Anchor">isPublic
</a></td><td></td></tr>
3056 <tr><td colspan=
"4" class=
"doc" id=
"isPublic1"><pre>Matches public C++ declarations and C++ base specifers that specify public
3061 public: int a; // fieldDecl(isPublic()) matches 'a'
3067 class Derived1 : public Base {}; // matches 'Base'
3068 struct Derived2 : Base {}; // matches 'Base'
3072 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>></td><td class=
"name" onclick=
"toggle('isVirtual1')"><a name=
"isVirtual1Anchor">isVirtual
</a></td><td></td></tr>
3073 <tr><td colspan=
"4" class=
"doc" id=
"isVirtual1"><pre>Matches declarations of virtual methods and C++ base specifers that specify
3074 virtual inheritance.
3079 virtual void x(); // matches x
3084 class DirectlyDerived : virtual Base {}; // matches Base
3085 class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
3087 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>>
3091 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr
</a>></td><td class=
"name" onclick=
"toggle('equals5')"><a name=
"equals5Anchor">equals
</a></td><td>bool Value
</td></tr>
3092 <tr><td colspan=
"4" class=
"doc" id=
"equals5"><pre></pre></td></tr>
3095 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr
</a>></td><td class=
"name" onclick=
"toggle('equals2')"><a name=
"equals2Anchor">equals
</a></td><td>const ValueT Value
</td></tr>
3096 <tr><td colspan=
"4" class=
"doc" id=
"equals2"><pre>Matches literals that are equal to the given value of type ValueT.
3099 f('false,
3.14,
42);
3100 characterLiteral(equals(
0))
3101 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(
0))
3103 floatLiteral(equals(
3.14)) and floatLiteral(equals(
314e-2))
3105 integerLiteral(equals(
42))
3108 Note that you cannot directly match a negative numeric literal because the
3109 minus sign is not part of the literal: It is a unary operator whose operand
3110 is the positive numeric literal. Instead, you must use a unaryOperator()
3111 matcher to match the minus sign:
3113 unaryOperator(hasOperatorName(
"-"),
3114 hasUnaryOperand(integerLiteral(equals(
13))))
3116 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr
</a>>,
3117 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral
</a>>
3121 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr
</a>></td><td class=
"name" onclick=
"toggle('equals11')"><a name=
"equals11Anchor">equals
</a></td><td>double Value
</td></tr>
3122 <tr><td colspan=
"4" class=
"doc" id=
"equals11"><pre></pre></td></tr>
3125 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr
</a>></td><td class=
"name" onclick=
"toggle('equals8')"><a name=
"equals8Anchor">equals
</a></td><td>unsigned Value
</td></tr>
3126 <tr><td colspan=
"4" class=
"doc" id=
"equals8"><pre></pre></td></tr>
3129 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt
</a>></td><td class=
"name" onclick=
"toggle('isCatchAll0')"><a name=
"isCatchAll0Anchor">isCatchAll
</a></td><td></td></tr>
3130 <tr><td colspan=
"4" class=
"doc" id=
"isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler.
3140 cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
3144 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr
</a>></td><td class=
"name" onclick=
"toggle('argumentCountAtLeast1')"><a name=
"argumentCountAtLeast1Anchor">argumentCountAtLeast
</a></td><td>unsigned N
</td></tr>
3145 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountAtLeast1"><pre>Checks that a call expression or a constructor call expression has at least
3146 the specified number of arguments (including absent default arguments).
3148 Example matches f(
0,
0) and g(
0,
0,
0)
3149 (matcher = callExpr(argumentCountAtLeast(
2)))
3150 void f(int x, int y);
3151 void g(int x, int y, int z);
3157 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr
</a>></td><td class=
"name" onclick=
"toggle('argumentCountIs1')"><a name=
"argumentCountIs1Anchor">argumentCountIs
</a></td><td>unsigned N
</td></tr>
3158 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has
3159 a specific number of arguments (including absent default arguments).
3161 Example matches f(
0,
0) (matcher = callExpr(argumentCountIs(
2)))
3162 void f(int x, int y);
3167 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr
</a>></td><td class=
"name" onclick=
"toggle('isListInitialization0')"><a name=
"isListInitialization0Anchor">isListInitialization
</a></td><td></td></tr>
3168 <tr><td colspan=
"4" class=
"doc" id=
"isListInitialization0"><pre>Matches a constructor call expression which uses list initialization.
3172 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr
</a>></td><td class=
"name" onclick=
"toggle('requiresZeroInitialization0')"><a name=
"requiresZeroInitialization0Anchor">requiresZeroInitialization
</a></td><td></td></tr>
3173 <tr><td colspan=
"4" class=
"doc" id=
"requiresZeroInitialization0"><pre>Matches a constructor call expression which requires
3174 zero initialization.
3178 struct point { double x; double y; };
3179 point pt[
2] = { {
1.0,
2.0 } };
3181 initListExpr(has(cxxConstructExpr(requiresZeroInitialization()))
3182 will match the implicit array filler for pt[
1].
3186 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl
</a>></td><td class=
"name" onclick=
"toggle('isCopyConstructor0')"><a name=
"isCopyConstructor0Anchor">isCopyConstructor
</a></td><td></td></tr>
3187 <tr><td colspan=
"4" class=
"doc" id=
"isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors.
3192 S(const S
&); // #
2
3193 S(S
&&); // #
3
3195 cxxConstructorDecl(isCopyConstructor()) will match #
2, but not #
1 or #
3.
3199 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl
</a>></td><td class=
"name" onclick=
"toggle('isDefaultConstructor0')"><a name=
"isDefaultConstructor0Anchor">isDefaultConstructor
</a></td><td></td></tr>
3200 <tr><td colspan=
"4" class=
"doc" id=
"isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors.
3205 S(const S
&); // #
2
3206 S(S
&&); // #
3
3208 cxxConstructorDecl(isDefaultConstructor()) will match #
1, but not #
2 or #
3.
3212 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl
</a>></td><td class=
"name" onclick=
"toggle('isDelegatingConstructor0')"><a name=
"isDelegatingConstructor0Anchor">isDelegatingConstructor
</a></td><td></td></tr>
3213 <tr><td colspan=
"4" class=
"doc" id=
"isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor.
3219 S(S
&&) : S() {} // #
3
3221 S::S() : S(
0) {} // #
4
3222 cxxConstructorDecl(isDelegatingConstructor()) will match #
3 and #
4, but not
3227 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl
</a>></td><td class=
"name" onclick=
"toggle('isExplicit0')"><a name=
"isExplicit0Anchor">isExplicit
</a></td><td></td></tr>
3228 <tr><td colspan=
"4" class=
"doc" id=
"isExplicit0"><pre>Matches constructor, conversion function, and deduction guide declarations
3229 that have an explicit specifier if this explicit specifier is resolved to
3233 template
<bool b
>
3236 explicit S(double); // #
2
3237 operator int(); // #
3
3238 explicit operator bool(); // #
4
3239 explicit(false) S(bool) // #
7
3240 explicit(true) S(char) // #
8
3241 explicit(b) S(S) // #
9
3243 S(int) -
> S
<true
> // #
5
3244 explicit S(double) -
> S
<false
> // #
6
3245 cxxConstructorDecl(isExplicit()) will match #
2 and #
8, but not #
1, #
7 or #
9.
3246 cxxConversionDecl(isExplicit()) will match #
4, but not #
3.
3247 cxxDeductionGuideDecl(isExplicit()) will match #
6, but not #
5.
3251 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl
</a>></td><td class=
"name" onclick=
"toggle('isInheritingConstructor0')"><a name=
"isInheritingConstructor0Anchor">isInheritingConstructor
</a></td><td></td></tr>
3252 <tr><td colspan=
"4" class=
"doc" id=
"isInheritingConstructor0"><pre></pre></td></tr>
3255 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl
</a>></td><td class=
"name" onclick=
"toggle('isMoveConstructor0')"><a name=
"isMoveConstructor0Anchor">isMoveConstructor
</a></td><td></td></tr>
3256 <tr><td colspan=
"4" class=
"doc" id=
"isMoveConstructor0"><pre>Matches constructor declarations that are move constructors.
3261 S(const S
&); // #
2
3262 S(S
&&); // #
3
3264 cxxConstructorDecl(isMoveConstructor()) will match #
3, but not #
1 or #
2.
3268 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl
</a>></td><td class=
"name" onclick=
"toggle('isExplicit1')"><a name=
"isExplicit1Anchor">isExplicit
</a></td><td></td></tr>
3269 <tr><td colspan=
"4" class=
"doc" id=
"isExplicit1"><pre>Matches constructor, conversion function, and deduction guide declarations
3270 that have an explicit specifier if this explicit specifier is resolved to
3274 template
<bool b
>
3277 explicit S(double); // #
2
3278 operator int(); // #
3
3279 explicit operator bool(); // #
4
3280 explicit(false) S(bool) // #
7
3281 explicit(true) S(char) // #
8
3282 explicit(b) S(S) // #
9
3284 S(int) -
> S
<true
> // #
5
3285 explicit S(double) -
> S
<false
> // #
6
3286 cxxConstructorDecl(isExplicit()) will match #
2 and #
8, but not #
1, #
7 or #
9.
3287 cxxConversionDecl(isExplicit()) will match #
4, but not #
3.
3288 cxxDeductionGuideDecl(isExplicit()) will match #
6, but not #
5.
3292 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>></td><td class=
"name" onclick=
"toggle('isBaseInitializer0')"><a name=
"isBaseInitializer0Anchor">isBaseInitializer
</a></td><td></td></tr>
3293 <tr><td colspan=
"4" class=
"doc" id=
"isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as
3294 opposed to a member.
3305 cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
3306 will match E(), but not match D(int).
3310 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>></td><td class=
"name" onclick=
"toggle('isMemberInitializer0')"><a name=
"isMemberInitializer0Anchor">isMemberInitializer
</a></td><td></td></tr>
3311 <tr><td colspan=
"4" class=
"doc" id=
"isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as
3323 cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
3324 will match D(int), but not match E().
3328 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>></td><td class=
"name" onclick=
"toggle('isWritten0')"><a name=
"isWritten0Anchor">isWritten
</a></td><td></td></tr>
3329 <tr><td colspan=
"4" class=
"doc" id=
"isWritten0"><pre>Matches a constructor initializer if it is explicitly written in
3330 code (as opposed to implicitly added by the compiler).
3335 Foo(int) : foo_(
"A") { }
3338 cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
3339 will match Foo(int), but not Foo()
3343 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXDeductionGuideDecl.html">CXXDeductionGuideDecl
</a>></td><td class=
"name" onclick=
"toggle('isExplicit2')"><a name=
"isExplicit2Anchor">isExplicit
</a></td><td></td></tr>
3344 <tr><td colspan=
"4" class=
"doc" id=
"isExplicit2"><pre>Matches constructor, conversion function, and deduction guide declarations
3345 that have an explicit specifier if this explicit specifier is resolved to
3349 template
<bool b
>
3352 explicit S(double); // #
2
3353 operator int(); // #
3
3354 explicit operator bool(); // #
4
3355 explicit(false) S(bool) // #
7
3356 explicit(true) S(char) // #
8
3357 explicit(b) S(S) // #
9
3359 S(int) -
> S
<true
> // #
5
3360 explicit S(double) -
> S
<false
> // #
6
3361 cxxConstructorDecl(isExplicit()) will match #
2 and #
8, but not #
1, #
7 or #
9.
3362 cxxConversionDecl(isExplicit()) will match #
4, but not #
3.
3363 cxxDeductionGuideDecl(isExplicit()) will match #
6, but not #
5.
3367 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr
</a>></td><td class=
"name" onclick=
"toggle('hasMemberName0')"><a name=
"hasMemberName0Anchor">hasMemberName
</a></td><td>std::string N
</td></tr>
3368 <tr><td colspan=
"4" class=
"doc" id=
"hasMemberName0"><pre>Matches template-dependent, but known, member names.
3370 In template declarations, dependent members are not resolved and so can
3371 not be matched to particular named declarations.
3373 This matcher allows to match on the known name of members.
3376 template
<typename T
>
3380 template
<typename T
>
3385 cxxDependentScopeMemberExpr(hasMemberName(
"mem")) matches `s.mem()`
3389 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr
</a>></td><td class=
"name" onclick=
"toggle('isArrow2')"><a name=
"isArrow2Anchor">isArrow
</a></td><td></td></tr>
3390 <tr><td colspan=
"4" class=
"doc" id=
"isArrow2"><pre>Matches member expressions that are called with '-
>' as opposed
3393 Member calls on the implicit this pointer match as called with '-
>'.
3397 void x() { this-
>x(); x(); Y y; y.x(); a; this-
>b; Y::b; }
3398 template
<class T
> void f() { this-
>f
<T
>(); f
<T
>(); }
3402 template
<class T
>
3404 void x() { this-
>m; }
3406 memberExpr(isArrow())
3407 matches this-
>x, x, y.x, a, this-
>b
3408 cxxDependentScopeMemberExpr(isArrow())
3410 unresolvedMemberExpr(isArrow())
3411 matches this-
>f
<T
>, f
<T
>
3415 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr
</a>></td><td class=
"name" onclick=
"toggle('memberHasSameNameAsBoundNode0')"><a name=
"memberHasSameNameAsBoundNode0Anchor">memberHasSameNameAsBoundNode
</a></td><td>std::string BindingID
</td></tr>
3416 <tr><td colspan=
"4" class=
"doc" id=
"memberHasSameNameAsBoundNode0"><pre>Matches template-dependent, but known, member names against an already-bound
3419 In template declarations, dependent members are not resolved and so can
3420 not be matched to particular named declarations.
3422 This matcher allows to match on the name of already-bound VarDecl, FieldDecl
3423 and CXXMethodDecl nodes.
3426 template
<typename T
>
3430 template
<typename T
>
3437 cxxDependentScopeMemberExpr(
3438 hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
3439 hasDeclaration(classTemplateDecl(has(cxxRecordDecl(has(
3440 cxxMethodDecl(hasName(
"mem")).bind(
"templMem")
3443 memberHasSameNameAsBoundNode(
"templMem")
3446 first matches and binds the @c mem member of the @c S template, then
3447 compares its name to the usage in @c s.mem() in the @c x function template
3451 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr
</a>></td><td class=
"name" onclick=
"toggle('hasOperatorName3')"><a name=
"hasOperatorName3Anchor">hasOperatorName
</a></td><td>std::string Name
</td></tr>
3452 <tr><td colspan=
"4" class=
"doc" id=
"hasOperatorName3"><pre>Matches the operator Name of operator expressions and fold expressions
3455 Example matches a || b (matcher = binaryOperator(hasOperatorName(
"||")))
3458 Example matches `(
0 + ... + args)`
3459 (matcher = cxxFoldExpr(hasOperatorName(
"+")))
3460 template
<typename... Args
>
3461 auto sum(Args... args) {
3462 return (
0 + ... + args);
3467 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr
</a>></td><td class=
"name" onclick=
"toggle('isBinaryFold0')"><a name=
"isBinaryFold0Anchor">isBinaryFold
</a></td><td></td></tr>
3468 <tr><td colspan=
"4" class=
"doc" id=
"isBinaryFold0"><pre>Matches binary fold expressions, i.e. fold expressions with an initializer.
3470 Example matches `(
0 + ... + args)`
3471 (matcher = cxxFoldExpr(isBinaryFold()))
3472 template
<typename... Args
>
3473 auto sum(Args... args) {
3474 return (
0 + ... + args);
3477 template
<typename... Args
>
3478 auto multiply(Args... args) {
3479 return (args * ...);
3484 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr
</a>></td><td class=
"name" onclick=
"toggle('isLeftFold0')"><a name=
"isLeftFold0Anchor">isLeftFold
</a></td><td></td></tr>
3485 <tr><td colspan=
"4" class=
"doc" id=
"isLeftFold0"><pre>Matches left-folding fold expressions.
3487 Example matches `(
0 + ... + args)`
3488 (matcher = cxxFoldExpr(isLeftFold()))
3489 template
<typename... Args
>
3490 auto sum(Args... args) {
3491 return (
0 + ... + args);
3494 template
<typename... Args
>
3495 auto multiply(Args... args) {
3496 return (args * ... *
1);
3501 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr
</a>></td><td class=
"name" onclick=
"toggle('isRightFold0')"><a name=
"isRightFold0Anchor">isRightFold
</a></td><td></td></tr>
3502 <tr><td colspan=
"4" class=
"doc" id=
"isRightFold0"><pre>Matches right-folding fold expressions.
3504 Example matches `(args * ... *
1)`
3505 (matcher = cxxFoldExpr(isRightFold()))
3506 template
<typename... Args
>
3507 auto sum(Args... args) {
3508 return (
0 + ... + args);
3511 template
<typename... Args
>
3512 auto multiply(Args... args) {
3513 return (args * ... *
1);
3518 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr
</a>></td><td class=
"name" onclick=
"toggle('isUnaryFold0')"><a name=
"isUnaryFold0Anchor">isUnaryFold
</a></td><td></td></tr>
3519 <tr><td colspan=
"4" class=
"doc" id=
"isUnaryFold0"><pre>Matches unary fold expressions, i.e. fold expressions without an
3522 Example matches `(args * ...)`
3523 (matcher = cxxFoldExpr(isUnaryFold()))
3524 template
<typename... Args
>
3525 auto sum(Args... args) {
3526 return (
0 + ... + args);
3529 template
<typename... Args
>
3530 auto multiply(Args... args) {
3531 return (args * ...);
3536 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>></td><td class=
"name" onclick=
"toggle('isConst0')"><a name=
"isConst0Anchor">isConst
</a></td><td></td></tr>
3537 <tr><td colspan=
"4" class=
"doc" id=
"isConst0"><pre>Matches if the given method declaration is const.
3545 cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
3549 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>></td><td class=
"name" onclick=
"toggle('isCopyAssignmentOperator0')"><a name=
"isCopyAssignmentOperator0Anchor">isCopyAssignmentOperator
</a></td><td></td></tr>
3550 <tr><td colspan=
"4" class=
"doc" id=
"isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment
3555 A
&operator=(const A
&);
3556 A
&operator=(A
&&);
3559 cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not
3564 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>></td><td class=
"name" onclick=
"toggle('isFinal1')"><a name=
"isFinal1Anchor">isFinal
</a></td><td></td></tr>
3565 <tr><td colspan=
"4" class=
"doc" id=
"isFinal1"><pre>Matches if the given method or class declaration is final.
3577 matches A and C::f, but not B, C, or B::f
3581 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>></td><td class=
"name" onclick=
"toggle('isMoveAssignmentOperator0')"><a name=
"isMoveAssignmentOperator0Anchor">isMoveAssignmentOperator
</a></td><td></td></tr>
3582 <tr><td colspan=
"4" class=
"doc" id=
"isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment
3587 A
&operator=(const A
&);
3588 A
&operator=(A
&&);
3591 cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not
3596 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>></td><td class=
"name" onclick=
"toggle('isOverride0')"><a name=
"isOverride0Anchor">isOverride
</a></td><td></td></tr>
3597 <tr><td colspan=
"4" class=
"doc" id=
"isOverride0"><pre>Matches if the given method declaration overrides another method.
3604 class B : public A {
3612 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>></td><td class=
"name" onclick=
"toggle('isPure0')"><a name=
"isPure0Anchor">isPure
</a></td><td></td></tr>
3613 <tr><td colspan=
"4" class=
"doc" id=
"isPure0"><pre>Matches if the given method declaration is pure.
3618 virtual void x() =
0;
3624 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>></td><td class=
"name" onclick=
"toggle('isUserProvided0')"><a name=
"isUserProvided0Anchor">isUserProvided
</a></td><td></td></tr>
3625 <tr><td colspan=
"4" class=
"doc" id=
"isUserProvided0"><pre>Matches method declarations that are user-provided.
3630 S(const S
&) = default; // #
2
3631 S(S
&&) = delete; // #
3
3633 cxxConstructorDecl(isUserProvided()) will match #
1, but not #
2 or #
3.
3637 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>></td><td class=
"name" onclick=
"toggle('isVirtual0')"><a name=
"isVirtual0Anchor">isVirtual
</a></td><td></td></tr>
3638 <tr><td colspan=
"4" class=
"doc" id=
"isVirtual0"><pre>Matches declarations of virtual methods and C++ base specifers that specify
3639 virtual inheritance.
3644 virtual void x(); // matches x
3649 class DirectlyDerived : virtual Base {}; // matches Base
3650 class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
3652 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>>
3656 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>></td><td class=
"name" onclick=
"toggle('isVirtualAsWritten0')"><a name=
"isVirtualAsWritten0Anchor">isVirtualAsWritten
</a></td><td></td></tr>
3657 <tr><td colspan=
"4" class=
"doc" id=
"isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit
"virtual".
3664 class B : public A {
3668 matches A::x but not B::x
3672 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr
</a>></td><td class=
"name" onclick=
"toggle('isArray0')"><a name=
"isArray0Anchor">isArray
</a></td><td></td></tr>
3673 <tr><td colspan=
"4" class=
"doc" id=
"isArray0"><pre>Matches array new expressions.
3676 MyClass *p1 = new MyClass[
10];
3677 cxxNewExpr(isArray())
3678 matches the expression 'new MyClass[
10]'.
3682 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr
</a>></td><td class=
"name" onclick=
"toggle('hasAnyOperatorName1')"><a name=
"hasAnyOperatorName1Anchor">hasAnyOperatorName
</a></td><td>StringRef, ..., StringRef
</td></tr>
3683 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOperatorName1"><pre>Matches operator expressions (binary or unary) that have any of the
3686 hasAnyOperatorName(
"+",
"-")
3688 anyOf(hasOperatorName(
"+"), hasOperatorName(
"-"))
3692 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr
</a>></td><td class=
"name" onclick=
"toggle('hasAnyOverloadedOperatorName0')"><a name=
"hasAnyOverloadedOperatorName0Anchor">hasAnyOverloadedOperatorName
</a></td><td>StringRef, ..., StringRef
</td></tr>
3693 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOverloadedOperatorName0"><pre>Matches overloaded operator names.
3695 Matches overloaded operator names specified in strings without the
3696 "operator" prefix: e.g.
"<<".
3698 hasAnyOverloadedOperatorName(
"+",
"-")
3700 anyOf(hasOverloadedOperatorName(
"+"), hasOverloadedOperatorName(
"-"))
3704 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr
</a>></td><td class=
"name" onclick=
"toggle('hasOperatorName1')"><a name=
"hasOperatorName1Anchor">hasOperatorName
</a></td><td>std::string Name
</td></tr>
3705 <tr><td colspan=
"4" class=
"doc" id=
"hasOperatorName1"><pre>Matches the operator Name of operator expressions and fold expressions
3708 Example matches a || b (matcher = binaryOperator(hasOperatorName(
"||")))
3711 Example matches `(
0 + ... + args)`
3712 (matcher = cxxFoldExpr(hasOperatorName(
"+")))
3713 template
<typename... Args
>
3714 auto sum(Args... args) {
3715 return (
0 + ... + args);
3720 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr
</a>></td><td class=
"name" onclick=
"toggle('hasOverloadedOperatorName1')"><a name=
"hasOverloadedOperatorName1Anchor">hasOverloadedOperatorName
</a></td><td>StringRef Name
</td></tr>
3721 <tr><td colspan=
"4" class=
"doc" id=
"hasOverloadedOperatorName1"><pre>Matches overloaded operator names.
3723 Matches overloaded operator names specified in strings without the
3724 "operator" prefix: e.g.
"<<".
3727 class A { int operator*(); };
3728 const A
&operator
<<(const A
&a, const A
&b);
3730 a
<< a; //
<-- This matches
3732 cxxOperatorCallExpr(hasOverloadedOperatorName(
"<<"))) matches the
3734 cxxRecordDecl(hasMethod(hasOverloadedOperatorName(
"*")))
3735 matches the declaration of A.
3737 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>>
3741 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr
</a>></td><td class=
"name" onclick=
"toggle('isAssignmentOperator1')"><a name=
"isAssignmentOperator1Anchor">isAssignmentOperator
</a></td><td></td></tr>
3742 <tr><td colspan=
"4" class=
"doc" id=
"isAssignmentOperator1"><pre>Matches all kinds of assignment operators.
3744 Example
1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3748 Example
2: matches s1 = s2
3749 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3750 struct S { S
& operator=(const S
&); };
3751 void x() { S s1, s2; s1 = s2; }
3755 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr
</a>></td><td class=
"name" onclick=
"toggle('isComparisonOperator1')"><a name=
"isComparisonOperator1Anchor">isComparisonOperator
</a></td><td></td></tr>
3756 <tr><td colspan=
"4" class=
"doc" id=
"isComparisonOperator1"><pre>Matches comparison operators.
3758 Example
1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3762 Example
2: matches s1
< s2
3763 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3764 struct S { bool operator
<(const S
& other); };
3765 void x(S s1, S s2) { bool b1 = s1
< s2; }
3769 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>></td><td class=
"name" onclick=
"toggle('hasDefinition0')"><a name=
"hasDefinition0Anchor">hasDefinition
</a></td><td></td></tr>
3770 <tr><td colspan=
"4" class=
"doc" id=
"hasDefinition0"><pre>Matches a class declaration that is defined.
3772 Example matches x (matcher = cxxRecordDecl(hasDefinition()))
3778 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>></td><td class=
"name" onclick=
"toggle('isDerivedFrom2')"><a name=
"isDerivedFrom2Anchor">isDerivedFrom
</a></td><td>std::string BaseName
</td></tr>
3779 <tr><td colspan=
"4" class=
"doc" id=
"isDerivedFrom2"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
3783 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>></td><td class=
"name" onclick=
"toggle('isDirectlyDerivedFrom2')"><a name=
"isDirectlyDerivedFrom2Anchor">isDirectlyDerivedFrom
</a></td><td>std::string BaseName
</td></tr>
3784 <tr><td colspan=
"4" class=
"doc" id=
"isDirectlyDerivedFrom2"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
3788 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>></td><td class=
"name" onclick=
"toggle('isExplicitTemplateSpecialization2')"><a name=
"isExplicitTemplateSpecialization2Anchor">isExplicitTemplateSpecialization
</a></td><td></td></tr>
3789 <tr><td colspan=
"4" class=
"doc" id=
"isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or
3790 static member variable template instantiations.
3793 template
<typename T
> void A(T t) { }
3794 template
<> void A(int N) { }
3795 functionDecl(isExplicitTemplateSpecialization())
3796 matches the specialization A
<int
>().
3798 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>>
3802 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>></td><td class=
"name" onclick=
"toggle('isFinal0')"><a name=
"isFinal0Anchor">isFinal
</a></td><td></td></tr>
3803 <tr><td colspan=
"4" class=
"doc" id=
"isFinal0"><pre>Matches if the given method or class declaration is final.
3815 matches A and C::f, but not B, C, or B::f
3819 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>></td><td class=
"name" onclick=
"toggle('isLambda0')"><a name=
"isLambda0Anchor">isLambda
</a></td><td></td></tr>
3820 <tr><td colspan=
"4" class=
"doc" id=
"isLambda0"><pre>Matches the generated class of lambda expressions.
3825 cxxRecordDecl(isLambda()) matches the implicit class declaration of
3830 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>></td><td class=
"name" onclick=
"toggle('isSameOrDerivedFrom2')"><a name=
"isSameOrDerivedFrom2Anchor">isSameOrDerivedFrom
</a></td><td>std::string BaseName
</td></tr>
3831 <tr><td colspan=
"4" class=
"doc" id=
"isSameOrDerivedFrom2"><pre>Overloaded method as shortcut for
3832 isSameOrDerivedFrom(hasName(...)).
3836 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>></td><td class=
"name" onclick=
"toggle('isTemplateInstantiation2')"><a name=
"isTemplateInstantiation2Anchor">isTemplateInstantiation
</a></td><td></td></tr>
3837 <tr><td colspan=
"4" class=
"doc" id=
"isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static
3838 member variable template instantiations.
3841 template
<typename T
> class X {}; class A {}; X
<A
> x;
3843 template
<typename T
> class X {}; class A {}; template class X
<A
>;
3845 template
<typename T
> class X {}; class A {}; extern template class X
<A
>;
3846 cxxRecordDecl(hasName(
"::X"), isTemplateInstantiation())
3847 matches the template instantiation of X
<A
>.
3850 template
<typename T
> class X {}; class A {};
3851 template
<> class X
<A
> {}; X
<A
> x;
3852 cxxRecordDecl(hasName(
"::X"), isTemplateInstantiation())
3853 does not match, as X
<A
> is an explicit template specialization.
3855 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>>
3859 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator
</a>></td><td class=
"name" onclick=
"toggle('hasAnyOperatorName2')"><a name=
"hasAnyOperatorName2Anchor">hasAnyOperatorName
</a></td><td>StringRef, ..., StringRef
</td></tr>
3860 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOperatorName2"><pre>Matches operator expressions (binary or unary) that have any of the
3863 hasAnyOperatorName(
"+",
"-")
3865 anyOf(hasOperatorName(
"+"), hasOperatorName(
"-"))
3869 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator
</a>></td><td class=
"name" onclick=
"toggle('hasOperatorName2')"><a name=
"hasOperatorName2Anchor">hasOperatorName
</a></td><td>std::string Name
</td></tr>
3870 <tr><td colspan=
"4" class=
"doc" id=
"hasOperatorName2"><pre>Matches the operator Name of operator expressions and fold expressions
3873 Example matches a || b (matcher = binaryOperator(hasOperatorName(
"||")))
3876 Example matches `(
0 + ... + args)`
3877 (matcher = cxxFoldExpr(hasOperatorName(
"+")))
3878 template
<typename... Args
>
3879 auto sum(Args... args) {
3880 return (
0 + ... + args);
3885 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator
</a>></td><td class=
"name" onclick=
"toggle('isAssignmentOperator2')"><a name=
"isAssignmentOperator2Anchor">isAssignmentOperator
</a></td><td></td></tr>
3886 <tr><td colspan=
"4" class=
"doc" id=
"isAssignmentOperator2"><pre>Matches all kinds of assignment operators.
3888 Example
1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3892 Example
2: matches s1 = s2
3893 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3894 struct S { S
& operator=(const S
&); };
3895 void x() { S s1, s2; s1 = s2; }
3899 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator
</a>></td><td class=
"name" onclick=
"toggle('isComparisonOperator2')"><a name=
"isComparisonOperator2Anchor">isComparisonOperator
</a></td><td></td></tr>
3900 <tr><td colspan=
"4" class=
"doc" id=
"isComparisonOperator2"><pre>Matches comparison operators.
3902 Example
1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3906 Example
2: matches s1
< s2
3907 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3908 struct S { bool operator
<(const S
& other); };
3909 void x(S s1, S s2) { bool b1 = s1
< s2; }
3913 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>></td><td class=
"name" onclick=
"toggle('argumentCountAtLeast2')"><a name=
"argumentCountAtLeast2Anchor">argumentCountAtLeast
</a></td><td>unsigned N
</td></tr>
3914 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountAtLeast2"><pre>Checks that a call expression or a constructor call expression has at least
3915 the specified number of arguments (including absent default arguments).
3917 Example matches f(
0,
0) and g(
0,
0,
0)
3918 (matcher = callExpr(argumentCountAtLeast(
2)))
3919 void f(int x, int y);
3920 void g(int x, int y, int z);
3926 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>></td><td class=
"name" onclick=
"toggle('argumentCountIs2')"><a name=
"argumentCountIs2Anchor">argumentCountIs
</a></td><td>unsigned N
</td></tr>
3927 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has
3928 a specific number of arguments (including absent default arguments).
3930 Example matches f(
0,
0) (matcher = callExpr(argumentCountIs(
2)))
3931 void f(int x, int y);
3936 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr
</a>></td><td class=
"name" onclick=
"toggle('argumentCountAtLeast0')"><a name=
"argumentCountAtLeast0Anchor">argumentCountAtLeast
</a></td><td>unsigned N
</td></tr>
3937 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountAtLeast0"><pre>Checks that a call expression or a constructor call expression has at least
3938 the specified number of arguments (including absent default arguments).
3940 Example matches f(
0,
0) and g(
0,
0,
0)
3941 (matcher = callExpr(argumentCountAtLeast(
2)))
3942 void f(int x, int y);
3943 void g(int x, int y, int z);
3949 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr
</a>></td><td class=
"name" onclick=
"toggle('argumentCountIs0')"><a name=
"argumentCountIs0Anchor">argumentCountIs
</a></td><td>unsigned N
</td></tr>
3950 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has
3951 a specific number of arguments (including absent default arguments).
3953 Example matches f(
0,
0) (matcher = callExpr(argumentCountIs(
2)))
3954 void f(int x, int y);
3959 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr
</a>></td><td class=
"name" onclick=
"toggle('usesADL0')"><a name=
"usesADL0Anchor">usesADL
</a></td><td></td></tr>
3960 <tr><td colspan=
"4" class=
"doc" id=
"usesADL0"><pre>Matches call expressions which were resolved using ADL.
3962 Example matches y(x) but not y(
42) or NS::y(x).
3973 NS::y(x); // Doesn't match
3974 y(
42); // Doesn't match
3976 y(x); // Found by both unqualified lookup and ADL, doesn't match
3981 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr
</a>></td><td class=
"name" onclick=
"toggle('hasCastKind0')"><a name=
"hasCastKind0Anchor">hasCastKind
</a></td><td>CastKind Kind
</td></tr>
3982 <tr><td colspan=
"4" class=
"doc" id=
"hasCastKind0"><pre>Matches casts that has a given cast kind.
3984 Example: matches the implicit cast around
0
3985 (matcher = castExpr(hasCastKind(CK_NullToPointer)))
3988 If the matcher is use from clang-query, CastKind parameter
3989 should be passed as a quoted string. e.g., hasCastKind(
"CK_NullToPointer").
3993 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral
</a>></td><td class=
"name" onclick=
"toggle('equals4')"><a name=
"equals4Anchor">equals
</a></td><td>bool Value
</td></tr>
3994 <tr><td colspan=
"4" class=
"doc" id=
"equals4"><pre></pre></td></tr>
3997 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral
</a>></td><td class=
"name" onclick=
"toggle('equals3')"><a name=
"equals3Anchor">equals
</a></td><td>const ValueT Value
</td></tr>
3998 <tr><td colspan=
"4" class=
"doc" id=
"equals3"><pre>Matches literals that are equal to the given value of type ValueT.
4001 f('false,
3.14,
42);
4002 characterLiteral(equals(
0))
4003 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(
0))
4005 floatLiteral(equals(
3.14)) and floatLiteral(equals(
314e-2))
4007 integerLiteral(equals(
42))
4010 Note that you cannot directly match a negative numeric literal because the
4011 minus sign is not part of the literal: It is a unary operator whose operand
4012 is the positive numeric literal. Instead, you must use a unaryOperator()
4013 matcher to match the minus sign:
4015 unaryOperator(hasOperatorName(
"-"),
4016 hasUnaryOperand(integerLiteral(equals(
13))))
4018 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr
</a>>,
4019 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral
</a>>
4023 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral
</a>></td><td class=
"name" onclick=
"toggle('equals10')"><a name=
"equals10Anchor">equals
</a></td><td>double Value
</td></tr>
4024 <tr><td colspan=
"4" class=
"doc" id=
"equals10"><pre></pre></td></tr>
4027 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral
</a>></td><td class=
"name" onclick=
"toggle('equals7')"><a name=
"equals7Anchor">equals
</a></td><td>unsigned Value
</td></tr>
4028 <tr><td colspan=
"4" class=
"doc" id=
"equals7"><pre></pre></td></tr>
4031 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl
</a>></td><td class=
"name" onclick=
"toggle('templateArgumentCountIs0')"><a name=
"templateArgumentCountIs0Anchor">templateArgumentCountIs
</a></td><td>unsigned N
</td></tr>
4032 <tr><td colspan=
"4" class=
"doc" id=
"templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N.
4035 template
<typename T
> struct C {};
4037 classTemplateSpecializationDecl(templateArgumentCountIs(
1))
4038 matches C
<int
>.
4042 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt
</a>></td><td class=
"name" onclick=
"toggle('statementCountIs0')"><a name=
"statementCountIs0Anchor">statementCountIs
</a></td><td>unsigned N
</td></tr>
4043 <tr><td colspan=
"4" class=
"doc" id=
"statementCountIs0"><pre>Checks that a compound statement contains a specific number of
4048 compoundStmt(statementCountIs(
0)))
4050 but does not match the outer compound statement.
4054 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType
</a>></td><td class=
"name" onclick=
"toggle('hasSize0')"><a name=
"hasSize0Anchor">hasSize
</a></td><td>unsigned N
</td></tr>
4055 <tr><td colspan=
"4" class=
"doc" id=
"hasSize0"><pre>Matches nodes that have the specified size.
4062 wchar_t *ws = L
"abcd";
4064 constantArrayType(hasSize(
42))
4065 matches
"int a[42]" and
"int b[2 * 21]"
4066 stringLiteral(hasSize(
4))
4067 matches
"abcd", L
"abcd"
4071 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt
</a>></td><td class=
"name" onclick=
"toggle('declCountIs0')"><a name=
"declCountIs0Anchor">declCountIs
</a></td><td>unsigned N
</td></tr>
4072 <tr><td colspan=
"4" class=
"doc" id=
"declCountIs0"><pre>Matches declaration statements that contain a specific number of
4080 matches 'int a, b;' and 'int d =
2, e;', but not 'int c;'.
4084 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('equalsBoundNode1')"><a name=
"equalsBoundNode1Anchor">equalsBoundNode
</a></td><td>std::string ID
</td></tr>
4085 <tr><td colspan=
"4" class=
"doc" id=
"equalsBoundNode1"><pre>Matches if a node equals a previously bound node.
4087 Matches a node if it equals the node previously bound to ID.
4090 class X { int a; int b; };
4092 has(fieldDecl(hasName(
"a"), hasType(type().bind(
"t")))),
4093 has(fieldDecl(hasName(
"b"), hasType(type(equalsBoundNode(
"t"))))))
4094 matches the class X, as a and b have the same type.
4096 Note that when multiple matches are involved via forEach* matchers,
4097 equalsBoundNodes acts as a filter.
4100 forEachDescendant(varDecl().bind(
"d")),
4101 forEachDescendant(declRefExpr(to(decl(equalsBoundNode(
"d"))))))
4102 will trigger a match for each combination of variable declaration
4103 and reference to that variable declaration within a compound statement.
4107 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('equalsNode0')"><a name=
"equalsNode0Anchor">equalsNode
</a></td><td>const Decl* Other
</td></tr>
4108 <tr><td colspan=
"4" class=
"doc" id=
"equalsNode0"><pre>Matches if a node equals another node.
4110 Decl has pointer identity in the AST.
4114 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('hasAttr0')"><a name=
"hasAttr0Anchor">hasAttr
</a></td><td>attr::Kind AttrKind
</td></tr>
4115 <tr><td colspan=
"4" class=
"doc" id=
"hasAttr0"><pre>Matches declaration that has a given attribute.
4118 __attribute__((device)) void f() { ... }
4119 decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
4120 f. If the matcher is used from clang-query, attr::Kind parameter should be
4121 passed as a quoted string. e.g., hasAttr(
"attr::CUDADevice").
4125 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('isExpandedFromMacro0')"><a name=
"isExpandedFromMacro0Anchor">isExpandedFromMacro
</a></td><td>std::string MacroName
</td></tr>
4126 <tr><td colspan=
"4" class=
"doc" id=
"isExpandedFromMacro0"><pre>Matches statements that are (transitively) expanded from the named macro.
4127 Does not match if only part of the statement is expanded from that macro or
4128 if different parts of the statement are expanded from different
4129 appearances of the macro.
4133 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('isExpansionInFileMatching0')"><a name=
"isExpansionInFileMatching0Anchor">isExpansionInFileMatching
</a></td><td>StringRef RegExp, Regex::RegexFlags Flags = NoFlags
</td></tr>
4134 <tr><td colspan=
"4" class=
"doc" id=
"isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is
4135 partially matching a given regex.
4137 Example matches Y but not X
4138 (matcher = cxxRecordDecl(isExpansionInFileMatching(
"AST.*"))
4139 #include
"ASTMatcher.h"
4144 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>>
4146 If the matcher is used in clang-query, RegexFlags parameter
4147 should be passed as a quoted string. e.g:
"NoFlags".
4148 Flags can be combined with '|' example
"IgnoreCase | BasicRegex"
4152 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('isExpansionInMainFile0')"><a name=
"isExpansionInMainFile0Anchor">isExpansionInMainFile
</a></td><td></td></tr>
4153 <tr><td colspan=
"4" class=
"doc" id=
"isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file.
4155 Example matches X but not Y
4156 (matcher = cxxRecordDecl(isExpansionInMainFile())
4157 #include
<Y.h
>
4162 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>>
4166 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('isExpansionInSystemHeader0')"><a name=
"isExpansionInSystemHeader0Anchor">isExpansionInSystemHeader
</a></td><td></td></tr>
4167 <tr><td colspan=
"4" class=
"doc" id=
"isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files.
4169 Example matches Y but not X
4170 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
4171 #include
<SystemHeader.h
>
4176 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>>
4180 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('isImplicit0')"><a name=
"isImplicit0Anchor">isImplicit
</a></td><td></td></tr>
4181 <tr><td colspan=
"4" class=
"doc" id=
"isImplicit0"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
4182 implicit default/copy constructors).
4186 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('isInAnonymousNamespace0')"><a name=
"isInAnonymousNamespace0Anchor">isInAnonymousNamespace
</a></td><td></td></tr>
4187 <tr><td colspan=
"4" class=
"doc" id=
"isInAnonymousNamespace0"><pre>Matches declarations in an anonymous namespace.
4194 class vector {}; // #
1
4198 class vector {}; // #
2
4200 class vector{}; // #
3
4203 cxxRecordDecl(hasName(
"vector"), isInAnonymousNamespace()) will match
4208 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('isInStdNamespace0')"><a name=
"isInStdNamespace0Anchor">isInStdNamespace
</a></td><td></td></tr>
4209 <tr><td colspan=
"4" class=
"doc" id=
"isInStdNamespace0"><pre>Matches declarations in the namespace `std`, but not in nested namespaces.
4220 inline namespace __1 {
4221 class vector {}; // #
1
4222 namespace experimental {
4227 cxxRecordDecl(hasName(
"vector"), isInStdNamespace()) will match only #
1.
4231 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('isInstantiated0')"><a name=
"isInstantiated0Anchor">isInstantiated
</a></td><td></td></tr>
4232 <tr><td colspan=
"4" class=
"doc" id=
"isInstantiated0"><pre>Matches declarations that are template instantiations or are inside
4233 template instantiations.
4236 template
<typename T
> void A(T t) { T i; }
4239 functionDecl(isInstantiated())
4240 matches 'A(int) {...};' and 'A(unsigned) {...}'.
4244 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('isPrivate0')"><a name=
"isPrivate0Anchor">isPrivate
</a></td><td></td></tr>
4245 <tr><td colspan=
"4" class=
"doc" id=
"isPrivate0"><pre>Matches private C++ declarations and C++ base specifers that specify private
4252 private: int c; // fieldDecl(isPrivate()) matches 'c'
4256 struct Derived1 : private Base {}; // matches 'Base'
4257 class Derived2 : Base {}; // matches 'Base'
4261 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('isProtected0')"><a name=
"isProtected0Anchor">isProtected
</a></td><td></td></tr>
4262 <tr><td colspan=
"4" class=
"doc" id=
"isProtected0"><pre>Matches protected C++ declarations and C++ base specifers that specify
4263 protected inheritance.
4268 protected: int b; // fieldDecl(isProtected()) matches 'b'
4273 class Derived : protected Base {}; // matches 'Base'
4277 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>></td><td class=
"name" onclick=
"toggle('isPublic0')"><a name=
"isPublic0Anchor">isPublic
</a></td><td></td></tr>
4278 <tr><td colspan=
"4" class=
"doc" id=
"isPublic0"><pre>Matches public C++ declarations and C++ base specifers that specify public
4283 public: int a; // fieldDecl(isPublic()) matches 'a'
4289 class Derived1 : public Base {}; // matches 'Base'
4290 struct Derived2 : Base {}; // matches 'Base'
4294 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DesignatedInitExpr.html">DesignatedInitExpr
</a>></td><td class=
"name" onclick=
"toggle('designatorCountIs0')"><a name=
"designatorCountIs0Anchor">designatorCountIs
</a></td><td>unsigned N
</td></tr>
4295 <tr><td colspan=
"4" class=
"doc" id=
"designatorCountIs0"><pre>Matches designated initializer expressions that contain
4296 a specific number of designators.
4299 point ptarray[
10] = { [
2].y =
1.0, [
0].x =
1.0 };
4300 point ptarray2[
10] = { [
2].y =
1.0, [
2].x =
0.0, [
0].x =
1.0 };
4301 designatorCountIs(
2)
4302 matches '{ [
2].y =
1.0, [
0].x =
1.0 }',
4303 but not '{ [
2].y =
1.0, [
2].x =
0.0, [
0].x =
1.0 }'.
4307 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl
</a>></td><td class=
"name" onclick=
"toggle('isScoped0')"><a name=
"isScoped0Anchor">isScoped
</a></td><td></td></tr>
4308 <tr><td colspan=
"4" class=
"doc" id=
"isScoped0"><pre>Matches C++
11 scoped enum declaration.
4310 Example matches Y (matcher = enumDecl(isScoped()))
4316 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>></td><td class=
"name" onclick=
"toggle('isInstantiationDependent0')"><a name=
"isInstantiationDependent0Anchor">isInstantiationDependent
</a></td><td></td></tr>
4317 <tr><td colspan=
"4" class=
"doc" id=
"isInstantiationDependent0"><pre>Matches expressions that are instantiation-dependent even if it is
4318 neither type- nor value-dependent.
4320 In the following example, the expression sizeof(sizeof(T() + T()))
4321 is instantiation-dependent (since it involves a template parameter T),
4322 but is neither type- nor value-dependent, since the type of the inner
4323 sizeof is known (std::size_t) and therefore the size of the outer
4325 template
<typename T
>
4326 void f(T x, T y) { sizeof(sizeof(T() + T()); }
4327 expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T())
4331 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>></td><td class=
"name" onclick=
"toggle('isTypeDependent0')"><a name=
"isTypeDependent0Anchor">isTypeDependent
</a></td><td></td></tr>
4332 <tr><td colspan=
"4" class=
"doc" id=
"isTypeDependent0"><pre>Matches expressions that are type-dependent because the template type
4333 is not yet instantiated.
4335 For example, the expressions
"x" and
"x + y" are type-dependent in
4336 the following code, but
"y" is not type-dependent:
4337 template
<typename T
>
4338 void add(T x, int y) {
4341 expr(isTypeDependent()) matches x + y
4345 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>></td><td class=
"name" onclick=
"toggle('isValueDependent0')"><a name=
"isValueDependent0Anchor">isValueDependent
</a></td><td></td></tr>
4346 <tr><td colspan=
"4" class=
"doc" id=
"isValueDependent0"><pre>Matches expression that are value-dependent because they contain a
4347 non-type template parameter.
4349 For example, the array bound of
"Chars" in the following example is
4351 template
<int Size
> int f() { return Size; }
4352 expr(isValueDependent()) matches return Size
4356 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>></td><td class=
"name" onclick=
"toggle('nullPointerConstant0')"><a name=
"nullPointerConstant0Anchor">nullPointerConstant
</a></td><td></td></tr>
4357 <tr><td colspan=
"4" class=
"doc" id=
"nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as
4358 GNU's __null, C++
11's nullptr, or C's NULL macro.
4363 void *v3 = __null; // GNU extension
4364 char *cp = (char *)
0;
4367 expr(nullPointerConstant())
4368 matches the initializer for v1, v2, v3, cp, and ip. Does not match the
4373 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl
</a>></td><td class=
"name" onclick=
"toggle('hasBitWidth0')"><a name=
"hasBitWidth0Anchor">hasBitWidth
</a></td><td>unsigned Width
</td></tr>
4374 <tr><td colspan=
"4" class=
"doc" id=
"hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified
4383 fieldDecl(hasBitWidth(
2))
4384 matches 'int a;' and 'int c;' but not 'int b;'.
4388 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl
</a>></td><td class=
"name" onclick=
"toggle('isBitField0')"><a name=
"isBitField0Anchor">isBitField
</a></td><td></td></tr>
4389 <tr><td colspan=
"4" class=
"doc" id=
"isBitField0"><pre>Matches non-static data members that are bit-fields.
4396 fieldDecl(isBitField())
4397 matches 'int a;' but not 'int b;'.
4401 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral
</a>></td><td class=
"name" onclick=
"toggle('equals1')"><a name=
"equals1Anchor">equals
</a></td><td>const ValueT Value
</td></tr>
4402 <tr><td colspan=
"4" class=
"doc" id=
"equals1"><pre>Matches literals that are equal to the given value of type ValueT.
4405 f('false,
3.14,
42);
4406 characterLiteral(equals(
0))
4407 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(
0))
4409 floatLiteral(equals(
3.14)) and floatLiteral(equals(
314e-2))
4411 integerLiteral(equals(
42))
4414 Note that you cannot directly match a negative numeric literal because the
4415 minus sign is not part of the literal: It is a unary operator whose operand
4416 is the positive numeric literal. Instead, you must use a unaryOperator()
4417 matcher to match the minus sign:
4419 unaryOperator(hasOperatorName(
"-"),
4420 hasUnaryOperand(integerLiteral(equals(
13))))
4422 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr
</a>>,
4423 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral
</a>>
4427 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral
</a>></td><td class=
"name" onclick=
"toggle('equals12')"><a name=
"equals12Anchor">equals
</a></td><td>double Value
</td></tr>
4428 <tr><td colspan=
"4" class=
"doc" id=
"equals12"><pre></pre></td></tr>
4431 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('hasAnyOverloadedOperatorName1')"><a name=
"hasAnyOverloadedOperatorName1Anchor">hasAnyOverloadedOperatorName
</a></td><td>StringRef, ..., StringRef
</td></tr>
4432 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOverloadedOperatorName1"><pre>Matches overloaded operator names.
4434 Matches overloaded operator names specified in strings without the
4435 "operator" prefix: e.g.
"<<".
4437 hasAnyOverloadedOperatorName(
"+",
"-")
4439 anyOf(hasOverloadedOperatorName(
"+"), hasOverloadedOperatorName(
"-"))
4443 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('hasDynamicExceptionSpec0')"><a name=
"hasDynamicExceptionSpec0Anchor">hasDynamicExceptionSpec
</a></td><td></td></tr>
4444 <tr><td colspan=
"4" class=
"doc" id=
"hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification.
4449 void h() noexcept(true);
4450 void i() noexcept(false);
4452 void k() throw(int);
4453 void l() throw(...);
4454 functionDecl(hasDynamicExceptionSpec()) and
4455 functionProtoType(hasDynamicExceptionSpec())
4456 match the declarations of j, k, and l, but not f, g, h, or i.
4460 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('hasOverloadedOperatorName0')"><a name=
"hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName
</a></td><td>StringRef Name
</td></tr>
4461 <tr><td colspan=
"4" class=
"doc" id=
"hasOverloadedOperatorName0"><pre>Matches overloaded operator names.
4463 Matches overloaded operator names specified in strings without the
4464 "operator" prefix: e.g.
"<<".
4467 class A { int operator*(); };
4468 const A
&operator
<<(const A
&a, const A
&b);
4470 a
<< a; //
<-- This matches
4472 cxxOperatorCallExpr(hasOverloadedOperatorName(
"<<"))) matches the
4474 cxxRecordDecl(hasMethod(hasOverloadedOperatorName(
"*")))
4475 matches the declaration of A.
4477 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>>
4481 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('hasTrailingReturn0')"><a name=
"hasTrailingReturn0Anchor">hasTrailingReturn
</a></td><td></td></tr>
4482 <tr><td colspan=
"4" class=
"doc" id=
"hasTrailingReturn0"><pre>Matches a function declared with a trailing return type.
4484 Example matches Y (matcher = functionDecl(hasTrailingReturn()))
4486 auto Y() -
> int {}
4490 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isConsteval0')"><a name=
"isConsteval0Anchor">isConsteval
</a></td><td></td></tr>
4491 <tr><td colspan=
"4" class=
"doc" id=
"isConsteval0"><pre>Matches consteval function declarations and if consteval/if ! consteval
4496 void b() { if consteval {} }
4497 void c() { if ! consteval {} }
4498 void d() { if ! consteval {} else {} }
4499 functionDecl(isConsteval())
4500 matches the declaration of
"int a()".
4501 ifStmt(isConsteval())
4502 matches the if statement in
"void b()",
"void c()",
"void d()".
4506 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isConstexpr1')"><a name=
"isConstexpr1Anchor">isConstexpr
</a></td><td></td></tr>
4507 <tr><td colspan=
"4" class=
"doc" id=
"isConstexpr1"><pre>Matches constexpr variable and function declarations,
4511 constexpr int foo =
42;
4512 constexpr int bar();
4513 void baz() { if constexpr(
1 > 0) {} }
4514 varDecl(isConstexpr())
4515 matches the declaration of foo.
4516 functionDecl(isConstexpr())
4517 matches the declaration of bar.
4518 ifStmt(isConstexpr())
4519 matches the if statement in baz.
4523 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isDefaulted0')"><a name=
"isDefaulted0Anchor">isDefaulted
</a></td><td></td></tr>
4524 <tr><td colspan=
"4" class=
"doc" id=
"isDefaulted0"><pre>Matches defaulted function declarations.
4528 class B { ~B() = default; };
4529 functionDecl(isDefaulted())
4530 matches the declaration of ~B, but not ~A.
4534 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isDefinition3')"><a name=
"isDefinition3Anchor">isDefinition
</a></td><td></td></tr>
4535 <tr><td colspan=
"4" class=
"doc" id=
"isDefinition3"><pre>Matches if a declaration has a body attached.
4537 Example matches A, va, fa
4539 class B; // Doesn't match, as it has no body.
4541 extern int vb; // Doesn't match, as it doesn't define the variable.
4543 void fb(); // Doesn't match, as it has no body.
4545 - (void)ma; // Doesn't match, interface is declaration.
4551 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>>,
4552 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl
</a>>
4556 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isDeleted0')"><a name=
"isDeleted0Anchor">isDeleted
</a></td><td></td></tr>
4557 <tr><td colspan=
"4" class=
"doc" id=
"isDeleted0"><pre>Matches deleted function declarations.
4561 void DeletedFunc() = delete;
4562 functionDecl(isDeleted())
4563 matches the declaration of DeletedFunc, but not Func.
4567 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isExplicitTemplateSpecialization0')"><a name=
"isExplicitTemplateSpecialization0Anchor">isExplicitTemplateSpecialization
</a></td><td></td></tr>
4568 <tr><td colspan=
"4" class=
"doc" id=
"isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or
4569 static member variable template instantiations.
4572 template
<typename T
> void A(T t) { }
4573 template
<> void A(int N) { }
4574 functionDecl(isExplicitTemplateSpecialization())
4575 matches the specialization A
<int
>().
4577 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>>
4581 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isExternC0')"><a name=
"isExternC0Anchor">isExternC
</a></td><td></td></tr>
4582 <tr><td colspan=
"4" class=
"doc" id=
"isExternC0"><pre>Matches extern
"C" function or variable declarations.
4585 extern
"C" void f() {}
4586 extern
"C" { void g() {} }
4588 extern
"C" int x =
1;
4589 extern
"C" int y =
2;
4591 functionDecl(isExternC())
4592 matches the declaration of f and g, but not the declaration of h.
4593 varDecl(isExternC())
4594 matches the declaration of x and y, but not the declaration of z.
4598 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isInline1')"><a name=
"isInline1Anchor">isInline
</a></td><td></td></tr>
4599 <tr><td colspan=
"4" class=
"doc" id=
"isInline1"><pre>Matches functions, variables and namespace declarations that are marked with
4606 inline namespace m {}
4609 functionDecl(isInline()) will match ::f().
4610 namespaceDecl(isInline()) will match n::m.
4611 varDecl(isInline()) will match Foo;
4615 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isMain0')"><a name=
"isMain0Anchor">isMain
</a></td><td></td></tr>
4616 <tr><td colspan=
"4" class=
"doc" id=
"isMain0"><pre>Determines whether the function is
"main", which is the entry point
4617 into an executable program.
4621 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isNoReturn0')"><a name=
"isNoReturn0Anchor">isNoReturn
</a></td><td></td></tr>
4622 <tr><td colspan=
"4" class=
"doc" id=
"isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute.
4626 [[noreturn]] void a();
4627 __attribute__((noreturn)) void b();
4628 struct c { [[noreturn]] c(); };
4629 functionDecl(isNoReturn())
4630 matches all of those except
4635 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isNoThrow0')"><a name=
"isNoThrow0Anchor">isNoThrow
</a></td><td></td></tr>
4636 <tr><td colspan=
"4" class=
"doc" id=
"isNoThrow0"><pre>Matches functions that have a non-throwing exception specification.
4642 void i() throw(int);
4643 void j() noexcept(false);
4644 functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
4645 match the declarations of g, and h, but not f, i or j.
4649 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isStaticStorageClass0')"><a name=
"isStaticStorageClass0Anchor">isStaticStorageClass
</a></td><td></td></tr>
4650 <tr><td colspan=
"4" class=
"doc" id=
"isStaticStorageClass0"><pre>Matches variable/function declarations that have
"static" storage
4651 class specifier (
"static" keyword) written in the source.
4658 functionDecl(isStaticStorageClass())
4659 matches the function declaration f.
4660 varDecl(isStaticStorageClass())
4661 matches the variable declaration i.
4665 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isTemplateInstantiation0')"><a name=
"isTemplateInstantiation0Anchor">isTemplateInstantiation
</a></td><td></td></tr>
4666 <tr><td colspan=
"4" class=
"doc" id=
"isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static
4667 member variable template instantiations.
4670 template
<typename T
> class X {}; class A {}; X
<A
> x;
4672 template
<typename T
> class X {}; class A {}; template class X
<A
>;
4674 template
<typename T
> class X {}; class A {}; extern template class X
<A
>;
4675 cxxRecordDecl(hasName(
"::X"), isTemplateInstantiation())
4676 matches the template instantiation of X
<A
>.
4679 template
<typename T
> class X {}; class A {};
4680 template
<> class X
<A
> {}; X
<A
> x;
4681 cxxRecordDecl(hasName(
"::X"), isTemplateInstantiation())
4682 does not match, as X
<A
> is an explicit template specialization.
4684 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>>
4688 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isVariadic0')"><a name=
"isVariadic0Anchor">isVariadic
</a></td><td></td></tr>
4689 <tr><td colspan=
"4" class=
"doc" id=
"isVariadic0"><pre>Matches if a function declaration is variadic.
4691 Example matches f, but not g or h. The function i will not match, even when
4695 template
<typename... Ts
> void h(Ts...);
4700 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('isWeak0')"><a name=
"isWeak0Anchor">isWeak
</a></td><td></td></tr>
4701 <tr><td colspan=
"4" class=
"doc" id=
"isWeak0"><pre>Matches weak function declarations.
4704 void foo() __attribute__((__weakref__(
"__foo")));
4706 functionDecl(isWeak())
4707 matches the weak declaration
"foo", but not
"bar".
4711 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl
</a>></td><td class=
"name" onclick=
"toggle('parameterCountIs0')"><a name=
"parameterCountIs0Anchor">parameterCountIs
</a></td><td>unsigned N
</td></tr>
4712 <tr><td colspan=
"4" class=
"doc" id=
"parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
4713 specific parameter count.
4717 void g(int i, int j) {}
4718 void h(int i, int j);
4720 void k(int x, int y, int z, ...);
4721 functionDecl(parameterCountIs(
2))
4723 functionProtoType(parameterCountIs(
2))
4725 functionProtoType(parameterCountIs(
3))
4730 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType
</a>></td><td class=
"name" onclick=
"toggle('hasDynamicExceptionSpec1')"><a name=
"hasDynamicExceptionSpec1Anchor">hasDynamicExceptionSpec
</a></td><td></td></tr>
4731 <tr><td colspan=
"4" class=
"doc" id=
"hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification.
4736 void h() noexcept(true);
4737 void i() noexcept(false);
4739 void k() throw(int);
4740 void l() throw(...);
4741 functionDecl(hasDynamicExceptionSpec()) and
4742 functionProtoType(hasDynamicExceptionSpec())
4743 match the declarations of j, k, and l, but not f, g, h, or i.
4747 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType
</a>></td><td class=
"name" onclick=
"toggle('isNoThrow1')"><a name=
"isNoThrow1Anchor">isNoThrow
</a></td><td></td></tr>
4748 <tr><td colspan=
"4" class=
"doc" id=
"isNoThrow1"><pre>Matches functions that have a non-throwing exception specification.
4754 void i() throw(int);
4755 void j() noexcept(false);
4756 functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
4757 match the declarations of g, and h, but not f, i or j.
4761 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType
</a>></td><td class=
"name" onclick=
"toggle('parameterCountIs1')"><a name=
"parameterCountIs1Anchor">parameterCountIs
</a></td><td>unsigned N
</td></tr>
4762 <tr><td colspan=
"4" class=
"doc" id=
"parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
4763 specific parameter count.
4767 void g(int i, int j) {}
4768 void h(int i, int j);
4770 void k(int x, int y, int z, ...);
4771 functionDecl(parameterCountIs(
2))
4773 functionProtoType(parameterCountIs(
2))
4775 functionProtoType(parameterCountIs(
3))
4780 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt
</a>></td><td class=
"name" onclick=
"toggle('isConsteval1')"><a name=
"isConsteval1Anchor">isConsteval
</a></td><td></td></tr>
4781 <tr><td colspan=
"4" class=
"doc" id=
"isConsteval1"><pre>Matches consteval function declarations and if consteval/if ! consteval
4786 void b() { if consteval {} }
4787 void c() { if ! consteval {} }
4788 void d() { if ! consteval {} else {} }
4789 functionDecl(isConsteval())
4790 matches the declaration of
"int a()".
4791 ifStmt(isConsteval())
4792 matches the if statement in
"void b()",
"void c()",
"void d()".
4796 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt
</a>></td><td class=
"name" onclick=
"toggle('isConstexpr2')"><a name=
"isConstexpr2Anchor">isConstexpr
</a></td><td></td></tr>
4797 <tr><td colspan=
"4" class=
"doc" id=
"isConstexpr2"><pre>Matches constexpr variable and function declarations,
4801 constexpr int foo =
42;
4802 constexpr int bar();
4803 void baz() { if constexpr(
1 > 0) {} }
4804 varDecl(isConstexpr())
4805 matches the declaration of foo.
4806 functionDecl(isConstexpr())
4807 matches the declaration of bar.
4808 ifStmt(isConstexpr())
4809 matches the if statement in baz.
4813 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral
</a>></td><td class=
"name" onclick=
"toggle('equals6')"><a name=
"equals6Anchor">equals
</a></td><td>bool Value
</td></tr>
4814 <tr><td colspan=
"4" class=
"doc" id=
"equals6"><pre></pre></td></tr>
4817 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral
</a>></td><td class=
"name" onclick=
"toggle('equals0')"><a name=
"equals0Anchor">equals
</a></td><td>const ValueT Value
</td></tr>
4818 <tr><td colspan=
"4" class=
"doc" id=
"equals0"><pre>Matches literals that are equal to the given value of type ValueT.
4821 f('false,
3.14,
42);
4822 characterLiteral(equals(
0))
4823 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(
0))
4825 floatLiteral(equals(
3.14)) and floatLiteral(equals(
314e-2))
4827 integerLiteral(equals(
42))
4830 Note that you cannot directly match a negative numeric literal because the
4831 minus sign is not part of the literal: It is a unary operator whose operand
4832 is the positive numeric literal. Instead, you must use a unaryOperator()
4833 matcher to match the minus sign:
4835 unaryOperator(hasOperatorName(
"-"),
4836 hasUnaryOperand(integerLiteral(equals(
13))))
4838 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr
</a>>,
4839 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral
</a>>
4843 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral
</a>></td><td class=
"name" onclick=
"toggle('equals13')"><a name=
"equals13Anchor">equals
</a></td><td>double Value
</td></tr>
4844 <tr><td colspan=
"4" class=
"doc" id=
"equals13"><pre></pre></td></tr>
4847 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral
</a>></td><td class=
"name" onclick=
"toggle('equals9')"><a name=
"equals9Anchor">equals
</a></td><td>unsigned Value
</td></tr>
4848 <tr><td colspan=
"4" class=
"doc" id=
"equals9"><pre></pre></td></tr>
4851 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture
</a>></td><td class=
"name" onclick=
"toggle('capturesThis0')"><a name=
"capturesThis0Anchor">capturesThis
</a></td><td></td></tr>
4852 <tr><td colspan=
"4" class=
"doc" id=
"capturesThis0"><pre>Matches a `LambdaCapture` that refers to 'this'.
4858 auto l = [this]() { return cc; };
4862 lambdaExpr(hasAnyCapture(lambdaCapture(capturesThis())))
4863 matches `[this]() { return cc; }`.
4867 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html">LambdaCapture
</a>></td><td class=
"name" onclick=
"toggle('isImplicit2')"><a name=
"isImplicit2Anchor">isImplicit
</a></td><td></td></tr>
4868 <tr><td colspan=
"4" class=
"doc" id=
"isImplicit2"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
4869 implicit default/copy constructors).
4873 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr
</a>></td><td class=
"name" onclick=
"toggle('isArrow0')"><a name=
"isArrow0Anchor">isArrow
</a></td><td></td></tr>
4874 <tr><td colspan=
"4" class=
"doc" id=
"isArrow0"><pre>Matches member expressions that are called with '-
>' as opposed
4877 Member calls on the implicit this pointer match as called with '-
>'.
4881 void x() { this-
>x(); x(); Y y; y.x(); a; this-
>b; Y::b; }
4882 template
<class T
> void f() { this-
>f
<T
>(); f
<T
>(); }
4886 template
<class T
>
4888 void x() { this-
>m; }
4890 memberExpr(isArrow())
4891 matches this-
>x, x, y.x, a, this-
>b
4892 cxxDependentScopeMemberExpr(isArrow())
4894 unresolvedMemberExpr(isArrow())
4895 matches this-
>f
<T
>, f
<T
>
4899 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl
</a>></td><td class=
"name" onclick=
"toggle('hasAnyName0')"><a name=
"hasAnyName0Anchor">hasAnyName
</a></td><td>StringRef, ..., StringRef
</td></tr>
4900 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names.
4902 This matcher is only provided as a performance optimization of hasName.
4904 is equivalent to, but faster than
4905 anyOf(hasName(a), hasName(b), hasName(c))
4909 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl
</a>></td><td class=
"name" onclick=
"toggle('hasExternalFormalLinkage0')"><a name=
"hasExternalFormalLinkage0Anchor">hasExternalFormalLinkage
</a></td><td></td></tr>
4910 <tr><td colspan=
"4" class=
"doc" id=
"hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage.
4912 Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))
4919 Example matches f() because it has external formal linkage despite being
4920 unique to the translation unit as though it has internal likage
4921 (matcher = functionDecl(hasExternalFormalLinkage()))
4929 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl
</a>></td><td class=
"name" onclick=
"toggle('hasName0')"><a name=
"hasName0Anchor">hasName
</a></td><td>StringRef Name
</td></tr>
4930 <tr><td colspan=
"4" class=
"doc" id=
"hasName0"><pre>Matches NamedDecl nodes that have the specified name.
4932 Supports specifying enclosing namespaces or classes by prefixing the name
4933 with '
<enclosing
>::'.
4934 Does not match typedefs of an underlying type with the given name.
4936 Example matches X (Name ==
"X")
4939 Example matches X (Name is one of
"::a::b::X",
"a::b::X",
"b::X",
"X")
4940 namespace a { namespace b { class X; } }
4944 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl
</a>></td><td class=
"name" onclick=
"toggle('matchesName0')"><a name=
"matchesName0Anchor">matchesName
</a></td><td>StringRef RegExp, Regex::RegexFlags Flags = NoFlags
</td></tr>
4945 <tr><td colspan=
"4" class=
"doc" id=
"matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain
4946 a substring matched by the given RegExp.
4948 Supports specifying enclosing namespaces or classes by
4949 prefixing the name with '
<enclosing
>::'. Does not match typedefs
4950 of an underlying type with the given name.
4952 Example matches X (regexp ==
"::X")
4955 Example matches X (regexp is one of
"::X",
"^foo::.*X", among others)
4956 namespace foo { namespace bar { class X; } }
4958 If the matcher is used in clang-query, RegexFlags parameter
4959 should be passed as a quoted string. e.g:
"NoFlags".
4960 Flags can be combined with '|' example
"IgnoreCase | BasicRegex"
4964 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl
</a>></td><td class=
"name" onclick=
"toggle('isAnonymous0')"><a name=
"isAnonymous0Anchor">isAnonymous
</a></td><td></td></tr>
4965 <tr><td colspan=
"4" class=
"doc" id=
"isAnonymous0"><pre>Matches anonymous namespace declarations.
4971 namespaceDecl(isAnonymous()) will match #
1 but not ::n.
4975 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl
</a>></td><td class=
"name" onclick=
"toggle('isInline0')"><a name=
"isInline0Anchor">isInline
</a></td><td></td></tr>
4976 <tr><td colspan=
"4" class=
"doc" id=
"isInline0"><pre>Matches functions, variables and namespace declarations that are marked with
4983 inline namespace m {}
4986 functionDecl(isInline()) will match ::f().
4987 namespaceDecl(isInline()) will match n::m.
4988 varDecl(isInline()) will match Foo;
4992 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause
</a>></td><td class=
"name" onclick=
"toggle('isFirstPrivateKind0')"><a name=
"isFirstPrivateKind0Anchor">isFirstPrivateKind
</a></td><td></td></tr>
4993 <tr><td colspan=
"4" class=
"doc" id=
"isFirstPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``firstprivate`` kind
4998 #pragma omp parallel
4999 #pragma omp parallel default(none)
5000 #pragma omp parallel default(shared)
5001 #pragma omp parallel default(private)
5002 #pragma omp parallel default(firstprivate)
5004 ``ompDefaultClause(isFirstPrivateKind())`` matches only
5005 ``default(firstprivate)``.
5009 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause
</a>></td><td class=
"name" onclick=
"toggle('isNoneKind0')"><a name=
"isNoneKind0Anchor">isNoneKind
</a></td><td></td></tr>
5010 <tr><td colspan=
"4" class=
"doc" id=
"isNoneKind0"><pre>Matches if the OpenMP ``default`` clause has ``none`` kind specified.
5014 #pragma omp parallel
5015 #pragma omp parallel default(none)
5016 #pragma omp parallel default(shared)
5017 #pragma omp parallel default(private)
5018 #pragma omp parallel default(firstprivate)
5020 ``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
5024 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause
</a>></td><td class=
"name" onclick=
"toggle('isPrivateKind0')"><a name=
"isPrivateKind0Anchor">isPrivateKind
</a></td><td></td></tr>
5025 <tr><td colspan=
"4" class=
"doc" id=
"isPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``private`` kind
5030 #pragma omp parallel
5031 #pragma omp parallel default(none)
5032 #pragma omp parallel default(shared)
5033 #pragma omp parallel default(private)
5034 #pragma omp parallel default(firstprivate)
5036 ``ompDefaultClause(isPrivateKind())`` matches only
5037 ``default(private)``.
5041 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1OMPDefaultClause.html">OMPDefaultClause
</a>></td><td class=
"name" onclick=
"toggle('isSharedKind0')"><a name=
"isSharedKind0Anchor">isSharedKind
</a></td><td></td></tr>
5042 <tr><td colspan=
"4" class=
"doc" id=
"isSharedKind0"><pre>Matches if the OpenMP ``default`` clause has ``shared`` kind specified.
5046 #pragma omp parallel
5047 #pragma omp parallel default(none)
5048 #pragma omp parallel default(shared)
5049 #pragma omp parallel default(private)
5050 #pragma omp parallel default(firstprivate)
5052 ``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``.
5056 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html">OMPExecutableDirective
</a>></td><td class=
"name" onclick=
"toggle('isAllowedToContainClauseKind0')"><a name=
"isAllowedToContainClauseKind0Anchor">isAllowedToContainClauseKind
</a></td><td>OpenMPClauseKind CKind
</td></tr>
5057 <tr><td colspan=
"4" class=
"doc" id=
"isAllowedToContainClauseKind0"><pre>Matches if the OpenMP directive is allowed to contain the specified OpenMP
5062 #pragma omp parallel
5063 #pragma omp parallel for
5066 `ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches
5067 ``omp parallel`` and ``omp parallel for``.
5069 If the matcher is use from clang-query, ``OpenMPClauseKind`` parameter
5070 should be passed as a quoted string. e.g.,
5071 ``isAllowedToContainClauseKind(
"OMPC_default").``
5075 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html">OMPExecutableDirective
</a>></td><td class=
"name" onclick=
"toggle('isStandaloneDirective0')"><a name=
"isStandaloneDirective0Anchor">isStandaloneDirective
</a></td><td></td></tr>
5076 <tr><td colspan=
"4" class=
"doc" id=
"isStandaloneDirective0"><pre>Matches standalone OpenMP directives,
5077 i.e., directives that can't have a structured block.
5081 #pragma omp parallel
5083 #pragma omp taskyield
5085 ``ompExecutableDirective(isStandaloneDirective()))`` matches
5090 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl
</a>></td><td class=
"name" onclick=
"toggle('isDerivedFrom3')"><a name=
"isDerivedFrom3Anchor">isDerivedFrom
</a></td><td>std::string BaseName
</td></tr>
5091 <tr><td colspan=
"4" class=
"doc" id=
"isDerivedFrom3"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
5095 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl
</a>></td><td class=
"name" onclick=
"toggle('isDirectlyDerivedFrom3')"><a name=
"isDirectlyDerivedFrom3Anchor">isDirectlyDerivedFrom
</a></td><td>std::string BaseName
</td></tr>
5096 <tr><td colspan=
"4" class=
"doc" id=
"isDirectlyDerivedFrom3"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
5100 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl
</a>></td><td class=
"name" onclick=
"toggle('isSameOrDerivedFrom3')"><a name=
"isSameOrDerivedFrom3Anchor">isSameOrDerivedFrom
</a></td><td>std::string BaseName
</td></tr>
5101 <tr><td colspan=
"4" class=
"doc" id=
"isSameOrDerivedFrom3"><pre>Overloaded method as shortcut for
5102 isSameOrDerivedFrom(hasName(...)).
5106 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr
</a>></td><td class=
"name" onclick=
"toggle('argumentCountAtLeast3')"><a name=
"argumentCountAtLeast3Anchor">argumentCountAtLeast
</a></td><td>unsigned N
</td></tr>
5107 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountAtLeast3"><pre>Checks that a call expression or a constructor call expression has at least
5108 the specified number of arguments (including absent default arguments).
5110 Example matches f(
0,
0) and g(
0,
0,
0)
5111 (matcher = callExpr(argumentCountAtLeast(
2)))
5112 void f(int x, int y);
5113 void g(int x, int y, int z);
5119 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr
</a>></td><td class=
"name" onclick=
"toggle('argumentCountIs3')"><a name=
"argumentCountIs3Anchor">argumentCountIs
</a></td><td>unsigned N
</td></tr>
5120 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountIs3"><pre>Checks that a call expression or a constructor call expression has
5121 a specific number of arguments (including absent default arguments).
5123 Example matches f(
0,
0) (matcher = callExpr(argumentCountIs(
2)))
5124 void f(int x, int y);
5129 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr
</a>></td><td class=
"name" onclick=
"toggle('hasAnySelector0')"><a name=
"hasAnySelector0Anchor">hasAnySelector
</a></td><td>StringRef, ..., StringRef
</td></tr>
5130 <tr><td colspan=
"4" class=
"doc" id=
"hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the
5131 Selector.getAsString()
5133 matcher = objCMessageExpr(hasSelector(
"methodA:",
"methodB:"));
5134 matches both of the expressions below:
5135 [myObj methodA:argA];
5136 [myObj methodB:argB];
5140 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr
</a>></td><td class=
"name" onclick=
"toggle('hasKeywordSelector0')"><a name=
"hasKeywordSelector0Anchor">hasKeywordSelector
</a></td><td></td></tr>
5141 <tr><td colspan=
"4" class=
"doc" id=
"hasKeywordSelector0"><pre>Matches when the selector is a keyword selector
5143 objCMessageExpr(hasKeywordSelector()) matches the generated setFrame
5144 message expression in
5146 UIWebView *webView = ...;
5147 CGRect bodyFrame = webView.frame;
5148 bodyFrame.size.height = self.bodyContentHeight;
5149 webView.frame = bodyFrame;
5150 // ^---- matches here
5154 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr
</a>></td><td class=
"name" onclick=
"toggle('hasNullSelector0')"><a name=
"hasNullSelector0Anchor">hasNullSelector
</a></td><td></td></tr>
5155 <tr><td colspan=
"4" class=
"doc" id=
"hasNullSelector0"><pre>Matches when the selector is the empty selector
5157 Matches only when the selector of the objCMessageExpr is NULL. This may
5158 represent an error condition in the tree!
5162 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr
</a>></td><td class=
"name" onclick=
"toggle('hasSelector0')"><a name=
"hasSelector0Anchor">hasSelector
</a></td><td>std::string BaseName
</td></tr>
5163 <tr><td colspan=
"4" class=
"doc" id=
"hasSelector0"><pre>Matches when BaseName == Selector.getAsString()
5165 matcher = objCMessageExpr(hasSelector(
"loadHTMLString:baseURL:"));
5166 matches the outer message expr in the code below, but NOT the message
5167 invocation for self.bodyView.
5168 [self.bodyView loadHTMLString:html baseURL:NULL];
5172 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr
</a>></td><td class=
"name" onclick=
"toggle('hasUnarySelector0')"><a name=
"hasUnarySelector0Anchor">hasUnarySelector
</a></td><td></td></tr>
5173 <tr><td colspan=
"4" class=
"doc" id=
"hasUnarySelector0"><pre>Matches when the selector is a Unary Selector
5175 matcher = objCMessageExpr(matchesSelector(hasUnarySelector());
5176 matches self.bodyView in the code below, but NOT the outer message
5177 invocation of
"loadHTMLString:baseURL:".
5178 [self.bodyView loadHTMLString:html baseURL:NULL];
5182 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr
</a>></td><td class=
"name" onclick=
"toggle('isClassMessage0')"><a name=
"isClassMessage0Anchor">isClassMessage
</a></td><td></td></tr>
5183 <tr><td colspan=
"4" class=
"doc" id=
"isClassMessage0"><pre>Returns true when the Objective-C message is sent to a class.
5186 matcher = objcMessageExpr(isClassMessage())
5188 [NSString stringWithFormat:@
"format"];
5190 NSString *x = @
"hello";
5191 [x containsString:@
"h"];
5195 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr
</a>></td><td class=
"name" onclick=
"toggle('isInstanceMessage0')"><a name=
"isInstanceMessage0Anchor">isInstanceMessage
</a></td><td></td></tr>
5196 <tr><td colspan=
"4" class=
"doc" id=
"isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance.
5199 matcher = objcMessageExpr(isInstanceMessage())
5201 NSString *x = @
"hello";
5202 [x containsString:@
"h"];
5204 [NSString stringWithFormat:@
"format"];
5208 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr
</a>></td><td class=
"name" onclick=
"toggle('matchesSelector0')"><a name=
"matchesSelector0Anchor">matchesSelector
</a></td><td>StringRef RegExp, Regex::RegexFlags Flags = NoFlags
</td></tr>
5209 <tr><td colspan=
"4" class=
"doc" id=
"matchesSelector0"><pre>Matches ObjC selectors whose name contains
5210 a substring matched by the given RegExp.
5211 matcher = objCMessageExpr(matchesSelector(
"loadHTMLStringmatches the outer message expr in the code below, but NOT the message
5212 invocation for self.bodyView.
5213 [self.bodyView loadHTMLString:html baseURL:NULL];
5215 If the matcher is used in clang-query, RegexFlags parameter
5216 should be passed as a quoted string. e.g: "NoFlags
".
5217 Flags can be combined with '|' example "IgnoreCase | BasicRegex
"
5221 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html
">ObjCMessageExpr</a>></td><td class="name
" onclick="toggle('numSelectorArgs0')
"><a name="numSelectorArgs0Anchor
">numSelectorArgs</a></td><td>unsigned N</td></tr>
5222 <tr><td colspan="4" class="doc
" id="numSelectorArgs0
"><pre>Matches when the selector has the specified number of arguments
5224 matcher = objCMessageExpr(numSelectorArgs(0));
5225 matches self.bodyView in the code below
5227 matcher = objCMessageExpr(numSelectorArgs(2));
5228 matches the invocation of "loadHTMLString:baseURL:
" but not that
5230 [self.bodyView loadHTMLString:html baseURL:NULL];
5234 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html
">ObjCMethodDecl</a>></td><td class="name
" onclick="toggle('isClassMethod0')
"><a name="isClassMethod0Anchor
">isClassMethod</a></td><td></td></tr>
5235 <tr><td colspan="4" class="doc
" id="isClassMethod0
"><pre>Returns true when the Objective-C method declaration is a class method.
5238 matcher = objcMethodDecl(isClassMethod())
5240 @interface I + (void)foo; @end
5242 @interface I - (void)bar; @end
5246 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html
">ObjCMethodDecl</a>></td><td class="name
" onclick="toggle('isDefinition2')
"><a name="isDefinition2Anchor
">isDefinition</a></td><td></td></tr>
5247 <tr><td colspan="4" class="doc
" id="isDefinition2
"><pre>Matches if a declaration has a body attached.
5249 Example matches A, va, fa
5251 class B; // Doesn't match, as it has no body.
5253 extern int vb; // Doesn't match, as it doesn't define the variable.
5255 void fb(); // Doesn't match, as it has no body.
5257 - (void)ma; // Doesn't match, interface is declaration.
5263 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html
">TagDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>>,
5264 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html
">ObjCMethodDecl</a>>
5268 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html
">ObjCMethodDecl</a>></td><td class="name
" onclick="toggle('isInstanceMethod0')
"><a name="isInstanceMethod0Anchor
">isInstanceMethod</a></td><td></td></tr>
5269 <tr><td colspan="4" class="doc
" id="isInstanceMethod0
"><pre>Returns true when the Objective-C method declaration is an instance method.
5272 matcher = objcMethodDecl(isInstanceMethod())
5274 @interface I - (void)bar; @end
5276 @interface I + (void)foo; @end
5280 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html
">ParmVarDecl</a>></td><td class="name
" onclick="toggle('hasDefaultArgument0')
"><a name="hasDefaultArgument0Anchor
">hasDefaultArgument</a></td><td></td></tr>
5281 <tr><td colspan="4" class="doc
" id="hasDefaultArgument0
"><pre>Matches a declaration that has default arguments.
5283 Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
5285 void y(int val = 0) {}
5287 Deprecated. Use hasInitializer() instead to be able to
5288 match on the contents of the default argument. For example:
5290 void x(int val = 7) {}
5291 void y(int val = 42) {}
5292 parmVarDecl(hasInitializer(integerLiteral(equals(42))))
5293 matches the parameter of y
5296 parmVarDecl(hasInitializer(anything()))
5297 is equivalent to parmVarDecl(hasDefaultArgument()).
5301 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html
">ParmVarDecl</a>></td><td class="name
" onclick="toggle('isAtPosition0')
"><a name="isAtPosition0Anchor
">isAtPosition</a></td><td>unsigned N</td></tr>
5302 <tr><td colspan="4" class="doc
" id="isAtPosition0
"><pre>Matches the ParmVarDecl nodes that are at the N'th position in the parameter
5303 list. The parameter list could be that of either a block, function, or
5309 void f(int a, int b, int c) {
5312 ``parmVarDecl(isAtPosition(0))`` matches ``int a``.
5314 ``parmVarDecl(isAtPosition(1))`` matches ``int b``.
5318 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('asString0')
"><a name="asString0Anchor
">asString</a></td><td>std::string Name</td></tr>
5319 <tr><td colspan="4" class="doc
" id="asString0
"><pre>Matches if the matched type is represented by the given string.
5322 class Y { public: void x(); };
5323 void z() { Y* y; y->x(); }
5324 cxxMemberCallExpr(on(hasType(asString("class Y *
"))))
5329 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('equalsBoundNode3')
"><a name="equalsBoundNode3Anchor
">equalsBoundNode</a></td><td>std::string ID</td></tr>
5330 <tr><td colspan="4" class="doc
" id="equalsBoundNode3
"><pre>Matches if a node equals a previously bound node.
5332 Matches a node if it equals the node previously bound to ID.
5335 class X { int a; int b; };
5337 has(fieldDecl(hasName("a
"), hasType(type().bind("t
")))),
5338 has(fieldDecl(hasName("b
"), hasType(type(equalsBoundNode("t
"))))))
5339 matches the class X, as a and b have the same type.
5341 Note that when multiple matches are involved via forEach* matchers,
5342 equalsBoundNodes acts as a filter.
5345 forEachDescendant(varDecl().bind("d
")),
5346 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d
"))))))
5347 will trigger a match for each combination of variable declaration
5348 and reference to that variable declaration within a compound statement.
5352 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('hasLocalQualifiers0')
"><a name="hasLocalQualifiers0Anchor
">hasLocalQualifiers</a></td><td></td></tr>
5353 <tr><td colspan="4" class="doc
" id="hasLocalQualifiers0
"><pre>Matches QualType nodes that have local CV-qualifiers attached to
5354 the node, not hidden within a typedef.
5357 typedef const int const_int;
5362 varDecl(hasType(hasLocalQualifiers())) matches only j and k.
5363 i is const-qualified but the qualifier is not local.
5367 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('isAnyCharacter0')
"><a name="isAnyCharacter0Anchor
">isAnyCharacter</a></td><td></td></tr>
5368 <tr><td colspan="4" class="doc
" id="isAnyCharacter0
"><pre>Matches QualType nodes that are of character type.
5374 functionDecl(hasAnyParameter(hasType(isAnyCharacter())))
5375 matches "a(char)
", "b(wchar_t)
", but not "c(double)
".
5379 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('isAnyPointer0')
"><a name="isAnyPointer0Anchor
">isAnyPointer</a></td><td></td></tr>
5380 <tr><td colspan="4" class="doc
" id="isAnyPointer0
"><pre>Matches QualType nodes that are of any pointer type; this includes
5381 the Objective-C object pointer type, which is different despite being
5382 syntactically similar.
5392 varDecl(hasType(isAnyPointer()))
5393 matches "int *i
" and "Foo *f
", but not "int j
".
5397 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('isConstQualified0')
"><a name="isConstQualified0Anchor
">isConstQualified</a></td><td></td></tr>
5398 <tr><td colspan="4" class="doc
" id="isConstQualified0
"><pre>Matches QualType nodes that are const-qualified, i.e., that
5399 include "top-level
" const.
5406 void e(int const) {};
5407 functionDecl(hasAnyParameter(hasType(isConstQualified())))
5408 matches "void b(int const)
", "void c(const int)
" and
5409 "void e(int const) {}
". It does not match d as there
5410 is no top-level const on the parameter type "const int *
".
5414 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('isInteger0')
"><a name="isInteger0Anchor
">isInteger</a></td><td></td></tr>
5415 <tr><td colspan="4" class="doc
" id="isInteger0
"><pre>Matches QualType nodes that are of integer type.
5421 functionDecl(hasAnyParameter(hasType(isInteger())))
5422 matches "a(int)
", "b(long)
", but not "c(double)
".
5426 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('isSignedInteger0')
"><a name="isSignedInteger0Anchor
">isSignedInteger</a></td><td></td></tr>
5427 <tr><td colspan="4" class="doc
" id="isSignedInteger0
"><pre>Matches QualType nodes that are of signed integer type.
5431 void b(unsigned long);
5433 functionDecl(hasAnyParameter(hasType(isSignedInteger())))
5434 matches "a(int)
", but not "b(unsigned long)
" and "c(double)
".
5438 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('isUnsignedInteger0')
"><a name="isUnsignedInteger0Anchor
">isUnsignedInteger</a></td><td></td></tr>
5439 <tr><td colspan="4" class="doc
" id="isUnsignedInteger0
"><pre>Matches QualType nodes that are of unsigned integer type.
5443 void b(unsigned long);
5445 functionDecl(hasAnyParameter(hasType(isUnsignedInteger())))
5446 matches "b(unsigned long)
", but not "a(int)
" and "c(double)
".
5450 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('isVolatileQualified0')
"><a name="isVolatileQualified0Anchor
">isVolatileQualified</a></td><td></td></tr>
5451 <tr><td colspan="4" class="doc
" id="isVolatileQualified0
"><pre>Matches QualType nodes that are volatile-qualified, i.e., that
5452 include "top-level
" volatile.
5456 void b(int volatile);
5457 void c(volatile int);
5458 void d(volatile int*);
5459 void e(int volatile) {};
5460 functionDecl(hasAnyParameter(hasType(isVolatileQualified())))
5461 matches "void b(int volatile)
", "void c(volatile int)
" and
5462 "void e(int volatile) {}
". It does not match d as there
5463 is no top-level volatile on the parameter type "volatile int *
".
5467 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>></td><td class="name
" onclick="toggle('equalsBoundNode0')
"><a name="equalsBoundNode0Anchor
">equalsBoundNode</a></td><td>std::string ID</td></tr>
5468 <tr><td colspan="4" class="doc
" id="equalsBoundNode0
"><pre>Matches if a node equals a previously bound node.
5470 Matches a node if it equals the node previously bound to ID.
5473 class X { int a; int b; };
5475 has(fieldDecl(hasName("a
"), hasType(type().bind("t
")))),
5476 has(fieldDecl(hasName("b
"), hasType(type(equalsBoundNode("t
"))))))
5477 matches the class X, as a and b have the same type.
5479 Note that when multiple matches are involved via forEach* matchers,
5480 equalsBoundNodes acts as a filter.
5483 forEachDescendant(varDecl().bind("d
")),
5484 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d
"))))))
5485 will trigger a match for each combination of variable declaration
5486 and reference to that variable declaration within a compound statement.
5490 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>></td><td class="name
" onclick="toggle('equalsNode1')
"><a name="equalsNode1Anchor
">equalsNode</a></td><td>const Stmt* Other</td></tr>
5491 <tr><td colspan="4" class="doc
" id="equalsNode1
"><pre>Matches if a node equals another node.
5493 Stmt has pointer identity in the AST.
5497 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>></td><td class="name
" onclick="toggle('isExpandedFromMacro1')
"><a name="isExpandedFromMacro1Anchor
">isExpandedFromMacro</a></td><td>std::string MacroName</td></tr>
5498 <tr><td colspan="4" class="doc
" id="isExpandedFromMacro1
"><pre>Matches statements that are (transitively) expanded from the named macro.
5499 Does not match if only part of the statement is expanded from that macro or
5500 if different parts of the statement are expanded from different
5501 appearances of the macro.
5505 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>></td><td class="name
" onclick="toggle('isExpansionInFileMatching1')
"><a name="isExpansionInFileMatching1Anchor
">isExpansionInFileMatching</a></td><td>StringRef RegExp, Regex::RegexFlags Flags = NoFlags</td></tr>
5506 <tr><td colspan="4" class="doc
" id="isExpansionInFileMatching1
"><pre>Matches AST nodes that were expanded within files whose name is
5507 partially matching a given regex.
5509 Example matches Y but not X
5510 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*
"))
5511 #include "ASTMatcher.h
"
5516 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>>
5518 If the matcher is used in clang-query, RegexFlags parameter
5519 should be passed as a quoted string. e.g: "NoFlags
".
5520 Flags can be combined with '|' example "IgnoreCase | BasicRegex
"
5524 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>></td><td class="name
" onclick="toggle('isExpansionInMainFile1')
"><a name="isExpansionInMainFile1Anchor
">isExpansionInMainFile</a></td><td></td></tr>
5525 <tr><td colspan="4" class="doc
" id="isExpansionInMainFile1
"><pre>Matches AST nodes that were expanded within the main-file.
5527 Example matches X but not Y
5528 (matcher = cxxRecordDecl(isExpansionInMainFile())
5529 #include <Y.h>
5534 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>>
5538 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>></td><td class="name
" onclick="toggle('isExpansionInSystemHeader1')
"><a name="isExpansionInSystemHeader1Anchor
">isExpansionInSystemHeader</a></td><td></td></tr>
5539 <tr><td colspan="4" class="doc
" id="isExpansionInSystemHeader1
"><pre>Matches AST nodes that were expanded within system-header-files.
5541 Example matches Y but not X
5542 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
5543 #include <SystemHeader.h>
5548 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>>
5552 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>></td><td class="name
" onclick="toggle('isInTemplateInstantiation0')
"><a name="isInTemplateInstantiation0Anchor
">isInTemplateInstantiation</a></td><td></td></tr>
5553 <tr><td colspan="4" class="doc
" id="isInTemplateInstantiation0
"><pre>Matches statements inside of a template instantiation.
5557 template<typename T> void A(T t) { T i; j += 42;}
5560 declStmt(isInTemplateInstantiation())
5561 matches 'int i;' and 'unsigned i'.
5562 unless(stmt(isInTemplateInstantiation()))
5563 will NOT match j += 42; as it's shared between the template definition and
5568 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html
">StringLiteral</a>></td><td class="name
" onclick="toggle('hasSize1')
"><a name="hasSize1Anchor
">hasSize</a></td><td>unsigned N</td></tr>
5569 <tr><td colspan="4" class="doc
" id="hasSize1
"><pre>Matches nodes that have the specified size.
5576 wchar_t *ws = L"abcd
";
5578 constantArrayType(hasSize(42))
5579 matches "int a[
42]
" and "int b[
2 *
21]
"
5580 stringLiteral(hasSize(4))
5581 matches "abcd
", L"abcd
"
5585 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html
">TagDecl</a>></td><td class="name
" onclick="toggle('isClass0')
"><a name="isClass0Anchor
">isClass</a></td><td></td></tr>
5586 <tr><td colspan="4" class="doc
" id="isClass0
"><pre>Matches TagDecl object that are spelled with "class.
"
5588 Example matches C, but not S, U or E.
5596 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html
">TagDecl</a>></td><td class="name
" onclick="toggle('isDefinition0')
"><a name="isDefinition0Anchor
">isDefinition</a></td><td></td></tr>
5597 <tr><td colspan="4" class="doc
" id="isDefinition0
"><pre>Matches if a declaration has a body attached.
5599 Example matches A, va, fa
5601 class B; // Doesn't match, as it has no body.
5603 extern int vb; // Doesn't match, as it doesn't define the variable.
5605 void fb(); // Doesn't match, as it has no body.
5607 - (void)ma; // Doesn't match, interface is declaration.
5613 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html
">TagDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>>,
5614 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html
">ObjCMethodDecl</a>>
5618 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html
">TagDecl</a>></td><td class="name
" onclick="toggle('isEnum0')
"><a name="isEnum0Anchor
">isEnum</a></td><td></td></tr>
5619 <tr><td colspan="4" class="doc
" id="isEnum0
"><pre>Matches TagDecl object that are spelled with "enum.
"
5621 Example matches E, but not C, S or U.
5629 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html
">TagDecl</a>></td><td class="name
" onclick="toggle('isStruct0')
"><a name="isStruct0Anchor
">isStruct</a></td><td></td></tr>
5630 <tr><td colspan="4" class="doc
" id="isStruct0
"><pre>Matches TagDecl object that are spelled with "struct.
"
5632 Example matches S, but not C, U or E.
5640 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html
">TagDecl</a>></td><td class="name
" onclick="toggle('isUnion0')
"><a name="isUnion0Anchor
">isUnion</a></td><td></td></tr>
5641 <tr><td colspan="4" class="doc
" id="isUnion0
"><pre>Matches TagDecl object that are spelled with "union.
"
5643 Example matches U, but not C, S or E.
5651 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>></td><td class="name
" onclick="toggle('equalsIntegralValue0')
"><a name="equalsIntegralValue0Anchor
">equalsIntegralValue</a></td><td>std::string Value</td></tr>
5652 <tr><td colspan="4" class="doc
" id="equalsIntegralValue0
"><pre>Matches a TemplateArgument of integral type with a given value.
5654 Note that 'Value' is a string as the template argument's value is
5655 an arbitrary precision integer. 'Value' must be euqal to the canonical
5656 representation of that integral value in base 10.
5659 template<int T> struct C {};
5661 classTemplateSpecializationDecl(
5662 hasAnyTemplateArgument(equalsIntegralValue("42")))
5663 matches the implicit instantiation of C in C<42>.
5667 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>></td><td class="name
" onclick="toggle('isIntegral0')
"><a name="isIntegral0Anchor
">isIntegral</a></td><td></td></tr>
5668 <tr><td colspan="4" class="doc
" id="isIntegral0
"><pre>Matches a TemplateArgument that is an integral value.
5671 template<int T> struct C {};
5673 classTemplateSpecializationDecl(
5674 hasAnyTemplateArgument(isIntegral()))
5675 matches the implicit instantiation of C in C<42>
5676 with isIntegral() matching 42.
5680 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>></td><td class="name
" onclick="toggle('templateArgumentCountIs1')
"><a name="templateArgumentCountIs1Anchor
">templateArgumentCountIs</a></td><td>unsigned N</td></tr>
5681 <tr><td colspan="4" class="doc
" id="templateArgumentCountIs1
"><pre>Matches if the number of template arguments equals N.
5684 template<typename T> struct C {};
5686 classTemplateSpecializationDecl(templateArgumentCountIs(1))
5687 matches C<int>.
5691 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>></td><td class="name
" onclick="toggle('isExpandedFromMacro2')
"><a name="isExpandedFromMacro2Anchor
">isExpandedFromMacro</a></td><td>std::string MacroName</td></tr>
5692 <tr><td colspan="4" class="doc
" id="isExpandedFromMacro2
"><pre>Matches statements that are (transitively) expanded from the named macro.
5693 Does not match if only part of the statement is expanded from that macro or
5694 if different parts of the statement are expanded from different
5695 appearances of the macro.
5699 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>></td><td class="name
" onclick="toggle('isExpansionInFileMatching2')
"><a name="isExpansionInFileMatching2Anchor
">isExpansionInFileMatching</a></td><td>StringRef RegExp, Regex::RegexFlags Flags = NoFlags</td></tr>
5700 <tr><td colspan="4" class="doc
" id="isExpansionInFileMatching2
"><pre>Matches AST nodes that were expanded within files whose name is
5701 partially matching a given regex.
5703 Example matches Y but not X
5704 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*
"))
5705 #include "ASTMatcher.h
"
5710 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>>
5712 If the matcher is used in clang-query, RegexFlags parameter
5713 should be passed as a quoted string. e.g: "NoFlags
".
5714 Flags can be combined with '|' example "IgnoreCase | BasicRegex
"
5718 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>></td><td class="name
" onclick="toggle('isExpansionInMainFile2')
"><a name="isExpansionInMainFile2Anchor
">isExpansionInMainFile</a></td><td></td></tr>
5719 <tr><td colspan="4" class="doc
" id="isExpansionInMainFile2
"><pre>Matches AST nodes that were expanded within the main-file.
5721 Example matches X but not Y
5722 (matcher = cxxRecordDecl(isExpansionInMainFile())
5723 #include <Y.h>
5728 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>>
5732 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>></td><td class="name
" onclick="toggle('isExpansionInSystemHeader2')
"><a name="isExpansionInSystemHeader2Anchor
">isExpansionInSystemHeader</a></td><td></td></tr>
5733 <tr><td colspan="4" class="doc
" id="isExpansionInSystemHeader2
"><pre>Matches AST nodes that were expanded within system-header-files.
5735 Example matches Y but not X
5736 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
5737 #include <SystemHeader.h>
5742 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>>
5746 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td><td class="name
" onclick="toggle('booleanType0')
"><a name="booleanType0Anchor
">booleanType</a></td><td></td></tr>
5747 <tr><td colspan="4" class="doc
" id="booleanType0
"><pre>Matches type bool.
5750 struct S { bool func(); };
5751 functionDecl(returns(booleanType()))
5752 matches "bool func();
"
5756 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td><td class="name
" onclick="toggle('equalsBoundNode2')
"><a name="equalsBoundNode2Anchor
">equalsBoundNode</a></td><td>std::string ID</td></tr>
5757 <tr><td colspan="4" class="doc
" id="equalsBoundNode2
"><pre>Matches if a node equals a previously bound node.
5759 Matches a node if it equals the node previously bound to ID.
5762 class X { int a; int b; };
5764 has(fieldDecl(hasName("a
"), hasType(type().bind("t
")))),
5765 has(fieldDecl(hasName("b
"), hasType(type(equalsBoundNode("t
"))))))
5766 matches the class X, as a and b have the same type.
5768 Note that when multiple matches are involved via forEach* matchers,
5769 equalsBoundNodes acts as a filter.
5772 forEachDescendant(varDecl().bind("d
")),
5773 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d
"))))))
5774 will trigger a match for each combination of variable declaration
5775 and reference to that variable declaration within a compound statement.
5779 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td><td class="name
" onclick="toggle('equalsNode2')
"><a name="equalsNode2Anchor
">equalsNode</a></td><td>const Type* Other</td></tr>
5780 <tr><td colspan="4" class="doc
" id="equalsNode2
"><pre>Matches if a node equals another node.
5782 Type has pointer identity in the AST.
5786 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td><td class="name
" onclick="toggle('realFloatingPointType0')
"><a name="realFloatingPointType0Anchor
">realFloatingPointType</a></td><td></td></tr>
5787 <tr><td colspan="4" class="doc
" id="realFloatingPointType0
"><pre>Matches any real floating-point type (float, double, long double).
5792 realFloatingPointType()
5793 matches "float f
" but not "int i
"
5797 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td><td class="name
" onclick="toggle('voidType0')
"><a name="voidType0Anchor
">voidType</a></td><td></td></tr>
5798 <tr><td colspan="4" class="doc
" id="voidType0
"><pre>Matches type void.
5801 struct S { void func(); };
5802 functionDecl(returns(voidType()))
5803 matches "void func();
"
5807 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html
">UnaryExprOrTypeTraitExpr</a>></td><td class="name
" onclick="toggle('ofKind0')
"><a name="ofKind0Anchor
">ofKind</a></td><td>UnaryExprOrTypeTrait Kind</td></tr>
5808 <tr><td colspan="4" class="doc
" id="ofKind0
"><pre>Matches unary expressions of a certain kind.
5812 int s = sizeof(x) + alignof(x)
5813 unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
5816 If the matcher is use from clang-query, UnaryExprOrTypeTrait parameter
5817 should be passed as a quoted string. e.g., ofKind("UETT_SizeOf
").
5821 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html
">UnaryOperator</a>></td><td class="name
" onclick="toggle('hasAnyOperatorName3')
"><a name="hasAnyOperatorName3Anchor
">hasAnyOperatorName</a></td><td>StringRef, ..., StringRef</td></tr>
5822 <tr><td colspan="4" class="doc
" id="hasAnyOperatorName3
"><pre>Matches operator expressions (binary or unary) that have any of the
5825 hasAnyOperatorName("+
", "-
")
5827 anyOf(hasOperatorName("+
"), hasOperatorName("-
"))
5831 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html
">UnaryOperator</a>></td><td class="name
" onclick="toggle('hasOperatorName4')
"><a name="hasOperatorName4Anchor
">hasOperatorName</a></td><td>std::string Name</td></tr>
5832 <tr><td colspan="4" class="doc
" id="hasOperatorName4
"><pre>Matches the operator Name of operator expressions and fold expressions
5835 Example matches a || b (matcher = binaryOperator(hasOperatorName("||
")))
5838 Example matches `(0 + ... + args)`
5839 (matcher = cxxFoldExpr(hasOperatorName("+
")))
5840 template <typename... Args>
5841 auto sum(Args... args) {
5842 return (0 + ... + args);
5847 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html
">UnresolvedMemberExpr</a>></td><td class="name
" onclick="toggle('isArrow1')
"><a name="isArrow1Anchor
">isArrow</a></td><td></td></tr>
5848 <tr><td colspan="4" class="doc
" id="isArrow1
"><pre>Matches member expressions that are called with '->' as opposed
5851 Member calls on the implicit this pointer match as called with '->'.
5855 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
5856 template <class T> void f() { this->f<T>(); f<T>(); }
5860 template <class T>
5862 void x() { this->m; }
5864 memberExpr(isArrow())
5865 matches this->x, x, y.x, a, this->b
5866 cxxDependentScopeMemberExpr(isArrow())
5868 unresolvedMemberExpr(isArrow())
5869 matches this->f<T>, f<T>
5873 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('hasAutomaticStorageDuration0')
"><a name="hasAutomaticStorageDuration0Anchor
">hasAutomaticStorageDuration</a></td><td></td></tr>
5874 <tr><td colspan="4" class="doc
" id="hasAutomaticStorageDuration0
"><pre>Matches a variable declaration that has automatic storage duration.
5876 Example matches x, but not y, z, or a.
5877 (matcher = varDecl(hasAutomaticStorageDuration())
5887 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('hasGlobalStorage0')
"><a name="hasGlobalStorage0Anchor
">hasGlobalStorage</a></td><td></td></tr>
5888 <tr><td colspan="4" class="doc
" id="hasGlobalStorage0
"><pre>Matches a variable declaration that does not have local storage.
5890 Example matches y and z (matcher = varDecl(hasGlobalStorage())
5899 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('hasLocalStorage0')
"><a name="hasLocalStorage0Anchor
">hasLocalStorage</a></td><td></td></tr>
5900 <tr><td colspan="4" class="doc
" id="hasLocalStorage0
"><pre>Matches a variable declaration that has function scope and is a
5901 non-static local variable.
5903 Example matches x (matcher = varDecl(hasLocalStorage())
5912 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('hasStaticStorageDuration0')
"><a name="hasStaticStorageDuration0Anchor
">hasStaticStorageDuration</a></td><td></td></tr>
5913 <tr><td colspan="4" class="doc
" id="hasStaticStorageDuration0
"><pre>Matches a variable declaration that has static storage duration.
5914 It includes the variable declared at namespace scope and those declared
5915 with "static
" and "extern
" storage class specifiers.
5925 varDecl(hasStaticStorageDuration())
5926 matches the function declaration y, a, b and c.
5930 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('hasThreadStorageDuration0')
"><a name="hasThreadStorageDuration0Anchor
">hasThreadStorageDuration</a></td><td></td></tr>
5931 <tr><td colspan="4" class="doc
" id="hasThreadStorageDuration0
"><pre>Matches a variable declaration that has thread storage duration.
5933 Example matches z, but not x, z, or a.
5934 (matcher = varDecl(hasThreadStorageDuration())
5944 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('isConstexpr0')
"><a name="isConstexpr0Anchor
">isConstexpr</a></td><td></td></tr>
5945 <tr><td colspan="4" class="doc
" id="isConstexpr0
"><pre>Matches constexpr variable and function declarations,
5949 constexpr int foo = 42;
5950 constexpr int bar();
5951 void baz() { if constexpr(1 > 0) {} }
5952 varDecl(isConstexpr())
5953 matches the declaration of foo.
5954 functionDecl(isConstexpr())
5955 matches the declaration of bar.
5956 ifStmt(isConstexpr())
5957 matches the if statement in baz.
5961 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('isConstinit0')
"><a name="isConstinit0Anchor
">isConstinit</a></td><td></td></tr>
5962 <tr><td colspan="4" class="doc
" id="isConstinit0
"><pre>Matches constinit variable declarations.
5965 constinit int foo = 42;
5966 constinit const char* bar = "bar
";
5968 [[clang::require_constant_initialization]] int xyz = 42;
5969 varDecl(isConstinit())
5970 matches the declaration of `foo` and `bar`, but not `baz` and `xyz`.
5974 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('isDefinition1')
"><a name="isDefinition1Anchor
">isDefinition</a></td><td></td></tr>
5975 <tr><td colspan="4" class="doc
" id="isDefinition1
"><pre>Matches if a declaration has a body attached.
5977 Example matches A, va, fa
5979 class B; // Doesn't match, as it has no body.
5981 extern int vb; // Doesn't match, as it doesn't define the variable.
5983 void fb(); // Doesn't match, as it has no body.
5985 - (void)ma; // Doesn't match, interface is declaration.
5991 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagDecl.html
">TagDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>>,
5992 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html
">ObjCMethodDecl</a>>
5996 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('isExceptionVariable0')
"><a name="isExceptionVariable0Anchor
">isExceptionVariable</a></td><td></td></tr>
5997 <tr><td colspan="4" class="doc
" id="isExceptionVariable0
"><pre>Matches a variable declaration that is an exception variable from
5998 a C++ catch block, or an Objective-C statement.
6000 Example matches x (matcher = varDecl(isExceptionVariable())
6009 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('isExplicitTemplateSpecialization1')
"><a name="isExplicitTemplateSpecialization1Anchor
">isExplicitTemplateSpecialization</a></td><td></td></tr>
6010 <tr><td colspan="4" class="doc
" id="isExplicitTemplateSpecialization1
"><pre>Matches explicit template specializations of function, class, or
6011 static member variable template instantiations.
6014 template<typename T> void A(T t) { }
6015 template<> void A(int N) { }
6016 functionDecl(isExplicitTemplateSpecialization())
6017 matches the specialization A<int>().
6019 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html
">CXXRecordDecl</a>>
6023 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('isExternC1')
"><a name="isExternC1Anchor
">isExternC</a></td><td></td></tr>
6024 <tr><td colspan="4" class="doc
" id="isExternC1
"><pre>Matches extern "C
" function or variable declarations.
6027 extern "C
" void f() {}
6028 extern "C
" { void g() {} }
6030 extern "C
" int x = 1;
6031 extern "C
" int y = 2;
6033 functionDecl(isExternC())
6034 matches the declaration of f and g, but not the declaration of h.
6035 varDecl(isExternC())
6036 matches the declaration of x and y, but not the declaration of z.
6040 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('isInitCapture0')
"><a name="isInitCapture0Anchor
">isInitCapture</a></td><td></td></tr>
6041 <tr><td colspan="4" class="doc
" id="isInitCapture0
"><pre>Matches a variable serving as the implicit variable for a lambda init-
6044 Example matches x (matcher = varDecl(isInitCapture()))
6045 auto f = [x=3]() { return x; };
6049 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('isInline2')
"><a name="isInline2Anchor
">isInline</a></td><td></td></tr>
6050 <tr><td colspan="4" class="doc
" id="isInline2
"><pre>Matches functions, variables and namespace declarations that are marked with
6057 inline namespace m {}
6060 functionDecl(isInline()) will match ::f().
6061 namespaceDecl(isInline()) will match n::m.
6062 varDecl(isInline()) will match Foo;
6066 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('isStaticLocal0')
"><a name="isStaticLocal0Anchor
">isStaticLocal</a></td><td></td></tr>
6067 <tr><td colspan="4" class="doc
" id="isStaticLocal0
"><pre>Matches a static variable with local scope.
6069 Example matches y (matcher = varDecl(isStaticLocal()))
6078 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('isStaticStorageClass1')
"><a name="isStaticStorageClass1Anchor
">isStaticStorageClass</a></td><td></td></tr>
6079 <tr><td colspan="4" class="doc
" id="isStaticStorageClass1
"><pre>Matches variable/function declarations that have "static
" storage
6080 class specifier ("static
" keyword) written in the source.
6087 functionDecl(isStaticStorageClass())
6088 matches the function declaration f.
6089 varDecl(isStaticStorageClass())
6090 matches the variable declaration i.
6094 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('isTemplateInstantiation1')
"><a name="isTemplateInstantiation1Anchor
">isTemplateInstantiation</a></td><td></td></tr>
6095 <tr><td colspan="4" class="doc
" id="isTemplateInstantiation1
"><pre>Matches template instantiations of function, class, or static
6096 member variable template instantiations.
6099 template <typename T> class X {}; class A {}; X<A> x;
6101 template <typename T> class X {}; class A {}; template class X<A>;
6103 template <typename T> class X {}; class A {}; extern template class X<A>;
6104 cxxRecordDecl(hasName("::X
"), isTemplateInstantiation())
6105 matches the template instantiation of X<A>.
6108 template <typename T> class X {}; class A {};
6109 template <> class X<A> {}; X<A> x;
6110 cxxRecordDecl(hasName("::X
"), isTemplateInstantiation())
6111 does not match, as X<A> is an explicit template specialization.
6113 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html
">CXXRecordDecl</a>>
6116 <!--END_NARROWING_MATCHERS -->
6119 <!-- ======================================================================= -->
6120 <h2 id="traversal-matchers
">AST Traversal Matchers</h2>
6121 <!-- ======================================================================= -->
6123 <p>Traversal matchers specify the relationship to other nodes that are
6124 reachable from the current node.</p>
6126 <p>Note that there are special traversal matchers (has, hasDescendant, forEach and
6127 forEachDescendant) which work on all nodes and allow users to write more generic
6128 match expressions.</p>
6131 <tr style="text-align:left
"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
6132 <!-- START_TRAVERSAL_MATCHERS -->
6134 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('binaryOperation0')
"><a name="binaryOperation0Anchor
">binaryOperation</a></td><td>Matcher<*>...Matcher<*></td></tr>
6135 <tr><td colspan="4" class="doc
" id="binaryOperation0
"><pre>Matches nodes which can be used with binary operators.
6139 might be represented in the clang AST as a binaryOperator, a
6140 cxxOperatorCallExpr or a cxxRewrittenBinaryOperator, depending on
6142 * whether the types of var1 and var2 are fundamental (binaryOperator) or at
6143 least one is a class type (cxxOperatorCallExpr)
6144 * whether the code appears in a template declaration, if at least one of the
6145 vars is a dependent-type (binaryOperator)
6146 * whether the code relies on a rewritten binary operator, such as a
6147 spaceship operator or an inverted equality operator
6148 (cxxRewrittenBinaryOperator)
6150 This matcher elides details in places where the matchers for the nodes are
6155 hasOperatorName("!=
"),
6156 hasLHS(expr().bind("lhs
")),
6157 hasRHS(expr().bind("rhs
"))
6159 matches each use of "!=
" in:
6161 bool operator!=(const S&) const;
6170 template<typename T>
6178 bool operator==(const HasOpEq &) const;
6191 bool operator<=>(const HasOpEq &) const;
6194 void use_spaceship()
6204 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('eachOf0')
"><a name="eachOf0Anchor
">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr>
6205 <tr><td colspan="4" class="doc
" id="eachOf0
"><pre>Matches if any of the given matchers matches.
6207 Unlike anyOf, eachOf will generate a match result for each
6208 matching submatcher.
6211 class A { int a; int b; };
6213 cxxRecordDecl(eachOf(has(fieldDecl(hasName("a
")).bind("v
")),
6214 has(fieldDecl(hasName("b
")).bind("v
"))))
6215 will generate two results binding "v
", the first of which binds
6216 the field declaration of a, the second the field declaration of
6219 Usable as: Any Matcher
6223 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('findAll0')
"><a name="findAll0Anchor
">findAll</a></td><td>Matcher<*> Matcher</td></tr>
6224 <tr><td colspan="4" class="doc
" id="findAll0
"><pre>Matches if the node or any descendant matches.
6226 Generates results for each match.
6229 class A { class B {}; class C {}; };
6231 cxxRecordDecl(hasName("::A
"),
6232 findAll(cxxRecordDecl(isDefinition()).bind("m
")))
6233 will generate results for A, B and C.
6235 Usable as: Any Matcher
6239 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('forEachDescendant0')
"><a name="forEachDescendant0Anchor
">forEachDescendant</a></td><td>Matcher<*></td></tr>
6240 <tr><td colspan="4" class="doc
" id="forEachDescendant0
"><pre>Matches AST nodes that have descendant AST nodes that match the
6243 Example matches X, A, A::X, B, B::C, B::C::X
6244 (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X
")))))
6246 class A { class X {}; }; // Matches A, because A::X is a class of name
6248 class B { class C { class X {}; }; };
6250 DescendantT must be an AST base type.
6252 As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
6253 each result that matches instead of only on the first one.
6255 Note: Recursively combined ForEachDescendant can cause many matches:
6256 cxxRecordDecl(forEachDescendant(cxxRecordDecl(
6257 forEachDescendant(cxxRecordDecl())
6259 will match 10 times (plus injected class name matches) on:
6260 class A { class B { class C { class D { class E {}; }; }; }; };
6262 Usable as: Any Matcher
6266 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('forEach0')
"><a name="forEach0Anchor
">forEach</a></td><td>Matcher<*></td></tr>
6267 <tr><td colspan="4" class="doc
" id="forEach0
"><pre>Matches AST nodes that have child AST nodes that match the
6270 Example matches X, Y, Y::X, Z::Y, Z::Y::X
6271 (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X
")))
6273 class Y { class X {}; }; // Matches Y, because Y::X is a class of name X
6275 class Z { class Y { class X {}; }; }; // Does not match Z.
6277 ChildT must be an AST base type.
6279 As opposed to 'has', 'forEach' will cause a match for each result that
6280 matches instead of only on the first one.
6282 Usable as: Any Matcher
6286 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('hasAncestor0')
"><a name="hasAncestor0Anchor
">hasAncestor</a></td><td>Matcher<*></td></tr>
6287 <tr><td colspan="4" class="doc
" id="hasAncestor0
"><pre>Matches AST nodes that have an ancestor that matches the provided
6291 void f() { if (true) { int x = 42; } }
6292 void g() { for (;;) { int x = 43; } }
6293 expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.
6295 Usable as: Any Matcher
6299 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('hasDescendant0')
"><a name="hasDescendant0Anchor
">hasDescendant</a></td><td>Matcher<*></td></tr>
6300 <tr><td colspan="4" class="doc
" id="hasDescendant0
"><pre>Matches AST nodes that have descendant AST nodes that match the
6303 Example matches X, Y, Z
6304 (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X
")))))
6305 class X {}; // Matches X, because X::X is a class of name X inside X.
6306 class Y { class X {}; };
6307 class Z { class Y { class X {}; }; };
6309 DescendantT must be an AST base type.
6311 Usable as: Any Matcher
6315 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('has0')
"><a name="has0Anchor
">has</a></td><td>Matcher<*></td></tr>
6316 <tr><td colspan="4" class="doc
" id="has0
"><pre>Matches AST nodes that have child AST nodes that match the
6319 Example matches X, Y
6320 (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X
")))
6321 class X {}; // Matches X, because X::X is a class of name X inside X.
6322 class Y { class X {}; };
6323 class Z { class Y { class X {}; }; }; // Does not match Z.
6325 ChildT must be an AST base type.
6327 Usable as: Any Matcher
6328 Note that has is direct matcher, so it also matches things like implicit
6329 casts and paren casts. If you are matching with expr then you should
6330 probably consider using ignoringParenImpCasts like:
6331 has(ignoringParenImpCasts(expr())).
6335 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('hasParent0')
"><a name="hasParent0Anchor
">hasParent</a></td><td>Matcher<*></td></tr>
6336 <tr><td colspan="4" class="doc
" id="hasParent0
"><pre>Matches AST nodes that have a parent that matches the provided
6340 void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
6341 compoundStmt(hasParent(ifStmt())) matches "{ int x =
43; }
".
6343 Usable as: Any Matcher
6347 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('invocation0')
"><a name="invocation0Anchor
">invocation</a></td><td>Matcher<*>...Matcher<*></td></tr>
6348 <tr><td colspan="4" class="doc
" id="invocation0
"><pre>Matches function calls and constructor calls
6350 Because CallExpr and CXXConstructExpr do not share a common
6351 base class with API accessing arguments etc, AST Matchers for code
6352 which should match both are typically duplicated. This matcher
6353 removes the need for duplication.
6356 struct ConstructorTakesInt
6358 ConstructorTakesInt(int i) {}
6361 void callTakesInt(int i)
6372 ConstructorTakesInt cti(42);
6376 invocation(hasArgument(0, integerLiteral(equals(42))))
6377 matches the expression in both doCall and doConstruct
6381 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('optionally0')
"><a name="optionally0Anchor
">optionally</a></td><td>Matcher<*></td></tr>
6382 <tr><td colspan="4" class="doc
" id="optionally0
"><pre>Matches any node regardless of the submatcher.
6384 However, optionally will retain any bindings generated by the submatcher.
6385 Useful when additional information which may or may not present about a main
6386 matching node is desired.
6395 fieldDecl(hasName("bar
")).bind("var
")
6397 will produce a result binding for both "record
" and "var
".
6398 The matcher will produce a "record
" binding for even if there is no data
6399 member named "bar
" in that class.
6401 Usable as: Any Matcher
6405 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('traverse0')
"><a name="traverse0Anchor
">traverse</a></td><td>TraversalKind TK, Matcher<*> InnerMatcher</td></tr>
6406 <tr><td colspan="4" class="doc
" id="traverse0
"><pre>Causes all nested matchers to be matched with the specified traversal kind.
6414 traverse(TK_IgnoreUnlessSpelledInSource,
6415 varDecl(hasInitializer(floatLiteral().bind("init
")))
6417 matches the variable declaration with "init
" bound to the "3.0".
6421 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html
">AbstractConditionalOperator</a>></td><td class="name
" onclick="toggle('hasCondition5')
"><a name="hasCondition5Anchor
">hasCondition</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
6422 <tr><td colspan="4" class="doc
" id="hasCondition5
"><pre>Matches the condition expression of an if statement, for loop,
6423 switch statement or conditional operator.
6425 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
6430 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html
">AbstractConditionalOperator</a>></td><td class="name
" onclick="toggle('hasFalseExpression0')
"><a name="hasFalseExpression0Anchor
">hasFalseExpression</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
6431 <tr><td colspan="4" class="doc
" id="hasFalseExpression0
"><pre>Matches the false branch expression of a conditional operator
6432 (binary or ternary).
6440 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html
">AbstractConditionalOperator</a>></td><td class="name
" onclick="toggle('hasTrueExpression0')
"><a name="hasTrueExpression0Anchor
">hasTrueExpression</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
6441 <tr><td colspan="4" class="doc
" id="hasTrueExpression0
"><pre>Matches the true branch expression of a conditional operator.
6443 Example 1 (conditional ternary operator): matches a
6446 Example 2 (conditional binary operator): matches opaqueValueExpr(condition)
6451 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>></td><td class="name
" onclick="toggle('hasDeclaration15')
"><a name="hasDeclaration15Anchor
">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
6452 <tr><td colspan="4" class="doc
" id="hasDeclaration15
"><pre>Matches a node if the declaration associated with that node
6453 matches the given matcher.
6455 The associated declaration is:
6456 - for type nodes, the declaration of the underlying type
6457 - for CallExpr, the declaration of the callee
6458 - for MemberExpr, the declaration of the referenced member
6459 - for CXXConstructExpr, the declaration of the constructor
6460 - for CXXNewExpr, the declaration of the operator new
6461 - for ObjCIvarExpr, the declaration of the ivar
6463 For type nodes, hasDeclaration will generally match the declaration of the
6468 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6469 typedefDecl. A common use case is to match the underlying, desugared type.
6470 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6471 varDecl(hasType(hasUnqualifiedDesugaredType(
6472 recordType(hasDeclaration(decl())))))
6473 In this matcher, the decl will match the CXXRecordDecl of class X.
6475 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>>,
6476 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>,
6477 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>>,
6478 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>>,
6479 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>>,
6480 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>>,
6481 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
6485 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html
">ArraySubscriptExpr</a>></td><td class="name
" onclick="toggle('hasBase0')
"><a name="hasBase0Anchor
">hasBase</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
6486 <tr><td colspan="4" class="doc
" id="hasBase0
"><pre>Matches the base expression of an array subscript expression.
6490 void f() { i[1] = 42; }
6491 arraySubscriptExpression(hasBase(implicitCastExpr(
6492 hasSourceExpression(declRefExpr()))))
6493 matches i[1] with the declRefExpr() matching i
6497 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html
">ArraySubscriptExpr</a>></td><td class="name
" onclick="toggle('hasIndex0')
"><a name="hasIndex0Anchor
">hasIndex</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
6498 <tr><td colspan="4" class="doc
" id="hasIndex0
"><pre>Matches the index expression of an array subscript expression.
6502 void f() { i[1] = 42; }
6503 arraySubscriptExpression(hasIndex(integerLiteral()))
6504 matches i[1] with the integerLiteral() matching 1
6508 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html
">ArraySubscriptExpr</a>></td><td class="name
" onclick="toggle('hasLHS3')
"><a name="hasLHS3Anchor
">hasLHS</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
6509 <tr><td colspan="4" class="doc
" id="hasLHS3
"><pre>Matches the left hand side of binary operator expressions.
6511 Example matches a (matcher = binaryOperator(hasLHS()))
6516 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html
">ArraySubscriptExpr</a>></td><td class="name
" onclick="toggle('hasRHS3')
"><a name="hasRHS3Anchor
">hasRHS</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
6517 <tr><td colspan="4" class="doc
" id="hasRHS3
"><pre>Matches the right hand side of binary operator expressions.
6519 Example matches b (matcher = binaryOperator(hasRHS()))
6524 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArrayType.html
">ArrayType</a>></td><td class="name
" onclick="toggle('hasElementType0')
"><a name="hasElementType0Anchor
">hasElementType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td></tr>
6525 <tr><td colspan="4" class="doc
" id="hasElementType0
"><pre>Matches arrays and C99 complex types that have a specific element
6532 arrayType(hasElementType(builtinType()))
6535 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArrayType.html
">ArrayType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ComplexType.html
">ComplexType</a>>
6539 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html
">AtomicType</a>></td><td class="name
" onclick="toggle('hasValueType0')
"><a name="hasValueType0Anchor
">hasValueType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td></tr>
6540 <tr><td colspan="4" class="doc
" id="hasValueType0
"><pre>Matches atomic types with a specific value type.
6545 atomicType(hasValueType(isInteger()))
6546 matches "_Atomic(int) i
"
6548 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html
">AtomicType</a>>
6552 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html
">AutoType</a>></td><td class="name
" onclick="toggle('hasDeducedType0')
"><a name="hasDeducedType0Anchor
">hasDeducedType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td></tr>
6553 <tr><td colspan="4" class="doc
" id="hasDeducedType0
"><pre>Matches AutoType nodes where the deduced type is a specific type.
6555 Note: There is no TypeLoc for the deduced type and thus no
6556 getDeducedLoc() matcher.
6561 autoType(hasDeducedType(isInteger()))
6564 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html
">AutoType</a>>
6568 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BaseUsingDecl.html
">BaseUsingDecl</a>></td><td class="name
" onclick="toggle('hasAnyUsingShadowDecl0')
"><a name="hasAnyUsingShadowDecl0Anchor
">hasAnyUsingShadowDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html
">UsingShadowDecl</a>> InnerMatcher</td></tr>
6569 <tr><td colspan="4" class="doc
" id="hasAnyUsingShadowDecl0
"><pre>Matches any using shadow declaration.
6572 namespace X { void b(); }
6574 usingDecl(hasAnyUsingShadowDecl(hasName("b
"))))
6575 matches using X::b </pre></td></tr>
6578 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html
">BinaryOperator</a>></td><td class="name
" onclick="toggle('hasEitherOperand0')
"><a name="hasEitherOperand0Anchor
">hasEitherOperand</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
6579 <tr><td colspan="4" class="doc
" id="hasEitherOperand0
"><pre>Matches if either the left hand side or the right hand side of a
6580 binary operator or fold expression matches.
6584 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html
">BinaryOperator</a>></td><td class="name
" onclick="toggle('hasLHS0')
"><a name="hasLHS0Anchor
">hasLHS</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
6585 <tr><td colspan="4" class="doc
" id="hasLHS0
"><pre>Matches the left hand side of binary operator expressions.
6587 Example matches a (matcher = binaryOperator(hasLHS()))
6592 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html
">BinaryOperator</a>></td><td class="name
" onclick="toggle('hasOperands0')
"><a name="hasOperands0Anchor
">hasOperands</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> Matcher1, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> Matcher2</td></tr>
6593 <tr><td colspan="4" class="doc
" id="hasOperands0
"><pre>Matches if both matchers match with opposite sides of the binary operator
6596 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
6597 integerLiteral(equals(2)))
6605 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html
">BinaryOperator</a>></td><td class="name
" onclick="toggle('hasRHS0')
"><a name="hasRHS0Anchor
">hasRHS</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
6606 <tr><td colspan="4" class="doc
" id="hasRHS0
"><pre>Matches the right hand side of binary operator expressions.
6608 Example matches b (matcher = binaryOperator(hasRHS()))
6613 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BindingDecl.html
">BindingDecl</a>></td><td class="name
" onclick="toggle('forDecomposition0')
"><a name="forDecomposition0Anchor
">forDecomposition</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html
">ValueDecl</a>> InnerMatcher</td></tr>
6614 <tr><td colspan="4" class="doc
" id="forDecomposition0
"><pre>Matches the DecompositionDecl the binding belongs to.
6620 auto &[f, s, t] = arr;
6625 bindingDecl(hasName("f
"),
6626 forDecomposition(decompositionDecl())
6627 matches 'f' in 'auto &[f, s, t]'.
6631 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html
">BlockDecl</a>></td><td class="name
" onclick="toggle('hasAnyParameter2')
"><a name="hasAnyParameter2Anchor
">hasAnyParameter</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html
">ParmVarDecl</a>> InnerMatcher</td></tr>
6632 <tr><td colspan="4" class="doc
" id="hasAnyParameter2
"><pre>Matches any parameter of a function or an ObjC method declaration or a
6635 Does not match the 'this' parameter of a method.
6638 class X { void f(int x, int y, int z) {} };
6639 cxxMethodDecl(hasAnyParameter(hasName("y
")))
6640 matches f(int x, int y, int z) {}
6641 with hasAnyParameter(...)
6644 For ObjectiveC, given
6645 @interface I - (void) f:(int) y; @end
6647 the matcher objcMethodDecl(hasAnyParameter(hasName("y
")))
6648 matches the declaration of method f with hasParameter
6652 b = ^(int y) { printf("%d
", y) };
6654 the matcher blockDecl(hasAnyParameter(hasName("y
")))
6655 matches the declaration of the block b with hasParameter
6660 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html
">BlockDecl</a>></td><td class="name
" onclick="toggle('hasParameter2')
"><a name="hasParameter2Anchor
">hasParameter</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html
">ParmVarDecl</a>> InnerMatcher</td></tr>
6661 <tr><td colspan="4" class="doc
" id="hasParameter2
"><pre>Matches the n'th parameter of a function or an ObjC method
6662 declaration or a block.
6665 class X { void f(int x) {} };
6666 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
6668 with hasParameter(...)
6671 For ObjectiveC, given
6672 @interface I - (void) f:(int) y; @end
6674 the matcher objcMethodDecl(hasParameter(0, hasName("y
")))
6675 matches the declaration of method f with hasParameter
6680 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html
">BlockDecl</a>></td><td class="name
" onclick="toggle('hasTypeLoc0')
"><a name="hasTypeLoc0Anchor
">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> Inner</td></tr>
6681 <tr><td colspan="4" class="doc
" id="hasTypeLoc0
"><pre>Matches if the type location of a node matches the inner matcher.
6685 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
6689 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
6692 struct Foo { Foo(int, int); };
6694 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
6697 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html
">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>,
6698 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html
">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html
">CXXFunctionalCastExpr</a>>,
6699 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html
">CXXTemporaryObjectExpr</a>>,
6700 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
6701 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html
">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html
">CompoundLiteralExpr</a>>,
6702 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html
">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html
">ExplicitCastExpr</a>>,
6703 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html
">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html
">TemplateArgumentLoc</a>>,
6704 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
6708 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html
">BlockPointerType</a>></td><td class="name
" onclick="toggle('pointee0')
"><a name="pointee0Anchor
">pointee</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td></tr>
6709 <tr><td colspan="4" class="doc
" id="pointee0
"><pre>Narrows PointerType (and similar) matchers to those where the
6710 pointee matches a given matcher.
6716 pointerType(pointee(isConstQualified(), isInteger()))
6717 matches "int const *b
"
6719 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html
">BlockPointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html
">MemberPointerType</a>>,
6720 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html
">PointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html
">ReferenceType</a>>
6724 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>></td><td class="name
" onclick="toggle('hasTypeLoc1')
"><a name="hasTypeLoc1Anchor
">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> Inner</td></tr>
6725 <tr><td colspan="4" class="doc
" id="hasTypeLoc1
"><pre>Matches if the type location of a node matches the inner matcher.
6729 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
6733 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
6736 struct Foo { Foo(int, int); };
6738 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
6741 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html
">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>,
6742 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html
">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html
">CXXFunctionalCastExpr</a>>,
6743 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html
">CXXTemporaryObjectExpr</a>>,
6744 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
6745 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html
">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html
">CompoundLiteralExpr</a>>,
6746 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html
">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html
">ExplicitCastExpr</a>>,
6747 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html
">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html
">TemplateArgumentLoc</a>>,
6748 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
6752 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>></td><td class="name
" onclick="toggle('hasType8')
"><a name="hasType8Anchor
">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
6753 <tr><td colspan="4" class="doc
" id="hasType8
"><pre>Overloaded to match the declaration of the expression's or value
6756 In case of a value declaration (for example a variable declaration),
6757 this resolves one layer of indirection. For example, in the value
6758 declaration "X x;
", cxxRecordDecl(hasName("X
")) matches the declaration of
6759 X, while varDecl(hasType(cxxRecordDecl(hasName("X
")))) matches the
6762 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
6763 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
6764 and friend class X (matcher = friendDecl(hasType("X
"))
6765 and public virtual X (matcher = cxxBaseSpecifier(hasType(
6766 cxxRecordDecl(hasName("X
"))))
6768 void y(X &x) { x; X z; }
6769 class Y { friend class X; };
6770 class Z : public virtual X {};
6772 Example matches class Derived
6773 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base
"))))))
6775 class Derived : Base {};
6777 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html
">FriendDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html
">ValueDecl</a>>,
6778 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>
6782 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>></td><td class="name
" onclick="toggle('hasType4')
"><a name="hasType4Anchor
">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
6783 <tr><td colspan="4" class="doc
" id="hasType4
"><pre>Matches if the expression's or declaration's type matches a type
6786 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
6787 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
6788 and U (matcher = typedefDecl(hasType(asString("int
")))
6789 and friend class X (matcher = friendDecl(hasType("X
"))
6790 and public virtual X (matcher = cxxBaseSpecifier(hasType(
6791 asString("class X
")))
6793 void y(X &x) { x; X z; }
6795 class Y { friend class X; };
6796 class Z : public virtual X {};
6800 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>></td><td class="name
" onclick="toggle('forEachArgumentWithParam1')
"><a name="forEachArgumentWithParam1Anchor
">forEachArgumentWithParam</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> ArgMatcher, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html
">ParmVarDecl</a>> ParamMatcher</td></tr>
6801 <tr><td colspan="4" class="doc
" id="forEachArgumentWithParam1
"><pre>Matches all arguments and their respective ParmVarDecl.
6808 forEachArgumentWithParam(
6809 declRefExpr(to(varDecl(hasName("y
")))),
6810 parmVarDecl(hasType(isInteger()))
6813 with declRefExpr(...)
6815 and parmVarDecl(...)
6820 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>></td><td class="name
" onclick="toggle('forEachArgumentWithParamType1')
"><a name="forEachArgumentWithParamType1Anchor
">forEachArgumentWithParamType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> ArgMatcher, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> ParamMatcher</td></tr>
6821 <tr><td colspan="4" class="doc
" id="forEachArgumentWithParamType1
"><pre>Matches all arguments and their respective types for a CallExpr or
6822 CXXConstructExpr. It is very similar to forEachArgumentWithParam but
6823 it works on calls through function pointers as well.
6825 The difference is, that function pointers do not provide access to a
6826 ParmVarDecl, but only the QualType for each argument.
6832 void (*f_ptr)(int) = f;
6835 forEachArgumentWithParamType(
6836 declRefExpr(to(varDecl(hasName("y
")))),
6837 qualType(isInteger()).bind("type)
6839 matches f(y) and f_ptr(y)
6840 with declRefExpr(...)
6847 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr
</a>></td><td class=
"name" onclick=
"toggle('hasAnyArgument1')"><a name=
"hasAnyArgument1Anchor">hasAnyArgument
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
6848 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call
6849 expression, or an ObjC-message-send expression.
6852 void x(int, int, int) { int y; x(
1, y,
42); }
6853 callExpr(hasAnyArgument(declRefExpr()))
6855 with hasAnyArgument(...)
6858 For ObjectiveC, given
6859 @interface I - (void) f:(int) y; @end
6860 void foo(I *i) { [i f:
12]; }
6861 objcMessageExpr(hasAnyArgument(integerLiteral(equals(
12))))
6866 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr
</a>></td><td class=
"name" onclick=
"toggle('hasArgument1')"><a name=
"hasArgument1Anchor">hasArgument
</a></td><td>unsigned N, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
6867 <tr><td colspan=
"4" class=
"doc" id=
"hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor
6870 Example matches y in x(y)
6871 (matcher = callExpr(hasArgument(
0, declRefExpr())))
6872 void x(int) { int y; x(y); }
6876 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr
</a>></td><td class=
"name" onclick=
"toggle('hasDeclaration13')"><a name=
"hasDeclaration13Anchor">hasDeclaration
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>> InnerMatcher
</td></tr>
6877 <tr><td colspan=
"4" class=
"doc" id=
"hasDeclaration13"><pre>Matches a node if the declaration associated with that node
6878 matches the given matcher.
6880 The associated declaration is:
6881 - for type nodes, the declaration of the underlying type
6882 - for CallExpr, the declaration of the callee
6883 - for MemberExpr, the declaration of the referenced member
6884 - for CXXConstructExpr, the declaration of the constructor
6885 - for CXXNewExpr, the declaration of the operator new
6886 - for ObjCIvarExpr, the declaration of the ivar
6888 For type nodes, hasDeclaration will generally match the declaration of the
6893 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6894 typedefDecl. A common use case is to match the underlying, desugared type.
6895 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6896 varDecl(hasType(hasUnqualifiedDesugaredType(
6897 recordType(hasDeclaration(decl())))))
6898 In this matcher, the decl will match the CXXRecordDecl of class X.
6900 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr
</a>>,
6901 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr
</a>>,
6902 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt
</a>>,
6903 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType
</a>>,
6904 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType
</a>>,
6905 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType
</a>>,
6906 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType
</a>>
6910 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl
</a>></td><td class=
"name" onclick=
"toggle('forEachConstructorInitializer0')"><a name=
"forEachConstructorInitializer0Anchor">forEachConstructorInitializer
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>> InnerMatcher
</td></tr>
6911 <tr><td colspan=
"4" class=
"doc" id=
"forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition.
6914 class A { A() : i(
42), j(
42) {} int i; int j; };
6915 cxxConstructorDecl(forEachConstructorInitializer(
6916 forField(decl().bind(
"x"))
6918 will trigger two matches, binding for 'i' and 'j' respectively.
6922 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl
</a>></td><td class=
"name" onclick=
"toggle('hasAnyConstructorInitializer0')"><a name=
"hasAnyConstructorInitializer0Anchor">hasAnyConstructorInitializer
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>> InnerMatcher
</td></tr>
6923 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyConstructorInitializer0"><pre>Matches a constructor initializer.
6930 cxxRecordDecl(has(cxxConstructorDecl(
6931 hasAnyConstructorInitializer(anything())
6933 record matches Foo, hasAnyConstructorInitializer matches foo_(
1)
6937 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>></td><td class=
"name" onclick=
"toggle('forField0')"><a name=
"forField0Anchor">forField
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl
</a>> InnerMatcher
</td></tr>
6938 <tr><td colspan=
"4" class=
"doc" id=
"forField0"><pre>Matches the field declaration of a constructor initializer.
6945 cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
6946 forField(hasName(
"foo_"))))))
6948 with forField matching foo_
6952 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>></td><td class=
"name" onclick=
"toggle('hasTypeLoc2')"><a name=
"hasTypeLoc2Anchor">hasTypeLoc
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>> Inner
</td></tr>
6953 <tr><td colspan=
"4" class=
"doc" id=
"hasTypeLoc2"><pre>Matches if the type location of a node matches the inner matcher.
6957 declaratorDecl(hasTypeLoc(loc(asString(
"int"))))
6961 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString(
"int"))))
6964 struct Foo { Foo(int, int); };
6966 cxxFunctionalCastExpr(hasTypeLoc(loc(asString(
"struct Foo"))))
6969 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>>,
6970 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr
</a>>,
6971 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr
</a>>,
6972 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>>,
6973 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr
</a>>,
6974 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr
</a>>,
6975 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc
</a>>,
6976 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl
</a>>
6980 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>></td><td class=
"name" onclick=
"toggle('withInitializer0')"><a name=
"withInitializer0Anchor">withInitializer
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
6981 <tr><td colspan=
"4" class=
"doc" id=
"withInitializer0"><pre>Matches the initializer expression of a constructor initializer.
6988 cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
6989 withInitializer(integerLiteral(equals(
1)))))))
6991 with withInitializer matching (
1)
6995 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXDependentScopeMemberExpr.html">CXXDependentScopeMemberExpr
</a>></td><td class=
"name" onclick=
"toggle('hasObjectExpression2')"><a name=
"hasObjectExpression2Anchor">hasObjectExpression
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
6996 <tr><td colspan=
"4" class=
"doc" id=
"hasObjectExpression2"><pre>Matches a member expression where the object expression is matched by a
6997 given matcher. Implicit object expressions are included; that is, it matches
6998 use of implicit `this`.
7003 int f(X x) { x.m; return m; }
7005 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName(
"X")))))
7006 matches `x.m`, but not `m`; however,
7007 memberExpr(hasObjectExpression(hasType(pointsTo(
7008 cxxRecordDecl(hasName(
"X"))))))
7009 matches `m` (aka. `this-
>m`), but not `x.m`.
7013 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr
</a>></td><td class=
"name" onclick=
"toggle('callee1')"><a name=
"callee1Anchor">callee
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>> InnerMatcher
</td></tr>
7014 <tr><td colspan=
"4" class=
"doc" id=
"callee1"><pre>Matches if the call or fold expression's callee expression matches.
7017 class Y { void x() { this-
>x(); x(); Y y; y.x(); } };
7019 callExpr(callee(expr()))
7020 matches this-
>x(), x(), y.x(), f()
7022 matching this-
>x, x, y.x, f respectively
7025 template
<typename... Args
>
7026 auto sum(Args... args) {
7027 return (
0 + ... + args);
7030 template
<typename... Args
>
7031 auto multiply(Args... args) {
7032 return (args * ... *
1);
7034 cxxFoldExpr(callee(expr()))
7035 matches (args * ... *
1)
7039 Note: Callee cannot take the more general internal::Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>>
7040 because this introduces ambiguous overloads with calls to Callee taking a
7041 internal::Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>>, as the matcher hierarchy is purely
7042 implemented in terms of implicit casts.
7046 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr
</a>></td><td class=
"name" onclick=
"toggle('hasEitherOperand2')"><a name=
"hasEitherOperand2Anchor">hasEitherOperand
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7047 <tr><td colspan=
"4" class=
"doc" id=
"hasEitherOperand2"><pre>Matches if either the left hand side or the right hand side of a
7048 binary operator or fold expression matches.
7052 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr
</a>></td><td class=
"name" onclick=
"toggle('hasFoldInit0')"><a name=
"hasFoldInit0Anchor">hasFoldInit
</a></td><td>ast_matchers::Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMacher
</td></tr>
7053 <tr><td colspan=
"4" class=
"doc" id=
"hasFoldInit0"><pre>Matches the operand that does not contain the parameter pack.
7055 Example matches `(
0 + ... + args)` and `(args * ... *
1)`
7056 (matcher = cxxFoldExpr(hasFoldInit(expr())))
7057 with hasFoldInit(...)
7058 matching `
0` and `
1` respectively
7059 template
<typename... Args
>
7060 auto sum(Args... args) {
7061 return (
0 + ... + args);
7064 template
<typename... Args
>
7065 auto multiply(Args... args) {
7066 return (args * ... *
1);
7071 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr
</a>></td><td class=
"name" onclick=
"toggle('hasLHS4')"><a name=
"hasLHS4Anchor">hasLHS
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7072 <tr><td colspan=
"4" class=
"doc" id=
"hasLHS4"><pre>Matches the left hand side of binary operator expressions.
7074 Example matches a (matcher = binaryOperator(hasLHS()))
7079 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr
</a>></td><td class=
"name" onclick=
"toggle('hasOperands2')"><a name=
"hasOperands2Anchor">hasOperands
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> Matcher1, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> Matcher2
</td></tr>
7080 <tr><td colspan=
"4" class=
"doc" id=
"hasOperands2"><pre>Matches if both matchers match with opposite sides of the binary operator
7083 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(
1),
7084 integerLiteral(equals(
2)))
7092 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr
</a>></td><td class=
"name" onclick=
"toggle('hasPattern0')"><a name=
"hasPattern0Anchor">hasPattern
</a></td><td>ast_matchers::Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMacher
</td></tr>
7093 <tr><td colspan=
"4" class=
"doc" id=
"hasPattern0"><pre>Matches the operand that contains the parameter pack.
7095 Example matches `(
0 + ... + args)`
7096 (matcher = cxxFoldExpr(hasPattern(expr())))
7097 with hasPattern(...)
7099 template
<typename... Args
>
7100 auto sum(Args... args) {
7101 return (
0 + ... + args);
7104 template
<typename... Args
>
7105 auto multiply(Args... args) {
7106 return (args * ... *
1);
7111 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFoldExpr.html">CXXFoldExpr
</a>></td><td class=
"name" onclick=
"toggle('hasRHS4')"><a name=
"hasRHS4Anchor">hasRHS
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7112 <tr><td colspan=
"4" class=
"doc" id=
"hasRHS4"><pre>Matches the right hand side of binary operator expressions.
7114 Example matches b (matcher = binaryOperator(hasRHS()))
7119 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt
</a>></td><td class=
"name" onclick=
"toggle('hasBody3')"><a name=
"hasBody3Anchor">hasBody
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>> InnerMatcher
</td></tr>
7120 <tr><td colspan=
"4" class=
"doc" id=
"hasBody3"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
7121 definition that has a given body. Note that in case of functions or
7122 coroutines this matcher only matches the definition itself and not the
7123 other declarations of the same function or coroutine.
7127 forStmt(hasBody(compoundStmt()))
7128 matches 'for (;;) {}'
7135 functionDecl(hasBody(compoundStmt()))
7136 matches 'void f() {}'
7139 but does not match 'void f();'
7143 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt
</a>></td><td class=
"name" onclick=
"toggle('hasInitStatement2')"><a name=
"hasInitStatement2Anchor">hasInitStatement
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>> InnerMatcher
</td></tr>
7144 <tr><td colspan=
"4" class=
"doc" id=
"hasInitStatement2"><pre>Matches selection statements with initializer.
7148 if (int i = foobar(); i
> 0) {}
7149 switch (int i = foobar(); i) {}
7150 for (auto
& a = get_range(); auto
& x : a) {}
7153 if (foobar()
> 0) {}
7154 switch (foobar()) {}
7155 for (auto
& x : get_range()) {}
7157 ifStmt(hasInitStatement(anything()))
7158 matches the if statement in foo but not in bar.
7159 switchStmt(hasInitStatement(anything()))
7160 matches the switch statement in foo but not in bar.
7161 cxxForRangeStmt(hasInitStatement(anything()))
7162 matches the range for statement in foo but not in bar.
7166 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt
</a>></td><td class=
"name" onclick=
"toggle('hasLoopVariable0')"><a name=
"hasLoopVariable0Anchor">hasLoopVariable
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl
</a>> InnerMatcher
</td></tr>
7167 <tr><td colspan=
"4" class=
"doc" id=
"hasLoopVariable0"><pre>Matches the initialization statement of a for loop.
7170 forStmt(hasLoopVariable(anything()))
7176 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt
</a>></td><td class=
"name" onclick=
"toggle('hasRangeInit0')"><a name=
"hasRangeInit0Anchor">hasRangeInit
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7177 <tr><td colspan=
"4" class=
"doc" id=
"hasRangeInit0"><pre>Matches the range initialization statement of a for loop.
7180 forStmt(hasRangeInit(anything()))
7186 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr
</a>></td><td class=
"name" onclick=
"toggle('hasTypeLoc3')"><a name=
"hasTypeLoc3Anchor">hasTypeLoc
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>> Inner
</td></tr>
7187 <tr><td colspan=
"4" class=
"doc" id=
"hasTypeLoc3"><pre>Matches if the type location of a node matches the inner matcher.
7191 declaratorDecl(hasTypeLoc(loc(asString(
"int"))))
7195 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString(
"int"))))
7198 struct Foo { Foo(int, int); };
7200 cxxFunctionalCastExpr(hasTypeLoc(loc(asString(
"struct Foo"))))
7203 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>>,
7204 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr
</a>>,
7205 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr
</a>>,
7206 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>>,
7207 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr
</a>>,
7208 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr
</a>>,
7209 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc
</a>>,
7210 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl
</a>>
7214 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr
</a>></td><td class=
"name" onclick=
"toggle('onImplicitObjectArgument0')"><a name=
"onImplicitObjectArgument0Anchor">onImplicitObjectArgument
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7215 <tr><td colspan=
"4" class=
"doc" id=
"onImplicitObjectArgument0"><pre>Matches on the implicit object argument of a member call expression. Unlike
7216 `on`, matches the argument directly without stripping away anything.
7219 class Y { public: void m(); };
7221 class X : public Y { void g(); };
7222 void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); }
7223 cxxMemberCallExpr(onImplicitObjectArgument(hasType(
7224 cxxRecordDecl(hasName(
"Y")))))
7225 matches `y.m()`, `x.m()` and (g()).m(), but not `x.g()`.
7226 cxxMemberCallExpr(on(callExpr()))
7227 does not match `(g()).m()`, because the parens are not ignored.
7229 FIXME: Overload to allow directly matching types?
7233 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr
</a>></td><td class=
"name" onclick=
"toggle('on0')"><a name=
"on0Anchor">on
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7234 <tr><td colspan=
"4" class=
"doc" id=
"on0"><pre>Matches on the implicit object argument of a member call expression, after
7235 stripping off any parentheses or implicit casts.
7238 class Y { public: void m(); };
7240 class X : public Y {};
7241 void z(Y y, X x) { y.m(); (g()).m(); x.m(); }
7242 cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName(
"Y")))))
7243 matches `y.m()` and `(g()).m()`.
7244 cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName(
"X")))))
7246 cxxMemberCallExpr(on(callExpr()))
7247 matches `(g()).m()`.
7249 FIXME: Overload to allow directly matching types?
7253 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr
</a>></td><td class=
"name" onclick=
"toggle('thisPointerType1')"><a name=
"thisPointerType1Anchor">thisPointerType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>> InnerMatcher
</td></tr>
7254 <tr><td colspan=
"4" class=
"doc" id=
"thisPointerType1"><pre>Overloaded to match the type's declaration.
7258 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr
</a>></td><td class=
"name" onclick=
"toggle('thisPointerType0')"><a name=
"thisPointerType0Anchor">thisPointerType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType
</a>> InnerMatcher
</td></tr>
7259 <tr><td colspan=
"4" class=
"doc" id=
"thisPointerType0"><pre>Matches if the type of the expression's implicit object argument either
7260 matches the InnerMatcher, or is a pointer to a type that matches the
7264 class Y { public: void m(); };
7265 class X : public Y { void g(); };
7266 void z() { Y y; y.m(); Y *p; p-
>m(); X x; x.m(); x.g(); }
7267 cxxMemberCallExpr(thisPointerType(hasDeclaration(
7268 cxxRecordDecl(hasName(
"Y")))))
7269 matches `y.m()`, `p-
>m()` and `x.m()`.
7270 cxxMemberCallExpr(thisPointerType(hasDeclaration(
7271 cxxRecordDecl(hasName(
"X")))))
7276 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>></td><td class=
"name" onclick=
"toggle('forEachOverridden0')"><a name=
"forEachOverridden0Anchor">forEachOverridden
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>> InnerMatcher
</td></tr>
7277 <tr><td colspan=
"4" class=
"doc" id=
"forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may
7278 produce multiple matches.
7281 class A { virtual void f(); };
7282 class B : public A { void f(); };
7283 class C : public B { void f(); };
7284 cxxMethodDecl(ofClass(hasName(
"C")),
7285 forEachOverridden(cxxMethodDecl().bind(
"b"))).bind(
"d")
7286 matches once, with
"b" binding
"A::f" and
"d" binding
"C::f" (Note
7287 that B::f is not overridden by C::f).
7289 The check can produce multiple matches in case of multiple inheritance, e.g.
7290 class A1 { virtual void f(); };
7291 class A2 { virtual void f(); };
7292 class C : public A1, public A2 { void f(); };
7293 cxxMethodDecl(ofClass(hasName(
"C")),
7294 forEachOverridden(cxxMethodDecl().bind(
"b"))).bind(
"d")
7295 matches twice, once with
"b" binding
"A1::f" and
"d" binding
"C::f", and
7296 once with
"b" binding
"A2::f" and
"d" binding
"C::f".
7300 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>></td><td class=
"name" onclick=
"toggle('ofClass0')"><a name=
"ofClass0Anchor">ofClass
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>> InnerMatcher
</td></tr>
7301 <tr><td colspan=
"4" class=
"doc" id=
"ofClass0"><pre>Matches the class declaration that the given method declaration
7304 FIXME: Generalize this for other kinds of declarations.
7305 FIXME: What other kind of declarations would we need to generalize
7308 Example matches A() in the last line
7309 (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl(
7310 ofClass(hasName(
"A"))))))
7319 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr
</a>></td><td class=
"name" onclick=
"toggle('hasAnyPlacementArg0')"><a name=
"hasAnyPlacementArg0Anchor">hasAnyPlacementArg
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7320 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyPlacementArg0"><pre>Matches any placement new expression arguments.
7323 MyClass *p1 = new (Storage) MyClass();
7324 cxxNewExpr(hasAnyPlacementArg(anything()))
7325 matches the expression 'new (Storage,
16) MyClass()'.
7329 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr
</a>></td><td class=
"name" onclick=
"toggle('hasArraySize0')"><a name=
"hasArraySize0Anchor">hasArraySize
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7330 <tr><td colspan=
"4" class=
"doc" id=
"hasArraySize0"><pre>Matches array new expressions with a given array size.
7333 MyClass *p1 = new MyClass[
10];
7334 cxxNewExpr(hasArraySize(integerLiteral(equals(
10))))
7335 matches the expression 'new MyClass[
10]'.
7339 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr
</a>></td><td class=
"name" onclick=
"toggle('hasDeclaration12')"><a name=
"hasDeclaration12Anchor">hasDeclaration
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>> InnerMatcher
</td></tr>
7340 <tr><td colspan=
"4" class=
"doc" id=
"hasDeclaration12"><pre>Matches a node if the declaration associated with that node
7341 matches the given matcher.
7343 The associated declaration is:
7344 - for type nodes, the declaration of the underlying type
7345 - for CallExpr, the declaration of the callee
7346 - for MemberExpr, the declaration of the referenced member
7347 - for CXXConstructExpr, the declaration of the constructor
7348 - for CXXNewExpr, the declaration of the operator new
7349 - for ObjCIvarExpr, the declaration of the ivar
7351 For type nodes, hasDeclaration will generally match the declaration of the
7356 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7357 typedefDecl. A common use case is to match the underlying, desugared type.
7358 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7359 varDecl(hasType(hasUnqualifiedDesugaredType(
7360 recordType(hasDeclaration(decl())))))
7361 In this matcher, the decl will match the CXXRecordDecl of class X.
7363 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr
</a>>,
7364 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr
</a>>,
7365 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt
</a>>,
7366 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType
</a>>,
7367 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType
</a>>,
7368 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType
</a>>,
7369 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType
</a>>
7373 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr
</a>></td><td class=
"name" onclick=
"toggle('hasPlacementArg0')"><a name=
"hasPlacementArg0Anchor">hasPlacementArg
</a></td><td>unsigned Index, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7374 <tr><td colspan=
"4" class=
"doc" id=
"hasPlacementArg0"><pre>Matches placement new expression arguments.
7377 MyClass *p1 = new (Storage,
16) MyClass();
7378 cxxNewExpr(hasPlacementArg(
1, integerLiteral(equals(
16))))
7379 matches the expression 'new (Storage,
16) MyClass()'.
7383 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr
</a>></td><td class=
"name" onclick=
"toggle('hasTypeLoc4')"><a name=
"hasTypeLoc4Anchor">hasTypeLoc
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>> Inner
</td></tr>
7384 <tr><td colspan=
"4" class=
"doc" id=
"hasTypeLoc4"><pre>Matches if the type location of a node matches the inner matcher.
7388 declaratorDecl(hasTypeLoc(loc(asString(
"int"))))
7392 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString(
"int"))))
7395 struct Foo { Foo(int, int); };
7397 cxxFunctionalCastExpr(hasTypeLoc(loc(asString(
"struct Foo"))))
7400 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>>,
7401 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr
</a>>,
7402 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr
</a>>,
7403 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>>,
7404 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr
</a>>,
7405 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr
</a>>,
7406 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc
</a>>,
7407 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl
</a>>
7411 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr
</a>></td><td class=
"name" onclick=
"toggle('hasEitherOperand1')"><a name=
"hasEitherOperand1Anchor">hasEitherOperand
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7412 <tr><td colspan=
"4" class=
"doc" id=
"hasEitherOperand1"><pre>Matches if either the left hand side or the right hand side of a
7413 binary operator or fold expression matches.
7417 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr
</a>></td><td class=
"name" onclick=
"toggle('hasLHS1')"><a name=
"hasLHS1Anchor">hasLHS
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7418 <tr><td colspan=
"4" class=
"doc" id=
"hasLHS1"><pre>Matches the left hand side of binary operator expressions.
7420 Example matches a (matcher = binaryOperator(hasLHS()))
7425 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr
</a>></td><td class=
"name" onclick=
"toggle('hasOperands1')"><a name=
"hasOperands1Anchor">hasOperands
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> Matcher1, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> Matcher2
</td></tr>
7426 <tr><td colspan=
"4" class=
"doc" id=
"hasOperands1"><pre>Matches if both matchers match with opposite sides of the binary operator
7429 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(
1),
7430 integerLiteral(equals(
2)))
7438 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr
</a>></td><td class=
"name" onclick=
"toggle('hasRHS1')"><a name=
"hasRHS1Anchor">hasRHS
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7439 <tr><td colspan=
"4" class=
"doc" id=
"hasRHS1"><pre>Matches the right hand side of binary operator expressions.
7441 Example matches b (matcher = binaryOperator(hasRHS()))
7446 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr
</a>></td><td class=
"name" onclick=
"toggle('hasUnaryOperand1')"><a name=
"hasUnaryOperand1Anchor">hasUnaryOperand
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7447 <tr><td colspan=
"4" class=
"doc" id=
"hasUnaryOperand1"><pre>Matches if the operand of a unary operator matches.
7449 Example matches true (matcher = hasUnaryOperand(
7450 cxxBoolLiteral(equals(true))))
7455 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>></td><td class=
"name" onclick=
"toggle('hasAnyBase0')"><a name=
"hasAnyBase0Anchor">hasAnyBase
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>> BaseSpecMatcher
</td></tr>
7456 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyBase0"><pre>Matches C++ classes that have a direct or indirect base matching BaseSpecMatcher.
7459 matcher hasAnyBase(hasType(cxxRecordDecl(hasName(
"SpecialBase"))))
7464 class Proxy : SpecialBase {}; // matches Proxy
7465 class IndirectlyDerived : Proxy {}; //matches IndirectlyDerived
7467 FIXME: Refactor this and isDerivedFrom to reuse implementation.
7471 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>></td><td class=
"name" onclick=
"toggle('hasDirectBase0')"><a name=
"hasDirectBase0Anchor">hasDirectBase
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>> BaseSpecMatcher
</td></tr>
7472 <tr><td colspan=
"4" class=
"doc" id=
"hasDirectBase0"><pre>Matches C++ classes that have a direct base matching BaseSpecMatcher.
7475 matcher hasDirectBase(hasType(cxxRecordDecl(hasName(
"SpecialBase"))))
7480 class Proxy : SpecialBase {}; // matches Proxy
7481 class IndirectlyDerived : Proxy {}; // doesn't match
7485 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>></td><td class=
"name" onclick=
"toggle('hasMethod0')"><a name=
"hasMethod0Anchor">hasMethod
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl
</a>> InnerMatcher
</td></tr>
7486 <tr><td colspan=
"4" class=
"doc" id=
"hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher.
7489 class A { void func(); };
7490 class B { void member(); };
7492 cxxRecordDecl(hasMethod(hasName(
"func"))) matches the declaration of
7497 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>></td><td class=
"name" onclick=
"toggle('isDerivedFrom0')"><a name=
"isDerivedFrom0Anchor">isDerivedFrom
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl
</a>> Base
</td></tr>
7498 <tr><td colspan=
"4" class=
"doc" id=
"isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from a class
7499 matching Base, or Objective-C classes that directly or indirectly
7500 subclass a class matching Base.
7502 Note that a class is not considered to be derived from itself.
7504 Example matches Y, Z, C (Base == hasName(
"X"))
7506 class Y : public X {}; // directly derived
7507 class Z : public Y {}; // indirectly derived
7510 class C : public B {}; // derived from a typedef of X
7512 In the following example, Bar matches isDerivedFrom(hasName(
"X")):
7515 class Bar : public Foo {}; // derived from a type that X is a typedef of
7517 In the following example, Bar matches isDerivedFrom(hasName(
"NSObject"))
7518 @interface NSObject @end
7519 @interface Bar : NSObject @end
7521 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl
</a>>
7525 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>></td><td class=
"name" onclick=
"toggle('isDirectlyDerivedFrom0')"><a name=
"isDirectlyDerivedFrom0Anchor">isDirectlyDerivedFrom
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl
</a>> Base
</td></tr>
7526 <tr><td colspan=
"4" class=
"doc" id=
"isDirectlyDerivedFrom0"><pre>Matches C++ or Objective-C classes that are directly derived from a class
7529 Note that a class is not considered to be derived from itself.
7531 Example matches Y, C (Base == hasName(
"X"))
7533 class Y : public X {}; // directly derived
7534 class Z : public Y {}; // indirectly derived
7537 class C : public B {}; // derived from a typedef of X
7539 In the following example, Bar matches isDerivedFrom(hasName(
"X")):
7542 class Bar : public Foo {}; // derived from a type that X is a typedef of
7546 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl
</a>></td><td class=
"name" onclick=
"toggle('isSameOrDerivedFrom0')"><a name=
"isSameOrDerivedFrom0Anchor">isSameOrDerivedFrom
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl
</a>> Base
</td></tr>
7547 <tr><td colspan=
"4" class=
"doc" id=
"isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly
7552 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator
</a>></td><td class=
"name" onclick=
"toggle('hasEitherOperand3')"><a name=
"hasEitherOperand3Anchor">hasEitherOperand
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7553 <tr><td colspan=
"4" class=
"doc" id=
"hasEitherOperand3"><pre>Matches if either the left hand side or the right hand side of a
7554 binary operator or fold expression matches.
7558 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator
</a>></td><td class=
"name" onclick=
"toggle('hasLHS2')"><a name=
"hasLHS2Anchor">hasLHS
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7559 <tr><td colspan=
"4" class=
"doc" id=
"hasLHS2"><pre>Matches the left hand side of binary operator expressions.
7561 Example matches a (matcher = binaryOperator(hasLHS()))
7566 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator
</a>></td><td class=
"name" onclick=
"toggle('hasOperands3')"><a name=
"hasOperands3Anchor">hasOperands
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> Matcher1, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> Matcher2
</td></tr>
7567 <tr><td colspan=
"4" class=
"doc" id=
"hasOperands3"><pre>Matches if both matchers match with opposite sides of the binary operator
7570 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(
1),
7571 integerLiteral(equals(
2)))
7579 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator
</a>></td><td class=
"name" onclick=
"toggle('hasRHS2')"><a name=
"hasRHS2Anchor">hasRHS
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7580 <tr><td colspan=
"4" class=
"doc" id=
"hasRHS2"><pre>Matches the right hand side of binary operator expressions.
7582 Example matches b (matcher = binaryOperator(hasRHS()))
7587 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr
</a>></td><td class=
"name" onclick=
"toggle('hasTypeLoc5')"><a name=
"hasTypeLoc5Anchor">hasTypeLoc
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>> Inner
</td></tr>
7588 <tr><td colspan=
"4" class=
"doc" id=
"hasTypeLoc5"><pre>Matches if the type location of a node matches the inner matcher.
7592 declaratorDecl(hasTypeLoc(loc(asString(
"int"))))
7596 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString(
"int"))))
7599 struct Foo { Foo(int, int); };
7601 cxxFunctionalCastExpr(hasTypeLoc(loc(asString(
"struct Foo"))))
7604 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>>,
7605 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr
</a>>,
7606 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr
</a>>,
7607 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>>,
7608 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr
</a>>,
7609 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr
</a>>,
7610 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc
</a>>,
7611 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl
</a>>
7615 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>></td><td class=
"name" onclick=
"toggle('hasAnyArgument2')"><a name=
"hasAnyArgument2Anchor">hasAnyArgument
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7616 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call
7617 expression, or an ObjC-message-send expression.
7620 void x(int, int, int) { int y; x(
1, y,
42); }
7621 callExpr(hasAnyArgument(declRefExpr()))
7623 with hasAnyArgument(...)
7626 For ObjectiveC, given
7627 @interface I - (void) f:(int) y; @end
7628 void foo(I *i) { [i f:
12]; }
7629 objcMessageExpr(hasAnyArgument(integerLiteral(equals(
12))))
7634 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>></td><td class=
"name" onclick=
"toggle('hasArgument2')"><a name=
"hasArgument2Anchor">hasArgument
</a></td><td>unsigned N, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> InnerMatcher
</td></tr>
7635 <tr><td colspan=
"4" class=
"doc" id=
"hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor
7638 Example matches y in x(y)
7639 (matcher = callExpr(hasArgument(
0, declRefExpr())))
7640 void x(int) { int y; x(y); }
7644 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>></td><td class=
"name" onclick=
"toggle('hasTypeLoc6')"><a name=
"hasTypeLoc6Anchor">hasTypeLoc
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc
</a>> Inner
</td></tr>
7645 <tr><td colspan=
"4" class=
"doc" id=
"hasTypeLoc6"><pre>Matches if the type location of a node matches the inner matcher.
7649 declaratorDecl(hasTypeLoc(loc(asString(
"int"))))
7653 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString(
"int"))))
7656 struct Foo { Foo(int, int); };
7658 cxxFunctionalCastExpr(hasTypeLoc(loc(asString(
"struct Foo"))))
7661 Usable as: Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html">CXXBaseSpecifier
</a>>,
7662 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr
</a>>,
7663 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr
</a>>,
7664 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>>,
7665 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr
</a>>,
7666 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr
</a>>,
7667 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl
</a>>, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html">TemplateArgumentLoc
</a>>,
7668 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl
</a>>
7672 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr
</a>></td><td class=
"name" onclick=
"toggle('callee3')"><a name=
"callee3Anchor">callee
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>> InnerMatcher
</td></tr>
7673 <tr><td colspan=
"4" class=
"doc" id=
"callee3"><pre>Matches
1) if the call expression's callee's declaration matches the
7674 given matcher; or
2) if the Obj-C message expression's callee's method
7675 declaration matches the given matcher.
7677 Example matches y.x() (matcher = callExpr(callee(
7678 cxxMethodDecl(hasName(
"x")))))
7679 class Y { public: void x(); };
7680 void z() { Y y; y.x(); }
7682 Example
2. Matches [I foo] with
7683 objcMessageExpr(callee(objcMethodDecl(hasName(
"foo"))))
7685 @interface I: NSObject
7693 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr
</a>></td><td class=
"name" onclick=
"toggle('callee0')"><a name=
"callee0Anchor">callee
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt
</a>> InnerMatcher
</td></tr>
7694 <tr><td colspan=
"4" class=
"doc" id=
"callee0"><pre>Matches if the call or fold expression's callee expression matches.
7697 class Y { void x() { this-
>x(); x(); Y y; y.x(); } };
7699 callExpr(callee(expr()))
7700 matches this-
>x(), x(), y.x(), f()
7702 matching this-
>x, x, y.x, f respectively
7705 template
<typename... Args
>
7706 auto sum(Args... args) {
7707 return (
0 + ... + args);
7710 template
<typename... Args
>
7711 auto multiply(Args... args) {
7712 return (args * ... *
1);
7714 cxxFoldExpr(callee(expr()))
7715 matches (args * ... *
1)
7719 Note: Callee cannot take the more general internal::Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>>
7720 because this introduces ambiguous overloads with calls to Callee taking a
7721 internal::Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>>, as the matcher hierarchy is purely
7722 implemented in terms of implicit casts.
7726 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr
</a>></td><td class=
"name" onclick=
"toggle('forEachArgumentWithParam0')"><a name=
"forEachArgumentWithParam0Anchor">forEachArgumentWithParam
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> ArgMatcher, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl
</a>> ParamMatcher
</td></tr>
7727 <tr><td colspan=
"4" class=
"doc" id=
"forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl.
7734 forEachArgumentWithParam(
7735 declRefExpr(to(varDecl(hasName(
"y")))),
7736 parmVarDecl(hasType(isInteger()))
7739 with declRefExpr(...)
7741 and parmVarDecl(...)
7746 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr
</a>></td><td class=
"name" onclick=
"toggle('forEachArgumentWithParamType0')"><a name=
"forEachArgumentWithParamType0Anchor">forEachArgumentWithParamType
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>> ArgMatcher, Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType
</a>> ParamMatcher
</td></tr>
7747 <tr><td colspan=
"4" class=
"doc" id=
"forEachArgumentWithParamType0"><pre>Matches all arguments and their respective types for a CallExpr or
7748 CXXConstructExpr. It is very similar to forEachArgumentWithParam but
7749 it works on calls through function pointers as well.
7751 The difference is, that function pointers do not provide access to a
7752 ParmVarDecl, but only the QualType for each argument.
7758 void (*f_ptr)(int) = f;
7761 forEachArgumentWithParamType(
7762 declRefExpr(to(varDecl(hasName(
"y")))),
7763 qualType(isInteger()).bind(
"type)
7765 matches f(y) and f_ptr(y)
7766 with declRefExpr(...)
7773 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>></td><td class="name
" onclick="toggle('hasAnyArgument0')
"><a name="hasAnyArgument0Anchor
">hasAnyArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
7774 <tr><td colspan="4" class="doc
" id="hasAnyArgument0
"><pre>Matches any argument of a call expression or a constructor call
7775 expression, or an ObjC-message-send expression.
7778 void x(int, int, int) { int y; x(1, y, 42); }
7779 callExpr(hasAnyArgument(declRefExpr()))
7781 with hasAnyArgument(...)
7784 For ObjectiveC, given
7785 @interface I - (void) f:(int) y; @end
7786 void foo(I *i) { [i f:12]; }
7787 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
7792 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>></td><td class="name
" onclick="toggle('hasArgument0')
"><a name="hasArgument0Anchor
">hasArgument</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
7793 <tr><td colspan="4" class="doc
" id="hasArgument0
"><pre>Matches the n'th argument of a call expression or a constructor
7796 Example matches y in x(y)
7797 (matcher = callExpr(hasArgument(0, declRefExpr())))
7798 void x(int) { int y; x(y); }
7802 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>></td><td class="name
" onclick="toggle('hasDeclaration14')
"><a name="hasDeclaration14Anchor
">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
7803 <tr><td colspan="4" class="doc
" id="hasDeclaration14
"><pre>Matches a node if the declaration associated with that node
7804 matches the given matcher.
7806 The associated declaration is:
7807 - for type nodes, the declaration of the underlying type
7808 - for CallExpr, the declaration of the callee
7809 - for MemberExpr, the declaration of the referenced member
7810 - for CXXConstructExpr, the declaration of the constructor
7811 - for CXXNewExpr, the declaration of the operator new
7812 - for ObjCIvarExpr, the declaration of the ivar
7814 For type nodes, hasDeclaration will generally match the declaration of the
7819 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7820 typedefDecl. A common use case is to match the underlying, desugared type.
7821 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7822 varDecl(hasType(hasUnqualifiedDesugaredType(
7823 recordType(hasDeclaration(decl())))))
7824 In this matcher, the decl will match the CXXRecordDecl of class X.
7826 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>>,
7827 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>,
7828 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>>,
7829 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>>,
7830 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>>,
7831 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>>,
7832 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
7836 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html
">CaseStmt</a>></td><td class="name
" onclick="toggle('hasCaseConstant0')
"><a name="hasCaseConstant0Anchor
">hasCaseConstant</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
7837 <tr><td colspan="4" class="doc
" id="hasCaseConstant0
"><pre>If the given case statement does not use the GNU case range
7838 extension, matches the constant given in the statement.
7841 switch (1) { case 1: case 1+1: case 3 ... 4: ; }
7842 caseStmt(hasCaseConstant(integerLiteral()))
7847 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CastExpr.html
">CastExpr</a>></td><td class="name
" onclick="toggle('hasSourceExpression0')
"><a name="hasSourceExpression0Anchor
">hasSourceExpression</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
7848 <tr><td colspan="4" class="doc
" id="hasSourceExpression0
"><pre>Matches if the cast's source expression
7849 or opaque value's source expression matches the given matcher.
7851 Example 1: matches "a string
"
7852 (matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
7853 class URL { URL(string); };
7854 URL url = "a string
";
7856 Example 2: matches 'b' (matcher =
7857 opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
7862 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html
">ClassTemplateSpecializationDecl</a>></td><td class="name
" onclick="toggle('forEachTemplateArgument0')
"><a name="forEachTemplateArgument0Anchor
">forEachTemplateArgument</a></td><td>clang::ast_matchers::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>> InnerMatcher</td></tr>
7863 <tr><td colspan="4" class="doc
" id="forEachTemplateArgument0
"><pre>Matches classTemplateSpecialization, templateSpecializationType and
7864 functionDecl nodes where the template argument matches the inner matcher.
7865 This matcher may produce multiple matches.
7868 template <typename T, unsigned N, unsigned M>
7871 constexpr unsigned R = 2;
7872 Matrix<int, R * 2, R * 4> M;
7874 template <typename T, typename U>
7875 void f(T&& t, U&& u) {}
7879 templateSpecializationType(forEachTemplateArgument(isExpr(expr())))
7880 matches twice, with expr() matching 'R * 2' and 'R * 4'
7881 functionDecl(forEachTemplateArgument(refersToType(builtinType())))
7882 matches the specialization f<unsigned, bool> twice, for 'unsigned'
7887 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html
">ClassTemplateSpecializationDecl</a>></td><td class="name
" onclick="toggle('hasAnyTemplateArgument0')
"><a name="hasAnyTemplateArgument0Anchor
">hasAnyTemplateArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>> InnerMatcher</td></tr>
7888 <tr><td colspan="4" class="doc
" id="hasAnyTemplateArgument0
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
7889 functionDecl that have at least one TemplateArgument matching the given
7893 template<typename T> class A {};
7894 template<> class A<double> {};
7897 template<typename T> f() {};
7898 void func() { f<int>(); };
7900 classTemplateSpecializationDecl(hasAnyTemplateArgument(
7901 refersToType(asString("int
"))))
7902 matches the specialization A<int>
7904 functionDecl(hasAnyTemplateArgument(refersToType(asString("int
"))))
7905 matches the specialization f<int>
7909 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html
">ClassTemplateSpecializationDecl</a>></td><td class="name
" onclick="toggle('hasSpecializedTemplate0')
"><a name="hasSpecializedTemplate0Anchor
">hasSpecializedTemplate</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html
">ClassTemplateDecl</a>> InnerMatcher</td></tr>
7910 <tr><td colspan="4" class="doc
" id="hasSpecializedTemplate0
"><pre>Matches the specialized template of a specialization declaration.
7913 template<typename T> class A {}; #1
7914 template<> class A<int> {}; #2
7915 classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl()))
7916 matches '#2' with classTemplateDecl() matching the class template
7917 declaration of 'A' at #1.
7921 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html
">ClassTemplateSpecializationDecl</a>></td><td class="name
" onclick="toggle('hasTemplateArgument0')
"><a name="hasTemplateArgument0Anchor
">hasTemplateArgument</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>> InnerMatcher</td></tr>
7922 <tr><td colspan="4" class="doc
" id="hasTemplateArgument0
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
7923 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
7926 template<typename T, typename U> class A {};
7927 A<bool, int> b;
7928 A<int, bool> c;
7930 template<typename T> void f() {}
7931 void func() { f<int>(); };
7932 classTemplateSpecializationDecl(hasTemplateArgument(
7933 1, refersToType(asString("int
"))))
7934 matches the specialization A<bool, int>
7936 functionDecl(hasTemplateArgument(0, refersToType(asString("int
"))))
7937 matches the specialization f<int>
7941 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html
">ClassTemplateSpecializationDecl</a>></td><td class="name
" onclick="toggle('hasTypeLoc7')
"><a name="hasTypeLoc7Anchor
">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> Inner</td></tr>
7942 <tr><td colspan="4" class="doc
" id="hasTypeLoc7
"><pre>Matches if the type location of a node matches the inner matcher.
7946 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
7950 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
7953 struct Foo { Foo(int, int); };
7955 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
7958 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html
">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>,
7959 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html
">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html
">CXXFunctionalCastExpr</a>>,
7960 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html
">CXXTemporaryObjectExpr</a>>,
7961 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
7962 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html
">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html
">CompoundLiteralExpr</a>>,
7963 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html
">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html
">ExplicitCastExpr</a>>,
7964 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html
">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html
">TemplateArgumentLoc</a>>,
7965 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
7969 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ComplexType.html
">ComplexType</a>></td><td class="name
" onclick="toggle('hasElementType1')
"><a name="hasElementType1Anchor
">hasElementType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td></tr>
7970 <tr><td colspan="4" class="doc
" id="hasElementType1
"><pre>Matches arrays and C99 complex types that have a specific element
7977 arrayType(hasElementType(builtinType()))
7980 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArrayType.html
">ArrayType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ComplexType.html
">ComplexType</a>>
7984 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html
">CompoundLiteralExpr</a>></td><td class="name
" onclick="toggle('hasTypeLoc8')
"><a name="hasTypeLoc8Anchor
">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> Inner</td></tr>
7985 <tr><td colspan="4" class="doc
" id="hasTypeLoc8
"><pre>Matches if the type location of a node matches the inner matcher.
7989 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
7993 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
7996 struct Foo { Foo(int, int); };
7998 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
8001 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html
">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>,
8002 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html
">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html
">CXXFunctionalCastExpr</a>>,
8003 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html
">CXXTemporaryObjectExpr</a>>,
8004 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
8005 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html
">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html
">CompoundLiteralExpr</a>>,
8006 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html
">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html
">ExplicitCastExpr</a>>,
8007 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html
">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html
">TemplateArgumentLoc</a>>,
8008 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
8012 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html
">CompoundStmt</a>></td><td class="name
" onclick="toggle('hasAnySubstatement0')
"><a name="hasAnySubstatement0Anchor
">hasAnySubstatement</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
8013 <tr><td colspan="4" class="doc
" id="hasAnySubstatement0
"><pre>Matches compound statements where at least one substatement matches
8014 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
8018 hasAnySubstatement(compoundStmt())
8019 matches '{ {}; 1+2; }'
8025 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CoroutineBodyStmt.html
">CoroutineBodyStmt</a>></td><td class="name
" onclick="toggle('hasBody5')
"><a name="hasBody5Anchor
">hasBody</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
8026 <tr><td colspan="4" class="doc
" id="hasBody5
"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
8027 definition that has a given body. Note that in case of functions or
8028 coroutines this matcher only matches the definition itself and not the
8029 other declarations of the same function or coroutine.
8033 forStmt(hasBody(compoundStmt()))
8034 matches 'for (;;) {}'
8041 functionDecl(hasBody(compoundStmt()))
8042 matches 'void f() {}'
8045 but does not match 'void f();'
8049 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecayedType.html
">DecayedType</a>></td><td class="name
" onclick="toggle('hasDecayedType0')
"><a name="hasDecayedType0Anchor
">hasDecayedType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerType</td></tr>
8050 <tr><td colspan="4" class="doc
" id="hasDecayedType0
"><pre>Matches the decayed type, whoes decayed type matches InnerMatcher
8054 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>></td><td class="name
" onclick="toggle('hasDeclaration11')
"><a name="hasDeclaration11Anchor
">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
8055 <tr><td colspan="4" class="doc
" id="hasDeclaration11
"><pre>Matches a node if the declaration associated with that node
8056 matches the given matcher.
8058 The associated declaration is:
8059 - for type nodes, the declaration of the underlying type
8060 - for CallExpr, the declaration of the callee
8061 - for MemberExpr, the declaration of the referenced member
8062 - for CXXConstructExpr, the declaration of the constructor
8063 - for CXXNewExpr, the declaration of the operator new
8064 - for ObjCIvarExpr, the declaration of the ivar
8066 For type nodes, hasDeclaration will generally match the declaration of the
8071 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8072 typedefDecl. A common use case is to match the underlying, desugared type.
8073 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8074 varDecl(hasType(hasUnqualifiedDesugaredType(
8075 recordType(hasDeclaration(decl())))))
8076 In this matcher, the decl will match the CXXRecordDecl of class X.
8078 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>>,
8079 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>,
8080 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>>,
8081 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>>,
8082 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>>,
8083 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>>,
8084 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
8088 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>></td><td class="name
" onclick="toggle('hasTemplateArgumentLoc0')
"><a name="hasTemplateArgumentLoc0Anchor
">hasTemplateArgumentLoc</a></td><td>unsigned Index, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html
">TemplateArgumentLoc</a>> InnerMatcher</td></tr>
8089 <tr><td colspan="4" class="doc
" id="hasTemplateArgumentLoc0
"><pre>Matches template specialization `TypeLoc`s where the n'th
8090 `TemplateArgumentLoc` matches the given `InnerMatcher`.
8093 template<typename T, typename U> class A {};
8094 A<double, int> b;
8095 A<int, double> c;
8096 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
8097 hasTypeLoc(loc(asString("double
")))))))
8098 matches `A<double, int> b`, but not `A<int, double> c`.
8102 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>></td><td class="name
" onclick="toggle('throughUsingDecl0')
"><a name="throughUsingDecl0Anchor
">throughUsingDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html
">UsingShadowDecl</a>> Inner</td></tr>
8103 <tr><td colspan="4" class="doc
" id="throughUsingDecl0
"><pre>Matches if a node refers to a declaration through a specific
8104 using shadow declaration.
8107 namespace a { int f(); }
8110 declRefExpr(throughUsingDecl(anything()))
8113 namespace a { class X{}; }
8116 typeLoc(loc(usingType(throughUsingDecl(anything()))))
8119 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html
">UsingType</a>>
8123 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>></td><td class="name
" onclick="toggle('to0')
"><a name="to0Anchor
">to</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
8124 <tr><td colspan="4" class="doc
" id="to0
"><pre>Matches a DeclRefExpr that refers to a declaration that matches the
8127 Example matches x in if(x)
8128 (matcher = declRefExpr(to(varDecl(hasName("x
")))))
8134 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html
">DeclStmt</a>></td><td class="name
" onclick="toggle('containsDeclaration0')
"><a name="containsDeclaration0Anchor
">containsDeclaration</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
8135 <tr><td colspan="4" class="doc
" id="containsDeclaration0
"><pre>Matches the n'th declaration of a declaration statement.
8137 Note that this does not work for global declarations because the AST
8138 breaks up multiple-declaration DeclStmt's into multiple single-declaration
8140 Example: Given non-global declarations
8144 declStmt(containsDeclaration(
8145 0, varDecl(hasInitializer(anything()))))
8146 matches only 'int d = 2, e;', and
8147 declStmt(containsDeclaration(1, varDecl()))
8148 matches 'int a, b = 0' as well as 'int d = 2, e;'
8149 but 'int c;' is not matched.
8153 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html
">DeclStmt</a>></td><td class="name
" onclick="toggle('hasSingleDecl0')
"><a name="hasSingleDecl0Anchor
">hasSingleDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
8154 <tr><td colspan="4" class="doc
" id="hasSingleDecl0
"><pre>Matches the Decl of a DeclStmt which has a single declaration.
8159 declStmt(hasSingleDecl(anything()))
8160 matches 'int c;' but not 'int a, b;'.
8164 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html
">DeclaratorDecl</a>></td><td class="name
" onclick="toggle('hasTypeLoc9')
"><a name="hasTypeLoc9Anchor
">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> Inner</td></tr>
8165 <tr><td colspan="4" class="doc
" id="hasTypeLoc9
"><pre>Matches if the type location of a node matches the inner matcher.
8169 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
8173 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
8176 struct Foo { Foo(int, int); };
8178 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
8181 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html
">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>,
8182 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html
">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html
">CXXFunctionalCastExpr</a>>,
8183 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html
">CXXTemporaryObjectExpr</a>>,
8184 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
8185 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html
">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html
">CompoundLiteralExpr</a>>,
8186 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html
">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html
">ExplicitCastExpr</a>>,
8187 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html
">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html
">TemplateArgumentLoc</a>>,
8188 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
8192 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>></td><td class="name
" onclick="toggle('hasDeclContext0')
"><a name="hasDeclContext0Anchor
">hasDeclContext</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
8193 <tr><td colspan="4" class="doc
" id="hasDeclContext0
"><pre>Matches declarations whose declaration context, interpreted as a
8194 Decl, matches InnerMatcher.
8203 cxxRcordDecl(hasDeclContext(namedDecl(hasName("M
")))) matches the
8204 declaration of class D.
8208 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html
">DecltypeType</a>></td><td class="name
" onclick="toggle('hasUnderlyingType0')
"><a name="hasUnderlyingType0Anchor
">hasUnderlyingType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td></tr>
8209 <tr><td colspan="4" class="doc
" id="hasUnderlyingType0
"><pre>Matches DecltypeType or UsingType nodes to find the underlying type.
8213 decltype(2.0) b = 2.0;
8214 decltypeType(hasUnderlyingType(isInteger()))
8215 matches the type of "a
"
8217 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html
">DecltypeType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html
">UsingType</a>>
8221 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecompositionDecl.html
">DecompositionDecl</a>></td><td class="name
" onclick="toggle('hasAnyBinding0')
"><a name="hasAnyBinding0Anchor
">hasAnyBinding</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BindingDecl.html
">BindingDecl</a>> InnerMatcher</td></tr>
8222 <tr><td colspan="4" class="doc
" id="hasAnyBinding0
"><pre>Matches any binding of a DecompositionDecl.
8228 auto &[f, s, t] = arr;
8233 decompositionDecl(hasAnyBinding(bindingDecl(hasName("f
").bind("fBinding
"))))
8234 matches the decomposition decl with 'f' bound to "fBinding
".
8238 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecompositionDecl.html
">DecompositionDecl</a>></td><td class="name
" onclick="toggle('hasBinding0')
"><a name="hasBinding0Anchor
">hasBinding</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BindingDecl.html
">BindingDecl</a>> InnerMatcher</td></tr>
8239 <tr><td colspan="4" class="doc
" id="hasBinding0
"><pre>Matches the Nth binding of a DecompositionDecl.
8245 auto &[f, s, t] = arr;
8250 decompositionDecl(hasBinding(0,
8251 bindingDecl(hasName("f
").bind("fBinding
"))))
8252 matches the decomposition decl with 'f' bound to "fBinding
".
8256 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DoStmt.html
">DoStmt</a>></td><td class="name
" onclick="toggle('hasBody0')
"><a name="hasBody0Anchor
">hasBody</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
8257 <tr><td colspan="4" class="doc
" id="hasBody0
"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
8258 definition that has a given body. Note that in case of functions or
8259 coroutines this matcher only matches the definition itself and not the
8260 other declarations of the same function or coroutine.
8264 forStmt(hasBody(compoundStmt()))
8265 matches 'for (;;) {}'
8272 functionDecl(hasBody(compoundStmt()))
8273 matches 'void f() {}'
8276 but does not match 'void f();'
8280 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DoStmt.html
">DoStmt</a>></td><td class="name
" onclick="toggle('hasCondition3')
"><a name="hasCondition3Anchor
">hasCondition</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
8281 <tr><td colspan="4" class="doc
" id="hasCondition3
"><pre>Matches the condition expression of an if statement, for loop,
8282 switch statement or conditional operator.
8284 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8289 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ElaboratedTypeLoc.html
">ElaboratedTypeLoc</a>></td><td class="name
" onclick="toggle('hasNamedTypeLoc0')
"><a name="hasNamedTypeLoc0Anchor
">hasNamedTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> InnerMatcher</td></tr>
8290 <tr><td colspan="4" class="doc
" id="hasNamedTypeLoc0
"><pre>Matches elaborated `TypeLoc`s that have a named `TypeLoc` matching
8294 template <typename T>
8296 class C<int> c;
8300 elaboratedTypeLoc(hasNamedTypeLoc(templateSpecializationTypeLoc()));
8301 matches the `TypeLoc` of the variable declaration of `c`, but not `d`.
8305 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html
">ElaboratedType</a>></td><td class="name
" onclick="toggle('hasQualifier0')
"><a name="hasQualifier0Anchor
">hasQualifier</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html
">NestedNameSpecifier</a>> InnerMatcher</td></tr>
8306 <tr><td colspan="4" class="doc
" id="hasQualifier0
"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
8307 matches InnerMatcher if the qualifier exists.
8317 elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N
"))))
8318 matches the type of the variable declaration of d.
8322 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html
">ElaboratedType</a>></td><td class="name
" onclick="toggle('namesType0')
"><a name="namesType0Anchor
">namesType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
8323 <tr><td colspan="4" class="doc
" id="namesType0
"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher.
8333 elaboratedType(namesType(recordType(
8334 hasDeclaration(namedDecl(hasName("D
")))))) matches the type of the variable
8339 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>></td><td class="name
" onclick="toggle('hasDeclaration10')
"><a name="hasDeclaration10Anchor
">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
8340 <tr><td colspan="4" class="doc
" id="hasDeclaration10
"><pre>Matches a node if the declaration associated with that node
8341 matches the given matcher.
8343 The associated declaration is:
8344 - for type nodes, the declaration of the underlying type
8345 - for CallExpr, the declaration of the callee
8346 - for MemberExpr, the declaration of the referenced member
8347 - for CXXConstructExpr, the declaration of the constructor
8348 - for CXXNewExpr, the declaration of the operator new
8349 - for ObjCIvarExpr, the declaration of the ivar
8351 For type nodes, hasDeclaration will generally match the declaration of the
8356 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8357 typedefDecl. A common use case is to match the underlying, desugared type.
8358 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8359 varDecl(hasType(hasUnqualifiedDesugaredType(
8360 recordType(hasDeclaration(decl())))))
8361 In this matcher, the decl will match the CXXRecordDecl of class X.
8363 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>>,
8364 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>,
8365 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>>,
8366 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>>,
8367 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>>,
8368 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>>,
8369 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
8373 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html
">ExplicitCastExpr</a>></td><td class="name
" onclick="toggle('hasDestinationType0')
"><a name="hasDestinationType0Anchor
">hasDestinationType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
8374 <tr><td colspan="4" class="doc
" id="hasDestinationType0
"><pre>Matches casts whose destination type matches a given matcher.
8376 (Note: Clang's AST refers to other conversions as "casts
" too, and calls
8377 actual casts "explicit
" casts.)
8381 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html
">ExplicitCastExpr</a>></td><td class="name
" onclick="toggle('hasTypeLoc10')
"><a name="hasTypeLoc10Anchor
">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> Inner</td></tr>
8382 <tr><td colspan="4" class="doc
" id="hasTypeLoc10
"><pre>Matches if the type location of a node matches the inner matcher.
8386 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
8390 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
8393 struct Foo { Foo(int, int); };
8395 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
8398 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html
">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>,
8399 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html
">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html
">CXXFunctionalCastExpr</a>>,
8400 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html
">CXXTemporaryObjectExpr</a>>,
8401 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
8402 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html
">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html
">CompoundLiteralExpr</a>>,
8403 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html
">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html
">ExplicitCastExpr</a>>,
8404 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html
">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html
">TemplateArgumentLoc</a>>,
8405 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
8409 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>></td><td class="name
" onclick="toggle('hasType5')
"><a name="hasType5Anchor
">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
8410 <tr><td colspan="4" class="doc
" id="hasType5
"><pre>Overloaded to match the declaration of the expression's or value
8413 In case of a value declaration (for example a variable declaration),
8414 this resolves one layer of indirection. For example, in the value
8415 declaration "X x;
", cxxRecordDecl(hasName("X
")) matches the declaration of
8416 X, while varDecl(hasType(cxxRecordDecl(hasName("X
")))) matches the
8419 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
8420 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
8421 and friend class X (matcher = friendDecl(hasType("X
"))
8422 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8423 cxxRecordDecl(hasName("X
"))))
8425 void y(X &x) { x; X z; }
8426 class Y { friend class X; };
8427 class Z : public virtual X {};
8429 Example matches class Derived
8430 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base
"))))))
8432 class Derived : Base {};
8434 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html
">FriendDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html
">ValueDecl</a>>,
8435 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>
8439 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>></td><td class="name
" onclick="toggle('hasType0')
"><a name="hasType0Anchor
">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
8440 <tr><td colspan="4" class="doc
" id="hasType0
"><pre>Matches if the expression's or declaration's type matches a type
8443 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
8444 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
8445 and U (matcher = typedefDecl(hasType(asString("int
")))
8446 and friend class X (matcher = friendDecl(hasType("X
"))
8447 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8448 asString("class X
")))
8450 void y(X &x) { x; X z; }
8452 class Y { friend class X; };
8453 class Z : public virtual X {};
8457 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>></td><td class="name
" onclick="toggle('ignoringElidableConstructorCall0')
"><a name="ignoringElidableConstructorCall0Anchor
">ignoringElidableConstructorCall</a></td><td>ast_matchers::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
8458 <tr><td colspan="4" class="doc
" id="ignoringElidableConstructorCall0
"><pre>Matches expressions that match InnerMatcher that are possibly wrapped in an
8459 elidable constructor and other corresponding bookkeeping nodes.
8461 In C++17, elidable copy constructors are no longer being generated in the
8462 AST as it is not permitted by the standard. They are, however, part of the
8463 AST in C++14 and earlier. So, a matcher must abstract over these differences
8464 to work in all language modes. This matcher skips elidable constructor-call
8465 AST nodes, `ExprWithCleanups` nodes wrapping elidable constructor-calls and
8466 various implicit nodes inside the constructor calls, all of which will not
8467 appear in the C++17 AST.
8477 ``varDecl(hasInitializer(ignoringElidableConstructorCall(callExpr())))``
8478 matches ``H D = G()`` in C++11 through C++17 (and beyond).
8482 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>></td><td class="name
" onclick="toggle('ignoringImpCasts0')
"><a name="ignoringImpCasts0Anchor
">ignoringImpCasts</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
8483 <tr><td colspan="4" class="doc
" id="ignoringImpCasts0
"><pre>Matches expressions that match InnerMatcher after any implicit casts
8486 Parentheses and explicit casts are not discarded.
8495 varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
8496 varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
8497 would match the declarations for a, b, c, and d, but not e.
8499 varDecl(hasInitializer(integerLiteral()))
8500 varDecl(hasInitializer(declRefExpr()))
8501 only match the declarations for a.
8505 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>></td><td class="name
" onclick="toggle('ignoringImplicit0')
"><a name="ignoringImplicit0Anchor
">ignoringImplicit</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
8506 <tr><td colspan="4" class="doc
" id="ignoringImplicit0
"><pre>Matches expressions that match InnerMatcher after any implicit AST
8507 nodes are stripped off.
8509 Parentheses and explicit casts are not discarded.
8516 varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr())))
8517 would match the declarations for a, b, and c.
8519 varDecl(hasInitializer(cxxConstructExpr()))
8520 only match the declarations for b and c.
8524 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>></td><td class="name
" onclick="toggle('ignoringParenCasts0')
"><a name="ignoringParenCasts0Anchor
">ignoringParenCasts</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
8525 <tr><td colspan="4" class="doc
" id="ignoringParenCasts0
"><pre>Matches expressions that match InnerMatcher after parentheses and
8526 casts are stripped off.
8528 Implicit and non-C Style casts are also discarded.
8532 void* c = reinterpret_cast<char*>(0);
8535 varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
8536 would match the declarations for a, b, c, and d.
8538 varDecl(hasInitializer(integerLiteral()))
8539 only match the declaration for a.
8543 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>></td><td class="name
" onclick="toggle('ignoringParenImpCasts0')
"><a name="ignoringParenImpCasts0Anchor
">ignoringParenImpCasts</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
8544 <tr><td colspan="4" class="doc
" id="ignoringParenImpCasts0
"><pre>Matches expressions that match InnerMatcher after implicit casts and
8545 parentheses are stripped off.
8547 Explicit casts are not discarded.
8554 long e = ((long) 0l);
8556 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
8557 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
8558 would match the declarations for a, b, c, and d, but not e.
8560 varDecl(hasInitializer(integerLiteral()))
8561 varDecl(hasInitializer(declRefExpr()))
8562 would only match the declaration for a.
8566 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>></td><td class="name
" onclick="toggle('ignoringParens1')
"><a name="ignoringParens1Anchor
">ignoringParens</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
8567 <tr><td colspan="4" class="doc
" id="ignoringParens1
"><pre>Overload ignoringParens for Expr.
8570 const char* str = ("my-string
");
8572 implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral())))
8573 would match the implicit cast resulting from the assignment.
8577 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html
">FieldDecl</a>></td><td class="name
" onclick="toggle('hasInClassInitializer0')
"><a name="hasInClassInitializer0Anchor
">hasInClassInitializer</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
8578 <tr><td colspan="4" class="doc
" id="hasInClassInitializer0
"><pre>Matches non-static data members that have an in-class initializer.
8586 fieldDecl(hasInClassInitializer(integerLiteral(equals(2))))
8587 matches 'int a;' but not 'int b;'.
8588 fieldDecl(hasInClassInitializer(anything()))
8589 matches 'int a;' and 'int b;' but not 'int c;'.
8593 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ForStmt.html
">ForStmt</a>></td><td class="name
" onclick="toggle('hasBody1')
"><a name="hasBody1Anchor
">hasBody</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
8594 <tr><td colspan="4" class="doc
" id="hasBody1
"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
8595 definition that has a given body. Note that in case of functions or
8596 coroutines this matcher only matches the definition itself and not the
8597 other declarations of the same function or coroutine.
8601 forStmt(hasBody(compoundStmt()))
8602 matches 'for (;;) {}'
8609 functionDecl(hasBody(compoundStmt()))
8610 matches 'void f() {}'
8613 but does not match 'void f();'
8617 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ForStmt.html
">ForStmt</a>></td><td class="name
" onclick="toggle('hasCondition1')
"><a name="hasCondition1Anchor
">hasCondition</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
8618 <tr><td colspan="4" class="doc
" id="hasCondition1
"><pre>Matches the condition expression of an if statement, for loop,
8619 switch statement or conditional operator.
8621 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8626 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ForStmt.html
">ForStmt</a>></td><td class="name
" onclick="toggle('hasIncrement0')
"><a name="hasIncrement0Anchor
">hasIncrement</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
8627 <tr><td colspan="4" class="doc
" id="hasIncrement0
"><pre>Matches the increment statement of a for loop.
8630 forStmt(hasIncrement(unaryOperator(hasOperatorName("++
"))))
8632 for (x; x < N; ++x) { }
8636 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ForStmt.html
">ForStmt</a>></td><td class="name
" onclick="toggle('hasLoopInit0')
"><a name="hasLoopInit0Anchor
">hasLoopInit</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
8637 <tr><td colspan="4" class="doc
" id="hasLoopInit0
"><pre>Matches the initialization statement of a for loop.
8640 forStmt(hasLoopInit(declStmt()))
8641 matches 'int x = 0' in
8642 for (int x = 0; x < N; ++x) { }
8646 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html
">FriendDecl</a>></td><td class="name
" onclick="toggle('hasType6')
"><a name="hasType6Anchor
">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
8647 <tr><td colspan="4" class="doc
" id="hasType6
"><pre>Overloaded to match the declaration of the expression's or value
8650 In case of a value declaration (for example a variable declaration),
8651 this resolves one layer of indirection. For example, in the value
8652 declaration "X x;
", cxxRecordDecl(hasName("X
")) matches the declaration of
8653 X, while varDecl(hasType(cxxRecordDecl(hasName("X
")))) matches the
8656 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
8657 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
8658 and friend class X (matcher = friendDecl(hasType("X
"))
8659 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8660 cxxRecordDecl(hasName("X
"))))
8662 void y(X &x) { x; X z; }
8663 class Y { friend class X; };
8664 class Z : public virtual X {};
8666 Example matches class Derived
8667 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base
"))))))
8669 class Derived : Base {};
8671 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html
">FriendDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html
">ValueDecl</a>>,
8672 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>
8676 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html
">FriendDecl</a>></td><td class="name
" onclick="toggle('hasType1')
"><a name="hasType1Anchor
">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
8677 <tr><td colspan="4" class="doc
" id="hasType1
"><pre>Matches if the expression's or declaration's type matches a type
8680 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
8681 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
8682 and U (matcher = typedefDecl(hasType(asString("int
")))
8683 and friend class X (matcher = friendDecl(hasType("X
"))
8684 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8685 asString("class X
")))
8687 void y(X &x) { x; X z; }
8689 class Y { friend class X; };
8690 class Z : public virtual X {};
8694 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>></td><td class="name
" onclick="toggle('forEachTemplateArgument2')
"><a name="forEachTemplateArgument2Anchor
">forEachTemplateArgument</a></td><td>clang::ast_matchers::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>> InnerMatcher</td></tr>
8695 <tr><td colspan="4" class="doc
" id="forEachTemplateArgument2
"><pre>Matches classTemplateSpecialization, templateSpecializationType and
8696 functionDecl nodes where the template argument matches the inner matcher.
8697 This matcher may produce multiple matches.
8700 template <typename T, unsigned N, unsigned M>
8703 constexpr unsigned R = 2;
8704 Matrix<int, R * 2, R * 4> M;
8706 template <typename T, typename U>
8707 void f(T&& t, U&& u) {}
8711 templateSpecializationType(forEachTemplateArgument(isExpr(expr())))
8712 matches twice, with expr() matching 'R * 2' and 'R * 4'
8713 functionDecl(forEachTemplateArgument(refersToType(builtinType())))
8714 matches the specialization f<unsigned, bool> twice, for 'unsigned'
8719 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>></td><td class="name
" onclick="toggle('hasAnyBody0')
"><a name="hasAnyBody0Anchor
">hasAnyBody</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
8720 <tr><td colspan="4" class="doc
" id="hasAnyBody0
"><pre>Matches a function declaration that has a given body present in the AST.
8721 Note that this matcher matches all the declarations of a function whose
8722 body is present in the AST.
8728 functionDecl(hasAnyBody(compoundStmt()))
8729 matches both 'void f();'
8733 but does not match 'void g();'
8737 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>></td><td class="name
" onclick="toggle('hasAnyParameter0')
"><a name="hasAnyParameter0Anchor
">hasAnyParameter</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html
">ParmVarDecl</a>> InnerMatcher</td></tr>
8738 <tr><td colspan="4" class="doc
" id="hasAnyParameter0
"><pre>Matches any parameter of a function or an ObjC method declaration or a
8741 Does not match the 'this' parameter of a method.
8744 class X { void f(int x, int y, int z) {} };
8745 cxxMethodDecl(hasAnyParameter(hasName("y
")))
8746 matches f(int x, int y, int z) {}
8747 with hasAnyParameter(...)
8750 For ObjectiveC, given
8751 @interface I - (void) f:(int) y; @end
8753 the matcher objcMethodDecl(hasAnyParameter(hasName("y
")))
8754 matches the declaration of method f with hasParameter
8758 b = ^(int y) { printf("%d
", y) };
8760 the matcher blockDecl(hasAnyParameter(hasName("y
")))
8761 matches the declaration of the block b with hasParameter
8766 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>></td><td class="name
" onclick="toggle('hasAnyTemplateArgument2')
"><a name="hasAnyTemplateArgument2Anchor
">hasAnyTemplateArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>> InnerMatcher</td></tr>
8767 <tr><td colspan="4" class="doc
" id="hasAnyTemplateArgument2
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
8768 functionDecl that have at least one TemplateArgument matching the given
8772 template<typename T> class A {};
8773 template<> class A<double> {};
8776 template<typename T> f() {};
8777 void func() { f<int>(); };
8779 classTemplateSpecializationDecl(hasAnyTemplateArgument(
8780 refersToType(asString("int
"))))
8781 matches the specialization A<int>
8783 functionDecl(hasAnyTemplateArgument(refersToType(asString("int
"))))
8784 matches the specialization f<int>
8788 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>></td><td class="name
" onclick="toggle('hasBody4')
"><a name="hasBody4Anchor
">hasBody</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
8789 <tr><td colspan="4" class="doc
" id="hasBody4
"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
8790 definition that has a given body. Note that in case of functions or
8791 coroutines this matcher only matches the definition itself and not the
8792 other declarations of the same function or coroutine.
8796 forStmt(hasBody(compoundStmt()))
8797 matches 'for (;;) {}'
8804 functionDecl(hasBody(compoundStmt()))
8805 matches 'void f() {}'
8808 but does not match 'void f();'
8812 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>></td><td class="name
" onclick="toggle('hasExplicitSpecifier0')
"><a name="hasExplicitSpecifier0Anchor
">hasExplicitSpecifier</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
8813 <tr><td colspan="4" class="doc
" id="hasExplicitSpecifier0
"><pre>Matches the expression in an explicit specifier if present in the given
8817 template<bool b>
8820 explicit S(double); // #2
8821 operator int(); // #3
8822 explicit operator bool(); // #4
8823 explicit(false) S(bool) // # 7
8824 explicit(true) S(char) // # 8
8825 explicit(b) S(S) // # 9
8827 S(int) -> S<true> // #5
8828 explicit S(double) -> S<false> // #6
8829 cxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8 and #9, but not #1 or #2.
8830 cxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or #4.
8831 cxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not match #5 or #6.
8835 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>></td><td class="name
" onclick="toggle('hasParameter0')
"><a name="hasParameter0Anchor
">hasParameter</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html
">ParmVarDecl</a>> InnerMatcher</td></tr>
8836 <tr><td colspan="4" class="doc
" id="hasParameter0
"><pre>Matches the n'th parameter of a function or an ObjC method
8837 declaration or a block.
8840 class X { void f(int x) {} };
8841 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
8843 with hasParameter(...)
8846 For ObjectiveC, given
8847 @interface I - (void) f:(int) y; @end
8849 the matcher objcMethodDecl(hasParameter(0, hasName("y
")))
8850 matches the declaration of method f with hasParameter
8855 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>></td><td class="name
" onclick="toggle('hasReturnTypeLoc0')
"><a name="hasReturnTypeLoc0Anchor
">hasReturnTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> ReturnMatcher</td></tr>
8856 <tr><td colspan="4" class="doc
" id="hasReturnTypeLoc0
"><pre>Matches a function declared with the specified return `TypeLoc`.
8859 int f() { return 5; }
8861 functionDecl(hasReturnTypeLoc(loc(asString("int
"))))
8862 matches the declaration of `f`, but not `g`.
8866 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>></td><td class="name
" onclick="toggle('hasTemplateArgument2')
"><a name="hasTemplateArgument2Anchor
">hasTemplateArgument</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>> InnerMatcher</td></tr>
8867 <tr><td colspan="4" class="doc
" id="hasTemplateArgument2
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
8868 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
8871 template<typename T, typename U> class A {};
8872 A<bool, int> b;
8873 A<int, bool> c;
8875 template<typename T> void f() {}
8876 void func() { f<int>(); };
8877 classTemplateSpecializationDecl(hasTemplateArgument(
8878 1, refersToType(asString("int
"))))
8879 matches the specialization A<bool, int>
8881 functionDecl(hasTemplateArgument(0, refersToType(asString("int
"))))
8882 matches the specialization f<int>
8886 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>></td><td class="name
" onclick="toggle('returns0')
"><a name="returns0Anchor
">returns</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
8887 <tr><td colspan="4" class="doc
" id="returns0
"><pre>Matches the return type of a function declaration.
8890 class X { int f() { return 1; } };
8891 cxxMethodDecl(returns(asString("int
")))
8892 matches int f() { return 1; }
8896 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html
">IfStmt</a>></td><td class="name
" onclick="toggle('hasCondition0')
"><a name="hasCondition0Anchor
">hasCondition</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
8897 <tr><td colspan="4" class="doc
" id="hasCondition0
"><pre>Matches the condition expression of an if statement, for loop,
8898 switch statement or conditional operator.
8900 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8905 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html
">IfStmt</a>></td><td class="name
" onclick="toggle('hasConditionVariableStatement0')
"><a name="hasConditionVariableStatement0Anchor
">hasConditionVariableStatement</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html
">DeclStmt</a>> InnerMatcher</td></tr>
8906 <tr><td colspan="4" class="doc
" id="hasConditionVariableStatement0
"><pre>Matches the condition variable statement in an if statement.
8909 if (A* a = GetAPointer()) {}
8910 hasConditionVariableStatement(...)
8911 matches 'A* a = GetAPointer()'.
8915 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html
">IfStmt</a>></td><td class="name
" onclick="toggle('hasElse0')
"><a name="hasElse0Anchor
">hasElse</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
8916 <tr><td colspan="4" class="doc
" id="hasElse0
"><pre>Matches the else-statement of an if statement.
8918 Examples matches the if statement
8919 (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true)))))
8920 if (false) false; else true;
8924 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html
">IfStmt</a>></td><td class="name
" onclick="toggle('hasInitStatement0')
"><a name="hasInitStatement0Anchor
">hasInitStatement</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
8925 <tr><td colspan="4" class="doc
" id="hasInitStatement0
"><pre>Matches selection statements with initializer.
8929 if (int i = foobar(); i > 0) {}
8930 switch (int i = foobar(); i) {}
8931 for (auto& a = get_range(); auto& x : a) {}
8934 if (foobar() > 0) {}
8935 switch (foobar()) {}
8936 for (auto& x : get_range()) {}
8938 ifStmt(hasInitStatement(anything()))
8939 matches the if statement in foo but not in bar.
8940 switchStmt(hasInitStatement(anything()))
8941 matches the switch statement in foo but not in bar.
8942 cxxForRangeStmt(hasInitStatement(anything()))
8943 matches the range for statement in foo but not in bar.
8947 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1IfStmt.html
">IfStmt</a>></td><td class="name
" onclick="toggle('hasThen0')
"><a name="hasThen0Anchor
">hasThen</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
8948 <tr><td colspan="4" class="doc
" id="hasThen0
"><pre>Matches the then-statement of an if statement.
8950 Examples matches the if statement
8951 (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true)))))
8952 if (false) true; else false;
8956 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ImplicitCastExpr.html
">ImplicitCastExpr</a>></td><td class="name
" onclick="toggle('hasImplicitDestinationType0')
"><a name="hasImplicitDestinationType0Anchor
">hasImplicitDestinationType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
8957 <tr><td colspan="4" class="doc
" id="hasImplicitDestinationType0
"><pre>Matches implicit casts whose destination type matches a given
8962 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html
">InitListExpr</a>></td><td class="name
" onclick="toggle('hasInit0')
"><a name="hasInit0Anchor
">hasInit</a></td><td>unsigned N, ast_matchers::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
8963 <tr><td colspan="4" class="doc
" id="hasInit0
"><pre>Matches the n'th item of an initializer list expression.
8966 (matcher = initListExpr(hasInit(0, expr())))
8971 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html
">InitListExpr</a>></td><td class="name
" onclick="toggle('hasSyntacticForm0')
"><a name="hasSyntacticForm0Anchor
">hasSyntacticForm</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
8972 <tr><td colspan="4" class="doc
" id="hasSyntacticForm0
"><pre>Matches the syntactic form of init list expressions
8973 (if expression have it).
8977 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>></td><td class="name
" onclick="toggle('hasDeclaration9')
"><a name="hasDeclaration9Anchor
">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
8978 <tr><td colspan="4" class="doc
" id="hasDeclaration9
"><pre>Matches a node if the declaration associated with that node
8979 matches the given matcher.
8981 The associated declaration is:
8982 - for type nodes, the declaration of the underlying type
8983 - for CallExpr, the declaration of the callee
8984 - for MemberExpr, the declaration of the referenced member
8985 - for CXXConstructExpr, the declaration of the constructor
8986 - for CXXNewExpr, the declaration of the operator new
8987 - for ObjCIvarExpr, the declaration of the ivar
8989 For type nodes, hasDeclaration will generally match the declaration of the
8994 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8995 typedefDecl. A common use case is to match the underlying, desugared type.
8996 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8997 varDecl(hasType(hasUnqualifiedDesugaredType(
8998 recordType(hasDeclaration(decl())))))
8999 In this matcher, the decl will match the CXXRecordDecl of class X.
9001 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>>,
9002 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>,
9003 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>>,
9004 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>>,
9005 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>>,
9006 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>>,
9007 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
9011 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>></td><td class="name
" onclick="toggle('hasDeclaration8')
"><a name="hasDeclaration8Anchor
">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
9012 <tr><td colspan="4" class="doc
" id="hasDeclaration8
"><pre>Matches a node if the declaration associated with that node
9013 matches the given matcher.
9015 The associated declaration is:
9016 - for type nodes, the declaration of the underlying type
9017 - for CallExpr, the declaration of the callee
9018 - for MemberExpr, the declaration of the referenced member
9019 - for CXXConstructExpr, the declaration of the constructor
9020 - for CXXNewExpr, the declaration of the operator new
9021 - for ObjCIvarExpr, the declaration of the ivar
9023 For type nodes, hasDeclaration will generally match the declaration of the
9028 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9029 typedefDecl. A common use case is to match the underlying, desugared type.
9030 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9031 varDecl(hasType(hasUnqualifiedDesugaredType(
9032 recordType(hasDeclaration(decl())))))
9033 In this matcher, the decl will match the CXXRecordDecl of class X.
9035 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>>,
9036 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>,
9037 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>>,
9038 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>>,
9039 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>>,
9040 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>>,
9041 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
9045 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html
">LambdaCapture</a>></td><td class="name
" onclick="toggle('capturesVar0')
"><a name="capturesVar0Anchor
">capturesVar</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html
">ValueDecl</a>> InnerMatcher</td></tr>
9046 <tr><td colspan="4" class="doc
" id="capturesVar0
"><pre>Matches a `LambdaCapture` that refers to the specified `VarDecl`. The
9047 `VarDecl` can be a separate variable that is captured by value or
9048 reference, or a synthesized variable if the capture has an initializer.
9054 auto g = [x = 1](){};
9057 lambdaExpr(hasAnyCapture(lambdaCapture(capturesVar(hasName("x
")))),
9058 capturesVar(hasName("x
")) matches `x` and `x = 1`.
9062 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html
">LambdaExpr</a>></td><td class="name
" onclick="toggle('forEachLambdaCapture0')
"><a name="forEachLambdaCapture0Anchor
">forEachLambdaCapture</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html
">LambdaCapture</a>> InnerMatcher</td></tr>
9063 <tr><td colspan="4" class="doc
" id="forEachLambdaCapture0
"><pre>Matches each lambda capture in a lambda expression.
9069 auto f = [=]() { return x + y + z; };
9071 lambdaExpr(forEachLambdaCapture(
9072 lambdaCapture(capturesVar(varDecl(hasType(isInteger()))))))
9073 will trigger two matches, binding for 'x' and 'y' respectively.
9077 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html
">LambdaExpr</a>></td><td class="name
" onclick="toggle('hasAnyCapture0')
"><a name="hasAnyCapture0Anchor
">hasAnyCapture</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaCapture.html
">LambdaCapture</a>> InnerMatcher</td></tr>
9078 <tr><td colspan="4" class="doc
" id="hasAnyCapture0
"><pre>Matches any capture in a lambda expression.
9083 auto f = [=](){ return t; };
9085 lambdaExpr(hasAnyCapture(lambdaCapture())) and
9086 lambdaExpr(hasAnyCapture(lambdaCapture(refersToVarDecl(hasName("t
")))))
9087 both match `[=](){ return t; }`.
9091 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>></td><td class="name
" onclick="toggle('hasDeclaration7')
"><a name="hasDeclaration7Anchor
">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
9092 <tr><td colspan="4" class="doc
" id="hasDeclaration7
"><pre>Matches a node if the declaration associated with that node
9093 matches the given matcher.
9095 The associated declaration is:
9096 - for type nodes, the declaration of the underlying type
9097 - for CallExpr, the declaration of the callee
9098 - for MemberExpr, the declaration of the referenced member
9099 - for CXXConstructExpr, the declaration of the constructor
9100 - for CXXNewExpr, the declaration of the operator new
9101 - for ObjCIvarExpr, the declaration of the ivar
9103 For type nodes, hasDeclaration will generally match the declaration of the
9108 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9109 typedefDecl. A common use case is to match the underlying, desugared type.
9110 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9111 varDecl(hasType(hasUnqualifiedDesugaredType(
9112 recordType(hasDeclaration(decl())))))
9113 In this matcher, the decl will match the CXXRecordDecl of class X.
9115 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>>,
9116 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>,
9117 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>>,
9118 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>>,
9119 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>>,
9120 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>>,
9121 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
9125 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>></td><td class="name
" onclick="toggle('hasObjectExpression0')
"><a name="hasObjectExpression0Anchor
">hasObjectExpression</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
9126 <tr><td colspan="4" class="doc
" id="hasObjectExpression0
"><pre>Matches a member expression where the object expression is matched by a
9127 given matcher. Implicit object expressions are included; that is, it matches
9128 use of implicit `this`.
9133 int f(X x) { x.m; return m; }
9135 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X
")))))
9136 matches `x.m`, but not `m`; however,
9137 memberExpr(hasObjectExpression(hasType(pointsTo(
9138 cxxRecordDecl(hasName("X
"))))))
9139 matches `m` (aka. `this->m`), but not `x.m`.
9143 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>></td><td class="name
" onclick="toggle('member0')
"><a name="member0Anchor
">member</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html
">ValueDecl</a>> InnerMatcher</td></tr>
9144 <tr><td colspan="4" class="doc
" id="member0
"><pre>Matches a member expression where the member is matched by a
9148 struct { int first, second; } first, second;
9149 int i(second.first);
9150 int j(first.second);
9151 memberExpr(member(hasName("first
")))
9152 matches second.first
9153 but not first.second (because the member name there is "second
").
9157 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html
">MemberPointerType</a>></td><td class="name
" onclick="toggle('pointee1')
"><a name="pointee1Anchor
">pointee</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td></tr>
9158 <tr><td colspan="4" class="doc
" id="pointee1
"><pre>Narrows PointerType (and similar) matchers to those where the
9159 pointee matches a given matcher.
9165 pointerType(pointee(isConstQualified(), isInteger()))
9166 matches "int const *b
"
9168 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html
">BlockPointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html
">MemberPointerType</a>>,
9169 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html
">PointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html
">ReferenceType</a>>
9173 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html
">NamedDecl</a>></td><td class="name
" onclick="toggle('hasUnderlyingDecl0')
"><a name="hasUnderlyingDecl0Anchor
">hasUnderlyingDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html
">NamedDecl</a>> InnerMatcher</td></tr>
9174 <tr><td colspan="4" class="doc
" id="hasUnderlyingDecl0
"><pre>Matches a NamedDecl whose underlying declaration matches the given
9178 namespace N { template<class T> void f(T t); }
9179 template <class T> void g() { using N::f; f(T()); }
9180 unresolvedLookupExpr(hasAnyDeclaration(
9181 namedDecl(hasUnderlyingDecl(hasName("::N::f
")))))
9182 matches the use of f in g() .
9186 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html
">NestedNameSpecifierLoc</a>></td><td class="name
" onclick="toggle('hasPrefix1')
"><a name="hasPrefix1Anchor
">hasPrefix</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html
">NestedNameSpecifierLoc</a>> InnerMatcher</td></tr>
9187 <tr><td colspan="4" class="doc
" id="hasPrefix1
"><pre>Matches on the prefix of a NestedNameSpecifierLoc.
9190 struct A { struct B { struct C {}; }; };
9192 nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A
")))))
9197 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html
">NestedNameSpecifierLoc</a>></td><td class="name
" onclick="toggle('loc1')
"><a name="loc1Anchor
">loc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html
">NestedNameSpecifier</a>> InnerMatcher</td></tr>
9198 <tr><td colspan="4" class="doc
" id="loc1
"><pre>Matches NestedNameSpecifierLocs for which the given inner
9199 NestedNameSpecifier-matcher matches.
9203 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html
">NestedNameSpecifierLoc</a>></td><td class="name
" onclick="toggle('specifiesTypeLoc0')
"><a name="specifiesTypeLoc0Anchor
">specifiesTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> InnerMatcher</td></tr>
9204 <tr><td colspan="4" class="doc
" id="specifiesTypeLoc0
"><pre>Matches nested name specifier locs that specify a type matching the
9208 struct A { struct B { struct C {}; }; };
9210 nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
9211 hasDeclaration(cxxRecordDecl(hasName("A
")))))))
9216 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html
">NestedNameSpecifier</a>></td><td class="name
" onclick="toggle('hasPrefix0')
"><a name="hasPrefix0Anchor
">hasPrefix</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html
">NestedNameSpecifier</a>> InnerMatcher</td></tr>
9217 <tr><td colspan="4" class="doc
" id="hasPrefix0
"><pre>Matches on the prefix of a NestedNameSpecifier.
9220 struct A { struct B { struct C {}; }; };
9222 nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A
")))) and
9227 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html
">NestedNameSpecifier</a>></td><td class="name
" onclick="toggle('specifiesNamespace0')
"><a name="specifiesNamespace0Anchor
">specifiesNamespace</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html
">NamespaceDecl</a>> InnerMatcher</td></tr>
9228 <tr><td colspan="4" class="doc
" id="specifiesNamespace0
"><pre>Matches nested name specifiers that specify a namespace matching the
9229 given namespace matcher.
9232 namespace ns { struct A {}; }
9234 nestedNameSpecifier(specifiesNamespace(hasName("ns
")))
9239 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html
">NestedNameSpecifier</a>></td><td class="name
" onclick="toggle('specifiesType0')
"><a name="specifiesType0Anchor
">specifiesType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
9240 <tr><td colspan="4" class="doc
" id="specifiesType0
"><pre>Matches nested name specifiers that specify a type matching the
9241 given QualType matcher without qualifiers.
9244 struct A { struct B { struct C {}; }; };
9246 nestedNameSpecifier(specifiesType(
9247 hasDeclaration(cxxRecordDecl(hasName("A
")))
9253 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html
">OMPExecutableDirective</a>></td><td class="name
" onclick="toggle('hasAnyClause0')
"><a name="hasAnyClause0Anchor
">hasAnyClause</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPClause.html
">OMPClause</a>> InnerMatcher</td></tr>
9254 <tr><td colspan="4" class="doc
" id="hasAnyClause0
"><pre>Matches any clause in an OpenMP directive.
9258 #pragma omp parallel
9259 #pragma omp parallel default(none)
9261 ``ompExecutableDirective(hasAnyClause(anything()))`` matches
9262 ``omp parallel default(none)``.
9266 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OMPExecutableDirective.html
">OMPExecutableDirective</a>></td><td class="name
" onclick="toggle('hasStructuredBlock0')
"><a name="hasStructuredBlock0Anchor
">hasStructuredBlock</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
9267 <tr><td colspan="4" class="doc
" id="hasStructuredBlock0
"><pre>Matches the structured-block of the OpenMP executable directive
9269 Prerequisite: the executable directive must not be standalone directive.
9270 If it is, it will never match.
9274 #pragma omp parallel
9276 #pragma omp parallel
9279 ``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;``
9283 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html
">ObjCInterfaceDecl</a>></td><td class="name
" onclick="toggle('isDerivedFrom1')
"><a name="isDerivedFrom1Anchor
">isDerivedFrom</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html
">NamedDecl</a>> Base</td></tr>
9284 <tr><td colspan="4" class="doc
" id="isDerivedFrom1
"><pre>Matches C++ classes that are directly or indirectly derived from a class
9285 matching Base, or Objective-C classes that directly or indirectly
9286 subclass a class matching Base.
9288 Note that a class is not considered to be derived from itself.
9290 Example matches Y, Z, C (Base == hasName("X
"))
9292 class Y : public X {}; // directly derived
9293 class Z : public Y {}; // indirectly derived
9296 class C : public B {}; // derived from a typedef of X
9298 In the following example, Bar matches isDerivedFrom(hasName("X
")):
9301 class Bar : public Foo {}; // derived from a type that X is a typedef of
9303 In the following example, Bar matches isDerivedFrom(hasName("NSObject
"))
9304 @interface NSObject @end
9305 @interface Bar : NSObject @end
9307 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html
">CXXRecordDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html
">ObjCInterfaceDecl</a>>
9311 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html
">ObjCInterfaceDecl</a>></td><td class="name
" onclick="toggle('isDirectlyDerivedFrom1')
"><a name="isDirectlyDerivedFrom1Anchor
">isDirectlyDerivedFrom</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html
">NamedDecl</a>> Base</td></tr>
9312 <tr><td colspan="4" class="doc
" id="isDirectlyDerivedFrom1
"><pre>Matches C++ or Objective-C classes that are directly derived from a class
9315 Note that a class is not considered to be derived from itself.
9317 Example matches Y, C (Base == hasName("X
"))
9319 class Y : public X {}; // directly derived
9320 class Z : public Y {}; // indirectly derived
9323 class C : public B {}; // derived from a typedef of X
9325 In the following example, Bar matches isDerivedFrom(hasName("X
")):
9328 class Bar : public Foo {}; // derived from a type that X is a typedef of
9332 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html
">ObjCInterfaceDecl</a>></td><td class="name
" onclick="toggle('isSameOrDerivedFrom1')
"><a name="isSameOrDerivedFrom1Anchor
">isSameOrDerivedFrom</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html
">NamedDecl</a>> Base</td></tr>
9333 <tr><td colspan="4" class="doc
" id="isSameOrDerivedFrom1
"><pre>Similar to isDerivedFrom(), but also matches classes that directly
9338 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html
">ObjCMessageExpr</a>></td><td class="name
" onclick="toggle('callee2')
"><a name="callee2Anchor
">callee</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
9339 <tr><td colspan="4" class="doc
" id="callee2
"><pre>Matches 1) if the call expression's callee's declaration matches the
9340 given matcher; or 2) if the Obj-C message expression's callee's method
9341 declaration matches the given matcher.
9343 Example matches y.x() (matcher = callExpr(callee(
9344 cxxMethodDecl(hasName("x
")))))
9345 class Y { public: void x(); };
9346 void z() { Y y; y.x(); }
9348 Example 2. Matches [I foo] with
9349 objcMessageExpr(callee(objcMethodDecl(hasName("foo
"))))
9351 @interface I: NSObject
9359 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html
">ObjCMessageExpr</a>></td><td class="name
" onclick="toggle('hasAnyArgument3')
"><a name="hasAnyArgument3Anchor
">hasAnyArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
9360 <tr><td colspan="4" class="doc
" id="hasAnyArgument3
"><pre>Matches any argument of a call expression or a constructor call
9361 expression, or an ObjC-message-send expression.
9364 void x(int, int, int) { int y; x(1, y, 42); }
9365 callExpr(hasAnyArgument(declRefExpr()))
9367 with hasAnyArgument(...)
9370 For ObjectiveC, given
9371 @interface I - (void) f:(int) y; @end
9372 void foo(I *i) { [i f:12]; }
9373 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
9378 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html
">ObjCMessageExpr</a>></td><td class="name
" onclick="toggle('hasArgument3')
"><a name="hasArgument3Anchor
">hasArgument</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
9379 <tr><td colspan="4" class="doc
" id="hasArgument3
"><pre>Matches the n'th argument of a call expression or a constructor
9382 Example matches y in x(y)
9383 (matcher = callExpr(hasArgument(0, declRefExpr())))
9384 void x(int) { int y; x(y); }
9388 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html
">ObjCMessageExpr</a>></td><td class="name
" onclick="toggle('hasReceiver0')
"><a name="hasReceiver0Anchor
">hasReceiver</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
9389 <tr><td colspan="4" class="doc
" id="hasReceiver0
"><pre>Matches if the Objective-C message is sent to an instance,
9390 and the inner matcher matches on that instance.
9392 For example the method call in
9393 NSString *x = @"hello
";
9394 [x containsString:@"h
"];
9396 objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x
"))))))
9400 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html
">ObjCMessageExpr</a>></td><td class="name
" onclick="toggle('hasReceiverType0')
"><a name="hasReceiverType0Anchor
">hasReceiverType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
9401 <tr><td colspan="4" class="doc
" id="hasReceiverType0
"><pre>Matches on the receiver of an ObjectiveC Message expression.
9404 matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *
")));
9405 matches the [webView ...] message invocation.
9406 NSString *webViewJavaScript = ...
9407 UIWebView *webView = ...
9408 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript];
9412 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html
">ObjCMethodDecl</a>></td><td class="name
" onclick="toggle('hasAnyParameter1')
"><a name="hasAnyParameter1Anchor
">hasAnyParameter</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html
">ParmVarDecl</a>> InnerMatcher</td></tr>
9413 <tr><td colspan="4" class="doc
" id="hasAnyParameter1
"><pre>Matches any parameter of a function or an ObjC method declaration or a
9416 Does not match the 'this' parameter of a method.
9419 class X { void f(int x, int y, int z) {} };
9420 cxxMethodDecl(hasAnyParameter(hasName("y
")))
9421 matches f(int x, int y, int z) {}
9422 with hasAnyParameter(...)
9425 For ObjectiveC, given
9426 @interface I - (void) f:(int) y; @end
9428 the matcher objcMethodDecl(hasAnyParameter(hasName("y
")))
9429 matches the declaration of method f with hasParameter
9433 b = ^(int y) { printf("%d
", y) };
9435 the matcher blockDecl(hasAnyParameter(hasName("y
")))
9436 matches the declaration of the block b with hasParameter
9441 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html
">ObjCMethodDecl</a>></td><td class="name
" onclick="toggle('hasParameter1')
"><a name="hasParameter1Anchor
">hasParameter</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html
">ParmVarDecl</a>> InnerMatcher</td></tr>
9442 <tr><td colspan="4" class="doc
" id="hasParameter1
"><pre>Matches the n'th parameter of a function or an ObjC method
9443 declaration or a block.
9446 class X { void f(int x) {} };
9447 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
9449 with hasParameter(...)
9452 For ObjectiveC, given
9453 @interface I - (void) f:(int) y; @end
9455 the matcher objcMethodDecl(hasParameter(0, hasName("y
")))
9456 matches the declaration of method f with hasParameter
9461 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html
">ObjCPropertyDecl</a>></td><td class="name
" onclick="toggle('hasTypeLoc11')
"><a name="hasTypeLoc11Anchor
">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> Inner</td></tr>
9462 <tr><td colspan="4" class="doc
" id="hasTypeLoc11
"><pre>Matches if the type location of a node matches the inner matcher.
9466 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
9470 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
9473 struct Foo { Foo(int, int); };
9475 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
9478 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html
">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>,
9479 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html
">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html
">CXXFunctionalCastExpr</a>>,
9480 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html
">CXXTemporaryObjectExpr</a>>,
9481 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
9482 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html
">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html
">CompoundLiteralExpr</a>>,
9483 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html
">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html
">ExplicitCastExpr</a>>,
9484 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html
">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html
">TemplateArgumentLoc</a>>,
9485 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
9489 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OpaqueValueExpr.html
">OpaqueValueExpr</a>></td><td class="name
" onclick="toggle('hasSourceExpression1')
"><a name="hasSourceExpression1Anchor
">hasSourceExpression</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
9490 <tr><td colspan="4" class="doc
" id="hasSourceExpression1
"><pre>Matches if the cast's source expression
9491 or opaque value's source expression matches the given matcher.
9493 Example 1: matches "a string
"
9494 (matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
9495 class URL { URL(string); };
9496 URL url = "a string
";
9498 Example 2: matches 'b' (matcher =
9499 opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
9504 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1OverloadExpr.html
">OverloadExpr</a>></td><td class="name
" onclick="toggle('hasAnyDeclaration0')
"><a name="hasAnyDeclaration0Anchor
">hasAnyDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
9505 <tr><td colspan="4" class="doc
" id="hasAnyDeclaration0
"><pre>Matches an OverloadExpr if any of the declarations in the set of
9506 overloads matches the given matcher.
9509 template <typename T> void foo(T);
9510 template <typename T> void bar(T);
9511 template <typename T> void baz(T t) {
9515 unresolvedLookupExpr(hasAnyDeclaration(
9516 functionTemplateDecl(hasName("foo
"))))
9517 matches foo in foo(t); but not bar in bar(t);
9521 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html
">ParenType</a>></td><td class="name
" onclick="toggle('innerType0')
"><a name="innerType0Anchor
">innerType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td></tr>
9522 <tr><td colspan="4" class="doc
" id="innerType0
"><pre>Matches ParenType nodes where the inner type is a specific type.
9525 int (*ptr_to_array)[4];
9526 int (*ptr_to_func)(int);
9528 varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
9529 ptr_to_func but not ptr_to_array.
9531 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html
">ParenType</a>>
9535 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html
">PointerTypeLoc</a>></td><td class="name
" onclick="toggle('hasPointeeLoc0')
"><a name="hasPointeeLoc0Anchor
">hasPointeeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> PointeeMatcher</td></tr>
9536 <tr><td colspan="4" class="doc
" id="hasPointeeLoc0
"><pre>Matches pointer `TypeLoc`s that have a pointee `TypeLoc` matching
9541 pointerTypeLoc(hasPointeeLoc(loc(asString("int
"))))
9546 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html
">PointerType</a>></td><td class="name
" onclick="toggle('pointee2')
"><a name="pointee2Anchor
">pointee</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td></tr>
9547 <tr><td colspan="4" class="doc
" id="pointee2
"><pre>Narrows PointerType (and similar) matchers to those where the
9548 pointee matches a given matcher.
9554 pointerType(pointee(isConstQualified(), isInteger()))
9555 matches "int const *b
"
9557 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html
">BlockPointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html
">MemberPointerType</a>>,
9558 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html
">PointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html
">ReferenceType</a>>
9562 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('hasCanonicalType0')
"><a name="hasCanonicalType0Anchor
">hasCanonicalType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
9563 <tr><td colspan="4" class="doc
" id="hasCanonicalType0
"><pre>Matches QualTypes whose canonical type matches InnerMatcher.
9566 typedef int &int_ref;
9570 varDecl(hasType(qualType(referenceType()))))) will not match the
9571 declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does.
9575 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('hasDeclaration6')
"><a name="hasDeclaration6Anchor
">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
9576 <tr><td colspan="4" class="doc
" id="hasDeclaration6
"><pre>Matches a node if the declaration associated with that node
9577 matches the given matcher.
9579 The associated declaration is:
9580 - for type nodes, the declaration of the underlying type
9581 - for CallExpr, the declaration of the callee
9582 - for MemberExpr, the declaration of the referenced member
9583 - for CXXConstructExpr, the declaration of the constructor
9584 - for CXXNewExpr, the declaration of the operator new
9585 - for ObjCIvarExpr, the declaration of the ivar
9587 For type nodes, hasDeclaration will generally match the declaration of the
9592 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9593 typedefDecl. A common use case is to match the underlying, desugared type.
9594 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9595 varDecl(hasType(hasUnqualifiedDesugaredType(
9596 recordType(hasDeclaration(decl())))))
9597 In this matcher, the decl will match the CXXRecordDecl of class X.
9599 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>>,
9600 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>,
9601 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>>,
9602 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>>,
9603 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>>,
9604 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>>,
9605 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
9609 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('ignoringParens0')
"><a name="ignoringParens0Anchor
">ignoringParens</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
9610 <tr><td colspan="4" class="doc
" id="ignoringParens0
"><pre>Matches types that match InnerMatcher after any parens are stripped.
9615 varDecl(hasType(pointerType(pointee(ignoringParens(functionType())))))
9616 would match the declaration for fp.
9620 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('pointsTo1')
"><a name="pointsTo1Anchor
">pointsTo</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
9621 <tr><td colspan="4" class="doc
" id="pointsTo1
"><pre>Overloaded to match the pointee type's declaration.
9625 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('pointsTo0')
"><a name="pointsTo0Anchor
">pointsTo</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
9626 <tr><td colspan="4" class="doc
" id="pointsTo0
"><pre>Matches if the matched type is a pointer type and the pointee type
9627 matches the specified matcher.
9629 Example matches y->x()
9630 (matcher = cxxMemberCallExpr(on(hasType(pointsTo
9631 cxxRecordDecl(hasName("Y
")))))))
9632 class Y { public: void x(); };
9633 void z() { Y *y; y->x(); }
9637 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('references1')
"><a name="references1Anchor
">references</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
9638 <tr><td colspan="4" class="doc
" id="references1
"><pre>Overloaded to match the referenced type's declaration.
9642 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>></td><td class="name
" onclick="toggle('references0')
"><a name="references0Anchor
">references</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
9643 <tr><td colspan="4" class="doc
" id="references0
"><pre>Matches if the matched type is a reference type and the referenced
9644 type matches the specified matcher.
9646 Example matches X &x and const X &y
9647 (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X
"))))))
9657 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualifiedTypeLoc.html
">QualifiedTypeLoc</a>></td><td class="name
" onclick="toggle('hasUnqualifiedLoc0')
"><a name="hasUnqualifiedLoc0Anchor
">hasUnqualifiedLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> InnerMatcher</td></tr>
9658 <tr><td colspan="4" class="doc
" id="hasUnqualifiedLoc0
"><pre>Matches `QualifiedTypeLoc`s that have an unqualified `TypeLoc` matching
9664 qualifiedTypeLoc(hasUnqualifiedLoc(pointerTypeLoc()))
9665 matches the `TypeLoc` of the variable declaration of `x`, but not `y`.
9669 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>></td><td class="name
" onclick="toggle('hasDeclaration5')
"><a name="hasDeclaration5Anchor
">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
9670 <tr><td colspan="4" class="doc
" id="hasDeclaration5
"><pre>Matches a node if the declaration associated with that node
9671 matches the given matcher.
9673 The associated declaration is:
9674 - for type nodes, the declaration of the underlying type
9675 - for CallExpr, the declaration of the callee
9676 - for MemberExpr, the declaration of the referenced member
9677 - for CXXConstructExpr, the declaration of the constructor
9678 - for CXXNewExpr, the declaration of the operator new
9679 - for ObjCIvarExpr, the declaration of the ivar
9681 For type nodes, hasDeclaration will generally match the declaration of the
9686 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9687 typedefDecl. A common use case is to match the underlying, desugared type.
9688 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9689 varDecl(hasType(hasUnqualifiedDesugaredType(
9690 recordType(hasDeclaration(decl())))))
9691 In this matcher, the decl will match the CXXRecordDecl of class X.
9693 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>>,
9694 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>,
9695 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>>,
9696 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>>,
9697 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>>,
9698 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>>,
9699 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
9703 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html
">ReferenceTypeLoc</a>></td><td class="name
" onclick="toggle('hasReferentLoc0')
"><a name="hasReferentLoc0Anchor
">hasReferentLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> ReferentMatcher</td></tr>
9704 <tr><td colspan="4" class="doc
" id="hasReferentLoc0
"><pre>Matches reference `TypeLoc`s that have a referent `TypeLoc` matching
9710 referenceTypeLoc(hasReferentLoc(loc(asString("int
"))))
9715 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html
">ReferenceType</a>></td><td class="name
" onclick="toggle('pointee3')
"><a name="pointee3Anchor
">pointee</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td></tr>
9716 <tr><td colspan="4" class="doc
" id="pointee3
"><pre>Narrows PointerType (and similar) matchers to those where the
9717 pointee matches a given matcher.
9723 pointerType(pointee(isConstQualified(), isInteger()))
9724 matches "int const *b
"
9726 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html
">BlockPointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html
">MemberPointerType</a>>,
9727 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1PointerType.html
">PointerType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html
">ReferenceType</a>>
9731 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html
">ReturnStmt</a>></td><td class="name
" onclick="toggle('hasReturnValue0')
"><a name="hasReturnValue0Anchor
">hasReturnValue</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
9732 <tr><td colspan="4" class="doc
" id="hasReturnValue0
"><pre>Matches the return value expression of a return statement
9736 hasReturnValue(binaryOperator())
9737 matches 'return a + b'
9738 with binaryOperator()
9743 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1StmtExpr.html
">StmtExpr</a>></td><td class="name
" onclick="toggle('hasAnySubstatement1')
"><a name="hasAnySubstatement1Anchor
">hasAnySubstatement</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
9744 <tr><td colspan="4" class="doc
" id="hasAnySubstatement1
"><pre>Matches compound statements where at least one substatement matches
9745 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
9749 hasAnySubstatement(compoundStmt())
9750 matches '{ {}; 1+2; }'
9756 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>></td><td class="name
" onclick="toggle('alignOfExpr0')
"><a name="alignOfExpr0Anchor
">alignOfExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html
">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr>
9757 <tr><td colspan="4" class="doc
" id="alignOfExpr0
"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
9762 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>></td><td class="name
" onclick="toggle('forCallable0')
"><a name="forCallable0Anchor
">forCallable</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
9763 <tr><td colspan="4" class="doc
" id="forCallable0
"><pre>Matches declaration of the function, method, or block the statement
9767 F& operator=(const F& o) {
9768 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
9771 returnStmt(forCallable(functionDecl(hasName("operator=
"))))
9772 matches 'return *this'
9773 but does not match 'return v > 0'
9778 dispatch_sync(queue, ^{ int y = 2; });
9780 declStmt(forCallable(objcMethodDecl()))
9782 but does not match 'int y = 2'.
9783 whereas declStmt(forCallable(blockDecl()))
9785 but does not match 'int x = 1'.
9789 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>></td><td class="name
" onclick="toggle('forFunction0')
"><a name="forFunction0Anchor
">forFunction</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html
">FunctionDecl</a>> InnerMatcher</td></tr>
9790 <tr><td colspan="4" class="doc
" id="forFunction0
"><pre>Matches declaration of the function the statement belongs to.
9792 Deprecated. Use forCallable() to correctly handle the situation when
9793 the declaration is not a function (but a block or an Objective-C method).
9794 forFunction() not only fails to take non-functions into account but also
9795 may match the wrong declaration in their presence.
9798 F& operator=(const F& o) {
9799 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
9802 returnStmt(forFunction(hasName("operator=
")))
9803 matches 'return *this'
9804 but does not match 'return v > 0'
9808 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>></td><td class="name
" onclick="toggle('sizeOfExpr0')
"><a name="sizeOfExpr0Anchor
">sizeOfExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html
">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr>
9809 <tr><td colspan="4" class="doc
" id="sizeOfExpr0
"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
9814 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html
">SubstTemplateTypeParmType</a>></td><td class="name
" onclick="toggle('hasReplacementType0')
"><a name="hasReplacementType0Anchor
">hasReplacementType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td></tr>
9815 <tr><td colspan="4" class="doc
" id="hasReplacementType0
"><pre>Matches template type parameter substitutions that have a replacement
9816 type that matches the provided matcher.
9819 template <typename T>
9824 substTemplateTypeParmType(hasReplacementType(type())) matches int
9828 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html
">SwitchStmt</a>></td><td class="name
" onclick="toggle('forEachSwitchCase0')
"><a name="forEachSwitchCase0Anchor
">forEachSwitchCase</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html
">SwitchCase</a>> InnerMatcher</td></tr>
9829 <tr><td colspan="4" class="doc
" id="forEachSwitchCase0
"><pre>Matches each case or default statement belonging to the given switch
9830 statement. This matcher may produce multiple matches.
9833 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }
9834 switchStmt(forEachSwitchCase(caseStmt().bind("c
"))).bind("s
")
9835 matches four times, with "c
" binding each of "case
1:
", "case
2:
",
9836 "case
3:
" and "case
4:
", and "s
" respectively binding "switch (
1)
",
9837 "switch (
1)
", "switch (
2)
" and "switch (
2)
".
9841 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html
">SwitchStmt</a>></td><td class="name
" onclick="toggle('hasCondition4')
"><a name="hasCondition4Anchor
">hasCondition</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
9842 <tr><td colspan="4" class="doc
" id="hasCondition4
"><pre>Matches the condition expression of an if statement, for loop,
9843 switch statement or conditional operator.
9845 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
9850 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html
">SwitchStmt</a>></td><td class="name
" onclick="toggle('hasInitStatement1')
"><a name="hasInitStatement1Anchor
">hasInitStatement</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
9851 <tr><td colspan="4" class="doc
" id="hasInitStatement1
"><pre>Matches selection statements with initializer.
9855 if (int i = foobar(); i > 0) {}
9856 switch (int i = foobar(); i) {}
9857 for (auto& a = get_range(); auto& x : a) {}
9860 if (foobar() > 0) {}
9861 switch (foobar()) {}
9862 for (auto& x : get_range()) {}
9864 ifStmt(hasInitStatement(anything()))
9865 matches the if statement in foo but not in bar.
9866 switchStmt(hasInitStatement(anything()))
9867 matches the switch statement in foo but not in bar.
9868 cxxForRangeStmt(hasInitStatement(anything()))
9869 matches the range for statement in foo but not in bar.
9873 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>></td><td class="name
" onclick="toggle('hasDeclaration4')
"><a name="hasDeclaration4Anchor
">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
9874 <tr><td colspan="4" class="doc
" id="hasDeclaration4
"><pre>Matches a node if the declaration associated with that node
9875 matches the given matcher.
9877 The associated declaration is:
9878 - for type nodes, the declaration of the underlying type
9879 - for CallExpr, the declaration of the callee
9880 - for MemberExpr, the declaration of the referenced member
9881 - for CXXConstructExpr, the declaration of the constructor
9882 - for CXXNewExpr, the declaration of the operator new
9883 - for ObjCIvarExpr, the declaration of the ivar
9885 For type nodes, hasDeclaration will generally match the declaration of the
9890 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9891 typedefDecl. A common use case is to match the underlying, desugared type.
9892 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9893 varDecl(hasType(hasUnqualifiedDesugaredType(
9894 recordType(hasDeclaration(decl())))))
9895 In this matcher, the decl will match the CXXRecordDecl of class X.
9897 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>>,
9898 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>,
9899 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>>,
9900 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>>,
9901 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>>,
9902 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>>,
9903 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
9907 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html
">TemplateArgumentLoc</a>></td><td class="name
" onclick="toggle('hasTypeLoc12')
"><a name="hasTypeLoc12Anchor
">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> Inner</td></tr>
9908 <tr><td colspan="4" class="doc
" id="hasTypeLoc12
"><pre>Matches if the type location of a node matches the inner matcher.
9912 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
9916 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
9919 struct Foo { Foo(int, int); };
9921 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
9924 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html
">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>,
9925 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html
">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html
">CXXFunctionalCastExpr</a>>,
9926 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html
">CXXTemporaryObjectExpr</a>>,
9927 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
9928 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html
">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html
">CompoundLiteralExpr</a>>,
9929 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html
">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html
">ExplicitCastExpr</a>>,
9930 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html
">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html
">TemplateArgumentLoc</a>>,
9931 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
9935 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>></td><td class="name
" onclick="toggle('isExpr0')
"><a name="isExpr0Anchor
">isExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
9936 <tr><td colspan="4" class="doc
" id="isExpr0
"><pre>Matches a sugar TemplateArgument that refers to a certain expression.
9939 struct B { int next; };
9940 template<int(B::*next_ptr)> struct A {};
9941 A<&B::next> a;
9942 templateSpecializationType(hasAnyTemplateArgument(
9943 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next
"))))))))
9944 matches the specialization A<&B::next> with fieldDecl(...) matching
9949 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>></td><td class="name
" onclick="toggle('refersToDeclaration0')
"><a name="refersToDeclaration0Anchor
">refersToDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
9950 <tr><td colspan="4" class="doc
" id="refersToDeclaration0
"><pre>Matches a canonical TemplateArgument that refers to a certain
9954 struct B { int next; };
9955 template<int(B::*next_ptr)> struct A {};
9956 A<&B::next> a;
9957 classTemplateSpecializationDecl(hasAnyTemplateArgument(
9958 refersToDeclaration(fieldDecl(hasName("next
")))))
9959 matches the specialization A<&B::next> with fieldDecl(...) matching
9964 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>></td><td class="name
" onclick="toggle('refersToIntegralType0')
"><a name="refersToIntegralType0Anchor
">refersToIntegralType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
9965 <tr><td colspan="4" class="doc
" id="refersToIntegralType0
"><pre>Matches a TemplateArgument that refers to an integral type.
9968 template<int T> struct C {};
9970 classTemplateSpecializationDecl(
9971 hasAnyTemplateArgument(refersToIntegralType(asString("int
"))))
9972 matches the implicit instantiation of C in C<42>.
9976 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>></td><td class="name
" onclick="toggle('refersToTemplate0')
"><a name="refersToTemplate0Anchor
">refersToTemplate</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateName.html
">TemplateName</a>> InnerMatcher</td></tr>
9977 <tr><td colspan="4" class="doc
" id="refersToTemplate0
"><pre>Matches a TemplateArgument that refers to a certain template.
9980 template<template <typename> class S> class X {};
9981 template<typename T> class Y {};
9983 classTemplateSpecializationDecl(hasAnyTemplateArgument(
9984 refersToTemplate(templateName())))
9985 matches the specialization X<Y>
9989 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>></td><td class="name
" onclick="toggle('refersToType0')
"><a name="refersToType0Anchor
">refersToType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
9990 <tr><td colspan="4" class="doc
" id="refersToType0
"><pre>Matches a TemplateArgument that refers to a certain type.
9994 template<typename T> struct A {};
9996 classTemplateSpecializationDecl(hasAnyTemplateArgument(refersToType(
9997 recordType(hasDeclaration(recordDecl(hasName("X
")))))))
9998 matches the specialization of struct A generated by A<X>.
10002 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html
">TemplateSpecializationTypeLoc</a>></td><td class="name
" onclick="toggle('hasAnyTemplateArgumentLoc0')
"><a name="hasAnyTemplateArgumentLoc0Anchor
">hasAnyTemplateArgumentLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html
">TemplateArgumentLoc</a>> InnerMatcher</td></tr>
10003 <tr><td colspan="4" class="doc
" id="hasAnyTemplateArgumentLoc0
"><pre>Matches template specialization `TypeLoc`s that have at least one
10004 `TemplateArgumentLoc` matching the given `InnerMatcher`.
10007 template<typename T> class A {};
10009 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc(
10010 hasTypeLoc(loc(asString("int
")))))))
10011 matches `A<int> a`.
10015 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationTypeLoc.html
">TemplateSpecializationTypeLoc</a>></td><td class="name
" onclick="toggle('hasTemplateArgumentLoc1')
"><a name="hasTemplateArgumentLoc1Anchor
">hasTemplateArgumentLoc</a></td><td>unsigned Index, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html
">TemplateArgumentLoc</a>> InnerMatcher</td></tr>
10016 <tr><td colspan="4" class="doc
" id="hasTemplateArgumentLoc1
"><pre>Matches template specialization `TypeLoc`s where the n'th
10017 `TemplateArgumentLoc` matches the given `InnerMatcher`.
10020 template<typename T, typename U> class A {};
10021 A<double, int> b;
10022 A<int, double> c;
10023 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
10024 hasTypeLoc(loc(asString("double
")))))))
10025 matches `A<double, int> b`, but not `A<int, double> c`.
10029 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>></td><td class="name
" onclick="toggle('forEachTemplateArgument1')
"><a name="forEachTemplateArgument1Anchor
">forEachTemplateArgument</a></td><td>clang::ast_matchers::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>> InnerMatcher</td></tr>
10030 <tr><td colspan="4" class="doc
" id="forEachTemplateArgument1
"><pre>Matches classTemplateSpecialization, templateSpecializationType and
10031 functionDecl nodes where the template argument matches the inner matcher.
10032 This matcher may produce multiple matches.
10035 template <typename T, unsigned N, unsigned M>
10038 constexpr unsigned R = 2;
10039 Matrix<int, R * 2, R * 4> M;
10041 template <typename T, typename U>
10042 void f(T&& t, U&& u) {}
10046 templateSpecializationType(forEachTemplateArgument(isExpr(expr())))
10047 matches twice, with expr() matching 'R * 2' and 'R * 4'
10048 functionDecl(forEachTemplateArgument(refersToType(builtinType())))
10049 matches the specialization f<unsigned, bool> twice, for 'unsigned'
10054 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>></td><td class="name
" onclick="toggle('hasAnyTemplateArgument1')
"><a name="hasAnyTemplateArgument1Anchor
">hasAnyTemplateArgument</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>> InnerMatcher</td></tr>
10055 <tr><td colspan="4" class="doc
" id="hasAnyTemplateArgument1
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
10056 functionDecl that have at least one TemplateArgument matching the given
10060 template<typename T> class A {};
10061 template<> class A<double> {};
10064 template<typename T> f() {};
10065 void func() { f<int>(); };
10067 classTemplateSpecializationDecl(hasAnyTemplateArgument(
10068 refersToType(asString("int
"))))
10069 matches the specialization A<int>
10071 functionDecl(hasAnyTemplateArgument(refersToType(asString("int
"))))
10072 matches the specialization f<int>
10076 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>></td><td class="name
" onclick="toggle('hasDeclaration3')
"><a name="hasDeclaration3Anchor
">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
10077 <tr><td colspan="4" class="doc
" id="hasDeclaration3
"><pre>Matches a node if the declaration associated with that node
10078 matches the given matcher.
10080 The associated declaration is:
10081 - for type nodes, the declaration of the underlying type
10082 - for CallExpr, the declaration of the callee
10083 - for MemberExpr, the declaration of the referenced member
10084 - for CXXConstructExpr, the declaration of the constructor
10085 - for CXXNewExpr, the declaration of the operator new
10086 - for ObjCIvarExpr, the declaration of the ivar
10088 For type nodes, hasDeclaration will generally match the declaration of the
10089 sugared type. Given
10093 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
10094 typedefDecl. A common use case is to match the underlying, desugared type.
10095 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
10096 varDecl(hasType(hasUnqualifiedDesugaredType(
10097 recordType(hasDeclaration(decl())))))
10098 In this matcher, the decl will match the CXXRecordDecl of class X.
10100 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>>,
10101 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>,
10102 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>>,
10103 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>>,
10104 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>>,
10105 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>>,
10106 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
10110 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>></td><td class="name
" onclick="toggle('hasTemplateArgument1')
"><a name="hasTemplateArgument1Anchor
">hasTemplateArgument</a></td><td>unsigned N, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html
">TemplateArgument</a>> InnerMatcher</td></tr>
10111 <tr><td colspan="4" class="doc
" id="hasTemplateArgument1
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
10112 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
10115 template<typename T, typename U> class A {};
10116 A<bool, int> b;
10117 A<int, bool> c;
10119 template<typename T> void f() {}
10120 void func() { f<int>(); };
10121 classTemplateSpecializationDecl(hasTemplateArgument(
10122 1, refersToType(asString("int
"))))
10123 matches the specialization A<bool, int>
10125 functionDecl(hasTemplateArgument(0, refersToType(asString("int
"))))
10126 matches the specialization f<int>
10130 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>></td><td class="name
" onclick="toggle('hasDeclaration2')
"><a name="hasDeclaration2Anchor
">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
10131 <tr><td colspan="4" class="doc
" id="hasDeclaration2
"><pre>Matches a node if the declaration associated with that node
10132 matches the given matcher.
10134 The associated declaration is:
10135 - for type nodes, the declaration of the underlying type
10136 - for CallExpr, the declaration of the callee
10137 - for MemberExpr, the declaration of the referenced member
10138 - for CXXConstructExpr, the declaration of the constructor
10139 - for CXXNewExpr, the declaration of the operator new
10140 - for ObjCIvarExpr, the declaration of the ivar
10142 For type nodes, hasDeclaration will generally match the declaration of the
10143 sugared type. Given
10147 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
10148 typedefDecl. A common use case is to match the underlying, desugared type.
10149 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
10150 varDecl(hasType(hasUnqualifiedDesugaredType(
10151 recordType(hasDeclaration(decl())))))
10152 In this matcher, the decl will match the CXXRecordDecl of class X.
10154 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>>,
10155 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>,
10156 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>>,
10157 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>>,
10158 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>>,
10159 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>>,
10160 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
10164 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>></td><td class="name
" onclick="toggle('loc0')
"><a name="loc0Anchor
">loc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
10165 <tr><td colspan="4" class="doc
" id="loc0
"><pre>Matches TypeLocs for which the given inner
10166 QualType-matcher matches.
10170 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>></td><td class="name
" onclick="toggle('hasTypeLoc13')
"><a name="hasTypeLoc13Anchor
">hasTypeLoc</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html
">TypeLoc</a>> Inner</td></tr>
10171 <tr><td colspan="4" class="doc
" id="hasTypeLoc13
"><pre>Matches if the type location of a node matches the inner matcher.
10175 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
10179 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
10182 struct Foo { Foo(int, int); };
10183 auto x = Foo(1, 2);
10184 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
10187 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html
">BlockDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>,
10188 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html
">CXXCtorInitializer</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html
">CXXFunctionalCastExpr</a>>,
10189 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html
">CXXTemporaryObjectExpr</a>>,
10190 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
10191 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html
">ClassTemplateSpecializationDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html
">CompoundLiteralExpr</a>>,
10192 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html
">DeclaratorDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html
">ExplicitCastExpr</a>>,
10193 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html
">ObjCPropertyDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateArgumentLoc.html
">TemplateArgumentLoc</a>>,
10194 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
10198 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>></td><td class="name
" onclick="toggle('hasType2')
"><a name="hasType2Anchor
">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
10199 <tr><td colspan="4" class="doc
" id="hasType2
"><pre>Matches if the expression's or declaration's type matches a type
10202 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
10203 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
10204 and U (matcher = typedefDecl(hasType(asString("int
")))
10205 and friend class X (matcher = friendDecl(hasType("X
"))
10206 and public virtual X (matcher = cxxBaseSpecifier(hasType(
10207 asString("class X
")))
10209 void y(X &x) { x; X z; }
10211 class Y { friend class X; };
10212 class Z : public virtual X {};
10216 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>></td><td class="name
" onclick="toggle('hasDeclaration1')
"><a name="hasDeclaration1Anchor
">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
10217 <tr><td colspan="4" class="doc
" id="hasDeclaration1
"><pre>Matches a node if the declaration associated with that node
10218 matches the given matcher.
10220 The associated declaration is:
10221 - for type nodes, the declaration of the underlying type
10222 - for CallExpr, the declaration of the callee
10223 - for MemberExpr, the declaration of the referenced member
10224 - for CXXConstructExpr, the declaration of the constructor
10225 - for CXXNewExpr, the declaration of the operator new
10226 - for ObjCIvarExpr, the declaration of the ivar
10228 For type nodes, hasDeclaration will generally match the declaration of the
10229 sugared type. Given
10233 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
10234 typedefDecl. A common use case is to match the underlying, desugared type.
10235 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
10236 varDecl(hasType(hasUnqualifiedDesugaredType(
10237 recordType(hasDeclaration(decl())))))
10238 In this matcher, the decl will match the CXXRecordDecl of class X.
10240 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>>,
10241 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>,
10242 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>>,
10243 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>>,
10244 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>>,
10245 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>>,
10246 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
10250 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td><td class="name
" onclick="toggle('hasUnqualifiedDesugaredType0')
"><a name="hasUnqualifiedDesugaredType0Anchor
">hasUnqualifiedDesugaredType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>> InnerMatcher</td></tr>
10251 <tr><td colspan="4" class="doc
" id="hasUnqualifiedDesugaredType0
"><pre>Matches if the matched type matches the unqualified desugared
10252 type of the matched node.
10257 The matcher type(hasUnqualifiedDesugaredType(recordType())) matches
10262 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html
">UnaryExprOrTypeTraitExpr</a>></td><td class="name
" onclick="toggle('hasArgumentOfType0')
"><a name="hasArgumentOfType0Anchor
">hasArgumentOfType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
10263 <tr><td colspan="4" class="doc
" id="hasArgumentOfType0
"><pre>Matches unary expressions that have a specific type of argument.
10266 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
10267 unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int
"))
10268 matches sizeof(a) and alignof(c)
10272 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html
">UnaryOperator</a>></td><td class="name
" onclick="toggle('hasUnaryOperand0')
"><a name="hasUnaryOperand0Anchor
">hasUnaryOperand</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
10273 <tr><td colspan="4" class="doc
" id="hasUnaryOperand0
"><pre>Matches if the operand of a unary operator matches.
10275 Example matches true (matcher = hasUnaryOperand(
10276 cxxBoolLiteral(equals(true))))
10281 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedMemberExpr.html
">UnresolvedMemberExpr</a>></td><td class="name
" onclick="toggle('hasObjectExpression1')
"><a name="hasObjectExpression1Anchor
">hasObjectExpression</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
10282 <tr><td colspan="4" class="doc
" id="hasObjectExpression1
"><pre>Matches a member expression where the object expression is matched by a
10283 given matcher. Implicit object expressions are included; that is, it matches
10284 use of implicit `this`.
10289 int f(X x) { x.m; return m; }
10291 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X
")))))
10292 matches `x.m`, but not `m`; however,
10293 memberExpr(hasObjectExpression(hasType(pointsTo(
10294 cxxRecordDecl(hasName("X
"))))))
10295 matches `m` (aka. `this->m`), but not `x.m`.
10299 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>></td><td class="name
" onclick="toggle('hasDeclaration0')
"><a name="hasDeclaration0Anchor
">hasDeclaration</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
10300 <tr><td colspan="4" class="doc
" id="hasDeclaration0
"><pre>Matches a node if the declaration associated with that node
10301 matches the given matcher.
10303 The associated declaration is:
10304 - for type nodes, the declaration of the underlying type
10305 - for CallExpr, the declaration of the callee
10306 - for MemberExpr, the declaration of the referenced member
10307 - for CXXConstructExpr, the declaration of the constructor
10308 - for CXXNewExpr, the declaration of the operator new
10309 - for ObjCIvarExpr, the declaration of the ivar
10311 For type nodes, hasDeclaration will generally match the declaration of the
10312 sugared type. Given
10316 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
10317 typedefDecl. A common use case is to match the underlying, desugared type.
10318 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
10319 varDecl(hasType(hasUnqualifiedDesugaredType(
10320 recordType(hasDeclaration(decl())))))
10321 In this matcher, the decl will match the CXXRecordDecl of class X.
10323 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html
">AddrLabelExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html
">CallExpr</a>>,
10324 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html
">CXXConstructExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html
">CXXNewExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>,
10325 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1EnumType.html
">EnumType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html
">InjectedClassNameType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html
">LabelStmt</a>>,
10326 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html
">MemberExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordType.html
">RecordType</a>>,
10327 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TagType.html
">TagType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html
">TemplateSpecializationType</a>>,
10328 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html
">TemplateTypeParmType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefType.html
">TypedefType</a>>,
10329 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
10333 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html
">UsingShadowDecl</a>></td><td class="name
" onclick="toggle('hasTargetDecl0')
"><a name="hasTargetDecl0Anchor
">hasTargetDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html
">NamedDecl</a>> InnerMatcher</td></tr>
10334 <tr><td colspan="4" class="doc
" id="hasTargetDecl0
"><pre>Matches a using shadow declaration where the target declaration is
10335 matched by the given matcher.
10338 namespace X { int a; void b(); }
10341 usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
10342 matches using X::b but not using X::a </pre></td></tr>
10345 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html
">UsingType</a>></td><td class="name
" onclick="toggle('hasUnderlyingType1')
"><a name="hasUnderlyingType1Anchor
">hasUnderlyingType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Type.html
">Type</a>></td></tr>
10346 <tr><td colspan="4" class="doc
" id="hasUnderlyingType1
"><pre>Matches DecltypeType or UsingType nodes to find the underlying type.
10350 decltype(2.0) b = 2.0;
10351 decltypeType(hasUnderlyingType(isInteger()))
10352 matches the type of "a
"
10354 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html
">DecltypeType</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html
">UsingType</a>>
10358 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html
">UsingType</a>></td><td class="name
" onclick="toggle('throughUsingDecl1')
"><a name="throughUsingDecl1Anchor
">throughUsingDecl</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html
">UsingShadowDecl</a>> Inner</td></tr>
10359 <tr><td colspan="4" class="doc
" id="throughUsingDecl1
"><pre>Matches if a node refers to a declaration through a specific
10360 using shadow declaration.
10363 namespace a { int f(); }
10366 declRefExpr(throughUsingDecl(anything()))
10369 namespace a { class X{}; }
10372 typeLoc(loc(usingType(throughUsingDecl(anything()))))
10375 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html
">DeclRefExpr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingType.html
">UsingType</a>>
10379 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html
">ValueDecl</a>></td><td class="name
" onclick="toggle('hasType7')
"><a name="hasType7Anchor
">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
10380 <tr><td colspan="4" class="doc
" id="hasType7
"><pre>Overloaded to match the declaration of the expression's or value
10381 declaration's type.
10383 In case of a value declaration (for example a variable declaration),
10384 this resolves one layer of indirection. For example, in the value
10385 declaration "X x;
", cxxRecordDecl(hasName("X
")) matches the declaration of
10386 X, while varDecl(hasType(cxxRecordDecl(hasName("X
")))) matches the
10389 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
10390 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
10391 and friend class X (matcher = friendDecl(hasType("X
"))
10392 and public virtual X (matcher = cxxBaseSpecifier(hasType(
10393 cxxRecordDecl(hasName("X
"))))
10395 void y(X &x) { x; X z; }
10396 class Y { friend class X; };
10397 class Z : public virtual X {};
10399 Example matches class Derived
10400 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base
"))))))
10402 class Derived : Base {};
10404 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html
">FriendDecl</a>>, Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html
">ValueDecl</a>>,
10405 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>
10409 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html
">ValueDecl</a>></td><td class="name
" onclick="toggle('hasType3')
"><a name="hasType3Anchor
">hasType</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1QualType.html
">QualType</a>> InnerMatcher</td></tr>
10410 <tr><td colspan="4" class="doc
" id="hasType3
"><pre>Matches if the expression's or declaration's type matches a type
10413 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
10414 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
10415 and U (matcher = typedefDecl(hasType(asString("int
")))
10416 and friend class X (matcher = friendDecl(hasType("X
"))
10417 and public virtual X (matcher = cxxBaseSpecifier(hasType(
10418 asString("class X
")))
10420 void y(X &x) { x; X z; }
10422 class Y { friend class X; };
10423 class Z : public virtual X {};
10427 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VarDecl.html
">VarDecl</a>></td><td class="name
" onclick="toggle('hasInitializer0')
"><a name="hasInitializer0Anchor
">hasInitializer</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
10428 <tr><td colspan="4" class="doc
" id="hasInitializer0
"><pre>Matches a variable declaration that has an initializer expression
10429 that matches the given matcher.
10431 Example matches x (matcher = varDecl(hasInitializer(callExpr())))
10432 bool y() { return true; }
10437 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1VariableArrayType.html
">VariableArrayType</a>></td><td class="name
" onclick="toggle('hasSizeExpr0')
"><a name="hasSizeExpr0Anchor
">hasSizeExpr</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
10438 <tr><td colspan="4" class="doc
" id="hasSizeExpr0
"><pre>Matches VariableArrayType nodes that have a specific size
10445 variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
10446 varDecl(hasName("b
")))))))
10451 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html
">WhileStmt</a>></td><td class="name
" onclick="toggle('hasBody2')
"><a name="hasBody2Anchor
">hasBody</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Stmt.html
">Stmt</a>> InnerMatcher</td></tr>
10452 <tr><td colspan="4" class="doc
" id="hasBody2
"><pre>Matches a 'for', 'while', 'while' statement or a function or coroutine
10453 definition that has a given body. Note that in case of functions or
10454 coroutines this matcher only matches the definition itself and not the
10455 other declarations of the same function or coroutine.
10459 forStmt(hasBody(compoundStmt()))
10460 matches 'for (;;) {}'
10461 with compoundStmt()
10467 functionDecl(hasBody(compoundStmt()))
10468 matches 'void f() {}'
10469 with compoundStmt()
10471 but does not match 'void f();'
10475 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html
">WhileStmt</a>></td><td class="name
" onclick="toggle('hasCondition2')
"><a name="hasCondition2Anchor
">hasCondition</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</a>> InnerMatcher</td></tr>
10476 <tr><td colspan="4" class="doc
" id="hasCondition2
"><pre>Matches the condition expression of an if statement, for loop,
10477 switch statement or conditional operator.
10479 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
10483 <!--END_TRAVERSAL_MATCHERS -->