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(hasReturnArgument(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('cxxConstructorDecl0')"><a name=
"cxxConstructorDecl0Anchor">cxxConstructorDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl
</a>>...
</td></tr>
686 <tr><td colspan=
"4" class=
"doc" id=
"cxxConstructorDecl0"><pre>Matches C++ constructor declarations.
688 Example matches Foo::Foo() and Foo::Foo(int)
698 <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>
699 <tr><td colspan=
"4" class=
"doc" id=
"cxxConversionDecl0"><pre>Matches conversion operator declarations.
701 Example matches the operator.
702 class X { operator int() const; };
706 <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>
707 <tr><td colspan=
"4" class=
"doc" id=
"cxxDeductionGuideDecl0"><pre>Matches user-defined and implicitly generated deduction guide.
709 Example matches the deduction guide.
710 template
<typename T
>
712 X(int) -
> X
<int
>;
716 <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>
717 <tr><td colspan=
"4" class=
"doc" id=
"cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations.
719 Example matches Foo::~Foo()
727 <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>
728 <tr><td colspan=
"4" class=
"doc" id=
"cxxMethodDecl0"><pre>Matches method declarations.
731 class X { void y(); };
735 <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>
736 <tr><td colspan=
"4" class=
"doc" id=
"cxxRecordDecl0"><pre>Matches C++ class declarations.
740 template
<class T
> class Z {};
744 <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>
745 <tr><td colspan=
"4" class=
"doc" id=
"decl0"><pre>Matches declarations.
747 Examples matches X, C, and the friend declaration inside C;
755 <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>
756 <tr><td colspan=
"4" class=
"doc" id=
"declaratorDecl0"><pre>Matches declarator declarations (field, variable, function
757 and non-type template parameter declarations).
766 <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>
767 <tr><td colspan=
"4" class=
"doc" id=
"decompositionDecl0"><pre>Matches decomposition-declarations.
769 Examples matches the declaration node with foo and bar, but not
771 (matcher = declStmt(has(decompositionDecl())))
774 auto [foo, bar] = std::make_pair{
42,
42};
778 <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>
779 <tr><td colspan=
"4" class=
"doc" id=
"enumConstantDecl0"><pre>Matches enum constants.
781 Example matches A, B, C
788 <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>
789 <tr><td colspan=
"4" class=
"doc" id=
"enumDecl0"><pre>Matches enum declarations.
798 <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>
799 <tr><td colspan=
"4" class=
"doc" id=
"fieldDecl0"><pre>Matches field declarations.
808 <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>
809 <tr><td colspan=
"4" class=
"doc" id=
"friendDecl0"><pre>Matches friend declarations.
812 class X { friend void foo(); };
814 matches 'friend void foo()'.
818 <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>
819 <tr><td colspan=
"4" class=
"doc" id=
"functionDecl0"><pre>Matches function declarations.
826 <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>
827 <tr><td colspan=
"4" class=
"doc" id=
"functionTemplateDecl0"><pre>Matches C++ function template declarations.
830 template
<class T
> void f(T t) {}
834 <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>
835 <tr><td colspan=
"4" class=
"doc" id=
"indirectFieldDecl0"><pre>Matches indirect field declarations.
838 struct X { struct { int a; }; };
844 <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>
845 <tr><td colspan=
"4" class=
"doc" id=
"labelDecl0"><pre>Matches a declaration of label.
855 <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>
856 <tr><td colspan=
"4" class=
"doc" id=
"linkageSpecDecl0"><pre>Matches a declaration of a linkage specification.
861 matches
"extern "C
" {}"
865 <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>
866 <tr><td colspan=
"4" class=
"doc" id=
"namedDecl0"><pre>Matches a declaration of anything that could have a name.
868 Example matches X, S, the anonymous union type, i, and U;
878 <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>
879 <tr><td colspan=
"4" class=
"doc" id=
"namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias.
883 namespace alias = ::test;
885 matches
"namespace alias" but not
"namespace test"
889 <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>
890 <tr><td colspan=
"4" class=
"doc" id=
"namespaceDecl0"><pre>Matches a declaration of a namespace.
896 matches
"namespace {}" and
"namespace test {}"
900 <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>
901 <tr><td colspan=
"4" class=
"doc" id=
"nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations.
904 template
<typename T, int N
> struct C {};
905 nonTypeTemplateParmDecl()
906 matches 'N', but not 'T'.
910 <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>
911 <tr><td colspan=
"4" class=
"doc" id=
"objcCategoryDecl0"><pre>Matches Objective-C category declarations.
913 Example matches Foo (Additions)
914 @interface Foo (Additions)
919 <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>
920 <tr><td colspan=
"4" class=
"doc" id=
"objcCategoryImplDecl0"><pre>Matches Objective-C category definitions.
922 Example matches Foo (Additions)
923 @implementation 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('objcImplementationDecl0')"><a name=
"objcImplementationDecl0Anchor">objcImplementationDecl
</a></td><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCImplementationDecl.html">ObjCImplementationDecl
</a>>...
</td></tr>
929 <tr><td colspan=
"4" class=
"doc" id=
"objcImplementationDecl0"><pre>Matches Objective-C implementation declarations.
937 <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>
938 <tr><td colspan=
"4" class=
"doc" id=
"objcInterfaceDecl0"><pre>Matches Objective-C interface declarations.
946 <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>
947 <tr><td colspan=
"4" class=
"doc" id=
"objcIvarDecl0"><pre>Matches Objective-C instance variable declarations.
949 Example matches _enabled
950 @implementation Foo {
957 <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>
958 <tr><td colspan=
"4" class=
"doc" id=
"objcMethodDecl0"><pre>Matches Objective-C method declarations.
960 Example matches both declaration and definition of -[Foo method]
971 <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>
972 <tr><td colspan=
"4" class=
"doc" id=
"objcPropertyDecl0"><pre>Matches Objective-C property declarations.
974 Example matches enabled
976 @property BOOL enabled;
981 <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>
982 <tr><td colspan=
"4" class=
"doc" id=
"objcProtocolDecl0"><pre>Matches Objective-C protocol declarations.
984 Example matches FooDelegate
985 @protocol FooDelegate
990 <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>
991 <tr><td colspan=
"4" class=
"doc" id=
"parmVarDecl0"><pre>Matches parameter variable declarations.
1000 <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>
1001 <tr><td colspan=
"4" class=
"doc" id=
"recordDecl0"><pre>Matches class, struct, and union declarations.
1003 Example matches X, Z, U, and S
1005 template
<class T
> class Z {};
1011 <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>
1012 <tr><td colspan=
"4" class=
"doc" id=
"staticAssertDecl0"><pre>Matches a C++ static_assert declaration.
1017 static_assert(sizeof(S) == sizeof(int))
1022 static_assert(sizeof(S) == sizeof(int));
1026 <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>
1027 <tr><td colspan=
"4" class=
"doc" id=
"tagDecl0"><pre>Matches tag declarations.
1029 Example matches X, Z, U, S, E
1031 template
<class T
> class Z {};
1040 <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>
1041 <tr><td colspan=
"4" class=
"doc" id=
"templateTemplateParmDecl0"><pre>Matches template template parameter declarations.
1044 template
<template
<typename
> class Z, int N
> struct C {};
1045 templateTypeParmDecl()
1046 matches 'Z', but not 'N'.
1050 <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>
1051 <tr><td colspan=
"4" class=
"doc" id=
"templateTypeParmDecl0"><pre>Matches template type parameter declarations.
1054 template
<typename T, int N
> struct C {};
1055 templateTypeParmDecl()
1056 matches 'T', but not 'N'.
1060 <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>
1061 <tr><td colspan=
"4" class=
"doc" id=
"translationUnitDecl0"><pre>Matches the top declaration context.
1068 decl(hasDeclContext(translationUnitDecl()))
1069 matches
"int X", but not
"int Y".
1073 <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>
1074 <tr><td colspan=
"4" class=
"doc" id=
"typeAliasDecl0"><pre>Matches type alias declarations.
1080 matches
"using Y = int", but not
"typedef int X"
1084 <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>
1085 <tr><td colspan=
"4" class=
"doc" id=
"typeAliasTemplateDecl0"><pre>Matches type alias template declarations.
1087 typeAliasTemplateDecl() matches
1088 template
<typename T
>
1089 using Y = X
<T
>;
1093 <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>
1094 <tr><td colspan=
"4" class=
"doc" id=
"typedefDecl0"><pre>Matches typedef declarations.
1100 matches
"typedef int X", but not
"using Y = int"
1104 <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>
1105 <tr><td colspan=
"4" class=
"doc" id=
"typedefNameDecl0"><pre>Matches typedef name declarations.
1111 matches
"typedef int X" and
"using Y = int"
1115 <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>
1116 <tr><td colspan=
"4" class=
"doc" id=
"unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the
1120 template
<typename T
>
1121 struct Base { typedef T Foo; };
1123 template
<typename T
>
1124 struct S : private Base
<T
> {
1125 using typename Base
<T
>::Foo;
1127 unresolvedUsingTypenameDecl()
1128 matches using Base
<T
>::Foo
</pre></td></tr>
1131 <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>
1132 <tr><td colspan=
"4" class=
"doc" id=
"unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations.
1135 template
<typename X
>
1136 class C : private X {
1139 unresolvedUsingValueDecl()
1140 matches using X::x
</pre></td></tr>
1143 <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>
1144 <tr><td colspan=
"4" class=
"doc" id=
"usingDecl0"><pre>Matches using declarations.
1147 namespace X { int x; }
1150 matches using X::x
</pre></td></tr>
1153 <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>
1154 <tr><td colspan=
"4" class=
"doc" id=
"usingDirectiveDecl0"><pre>Matches using namespace declarations.
1157 namespace X { int x; }
1159 usingDirectiveDecl()
1160 matches using namespace X
</pre></td></tr>
1163 <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>
1164 <tr><td colspan=
"4" class=
"doc" id=
"usingEnumDecl0"><pre>Matches using-enum declarations.
1167 namespace X { enum x {...}; }
1170 matches using enum X::x
</pre></td></tr>
1173 <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>
1174 <tr><td colspan=
"4" class=
"doc" id=
"valueDecl0"><pre>Matches any value declaration.
1176 Example matches A, B, C and F
1182 <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>
1183 <tr><td colspan=
"4" class=
"doc" id=
"varDecl0"><pre>Matches variable declarations.
1185 Note: this does not match declarations of member variables, which are
1186 "field" declarations in Clang parlance.
1193 <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>
1194 <tr><td colspan=
"4" class=
"doc" id=
"lambdaCapture0"><pre>Matches lambda captures.
1200 auto g = [x =
1](){};
1202 In the matcher `lambdaExpr(hasAnyCapture(lambdaCapture()))`,
1203 `lambdaCapture()` matches `x` and `x=
1`.
1207 <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>
1208 <tr><td colspan=
"4" class=
"doc" id=
"nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
1212 <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>
1213 <tr><td colspan=
"4" class=
"doc" id=
"nestedNameSpecifier0"><pre>Matches nested name specifiers.
1217 struct A { static void f(); };
1219 void g() { A::f(); }
1222 nestedNameSpecifier()
1223 matches
"ns::" and both
"A::"
1227 <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>
1228 <tr><td colspan=
"4" class=
"doc" id=
"ompDefaultClause0"><pre>Matches OpenMP ``default`` clause.
1232 #pragma omp parallel default(none)
1233 #pragma omp parallel default(shared)
1234 #pragma omp parallel default(firstprivate)
1235 #pragma omp parallel
1237 ``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``, and
1238 ``default(firstprivate)``
1242 <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>
1243 <tr><td colspan=
"4" class=
"doc" id=
"qualType0"><pre>Matches QualTypes in the clang AST.
1247 <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>
1248 <tr><td colspan=
"4" class=
"doc" id=
"addrLabelExpr0"><pre>Matches address of label statements (GNU extension).
1252 void *ptr =
&&FOO;
1255 matches '
&&FOO'
1259 <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>
1260 <tr><td colspan=
"4" class=
"doc" id=
"arraySubscriptExpr0"><pre>Matches array subscript expressions.
1264 arraySubscriptExpr()
1269 <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>
1270 <tr><td colspan=
"4" class=
"doc" id=
"asmStmt0"><pre>Matches asm statements.
1275 matches '__asm(
"mov al, 2")'
1279 <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>
1280 <tr><td colspan=
"4" class=
"doc" id=
"atomicExpr0"><pre>Matches atomic builtins.
1281 Example matches __atomic_load_n(ptr,
1)
1282 void foo() { int *ptr; __atomic_load_n(ptr,
1); }
1286 <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>
1287 <tr><td colspan=
"4" class=
"doc" id=
"autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement.
1293 autoreleasePoolStmt(stmt()) matches the declaration of
"x"
1294 inside the autorelease pool.
1298 <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>
1299 <tr><td colspan=
"4" class=
"doc" id=
"binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension).
1301 Example matches a ?: b
1306 <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>
1307 <tr><td colspan=
"4" class=
"doc" id=
"binaryOperator0"><pre>Matches binary operator expressions.
1309 Example matches a || b
1311 See also the binaryOperation() matcher for more-general matching.
1315 <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>
1316 <tr><td colspan=
"4" class=
"doc" id=
"blockExpr0"><pre>Matches a reference to a block.
1318 Example: matches
"^{}":
1323 <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>
1324 <tr><td colspan=
"4" class=
"doc" id=
"breakStmt0"><pre>Matches break statements.
1327 while (true) { break; }
1333 <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>
1334 <tr><td colspan=
"4" class=
"doc" id=
"cStyleCastExpr0"><pre>Matches a C-style cast expression.
1336 Example: Matches (int)
2.2f in
1341 <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>
1342 <tr><td colspan=
"4" class=
"doc" id=
"callExpr0"><pre>Matches call expressions.
1344 Example matches x.y() and y()
1351 <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>
1352 <tr><td colspan=
"4" class=
"doc" id=
"caseStmt0"><pre>Matches case statements inside switch statements.
1355 switch(a) { case
42: break; default: break; }
1361 <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>
1362 <tr><td colspan=
"4" class=
"doc" id=
"castExpr0"><pre>Matches any cast nodes of Clang's AST.
1364 Example: castExpr() matches each of the following:
1366 const_cast
<Expr *
>(SubExpr);
1374 <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>
1375 <tr><td colspan=
"4" class=
"doc" id=
"characterLiteral0"><pre>Matches character literals (also matches wchar_t).
1377 Not matching Hex-encoded chars (e.g.
0x1234, which is a IntegerLiteral),
1380 Example matches 'a', L'a'
1386 <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>
1387 <tr><td colspan=
"4" class=
"doc" id=
"chooseExpr0"><pre>Matches GNU __builtin_choose_expr.
1391 <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>
1392 <tr><td colspan=
"4" class=
"doc" id=
"coawaitExpr0"><pre>Matches co_await expressions.
1397 matches 'co_await
1'
1401 <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>
1402 <tr><td colspan=
"4" class=
"doc" id=
"compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals
1404 Example match: {
1}, (
1,
2)
1406 vector int myvec = (vector int)(
1,
2);
1410 <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>
1411 <tr><td colspan=
"4" class=
"doc" id=
"compoundStmt0"><pre>Matches compound statements.
1413 Example matches '{}' and '{{}}' in 'for (;;) {{}}'
1418 <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>
1419 <tr><td colspan=
"4" class=
"doc" id=
"conditionalOperator0"><pre>Matches conditional operator expressions.
1421 Example matches a ? b : c
1426 <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>
1427 <tr><td colspan=
"4" class=
"doc" id=
"constantExpr0"><pre>Matches a constant expression wrapper.
1429 Example matches the constant in the case statement:
1430 (matcher = constantExpr())
1437 <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>
1438 <tr><td colspan=
"4" class=
"doc" id=
"continueStmt0"><pre>Matches continue statements.
1441 while (true) { continue; }
1447 <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>
1448 <tr><td colspan=
"4" class=
"doc" id=
"coreturnStmt0"><pre>Matches co_return statements.
1451 while (true) { co_return; }
1457 <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>
1458 <tr><td colspan=
"4" class=
"doc" id=
"coyieldExpr0"><pre>Matches co_yield expressions.
1463 matches 'co_yield
1'
1467 <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>
1468 <tr><td colspan=
"4" class=
"doc" id=
"cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression.
1471 kernel
<<<i,j
>>>();
1475 <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>
1476 <tr><td colspan=
"4" class=
"doc" id=
"cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created.
1478 Example matches FunctionTakesString(GetStringByValue())
1479 (matcher = cxxBindTemporaryExpr())
1480 FunctionTakesString(GetStringByValue());
1481 FunctionTakesStringByPointer(GetStringPointer());
1485 <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>
1486 <tr><td colspan=
"4" class=
"doc" id=
"cxxBoolLiteral0"><pre>Matches bool literals.
1488 Example matches true
1493 <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>
1494 <tr><td colspan=
"4" class=
"doc" id=
"cxxCatchStmt0"><pre>Matches catch statements.
1496 try {} catch(int i) {}
1498 matches 'catch(int i)'
1502 <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>
1503 <tr><td colspan=
"4" class=
"doc" id=
"cxxConstCastExpr0"><pre>Matches a const_cast expression.
1505 Example: Matches const_cast
<int*
>(
&r) in
1507 const int
&r(n);
1508 int* p = const_cast
<int*
>(
&r);
1512 <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>
1513 <tr><td colspan=
"4" class=
"doc" id=
"cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones).
1515 Example matches string(ptr, n) and ptr within arguments of f
1516 (matcher = cxxConstructExpr())
1517 void f(const string
&a, const string
&b);
1520 f(string(ptr, n), ptr);
1524 <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>
1525 <tr><td colspan=
"4" class=
"doc" id=
"cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site.
1527 Example matches the CXXDefaultArgExpr placeholder inserted for the
1528 default value of the second parameter in the call expression f(
42)
1529 (matcher = cxxDefaultArgExpr())
1530 void f(int x, int y =
0);
1535 <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>
1536 <tr><td colspan=
"4" class=
"doc" id=
"cxxDeleteExpr0"><pre>Matches delete expressions.
1545 <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>
1546 <tr><td colspan=
"4" class=
"doc" id=
"cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be
1547 resolved because the base expression or the member name was dependent.
1550 template
<class T
> void f() { T t; t.g(); }
1551 cxxDependentScopeMemberExpr()
1556 <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>
1557 <tr><td colspan=
"4" class=
"doc" id=
"cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression.
1560 cxxDynamicCastExpr()
1562 dynamic_cast
<D*
>(
&b);
1564 struct B { virtual ~B() {} }; struct D : B {};
1566 D* p = dynamic_cast
<D*
>(
&b);
1570 <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>
1571 <tr><td colspan=
"4" class=
"doc" id=
"cxxForRangeStmt0"><pre>Matches range-based for statements.
1573 cxxForRangeStmt() matches 'for (auto a : i)'
1574 int i[] = {
1,
2,
3}; for (auto a : i);
1575 for(int j =
0; j
< 5; ++j);
1579 <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>
1580 <tr><td colspan=
"4" class=
"doc" id=
"cxxFunctionalCastExpr0"><pre>Matches functional cast expressions
1582 Example: Matches Foo(bar);
1589 <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>
1590 <tr><td colspan=
"4" class=
"doc" id=
"cxxMemberCallExpr0"><pre>Matches member call expressions.
1592 Example matches x.y()
1598 <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>
1599 <tr><td colspan=
"4" class=
"doc" id=
"cxxNewExpr0"><pre>Matches new expressions.
1608 <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>
1609 <tr><td colspan=
"4" class=
"doc" id=
"cxxNoexceptExpr0"><pre>Matches noexcept expressions.
1613 bool b() noexcept(true);
1614 bool c() noexcept(false);
1615 bool d() noexcept(noexcept(a()));
1616 bool e = noexcept(b()) || noexcept(c());
1618 matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`.
1619 doesn't match the noexcept specifier in the declarations a, b, c or d.
1623 <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>
1624 <tr><td colspan=
"4" class=
"doc" id=
"cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal.
1628 <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>
1629 <tr><td colspan=
"4" class=
"doc" id=
"cxxOperatorCallExpr0"><pre>Matches overloaded operator calls.
1631 Note that if an operator isn't overloaded, it won't match. Instead, use
1632 binaryOperator matcher.
1633 Currently it does not match operators such as new delete.
1634 FIXME: figure out why these do not match?
1636 Example matches both operator
<<((o
<< b), c) and operator
<<(o, b)
1637 (matcher = cxxOperatorCallExpr())
1638 ostream
&operator
<< (ostream
&out, int i) { };
1639 ostream
&o; int b =
1, c =
1;
1640 o
<< b
<< c;
1641 See also the binaryOperation() matcher for more-general matching of binary
1642 uses of this AST node.
1646 <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>
1647 <tr><td colspan=
"4" class=
"doc" id=
"cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression.
1649 Either the source expression or the destination type can be matched
1650 using has(), but hasDestinationType() is more specific and can be
1653 Example matches reinterpret_cast
<char*
>(
&p) in
1654 void* p = reinterpret_cast
<char*
>(
&p);
1658 <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>
1659 <tr><td colspan=
"4" class=
"doc" id=
"cxxRewrittenBinaryOperator0"><pre>Matches rewritten binary operators
1661 Example matches use of
"<":
1662 #include
<compare
>
1663 struct HasSpaceshipMem {
1665 constexpr auto operator
<=
>(const HasSpaceshipMem
&) const = default;
1668 HasSpaceshipMem hs1, hs2;
1672 See also the binaryOperation() matcher for more-general matching
1677 <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>
1678 <tr><td colspan=
"4" class=
"doc" id=
"cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression.
1680 See also: hasDestinationType
1681 See also: reinterpretCast
1686 static_cast
<long
>(
8)
1688 long eight(static_cast
<long
>(
8));
1692 <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>
1693 <tr><td colspan=
"4" class=
"doc" id=
"cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions.
1696 std::vector
<int
> a({
1,
2,
3 });
1697 std::vector
<int
> b = {
4,
5 };
1699 std::pair
<int, int
> d = {
8,
9 };
1700 cxxStdInitializerListExpr()
1701 matches
"{ 1, 2, 3 }" and
"{ 4, 5 }"
1705 <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>
1706 <tr><td colspan=
"4" class=
"doc" id=
"cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N !=
1 arguments
1708 Example: Matches Foo(bar, bar)
1709 Foo h = Foo(bar, bar);
1713 <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>
1714 <tr><td colspan=
"4" class=
"doc" id=
"cxxThisExpr0"><pre>Matches implicit and explicit this expressions.
1716 Example matches the implicit this expression in
"return i".
1717 (matcher = cxxThisExpr())
1720 int f() { return i; }
1725 <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>
1726 <tr><td colspan=
"4" class=
"doc" id=
"cxxThrowExpr0"><pre>Matches throw expressions.
1728 try { throw
5; } catch(int i) {}
1734 <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>
1735 <tr><td colspan=
"4" class=
"doc" id=
"cxxTryStmt0"><pre>Matches try statements.
1737 try {} catch(int i) {}
1743 <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>
1744 <tr><td colspan=
"4" class=
"doc" id=
"cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions.
1746 Example matches T(t) in return statement of f
1747 (matcher = cxxUnresolvedConstructExpr())
1748 template
<typename T
>
1749 void f(const T
& t) { return T(t); }
1753 <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>
1754 <tr><td colspan=
"4" class=
"doc" id=
"declRefExpr0"><pre>Matches expressions that refer to declarations.
1756 Example matches x in if (x)
1762 <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>
1763 <tr><td colspan=
"4" class=
"doc" id=
"declStmt0"><pre>Matches declaration statements.
1772 <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>
1773 <tr><td colspan=
"4" class=
"doc" id=
"defaultStmt0"><pre>Matches default statements inside switch statements.
1776 switch(a) { case
42: break; default: break; }
1782 <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>
1783 <tr><td colspan=
"4" class=
"doc" id=
"dependentCoawaitExpr0"><pre>Matches co_await expressions where the type of the promise is dependent
1787 <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>
1788 <tr><td colspan=
"4" class=
"doc" id=
"designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99
6.7.8].
1790 Example: Matches { [
2].y =
1.0, [
0].x =
1.0 }
1791 point ptarray[
10] = { [
2].y =
1.0, [
0].x =
1.0 };
1795 <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>
1796 <tr><td colspan=
"4" class=
"doc" id=
"doStmt0"><pre>Matches do statements.
1801 matches 'do {} while(true)'
1805 <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>
1806 <tr><td colspan=
"4" class=
"doc" id=
"explicitCastExpr0"><pre>Matches explicit cast expressions.
1808 Matches any cast expression written in user code, whether it be a
1809 C-style cast, a functional-style cast, or a keyword cast.
1811 Does not match implicit conversions.
1813 Note: the name
"explicitCast" is chosen to match Clang's terminology, as
1814 Clang uses the term
"cast" to apply to implicit conversions as well as to
1815 actual cast expressions.
1817 See also: hasDestinationType.
1819 Example: matches all five of the casts in
1820 int((int)(reinterpret_cast
<int
>(static_cast
<int
>(const_cast
<int
>(
42)))))
1821 but does not match the implicit conversion in
1826 <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>
1827 <tr><td colspan=
"4" class=
"doc" id=
"expr0"><pre>Matches expressions.
1834 <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>
1835 <tr><td colspan=
"4" class=
"doc" id=
"exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end
1836 of the sub-expression's evaluation.
1838 Example matches std::string()
1839 const std::string str = std::string();
1843 <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>
1844 <tr><td colspan=
"4" class=
"doc" id=
"fixedPointLiteral0"><pre>Matches fixed point literals
1848 <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>
1849 <tr><td colspan=
"4" class=
"doc" id=
"floatLiteral0"><pre>Matches float literals of all sizes / encodings, e.g.
1850 1.0,
1.0f,
1.0L and
1e10.
1852 Does not match implicit conversions such as
1857 <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>
1858 <tr><td colspan=
"4" class=
"doc" id=
"forStmt0"><pre>Matches for statements.
1860 Example matches 'for (;;) {}'
1862 int i[] = {
1,
2,
3}; for (auto a : i);
1866 <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>
1867 <tr><td colspan=
"4" class=
"doc" id=
"genericSelectionExpr0"><pre>Matches C11 _Generic expression.
1871 <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>
1872 <tr><td colspan=
"4" class=
"doc" id=
"gnuNullExpr0"><pre>Matches GNU __null expression.
1876 <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>
1877 <tr><td colspan=
"4" class=
"doc" id=
"gotoStmt0"><pre>Matches goto statements.
1887 <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>
1888 <tr><td colspan=
"4" class=
"doc" id=
"ifStmt0"><pre>Matches if statements.
1890 Example matches 'if (x) {}'
1895 <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>
1896 <tr><td colspan=
"4" class=
"doc" id=
"imaginaryLiteral0"><pre>Matches imaginary literals, which are based on integer and floating
1897 point literals e.g.:
1i,
1.0i
1901 <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>
1902 <tr><td colspan=
"4" class=
"doc" id=
"implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST.
1904 This matches many different places, including function call return value
1905 eliding, as well as any type conversions.
1909 <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>
1910 <tr><td colspan=
"4" class=
"doc" id=
"implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions.
1913 point ptarray[
10] = { [
2].y =
1.0, [
2].x =
2.0, [
0].x =
1.0 };
1914 implicitValueInitExpr()
1915 matches
"[0].y" (implicitly)
1919 <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>
1920 <tr><td colspan=
"4" class=
"doc" id=
"initListExpr0"><pre>Matches init list expressions.
1924 struct B { int x, y; };
1927 matches
"{ 1, 2 }" and
"{ 5, 6 }"
1931 <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>
1932 <tr><td colspan=
"4" class=
"doc" id=
"integerLiteral0"><pre>Matches integer literals of all sizes / encodings, e.g.
1935 Does not match character-encoded integers such as L'a'.
1939 <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>
1940 <tr><td colspan=
"4" class=
"doc" id=
"labelStmt0"><pre>Matches label statements.
1950 <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>
1951 <tr><td colspan=
"4" class=
"doc" id=
"lambdaExpr0"><pre>Matches lambda expressions.
1953 Example matches [
&](){return
5;}
1954 [
&](){return
5;}
1958 <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>
1959 <tr><td colspan=
"4" class=
"doc" id=
"materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized.
1962 struct T {void func();};
1965 materializeTemporaryExpr() matches 'f()' in these statements
1974 <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>
1975 <tr><td colspan=
"4" class=
"doc" id=
"memberExpr0"><pre>Matches member expressions.
1979 void x() { this-
>x(); x(); Y y; y.x(); a; this-
>b; Y::b; }
1980 int a; static int b;
1983 matches this-
>x, x, y.x, a, this-
>b
1987 <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>
1988 <tr><td colspan=
"4" class=
"doc" id=
"nullStmt0"><pre>Matches null statements.
1992 matches the second ';'
1996 <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>
1997 <tr><td colspan=
"4" class=
"doc" id=
"objcCatchStmt0"><pre>Matches Objective-C @catch statements.
1999 Example matches @catch
2005 <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>
2006 <tr><td colspan=
"4" class=
"doc" id=
"objcFinallyStmt0"><pre>Matches Objective-C @finally statements.
2008 Example matches @finally
2014 <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>
2015 <tr><td colspan=
"4" class=
"doc" id=
"objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar.
2017 Example: matches
"a" in
"init" method:
2027 <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>
2028 <tr><td colspan=
"4" class=
"doc" id=
"objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions.
2030 The innermost message send invokes the
"alloc" class method on the
2031 NSString class, while the outermost message send invokes the
2032 "initWithString" instance method on the object returned from
2033 NSString's
"alloc". This matcher should match both message sends.
2034 [[NSString alloc] initWithString:@
"Hello"]
2038 <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>
2039 <tr><td colspan=
"4" class=
"doc" id=
"objcThrowStmt0"><pre>Matches Objective-C statements.
2041 Example matches @throw obj;
2045 <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>
2046 <tr><td colspan=
"4" class=
"doc" id=
"objcTryStmt0"><pre>Matches Objective-C @try statements.
2048 Example matches @try
2054 <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>
2055 <tr><td colspan=
"4" class=
"doc" id=
"ompExecutableDirective0"><pre>Matches any ``#pragma omp`` executable directive.
2059 #pragma omp parallel
2060 #pragma omp parallel default(none)
2061 #pragma omp taskyield
2063 ``ompExecutableDirective()`` matches ``omp parallel``,
2064 ``omp parallel default(none)`` and ``omp taskyield``.
2068 <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>
2069 <tr><td colspan=
"4" class=
"doc" id=
"opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers
2070 to reference another expressions and can be met
2071 in BinaryConditionalOperators, for example.
2078 <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>
2079 <tr><td colspan=
"4" class=
"doc" id=
"parenExpr0"><pre>Matches parentheses used in expressions.
2081 Example matches (foo() +
1)
2082 int foo() { return
1; }
2083 int a = (foo() +
1);
2087 <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>
2088 <tr><td colspan=
"4" class=
"doc" id=
"parenListExpr0"><pre>Matches paren list expressions.
2089 ParenListExprs don't have a predefined type and are used for late parsing.
2090 In the final AST, they can be met in template declarations.
2093 template
<typename T
> class X {
2096 int a =
0, b =
1; int i = (a, b);
2099 parenListExpr() matches
"*this" but NOT matches (a, b) because (a, b)
2100 has a predefined type and is a ParenExpr, not a ParenListExpr.
2104 <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>
2105 <tr><td colspan=
"4" class=
"doc" id=
"predefinedExpr0"><pre>Matches predefined identifier expressions [C99
6.4.2.2].
2107 Example: Matches __func__
2108 printf(
"%s", __func__);
2112 <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>
2113 <tr><td colspan=
"4" class=
"doc" id=
"returnStmt0"><pre>Matches return statements.
2122 <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>
2123 <tr><td colspan=
"4" class=
"doc" id=
"stmt0"><pre>Matches statements.
2128 matches both the compound statement '{ ++a; }' and '++a'.
2132 <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>
2133 <tr><td colspan=
"4" class=
"doc" id=
"stmtExpr0"><pre>Matches statement expression (GNU extension).
2135 Example match: ({ int X =
4; X; })
2136 int C = ({ int X =
4; X; });
2140 <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>
2141 <tr><td colspan=
"4" class=
"doc" id=
"stringLiteral0"><pre>Matches string literals (also matches wide string literals).
2143 Example matches
"abcd", L
"abcd"
2145 wchar_t *ws = L
"abcd";
2149 <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>
2150 <tr><td colspan=
"4" class=
"doc" id=
"substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters.
2153 template
<int N
>
2154 struct A { static const int n = N; };
2155 struct B : public A
<42> {};
2156 substNonTypeTemplateParmExpr()
2157 matches
"N" in the right-hand side of
"static const int n = N;"
2161 <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>
2162 <tr><td colspan=
"4" class=
"doc" id=
"switchCase0"><pre>Matches case and default statements inside switch statements.
2165 switch(a) { case
42: break; default: break; }
2167 matches 'case
42:' and 'default:'.
2171 <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>
2172 <tr><td colspan=
"4" class=
"doc" id=
"switchStmt0"><pre>Matches switch statements.
2175 switch(a) { case
42: break; default: break; }
2177 matches 'switch(a)'.
2181 <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>
2182 <tr><td colspan=
"4" class=
"doc" id=
"unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++
11) and vec_step (OpenCL)
2186 int y = sizeof(x) + alignof(x);
2187 unaryExprOrTypeTraitExpr()
2188 matches sizeof(x) and alignof(x)
2192 <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>
2193 <tr><td colspan=
"4" class=
"doc" id=
"unaryOperator0"><pre>Matches unary operator expressions.
2200 <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>
2201 <tr><td colspan=
"4" class=
"doc" id=
"unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing
2202 but could not be resolved to a specific declaration.
2205 template
<typename T
>
2206 T foo() { T a; return a; }
2207 template
<typename T
>
2211 unresolvedLookupExpr()
2212 matches foo
<T
>()
</pre></td></tr>
2215 <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>
2216 <tr><td colspan=
"4" class=
"doc" id=
"unresolvedMemberExpr0"><pre>Matches unresolved member expressions.
2220 template
<class T
> void f();
2223 template
<class T
> void h() { X x; x.f
<T
>(); x.g(); }
2224 unresolvedMemberExpr()
2225 matches x.f
<T
>
2229 <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>
2230 <tr><td colspan=
"4" class=
"doc" id=
"userDefinedLiteral0"><pre>Matches user defined literal operator call.
2232 Example match:
"foo"_suffix
2236 <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>
2237 <tr><td colspan=
"4" class=
"doc" id=
"whileStmt0"><pre>Matches while statements.
2242 matches 'while (true) {}'.
2246 <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>
2247 <tr><td colspan=
"4" class=
"doc" id=
"templateArgumentLoc0"><pre>Matches template arguments (with location info).
2250 template
<typename T
> struct C {};
2252 templateArgumentLoc()
2253 matches 'int' in C
<int
>.
2257 <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>
2258 <tr><td colspan=
"4" class=
"doc" id=
"templateArgument0"><pre>Matches template arguments.
2261 template
<typename T
> struct C {};
2264 matches 'int' in C
<int
>.
2268 <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>
2269 <tr><td colspan=
"4" class=
"doc" id=
"templateName0"><pre>Matches template name.
2272 template
<typename T
> class X { };
2275 matches 'X' in X
<int
>.
2279 <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>
2280 <tr><td colspan=
"4" class=
"doc" id=
"elaboratedTypeLoc0"><pre>Matches C or C++ elaborated `TypeLoc`s.
2286 matches the `TypeLoc` of the variable declaration of `ss`.
2290 <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>
2291 <tr><td colspan=
"4" class=
"doc" id=
"pointerTypeLoc0"><pre>Matches pointer `TypeLoc`s.
2300 <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>
2301 <tr><td colspan=
"4" class=
"doc" id=
"qualifiedTypeLoc0"><pre>Matches `QualifiedTypeLoc`s in the clang AST.
2306 matches `const int`.
2310 <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>
2311 <tr><td colspan=
"4" class=
"doc" id=
"referenceTypeLoc0"><pre>Matches reference `TypeLoc`s.
2316 int
&& r =
3;
2318 matches `int
&` and `int
&&`.
2322 <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>
2323 <tr><td colspan=
"4" class=
"doc" id=
"templateSpecializationTypeLoc0"><pre>Matches template specialization `TypeLoc`s.
2326 template
<typename T
> class C {};
2328 varDecl(hasTypeLoc(templateSpecializationTypeLoc(typeLoc())))
2329 matches `C
<char
> var`.
2333 <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>
2334 <tr><td colspan=
"4" class=
"doc" id=
"typeLoc0"><pre>Matches TypeLocs in the clang AST.
2338 <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>
2339 <tr><td colspan=
"4" class=
"doc" id=
"arrayType0"><pre>Matches all kinds of arrays.
2344 void f() { int c[a[
0]]; }
2346 matches
"int a[]",
"int b[4]" and
"int c[a[0]]";
2350 <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>
2351 <tr><td colspan=
"4" class=
"doc" id=
"atomicType0"><pre>Matches atomic types.
2356 matches
"_Atomic(int) i"
2360 <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>
2361 <tr><td colspan=
"4" class=
"doc" id=
"autoType0"><pre>Matches types nodes representing C++
11 auto types.
2366 for (auto i : v) { }
2368 matches
"auto n" and
"auto i"
2372 <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>
2373 <tr><td colspan=
"4" class=
"doc" id=
"blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as
2376 The pointee is always required to be a FunctionType.
2380 <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>
2381 <tr><td colspan=
"4" class=
"doc" id=
"builtinType0"><pre>Matches builtin Types.
2390 matches
"int b",
"float c" and
"bool d"
2394 <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>
2395 <tr><td colspan=
"4" class=
"doc" id=
"complexType0"><pre>Matches C99 complex types.
2400 matches
"_Complex float f"
2404 <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>
2405 <tr><td colspan=
"4" class=
"doc" id=
"constantArrayType0"><pre>Matches C arrays with a specified constant size.
2418 <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>
2419 <tr><td colspan=
"4" class=
"doc" id=
"decayedType0"><pre>Matches decayed type
2420 Example matches i[] in declaration of f.
2421 (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
2422 Example matches i[
1].
2423 (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())))))
2430 <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>
2431 <tr><td colspan=
"4" class=
"doc" id=
"decltypeType0"><pre>Matches types nodes representing C++
11 decltype(
<expr
>) types.
2436 decltype(i + j) result = i + j;
2438 matches
"decltype(i + j)"
2442 <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>
2443 <tr><td colspan=
"4" class=
"doc" id=
"deducedTemplateSpecializationType0"><pre>Matches C++
17 deduced template specialization types, e.g. deduced class
2447 template
<typename T
>
2448 class C { public: C(T); };
2451 deducedTemplateSpecializationType() matches the type in the declaration
2456 <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>
2457 <tr><td colspan=
"4" class=
"doc" id=
"dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression.
2460 template
<typename T, int Size
>
2464 dependentSizedArrayType
2465 matches
"T data[Size]"
2469 <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>
2470 <tr><td colspan=
"4" class=
"doc" id=
"elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a
2484 elaboratedType() matches the type of the variable declarations of both
2489 <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>
2490 <tr><td colspan=
"4" class=
"doc" id=
"enumType0"><pre>Matches enum types.
2494 enum class S { Red };
2499 enumType() matches the type of the variable declarations of both c and
2504 <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>
2505 <tr><td colspan=
"4" class=
"doc" id=
"functionProtoType0"><pre>Matches FunctionProtoType nodes.
2511 matches
"int (*f)(int)" and the type of
"g" in C++ mode.
2512 In C mode,
"g" is not matched because it does not contain a prototype.
2516 <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>
2517 <tr><td colspan=
"4" class=
"doc" id=
"functionType0"><pre>Matches FunctionType nodes.
2523 matches
"int (*f)(int)" and the type of
"g".
2527 <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>
2528 <tr><td colspan=
"4" class=
"doc" id=
"incompleteArrayType0"><pre>Matches C arrays with unspecified size.
2533 void f(int c[]) { int d[a[
0]]; };
2534 incompleteArrayType()
2535 matches
"int a[]" and
"int c[]"
2539 <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>
2540 <tr><td colspan=
"4" class=
"doc" id=
"injectedClassNameType0"><pre>Matches injected class name types.
2542 Example matches S s, but not S
<T
> s.
2543 (matcher = parmVarDecl(hasType(injectedClassNameType())))
2544 template
<typename T
> struct S {
2546 void g(S
<T
> s);
2551 <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>
2552 <tr><td colspan=
"4" class=
"doc" id=
"lValueReferenceType0"><pre>Matches lvalue reference types.
2557 int
&&c =
1;
2559 auto
&&e = c;
2560 auto
&&f =
2;
2563 lValueReferenceType() matches the types of b, d, and e. e is
2564 matched since the type is deduced as int
& by reference collapsing rules.
2568 <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>
2569 <tr><td colspan=
"4" class=
"doc" id=
"memberPointerType0"><pre>Matches member pointer types.
2578 <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>
2579 <tr><td colspan=
"4" class=
"doc" id=
"objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from
2580 a pointer type, despite being syntactically similar.
2589 matches
"Foo *f", but does not match
"int *a".
2593 <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>
2594 <tr><td colspan=
"4" class=
"doc" id=
"parenType0"><pre>Matches ParenType nodes.
2597 int (*ptr_to_array)[
4];
2598 int *array_of_ptrs[
4];
2600 varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not
2605 <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>
2606 <tr><td colspan=
"4" class=
"doc" id=
"pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer
2618 matches
"int *a", but does not match
"Foo *f".
2622 <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>
2623 <tr><td colspan=
"4" class=
"doc" id=
"rValueReferenceType0"><pre>Matches rvalue reference types.
2628 int
&&c =
1;
2630 auto
&&e = c;
2631 auto
&&f =
2;
2634 rValueReferenceType() matches the types of c and f. e is not
2635 matched as it is deduced to int
& by reference collapsing rules.
2639 <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>
2640 <tr><td colspan=
"4" class=
"doc" id=
"recordType0"><pre>Matches record types (e.g. structs, classes).
2649 recordType() matches the type of the variable declarations of both c
2654 <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>
2655 <tr><td colspan=
"4" class=
"doc" id=
"referenceType0"><pre>Matches both lvalue and rvalue reference types.
2660 int
&&c =
1;
2662 auto
&&e = c;
2663 auto
&&f =
2;
2666 referenceType() matches the types of b, c, d, e, and f.
2670 <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>
2671 <tr><td colspan=
"4" class=
"doc" id=
"substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a
2672 template type parameter.
2675 template
<typename T
>
2680 substTemplateTypeParmType() matches the type of 't' but not '
1'
2684 <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>
2685 <tr><td colspan=
"4" class=
"doc" id=
"tagType0"><pre>Matches tag types (record and enum types).
2694 tagType() matches the type of the variable declarations of both e
2699 <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>
2700 <tr><td colspan=
"4" class=
"doc" id=
"templateSpecializationType0"><pre>Matches template specialization types.
2703 template
<typename T
>
2706 template class C
<int
>; // A
2707 C
<char
> var; // B
2709 templateSpecializationType() matches the type of the explicit
2710 instantiation in A and the type of the variable declaration in B.
2714 <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>
2715 <tr><td colspan=
"4" class=
"doc" id=
"templateTypeParmType0"><pre>Matches template type parameter types.
2717 Example matches T, but not int.
2718 (matcher = templateTypeParmType())
2719 template
<typename T
> void f(int i);
2723 <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>
2724 <tr><td colspan=
"4" class=
"doc" id=
"type0"><pre>Matches Types in the clang AST.
2728 <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>
2729 <tr><td colspan=
"4" class=
"doc" id=
"typedefType0"><pre>Matches typedef types.
2734 matches
"typedef int X"
2738 <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>
2739 <tr><td colspan=
"4" class=
"doc" id=
"unaryTransformType0"><pre>Matches types nodes representing unary type transformations.
2742 typedef __underlying_type(T) type;
2743 unaryTransformType()
2744 matches
"__underlying_type(T)"
2748 <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>
2749 <tr><td colspan=
"4" class=
"doc" id=
"usingType0"><pre>Matches types specified through a using declaration.
2752 namespace a { struct S {}; }
2756 usingType() matches the type of the variable declaration of s.
2760 <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>
2761 <tr><td colspan=
"4" class=
"doc" id=
"variableArrayType0"><pre>Matches C arrays with a specified size that is not an
2762 integer-constant-expression.
2771 matches
"int c[a[0]]"
2774 <!--END_DECL_MATCHERS -->
2777 <!-- ======================================================================= -->
2778 <h2 id=
"narrowing-matchers">Narrowing Matchers
</h2>
2779 <!-- ======================================================================= -->
2781 <p>Narrowing matchers match certain attributes on the current node, thus
2782 narrowing down the set of nodes of the current type to match on.
</p>
2784 <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless)
2785 which allow users to create more powerful match expressions.
</p>
2788 <tr style=
"text-align:left"><th>Return type
</th><th>Name
</th><th>Parameters
</th></tr>
2789 <!-- START_NARROWING_MATCHERS -->
2791 <tr><td>Matcher
<*
></td><td class=
"name" onclick=
"toggle('allOf0')"><a name=
"allOf0Anchor">allOf
</a></td><td>Matcher
<*
>, ..., Matcher
<*
></td></tr>
2792 <tr><td colspan=
"4" class=
"doc" id=
"allOf0"><pre>Matches if all given matchers match.
2794 Usable as: Any Matcher
2798 <tr><td>Matcher
<*
></td><td class=
"name" onclick=
"toggle('anyOf0')"><a name=
"anyOf0Anchor">anyOf
</a></td><td>Matcher
<*
>, ..., Matcher
<*
></td></tr>
2799 <tr><td colspan=
"4" class=
"doc" id=
"anyOf0"><pre>Matches if any of the given matchers matches.
2801 Usable as: Any Matcher
2805 <tr><td>Matcher
<*
></td><td class=
"name" onclick=
"toggle('anything0')"><a name=
"anything0Anchor">anything
</a></td><td></td></tr>
2806 <tr><td colspan=
"4" class=
"doc" id=
"anything0"><pre>Matches any node.
2808 Useful when another matcher requires a child matcher, but there's no
2809 additional constraint. This will often be used with an explicit conversion
2810 to an internal::Matcher
<> type such as TypeMatcher.
2812 Example: DeclarationMatcher(anything()) matches all declarations, e.g.,
2813 "int* p" and
"void f()" in
2817 Usable as: Any Matcher
2821 <tr><td><em>unspecified
</em></td><td class=
"name" onclick=
"toggle('mapAnyOf0')"><a name=
"mapAnyOf0Anchor">mapAnyOf
</a></td><td>nodeMatcherFunction...
</td></tr>
2822 <tr><td colspan=
"4" class=
"doc" id=
"mapAnyOf0"><pre>Matches any of the NodeMatchers with InnerMatchers nested within
2828 mapAnyOf(ifStmt, forStmt).with(
2829 hasCondition(cxxBoolLiteralExpr(equals(true)))
2831 matches the if and the for. It is equivalent to:
2832 auto trueCond = hasCondition(cxxBoolLiteralExpr(equals(true)));
2834 ifStmt(trueCond).bind(
"trueCond"),
2835 forStmt(trueCond).bind(
"trueCond")
2838 The with() chain-call accepts zero or more matchers which are combined
2839 as-if with allOf() in each of the node matchers.
2840 Usable as: Any Matcher
2844 <tr><td>Matcher
<*
></td><td class=
"name" onclick=
"toggle('unless0')"><a name=
"unless0Anchor">unless
</a></td><td>Matcher
<*
></td></tr>
2845 <tr><td colspan=
"4" class=
"doc" id=
"unless0"><pre>Matches if the provided matcher does not match.
2847 Example matches Y (matcher = cxxRecordDecl(unless(hasName(
"X"))))
2851 Usable as: Any Matcher
2855 <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>
2856 <tr><td colspan=
"4" class=
"doc" id=
"isImplicit1"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
2857 implicit default/copy constructors).
2861 <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>
2862 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOperatorName0"><pre>Matches operator expressions (binary or unary) that have any of the
2865 hasAnyOperatorName(
"+",
"-")
2867 anyOf(hasOperatorName(
"+"), hasOperatorName(
"-"))
2871 <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>
2872 <tr><td colspan=
"4" class=
"doc" id=
"hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or
2875 Example matches a || b (matcher = binaryOperator(hasOperatorName(
"||")))
2880 <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>
2881 <tr><td colspan=
"4" class=
"doc" id=
"isAssignmentOperator0"><pre>Matches all kinds of assignment operators.
2883 Example
1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
2887 Example
2: matches s1 = s2
2888 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
2889 struct S { S
& operator=(const S
&); };
2890 void x() { S s1, s2; s1 = s2; }
2894 <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>
2895 <tr><td colspan=
"4" class=
"doc" id=
"isComparisonOperator0"><pre>Matches comparison operators.
2897 Example
1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
2901 Example
2: matches s1
< s2
2902 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
2903 struct S { bool operator
<(const S
& other); };
2904 void x(S s1, S s2) { bool b1 = s1
< s2; }
2908 <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>
2909 <tr><td colspan=
"4" class=
"doc" id=
"isPrivate1"><pre>Matches private C++ declarations and C++ base specifers that specify private
2916 private: int c; // fieldDecl(isPrivate()) matches 'c'
2920 struct Derived1 : private Base {}; // matches 'Base'
2921 class Derived2 : Base {}; // matches 'Base'
2925 <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>
2926 <tr><td colspan=
"4" class=
"doc" id=
"isProtected1"><pre>Matches protected C++ declarations and C++ base specifers that specify
2927 protected inheritance.
2932 protected: int b; // fieldDecl(isProtected()) matches 'b'
2937 class Derived : protected Base {}; // matches 'Base'
2941 <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>
2942 <tr><td colspan=
"4" class=
"doc" id=
"isPublic1"><pre>Matches public C++ declarations and C++ base specifers that specify public
2947 public: int a; // fieldDecl(isPublic()) matches 'a'
2953 class Derived1 : public Base {}; // matches 'Base'
2954 struct Derived2 : Base {}; // matches 'Base'
2958 <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>
2959 <tr><td colspan=
"4" class=
"doc" id=
"isVirtual1"><pre>Matches declarations of virtual methods and C++ base specifers that specify
2960 virtual inheritance.
2965 virtual void x(); // matches x
2970 class DirectlyDerived : virtual Base {}; // matches Base
2971 class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
2973 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>>
2977 <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>
2978 <tr><td colspan=
"4" class=
"doc" id=
"equals5"><pre></pre></td></tr>
2981 <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>
2982 <tr><td colspan=
"4" class=
"doc" id=
"equals2"><pre>Matches literals that are equal to the given value of type ValueT.
2985 f('false,
3.14,
42);
2986 characterLiteral(equals(
0))
2987 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(
0))
2989 floatLiteral(equals(
3.14)) and floatLiteral(equals(
314e-2))
2991 integerLiteral(equals(
42))
2994 Note that you cannot directly match a negative numeric literal because the
2995 minus sign is not part of the literal: It is a unary operator whose operand
2996 is the positive numeric literal. Instead, you must use a unaryOperator()
2997 matcher to match the minus sign:
2999 unaryOperator(hasOperatorName(
"-"),
3000 hasUnaryOperand(integerLiteral(equals(
13))))
3002 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>>,
3003 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>>
3007 <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>
3008 <tr><td colspan=
"4" class=
"doc" id=
"equals11"><pre></pre></td></tr>
3011 <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>
3012 <tr><td colspan=
"4" class=
"doc" id=
"equals8"><pre></pre></td></tr>
3015 <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>
3016 <tr><td colspan=
"4" class=
"doc" id=
"isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler.
3026 cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
3030 <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>
3031 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has
3032 a specific number of arguments (including absent default arguments).
3034 Example matches f(
0,
0) (matcher = callExpr(argumentCountIs(
2)))
3035 void f(int x, int y);
3040 <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>
3041 <tr><td colspan=
"4" class=
"doc" id=
"isListInitialization0"><pre>Matches a constructor call expression which uses list initialization.
3045 <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>
3046 <tr><td colspan=
"4" class=
"doc" id=
"requiresZeroInitialization0"><pre>Matches a constructor call expression which requires
3047 zero initialization.
3051 struct point { double x; double y; };
3052 point pt[
2] = { {
1.0,
2.0 } };
3054 initListExpr(has(cxxConstructExpr(requiresZeroInitialization()))
3055 will match the implicit array filler for pt[
1].
3059 <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>
3060 <tr><td colspan=
"4" class=
"doc" id=
"isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors.
3065 S(const S
&); // #
2
3066 S(S
&&); // #
3
3068 cxxConstructorDecl(isCopyConstructor()) will match #
2, but not #
1 or #
3.
3072 <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>
3073 <tr><td colspan=
"4" class=
"doc" id=
"isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors.
3078 S(const S
&); // #
2
3079 S(S
&&); // #
3
3081 cxxConstructorDecl(isDefaultConstructor()) will match #
1, but not #
2 or #
3.
3085 <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>
3086 <tr><td colspan=
"4" class=
"doc" id=
"isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor.
3092 S(S
&&) : S() {} // #
3
3094 S::S() : S(
0) {} // #
4
3095 cxxConstructorDecl(isDelegatingConstructor()) will match #
3 and #
4, but not
3100 <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>
3101 <tr><td colspan=
"4" class=
"doc" id=
"isExplicit0"><pre>Matches constructor, conversion function, and deduction guide declarations
3102 that have an explicit specifier if this explicit specifier is resolved to
3106 template
<bool b
>
3109 explicit S(double); // #
2
3110 operator int(); // #
3
3111 explicit operator bool(); // #
4
3112 explicit(false) S(bool) // #
7
3113 explicit(true) S(char) // #
8
3114 explicit(b) S(S) // #
9
3116 S(int) -
> S
<true
> // #
5
3117 explicit S(double) -
> S
<false
> // #
6
3118 cxxConstructorDecl(isExplicit()) will match #
2 and #
8, but not #
1, #
7 or #
9.
3119 cxxConversionDecl(isExplicit()) will match #
4, but not #
3.
3120 cxxDeductionGuideDecl(isExplicit()) will match #
6, but not #
5.
3124 <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>
3125 <tr><td colspan=
"4" class=
"doc" id=
"isInheritingConstructor0"><pre></pre></td></tr>
3128 <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>
3129 <tr><td colspan=
"4" class=
"doc" id=
"isMoveConstructor0"><pre>Matches constructor declarations that are move constructors.
3134 S(const S
&); // #
2
3135 S(S
&&); // #
3
3137 cxxConstructorDecl(isMoveConstructor()) will match #
3, but not #
1 or #
2.
3141 <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>
3142 <tr><td colspan=
"4" class=
"doc" id=
"isExplicit1"><pre>Matches constructor, conversion function, and deduction guide declarations
3143 that have an explicit specifier if this explicit specifier is resolved to
3147 template
<bool b
>
3150 explicit S(double); // #
2
3151 operator int(); // #
3
3152 explicit operator bool(); // #
4
3153 explicit(false) S(bool) // #
7
3154 explicit(true) S(char) // #
8
3155 explicit(b) S(S) // #
9
3157 S(int) -
> S
<true
> // #
5
3158 explicit S(double) -
> S
<false
> // #
6
3159 cxxConstructorDecl(isExplicit()) will match #
2 and #
8, but not #
1, #
7 or #
9.
3160 cxxConversionDecl(isExplicit()) will match #
4, but not #
3.
3161 cxxDeductionGuideDecl(isExplicit()) will match #
6, but not #
5.
3165 <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>
3166 <tr><td colspan=
"4" class=
"doc" id=
"isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as
3167 opposed to a member.
3178 cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
3179 will match E(), but not match D(int).
3183 <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>
3184 <tr><td colspan=
"4" class=
"doc" id=
"isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as
3196 cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
3197 will match D(int), but not match E().
3201 <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>
3202 <tr><td colspan=
"4" class=
"doc" id=
"isWritten0"><pre>Matches a constructor initializer if it is explicitly written in
3203 code (as opposed to implicitly added by the compiler).
3208 Foo(int) : foo_(
"A") { }
3211 cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
3212 will match Foo(int), but not Foo()
3216 <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>
3217 <tr><td colspan=
"4" class=
"doc" id=
"isExplicit2"><pre>Matches constructor, conversion function, and deduction guide declarations
3218 that have an explicit specifier if this explicit specifier is resolved to
3222 template
<bool b
>
3225 explicit S(double); // #
2
3226 operator int(); // #
3
3227 explicit operator bool(); // #
4
3228 explicit(false) S(bool) // #
7
3229 explicit(true) S(char) // #
8
3230 explicit(b) S(S) // #
9
3232 S(int) -
> S
<true
> // #
5
3233 explicit S(double) -
> S
<false
> // #
6
3234 cxxConstructorDecl(isExplicit()) will match #
2 and #
8, but not #
1, #
7 or #
9.
3235 cxxConversionDecl(isExplicit()) will match #
4, but not #
3.
3236 cxxDeductionGuideDecl(isExplicit()) will match #
6, but not #
5.
3240 <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>
3241 <tr><td colspan=
"4" class=
"doc" id=
"hasMemberName0"><pre>Matches template-dependent, but known, member names.
3243 In template declarations, dependent members are not resolved and so can
3244 not be matched to particular named declarations.
3246 This matcher allows to match on the known name of members.
3249 template
<typename T
>
3253 template
<typename T
>
3258 cxxDependentScopeMemberExpr(hasMemberName(
"mem")) matches `s.mem()`
3262 <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>
3263 <tr><td colspan=
"4" class=
"doc" id=
"isArrow2"><pre>Matches member expressions that are called with '-
>' as opposed
3266 Member calls on the implicit this pointer match as called with '-
>'.
3270 void x() { this-
>x(); x(); Y y; y.x(); a; this-
>b; Y::b; }
3271 template
<class T
> void f() { this-
>f
<T
>(); f
<T
>(); }
3275 template
<class T
>
3277 void x() { this-
>m; }
3279 memberExpr(isArrow())
3280 matches this-
>x, x, y.x, a, this-
>b
3281 cxxDependentScopeMemberExpr(isArrow())
3283 unresolvedMemberExpr(isArrow())
3284 matches this-
>f
<T
>, f
<T
>
3288 <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>
3289 <tr><td colspan=
"4" class=
"doc" id=
"memberHasSameNameAsBoundNode0"><pre>Matches template-dependent, but known, member names against an already-bound
3292 In template declarations, dependent members are not resolved and so can
3293 not be matched to particular named declarations.
3295 This matcher allows to match on the name of already-bound VarDecl, FieldDecl
3296 and CXXMethodDecl nodes.
3299 template
<typename T
>
3303 template
<typename T
>
3310 cxxDependentScopeMemberExpr(
3311 hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
3312 hasDeclaration(classTemplateDecl(has(cxxRecordDecl(has(
3313 cxxMethodDecl(hasName(
"mem")).bind(
"templMem")
3316 memberHasSameNameAsBoundNode(
"templMem")
3319 first matches and binds the @c mem member of the @c S template, then
3320 compares its name to the usage in @c s.mem() in the @c x function template
3324 <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>
3325 <tr><td colspan=
"4" class=
"doc" id=
"isConst0"><pre>Matches if the given method declaration is const.
3333 cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
3337 <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>
3338 <tr><td colspan=
"4" class=
"doc" id=
"isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment
3343 A
&operator=(const A
&);
3344 A
&operator=(A
&&);
3347 cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not
3352 <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>
3353 <tr><td colspan=
"4" class=
"doc" id=
"isFinal1"><pre>Matches if the given method or class declaration is final.
3365 matches A and C::f, but not B, C, or B::f
3369 <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>
3370 <tr><td colspan=
"4" class=
"doc" id=
"isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment
3375 A
&operator=(const A
&);
3376 A
&operator=(A
&&);
3379 cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not
3384 <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>
3385 <tr><td colspan=
"4" class=
"doc" id=
"isOverride0"><pre>Matches if the given method declaration overrides another method.
3392 class B : public A {
3400 <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>
3401 <tr><td colspan=
"4" class=
"doc" id=
"isPure0"><pre>Matches if the given method declaration is pure.
3406 virtual void x() =
0;
3412 <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>
3413 <tr><td colspan=
"4" class=
"doc" id=
"isUserProvided0"><pre>Matches method declarations that are user-provided.
3418 S(const S
&) = default; // #
2
3419 S(S
&&) = delete; // #
3
3421 cxxConstructorDecl(isUserProvided()) will match #
1, but not #
2 or #
3.
3425 <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>
3426 <tr><td colspan=
"4" class=
"doc" id=
"isVirtual0"><pre>Matches declarations of virtual methods and C++ base specifers that specify
3427 virtual inheritance.
3432 virtual void x(); // matches x
3437 class DirectlyDerived : virtual Base {}; // matches Base
3438 class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
3440 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>>
3444 <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>
3445 <tr><td colspan=
"4" class=
"doc" id=
"isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit
"virtual".
3452 class B : public A {
3456 matches A::x but not B::x
3460 <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>
3461 <tr><td colspan=
"4" class=
"doc" id=
"isArray0"><pre>Matches array new expressions.
3464 MyClass *p1 = new MyClass[
10];
3465 cxxNewExpr(isArray())
3466 matches the expression 'new MyClass[
10]'.
3470 <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>
3471 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOperatorName1"><pre>Matches operator expressions (binary or unary) that have any of the
3474 hasAnyOperatorName(
"+",
"-")
3476 anyOf(hasOperatorName(
"+"), hasOperatorName(
"-"))
3480 <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>
3481 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOverloadedOperatorName0"><pre>Matches overloaded operator names.
3483 Matches overloaded operator names specified in strings without the
3484 "operator" prefix: e.g.
"<<".
3486 hasAnyOverloadedOperatorName(
"+",
"-")
3488 anyOf(hasOverloadedOperatorName(
"+"), hasOverloadedOperatorName(
"-"))
3492 <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>
3493 <tr><td colspan=
"4" class=
"doc" id=
"hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or
3496 Example matches a || b (matcher = binaryOperator(hasOperatorName(
"||")))
3501 <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>
3502 <tr><td colspan=
"4" class=
"doc" id=
"hasOverloadedOperatorName1"><pre>Matches overloaded operator names.
3504 Matches overloaded operator names specified in strings without the
3505 "operator" prefix: e.g.
"<<".
3508 class A { int operator*(); };
3509 const A
&operator
<<(const A
&a, const A
&b);
3511 a
<< a; //
<-- This matches
3513 cxxOperatorCallExpr(hasOverloadedOperatorName(
"<<"))) matches the
3515 cxxRecordDecl(hasMethod(hasOverloadedOperatorName(
"*")))
3516 matches the declaration of A.
3518 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>>
3522 <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>
3523 <tr><td colspan=
"4" class=
"doc" id=
"isAssignmentOperator1"><pre>Matches all kinds of assignment operators.
3525 Example
1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3529 Example
2: matches s1 = s2
3530 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3531 struct S { S
& operator=(const S
&); };
3532 void x() { S s1, s2; s1 = s2; }
3536 <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>
3537 <tr><td colspan=
"4" class=
"doc" id=
"isComparisonOperator1"><pre>Matches comparison operators.
3539 Example
1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3543 Example
2: matches s1
< s2
3544 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3545 struct S { bool operator
<(const S
& other); };
3546 void x(S s1, S s2) { bool b1 = s1
< s2; }
3550 <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>
3551 <tr><td colspan=
"4" class=
"doc" id=
"hasDefinition0"><pre>Matches a class declaration that is defined.
3553 Example matches x (matcher = cxxRecordDecl(hasDefinition()))
3559 <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>
3560 <tr><td colspan=
"4" class=
"doc" id=
"isDerivedFrom2"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
3564 <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>
3565 <tr><td colspan=
"4" class=
"doc" id=
"isDirectlyDerivedFrom2"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
3569 <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>
3570 <tr><td colspan=
"4" class=
"doc" id=
"isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or
3571 static member variable template instantiations.
3574 template
<typename T
> void A(T t) { }
3575 template
<> void A(int N) { }
3576 functionDecl(isExplicitTemplateSpecialization())
3577 matches the specialization A
<int
>().
3579 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>>
3583 <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>
3584 <tr><td colspan=
"4" class=
"doc" id=
"isFinal0"><pre>Matches if the given method or class declaration is final.
3596 matches A and C::f, but not B, C, or B::f
3600 <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>
3601 <tr><td colspan=
"4" class=
"doc" id=
"isLambda0"><pre>Matches the generated class of lambda expressions.
3606 cxxRecordDecl(isLambda()) matches the implicit class declaration of
3611 <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>
3612 <tr><td colspan=
"4" class=
"doc" id=
"isSameOrDerivedFrom2"><pre>Overloaded method as shortcut for
3613 isSameOrDerivedFrom(hasName(...)).
3617 <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>
3618 <tr><td colspan=
"4" class=
"doc" id=
"isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static
3619 member variable template instantiations.
3622 template
<typename T
> class X {}; class A {}; X
<A
> x;
3624 template
<typename T
> class X {}; class A {}; template class X
<A
>;
3626 template
<typename T
> class X {}; class A {}; extern template class X
<A
>;
3627 cxxRecordDecl(hasName(
"::X"), isTemplateInstantiation())
3628 matches the template instantiation of X
<A
>.
3631 template
<typename T
> class X {}; class A {};
3632 template
<> class X
<A
> {}; X
<A
> x;
3633 cxxRecordDecl(hasName(
"::X"), isTemplateInstantiation())
3634 does not match, as X
<A
> is an explicit template specialization.
3636 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>>
3640 <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>
3641 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOperatorName2"><pre>Matches operator expressions (binary or unary) that have any of the
3644 hasAnyOperatorName(
"+",
"-")
3646 anyOf(hasOperatorName(
"+"), hasOperatorName(
"-"))
3650 <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>
3651 <tr><td colspan=
"4" class=
"doc" id=
"hasOperatorName2"><pre>Matches the operator Name of operator expressions (binary or
3654 Example matches a || b (matcher = binaryOperator(hasOperatorName(
"||")))
3659 <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>
3660 <tr><td colspan=
"4" class=
"doc" id=
"isAssignmentOperator2"><pre>Matches all kinds of assignment operators.
3662 Example
1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3666 Example
2: matches s1 = s2
3667 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3668 struct S { S
& operator=(const S
&); };
3669 void x() { S s1, s2; s1 = s2; }
3673 <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>
3674 <tr><td colspan=
"4" class=
"doc" id=
"isComparisonOperator2"><pre>Matches comparison operators.
3676 Example
1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3680 Example
2: matches s1
< s2
3681 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3682 struct S { bool operator
<(const S
& other); };
3683 void x(S s1, S s2) { bool b1 = s1
< s2; }
3687 <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>
3688 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has
3689 a specific number of arguments (including absent default arguments).
3691 Example matches f(
0,
0) (matcher = callExpr(argumentCountIs(
2)))
3692 void f(int x, int y);
3697 <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>
3698 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has
3699 a specific number of arguments (including absent default arguments).
3701 Example matches f(
0,
0) (matcher = callExpr(argumentCountIs(
2)))
3702 void f(int x, int y);
3707 <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>
3708 <tr><td colspan=
"4" class=
"doc" id=
"usesADL0"><pre>Matches call expressions which were resolved using ADL.
3710 Example matches y(x) but not y(
42) or NS::y(x).
3721 NS::y(x); // Doesn't match
3722 y(
42); // Doesn't match
3724 y(x); // Found by both unqualified lookup and ADL, doesn't match
3729 <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>
3730 <tr><td colspan=
"4" class=
"doc" id=
"hasCastKind0"><pre>Matches casts that has a given cast kind.
3732 Example: matches the implicit cast around
0
3733 (matcher = castExpr(hasCastKind(CK_NullToPointer)))
3736 If the matcher is use from clang-query, CastKind parameter
3737 should be passed as a quoted string. e.g., hasCastKind(
"CK_NullToPointer").
3741 <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>
3742 <tr><td colspan=
"4" class=
"doc" id=
"equals4"><pre></pre></td></tr>
3745 <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>
3746 <tr><td colspan=
"4" class=
"doc" id=
"equals3"><pre>Matches literals that are equal to the given value of type ValueT.
3749 f('false,
3.14,
42);
3750 characterLiteral(equals(
0))
3751 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(
0))
3753 floatLiteral(equals(
3.14)) and floatLiteral(equals(
314e-2))
3755 integerLiteral(equals(
42))
3758 Note that you cannot directly match a negative numeric literal because the
3759 minus sign is not part of the literal: It is a unary operator whose operand
3760 is the positive numeric literal. Instead, you must use a unaryOperator()
3761 matcher to match the minus sign:
3763 unaryOperator(hasOperatorName(
"-"),
3764 hasUnaryOperand(integerLiteral(equals(
13))))
3766 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>>,
3767 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>>
3771 <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>
3772 <tr><td colspan=
"4" class=
"doc" id=
"equals10"><pre></pre></td></tr>
3775 <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>
3776 <tr><td colspan=
"4" class=
"doc" id=
"equals7"><pre></pre></td></tr>
3779 <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>
3780 <tr><td colspan=
"4" class=
"doc" id=
"templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N.
3783 template
<typename T
> struct C {};
3785 classTemplateSpecializationDecl(templateArgumentCountIs(
1))
3786 matches C
<int
>.
3790 <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>
3791 <tr><td colspan=
"4" class=
"doc" id=
"statementCountIs0"><pre>Checks that a compound statement contains a specific number of
3796 compoundStmt(statementCountIs(
0)))
3798 but does not match the outer compound statement.
3802 <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>
3803 <tr><td colspan=
"4" class=
"doc" id=
"hasSize0"><pre>Matches nodes that have the specified size.
3810 wchar_t *ws = L
"abcd";
3812 constantArrayType(hasSize(
42))
3813 matches
"int a[42]" and
"int b[2 * 21]"
3814 stringLiteral(hasSize(
4))
3815 matches
"abcd", L
"abcd"
3819 <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>
3820 <tr><td colspan=
"4" class=
"doc" id=
"declCountIs0"><pre>Matches declaration statements that contain a specific number of
3828 matches 'int a, b;' and 'int d =
2, e;', but not 'int c;'.
3832 <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>
3833 <tr><td colspan=
"4" class=
"doc" id=
"equalsBoundNode1"><pre>Matches if a node equals a previously bound node.
3835 Matches a node if it equals the node previously bound to ID.
3838 class X { int a; int b; };
3840 has(fieldDecl(hasName(
"a"), hasType(type().bind(
"t")))),
3841 has(fieldDecl(hasName(
"b"), hasType(type(equalsBoundNode(
"t"))))))
3842 matches the class X, as a and b have the same type.
3844 Note that when multiple matches are involved via forEach* matchers,
3845 equalsBoundNodes acts as a filter.
3848 forEachDescendant(varDecl().bind(
"d")),
3849 forEachDescendant(declRefExpr(to(decl(equalsBoundNode(
"d"))))))
3850 will trigger a match for each combination of variable declaration
3851 and reference to that variable declaration within a compound statement.
3855 <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>
3856 <tr><td colspan=
"4" class=
"doc" id=
"equalsNode0"><pre>Matches if a node equals another node.
3858 Decl has pointer identity in the AST.
3862 <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>
3863 <tr><td colspan=
"4" class=
"doc" id=
"hasAttr0"><pre>Matches declaration that has a given attribute.
3866 __attribute__((device)) void f() { ... }
3867 decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
3868 f. If the matcher is used from clang-query, attr::Kind parameter should be
3869 passed as a quoted string. e.g., hasAttr(
"attr::CUDADevice").
3873 <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>
3874 <tr><td colspan=
"4" class=
"doc" id=
"isExpandedFromMacro0"><pre>Matches statements that are (transitively) expanded from the named macro.
3875 Does not match if only part of the statement is expanded from that macro or
3876 if different parts of the statement are expanded from different
3877 appearances of the macro.
3881 <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>
3882 <tr><td colspan=
"4" class=
"doc" id=
"isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is
3883 partially matching a given regex.
3885 Example matches Y but not X
3886 (matcher = cxxRecordDecl(isExpansionInFileMatching(
"AST.*"))
3887 #include
"ASTMatcher.h"
3892 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>>
3894 If the matcher is used in clang-query, RegexFlags parameter
3895 should be passed as a quoted string. e.g:
"NoFlags".
3896 Flags can be combined with '|' example
"IgnoreCase | BasicRegex"
3900 <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>
3901 <tr><td colspan=
"4" class=
"doc" id=
"isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file.
3903 Example matches X but not Y
3904 (matcher = cxxRecordDecl(isExpansionInMainFile())
3905 #include
<Y.h
>
3910 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>>
3914 <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>
3915 <tr><td colspan=
"4" class=
"doc" id=
"isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files.
3917 Example matches Y but not X
3918 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
3919 #include
<SystemHeader.h
>
3924 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>>
3928 <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>
3929 <tr><td colspan=
"4" class=
"doc" id=
"isImplicit0"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
3930 implicit default/copy constructors).
3934 <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>
3935 <tr><td colspan=
"4" class=
"doc" id=
"isInStdNamespace0"><pre>Matches declarations in the namespace `std`, but not in nested namespaces.
3946 inline namespace __1 {
3947 class vector {}; // #
1
3948 namespace experimental {
3953 cxxRecordDecl(hasName(
"vector"), isInStdNamespace()) will match only #
1.
3957 <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>
3958 <tr><td colspan=
"4" class=
"doc" id=
"isInstantiated0"><pre>Matches declarations that are template instantiations or are inside
3959 template instantiations.
3962 template
<typename T
> void A(T t) { T i; }
3965 functionDecl(isInstantiated())
3966 matches 'A(int) {...};' and 'A(unsigned) {...}'.
3970 <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>
3971 <tr><td colspan=
"4" class=
"doc" id=
"isPrivate0"><pre>Matches private C++ declarations and C++ base specifers that specify private
3978 private: int c; // fieldDecl(isPrivate()) matches 'c'
3982 struct Derived1 : private Base {}; // matches 'Base'
3983 class Derived2 : Base {}; // matches 'Base'
3987 <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>
3988 <tr><td colspan=
"4" class=
"doc" id=
"isProtected0"><pre>Matches protected C++ declarations and C++ base specifers that specify
3989 protected inheritance.
3994 protected: int b; // fieldDecl(isProtected()) matches 'b'
3999 class Derived : protected Base {}; // matches 'Base'
4003 <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>
4004 <tr><td colspan=
"4" class=
"doc" id=
"isPublic0"><pre>Matches public C++ declarations and C++ base specifers that specify public
4009 public: int a; // fieldDecl(isPublic()) matches 'a'
4015 class Derived1 : public Base {}; // matches 'Base'
4016 struct Derived2 : Base {}; // matches 'Base'
4020 <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>
4021 <tr><td colspan=
"4" class=
"doc" id=
"designatorCountIs0"><pre>Matches designated initializer expressions that contain
4022 a specific number of designators.
4025 point ptarray[
10] = { [
2].y =
1.0, [
0].x =
1.0 };
4026 point ptarray2[
10] = { [
2].y =
1.0, [
2].x =
0.0, [
0].x =
1.0 };
4027 designatorCountIs(
2)
4028 matches '{ [
2].y =
1.0, [
0].x =
1.0 }',
4029 but not '{ [
2].y =
1.0, [
2].x =
0.0, [
0].x =
1.0 }'.
4033 <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>
4034 <tr><td colspan=
"4" class=
"doc" id=
"isScoped0"><pre>Matches C++
11 scoped enum declaration.
4036 Example matches Y (matcher = enumDecl(isScoped()))
4042 <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>
4043 <tr><td colspan=
"4" class=
"doc" id=
"isInstantiationDependent0"><pre>Matches expressions that are instantiation-dependent even if it is
4044 neither type- nor value-dependent.
4046 In the following example, the expression sizeof(sizeof(T() + T()))
4047 is instantiation-dependent (since it involves a template parameter T),
4048 but is neither type- nor value-dependent, since the type of the inner
4049 sizeof is known (std::size_t) and therefore the size of the outer
4051 template
<typename T
>
4052 void f(T x, T y) { sizeof(sizeof(T() + T()); }
4053 expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T())
4057 <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>
4058 <tr><td colspan=
"4" class=
"doc" id=
"isTypeDependent0"><pre>Matches expressions that are type-dependent because the template type
4059 is not yet instantiated.
4061 For example, the expressions
"x" and
"x + y" are type-dependent in
4062 the following code, but
"y" is not type-dependent:
4063 template
<typename T
>
4064 void add(T x, int y) {
4067 expr(isTypeDependent()) matches x + y
4071 <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>
4072 <tr><td colspan=
"4" class=
"doc" id=
"isValueDependent0"><pre>Matches expression that are value-dependent because they contain a
4073 non-type template parameter.
4075 For example, the array bound of
"Chars" in the following example is
4077 template
<int Size
> int f() { return Size; }
4078 expr(isValueDependent()) matches return Size
4082 <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>
4083 <tr><td colspan=
"4" class=
"doc" id=
"nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as
4084 GNU's __null, C++
11's nullptr, or C's NULL macro.
4089 void *v3 = __null; // GNU extension
4090 char *cp = (char *)
0;
4093 expr(nullPointerConstant())
4094 matches the initializer for v1, v2, v3, cp, and ip. Does not match the
4099 <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>
4100 <tr><td colspan=
"4" class=
"doc" id=
"hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified
4109 fieldDecl(hasBitWidth(
2))
4110 matches 'int a;' and 'int c;' but not 'int b;'.
4114 <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>
4115 <tr><td colspan=
"4" class=
"doc" id=
"isBitField0"><pre>Matches non-static data members that are bit-fields.
4122 fieldDecl(isBitField())
4123 matches 'int a;' but not 'int b;'.
4127 <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>
4128 <tr><td colspan=
"4" class=
"doc" id=
"equals1"><pre>Matches literals that are equal to the given value of type ValueT.
4131 f('false,
3.14,
42);
4132 characterLiteral(equals(
0))
4133 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(
0))
4135 floatLiteral(equals(
3.14)) and floatLiteral(equals(
314e-2))
4137 integerLiteral(equals(
42))
4140 Note that you cannot directly match a negative numeric literal because the
4141 minus sign is not part of the literal: It is a unary operator whose operand
4142 is the positive numeric literal. Instead, you must use a unaryOperator()
4143 matcher to match the minus sign:
4145 unaryOperator(hasOperatorName(
"-"),
4146 hasUnaryOperand(integerLiteral(equals(
13))))
4148 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>>,
4149 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>>
4153 <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>
4154 <tr><td colspan=
"4" class=
"doc" id=
"equals12"><pre></pre></td></tr>
4157 <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>
4158 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOverloadedOperatorName1"><pre>Matches overloaded operator names.
4160 Matches overloaded operator names specified in strings without the
4161 "operator" prefix: e.g.
"<<".
4163 hasAnyOverloadedOperatorName(
"+",
"-")
4165 anyOf(hasOverloadedOperatorName(
"+"), hasOverloadedOperatorName(
"-"))
4169 <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>
4170 <tr><td colspan=
"4" class=
"doc" id=
"hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification.
4175 void h() noexcept(true);
4176 void i() noexcept(false);
4178 void k() throw(int);
4179 void l() throw(...);
4180 functionDecl(hasDynamicExceptionSpec()) and
4181 functionProtoType(hasDynamicExceptionSpec())
4182 match the declarations of j, k, and l, but not f, g, h, or i.
4186 <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>
4187 <tr><td colspan=
"4" class=
"doc" id=
"hasOverloadedOperatorName0"><pre>Matches overloaded operator names.
4189 Matches overloaded operator names specified in strings without the
4190 "operator" prefix: e.g.
"<<".
4193 class A { int operator*(); };
4194 const A
&operator
<<(const A
&a, const A
&b);
4196 a
<< a; //
<-- This matches
4198 cxxOperatorCallExpr(hasOverloadedOperatorName(
"<<"))) matches the
4200 cxxRecordDecl(hasMethod(hasOverloadedOperatorName(
"*")))
4201 matches the declaration of A.
4203 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>>
4207 <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>
4208 <tr><td colspan=
"4" class=
"doc" id=
"hasTrailingReturn0"><pre>Matches a function declared with a trailing return type.
4210 Example matches Y (matcher = functionDecl(hasTrailingReturn()))
4212 auto Y() -
> int {}
4216 <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>
4217 <tr><td colspan=
"4" class=
"doc" id=
"isConsteval0"><pre>Matches consteval function declarations and if consteval/if ! consteval
4222 void b() { if consteval {} }
4223 void c() { if ! consteval {} }
4224 void d() { if ! consteval {} else {} }
4225 functionDecl(isConsteval())
4226 matches the declaration of
"int a()".
4227 ifStmt(isConsteval())
4228 matches the if statement in
"void b()",
"void c()",
"void d()".
4232 <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>
4233 <tr><td colspan=
"4" class=
"doc" id=
"isConstexpr1"><pre>Matches constexpr variable and function declarations,
4237 constexpr int foo =
42;
4238 constexpr int bar();
4239 void baz() { if constexpr(
1 > 0) {} }
4240 varDecl(isConstexpr())
4241 matches the declaration of foo.
4242 functionDecl(isConstexpr())
4243 matches the declaration of bar.
4244 ifStmt(isConstexpr())
4245 matches the if statement in baz.
4249 <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>
4250 <tr><td colspan=
"4" class=
"doc" id=
"isDefaulted0"><pre>Matches defaulted function declarations.
4254 class B { ~B() = default; };
4255 functionDecl(isDefaulted())
4256 matches the declaration of ~B, but not ~A.
4260 <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>
4261 <tr><td colspan=
"4" class=
"doc" id=
"isDefinition3"><pre>Matches if a declaration has a body attached.
4263 Example matches A, va, fa
4265 class B; // Doesn't match, as it has no body.
4267 extern int vb; // Doesn't match, as it doesn't define the variable.
4269 void fb(); // Doesn't match, as it has no body.
4271 - (void)ma; // Doesn't match, interface is declaration.
4277 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>>,
4278 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl
</a>>
4282 <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>
4283 <tr><td colspan=
"4" class=
"doc" id=
"isDeleted0"><pre>Matches deleted function declarations.
4287 void DeletedFunc() = delete;
4288 functionDecl(isDeleted())
4289 matches the declaration of DeletedFunc, but not Func.
4293 <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>
4294 <tr><td colspan=
"4" class=
"doc" id=
"isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or
4295 static member variable template instantiations.
4298 template
<typename T
> void A(T t) { }
4299 template
<> void A(int N) { }
4300 functionDecl(isExplicitTemplateSpecialization())
4301 matches the specialization A
<int
>().
4303 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>>
4307 <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>
4308 <tr><td colspan=
"4" class=
"doc" id=
"isExternC0"><pre>Matches extern
"C" function or variable declarations.
4311 extern
"C" void f() {}
4312 extern
"C" { void g() {} }
4314 extern
"C" int x =
1;
4315 extern
"C" int y =
2;
4317 functionDecl(isExternC())
4318 matches the declaration of f and g, but not the declaration of h.
4319 varDecl(isExternC())
4320 matches the declaration of x and y, but not the declaration of z.
4324 <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>
4325 <tr><td colspan=
"4" class=
"doc" id=
"isInline1"><pre>Matches functions, variables and namespace declarations that are marked with
4332 inline namespace m {}
4335 functionDecl(isInline()) will match ::f().
4336 namespaceDecl(isInline()) will match n::m.
4337 varDecl(isInline()) will match Foo;
4341 <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>
4342 <tr><td colspan=
"4" class=
"doc" id=
"isMain0"><pre>Determines whether the function is
"main", which is the entry point
4343 into an executable program.
4347 <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>
4348 <tr><td colspan=
"4" class=
"doc" id=
"isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute.
4352 [[noreturn]] void a();
4353 __attribute__((noreturn)) void b();
4354 struct c { [[noreturn]] c(); };
4355 functionDecl(isNoReturn())
4356 matches all of those except
4361 <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>
4362 <tr><td colspan=
"4" class=
"doc" id=
"isNoThrow0"><pre>Matches functions that have a non-throwing exception specification.
4368 void i() throw(int);
4369 void j() noexcept(false);
4370 functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
4371 match the declarations of g, and h, but not f, i or j.
4375 <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>
4376 <tr><td colspan=
"4" class=
"doc" id=
"isStaticStorageClass0"><pre>Matches variable/function declarations that have
"static" storage
4377 class specifier (
"static" keyword) written in the source.
4384 functionDecl(isStaticStorageClass())
4385 matches the function declaration f.
4386 varDecl(isStaticStorageClass())
4387 matches the variable declaration i.
4391 <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>
4392 <tr><td colspan=
"4" class=
"doc" id=
"isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static
4393 member variable template instantiations.
4396 template
<typename T
> class X {}; class A {}; X
<A
> x;
4398 template
<typename T
> class X {}; class A {}; template class X
<A
>;
4400 template
<typename T
> class X {}; class A {}; extern template class X
<A
>;
4401 cxxRecordDecl(hasName(
"::X"), isTemplateInstantiation())
4402 matches the template instantiation of X
<A
>.
4405 template
<typename T
> class X {}; class A {};
4406 template
<> class X
<A
> {}; X
<A
> x;
4407 cxxRecordDecl(hasName(
"::X"), isTemplateInstantiation())
4408 does not match, as X
<A
> is an explicit template specialization.
4410 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>>
4414 <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>
4415 <tr><td colspan=
"4" class=
"doc" id=
"isVariadic0"><pre>Matches if a function declaration is variadic.
4417 Example matches f, but not g or h. The function i will not match, even when
4421 template
<typename... Ts
> void h(Ts...);
4426 <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>
4427 <tr><td colspan=
"4" class=
"doc" id=
"isWeak0"><pre>Matches weak function declarations.
4430 void foo() __attribute__((__weakref__(
"__foo")));
4432 functionDecl(isWeak())
4433 matches the weak declaration
"foo", but not
"bar".
4437 <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>
4438 <tr><td colspan=
"4" class=
"doc" id=
"parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
4439 specific parameter count.
4443 void g(int i, int j) {}
4444 void h(int i, int j);
4446 void k(int x, int y, int z, ...);
4447 functionDecl(parameterCountIs(
2))
4449 functionProtoType(parameterCountIs(
2))
4451 functionProtoType(parameterCountIs(
3))
4456 <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>
4457 <tr><td colspan=
"4" class=
"doc" id=
"hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification.
4462 void h() noexcept(true);
4463 void i() noexcept(false);
4465 void k() throw(int);
4466 void l() throw(...);
4467 functionDecl(hasDynamicExceptionSpec()) and
4468 functionProtoType(hasDynamicExceptionSpec())
4469 match the declarations of j, k, and l, but not f, g, h, or i.
4473 <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>
4474 <tr><td colspan=
"4" class=
"doc" id=
"isNoThrow1"><pre>Matches functions that have a non-throwing exception specification.
4480 void i() throw(int);
4481 void j() noexcept(false);
4482 functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
4483 match the declarations of g, and h, but not f, i or j.
4487 <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>
4488 <tr><td colspan=
"4" class=
"doc" id=
"parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
4489 specific parameter count.
4493 void g(int i, int j) {}
4494 void h(int i, int j);
4496 void k(int x, int y, int z, ...);
4497 functionDecl(parameterCountIs(
2))
4499 functionProtoType(parameterCountIs(
2))
4501 functionProtoType(parameterCountIs(
3))
4506 <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>
4507 <tr><td colspan=
"4" class=
"doc" id=
"isConsteval1"><pre>Matches consteval function declarations and if consteval/if ! consteval
4512 void b() { if consteval {} }
4513 void c() { if ! consteval {} }
4514 void d() { if ! consteval {} else {} }
4515 functionDecl(isConsteval())
4516 matches the declaration of
"int a()".
4517 ifStmt(isConsteval())
4518 matches the if statement in
"void b()",
"void c()",
"void d()".
4522 <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>
4523 <tr><td colspan=
"4" class=
"doc" id=
"isConstexpr2"><pre>Matches constexpr variable and function declarations,
4527 constexpr int foo =
42;
4528 constexpr int bar();
4529 void baz() { if constexpr(
1 > 0) {} }
4530 varDecl(isConstexpr())
4531 matches the declaration of foo.
4532 functionDecl(isConstexpr())
4533 matches the declaration of bar.
4534 ifStmt(isConstexpr())
4535 matches the if statement in baz.
4539 <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>
4540 <tr><td colspan=
"4" class=
"doc" id=
"equals6"><pre></pre></td></tr>
4543 <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>
4544 <tr><td colspan=
"4" class=
"doc" id=
"equals0"><pre>Matches literals that are equal to the given value of type ValueT.
4547 f('false,
3.14,
42);
4548 characterLiteral(equals(
0))
4549 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(
0))
4551 floatLiteral(equals(
3.14)) and floatLiteral(equals(
314e-2))
4553 integerLiteral(equals(
42))
4556 Note that you cannot directly match a negative numeric literal because the
4557 minus sign is not part of the literal: It is a unary operator whose operand
4558 is the positive numeric literal. Instead, you must use a unaryOperator()
4559 matcher to match the minus sign:
4561 unaryOperator(hasOperatorName(
"-"),
4562 hasUnaryOperand(integerLiteral(equals(
13))))
4564 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>>,
4565 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>>
4569 <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>
4570 <tr><td colspan=
"4" class=
"doc" id=
"equals13"><pre></pre></td></tr>
4573 <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>
4574 <tr><td colspan=
"4" class=
"doc" id=
"equals9"><pre></pre></td></tr>
4577 <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>
4578 <tr><td colspan=
"4" class=
"doc" id=
"capturesThis0"><pre>Matches a `LambdaCapture` that refers to 'this'.
4584 auto l = [this]() { return cc; };
4588 lambdaExpr(hasAnyCapture(lambdaCapture(capturesThis())))
4589 matches `[this]() { return cc; }`.
4593 <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>
4594 <tr><td colspan=
"4" class=
"doc" id=
"isImplicit2"><pre>Matches an entity that has been implicitly added by the compiler (e.g.
4595 implicit default/copy constructors).
4599 <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>
4600 <tr><td colspan=
"4" class=
"doc" id=
"isArrow0"><pre>Matches member expressions that are called with '-
>' as opposed
4603 Member calls on the implicit this pointer match as called with '-
>'.
4607 void x() { this-
>x(); x(); Y y; y.x(); a; this-
>b; Y::b; }
4608 template
<class T
> void f() { this-
>f
<T
>(); f
<T
>(); }
4612 template
<class T
>
4614 void x() { this-
>m; }
4616 memberExpr(isArrow())
4617 matches this-
>x, x, y.x, a, this-
>b
4618 cxxDependentScopeMemberExpr(isArrow())
4620 unresolvedMemberExpr(isArrow())
4621 matches this-
>f
<T
>, f
<T
>
4625 <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>
4626 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names.
4628 This matcher is only provided as a performance optimization of hasName.
4630 is equivalent to, but faster than
4631 anyOf(hasName(a), hasName(b), hasName(c))
4635 <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>
4636 <tr><td colspan=
"4" class=
"doc" id=
"hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage.
4638 Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))
4645 Example matches f() because it has external formal linkage despite being
4646 unique to the translation unit as though it has internal likage
4647 (matcher = functionDecl(hasExternalFormalLinkage()))
4655 <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>
4656 <tr><td colspan=
"4" class=
"doc" id=
"hasName0"><pre>Matches NamedDecl nodes that have the specified name.
4658 Supports specifying enclosing namespaces or classes by prefixing the name
4659 with '
<enclosing
>::'.
4660 Does not match typedefs of an underlying type with the given name.
4662 Example matches X (Name ==
"X")
4665 Example matches X (Name is one of
"::a::b::X",
"a::b::X",
"b::X",
"X")
4666 namespace a { namespace b { class X; } }
4670 <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>
4671 <tr><td colspan=
"4" class=
"doc" id=
"matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain
4672 a substring matched by the given RegExp.
4674 Supports specifying enclosing namespaces or classes by
4675 prefixing the name with '
<enclosing
>::'. Does not match typedefs
4676 of an underlying type with the given name.
4678 Example matches X (regexp ==
"::X")
4681 Example matches X (regexp is one of
"::X",
"^foo::.*X", among others)
4682 namespace foo { namespace bar { class X; } }
4684 If the matcher is used in clang-query, RegexFlags parameter
4685 should be passed as a quoted string. e.g:
"NoFlags".
4686 Flags can be combined with '|' example
"IgnoreCase | BasicRegex"
4690 <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>
4691 <tr><td colspan=
"4" class=
"doc" id=
"isAnonymous0"><pre>Matches anonymous namespace declarations.
4697 namespaceDecl(isAnonymous()) will match #
1 but not ::n.
4701 <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>
4702 <tr><td colspan=
"4" class=
"doc" id=
"isInline0"><pre>Matches functions, variables and namespace declarations that are marked with
4709 inline namespace m {}
4712 functionDecl(isInline()) will match ::f().
4713 namespaceDecl(isInline()) will match n::m.
4714 varDecl(isInline()) will match Foo;
4718 <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>
4719 <tr><td colspan=
"4" class=
"doc" id=
"isFirstPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``firstprivate`` kind
4724 #pragma omp parallel
4725 #pragma omp parallel default(none)
4726 #pragma omp parallel default(shared)
4727 #pragma omp parallel default(firstprivate)
4729 ``ompDefaultClause(isFirstPrivateKind())`` matches only
4730 ``default(firstprivate)``.
4734 <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>
4735 <tr><td colspan=
"4" class=
"doc" id=
"isNoneKind0"><pre>Matches if the OpenMP ``default`` clause has ``none`` kind specified.
4739 #pragma omp parallel
4740 #pragma omp parallel default(none)
4741 #pragma omp parallel default(shared)
4742 #pragma omp parallel default(firstprivate)
4744 ``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
4748 <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>
4749 <tr><td colspan=
"4" class=
"doc" id=
"isSharedKind0"><pre>Matches if the OpenMP ``default`` clause has ``shared`` kind specified.
4753 #pragma omp parallel
4754 #pragma omp parallel default(none)
4755 #pragma omp parallel default(shared)
4756 #pragma omp parallel default(firstprivate)
4758 ``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``.
4762 <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>
4763 <tr><td colspan=
"4" class=
"doc" id=
"isAllowedToContainClauseKind0"><pre>Matches if the OpenMP directive is allowed to contain the specified OpenMP
4768 #pragma omp parallel
4769 #pragma omp parallel for
4772 `ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches
4773 ``omp parallel`` and ``omp parallel for``.
4775 If the matcher is use from clang-query, ``OpenMPClauseKind`` parameter
4776 should be passed as a quoted string. e.g.,
4777 ``isAllowedToContainClauseKind(
"OMPC_default").``
4781 <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>
4782 <tr><td colspan=
"4" class=
"doc" id=
"isStandaloneDirective0"><pre>Matches standalone OpenMP directives,
4783 i.e., directives that can't have a structured block.
4787 #pragma omp parallel
4789 #pragma omp taskyield
4791 ``ompExecutableDirective(isStandaloneDirective()))`` matches
4796 <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>
4797 <tr><td colspan=
"4" class=
"doc" id=
"isDerivedFrom3"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
4801 <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>
4802 <tr><td colspan=
"4" class=
"doc" id=
"isDirectlyDerivedFrom3"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
4806 <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>
4807 <tr><td colspan=
"4" class=
"doc" id=
"isSameOrDerivedFrom3"><pre>Overloaded method as shortcut for
4808 isSameOrDerivedFrom(hasName(...)).
4812 <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>
4813 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountIs3"><pre>Checks that a call expression or a constructor call expression has
4814 a specific number of arguments (including absent default arguments).
4816 Example matches f(
0,
0) (matcher = callExpr(argumentCountIs(
2)))
4817 void f(int x, int y);
4822 <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>
4823 <tr><td colspan=
"4" class=
"doc" id=
"hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the
4824 Selector.getAsString()
4826 matcher = objCMessageExpr(hasSelector(
"methodA:",
"methodB:"));
4827 matches both of the expressions below:
4828 [myObj methodA:argA];
4829 [myObj methodB:argB];
4833 <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>
4834 <tr><td colspan=
"4" class=
"doc" id=
"hasKeywordSelector0"><pre>Matches when the selector is a keyword selector
4836 objCMessageExpr(hasKeywordSelector()) matches the generated setFrame
4837 message expression in
4839 UIWebView *webView = ...;
4840 CGRect bodyFrame = webView.frame;
4841 bodyFrame.size.height = self.bodyContentHeight;
4842 webView.frame = bodyFrame;
4843 // ^---- matches here
4847 <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>
4848 <tr><td colspan=
"4" class=
"doc" id=
"hasNullSelector0"><pre>Matches when the selector is the empty selector
4850 Matches only when the selector of the objCMessageExpr is NULL. This may
4851 represent an error condition in the tree!
4855 <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>
4856 <tr><td colspan=
"4" class=
"doc" id=
"hasSelector0"><pre>Matches when BaseName == Selector.getAsString()
4858 matcher = objCMessageExpr(hasSelector(
"loadHTMLString:baseURL:"));
4859 matches the outer message expr in the code below, but NOT the message
4860 invocation for self.bodyView.
4861 [self.bodyView loadHTMLString:html baseURL:NULL];
4865 <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>
4866 <tr><td colspan=
"4" class=
"doc" id=
"hasUnarySelector0"><pre>Matches when the selector is a Unary Selector
4868 matcher = objCMessageExpr(matchesSelector(hasUnarySelector());
4869 matches self.bodyView in the code below, but NOT the outer message
4870 invocation of
"loadHTMLString:baseURL:".
4871 [self.bodyView loadHTMLString:html baseURL:NULL];
4875 <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>
4876 <tr><td colspan=
"4" class=
"doc" id=
"isClassMessage0"><pre>Returns true when the Objective-C message is sent to a class.
4879 matcher = objcMessageExpr(isClassMessage())
4881 [NSString stringWithFormat:@
"format"];
4883 NSString *x = @
"hello";
4884 [x containsString:@
"h"];
4888 <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>
4889 <tr><td colspan=
"4" class=
"doc" id=
"isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance.
4892 matcher = objcMessageExpr(isInstanceMessage())
4894 NSString *x = @
"hello";
4895 [x containsString:@
"h"];
4897 [NSString stringWithFormat:@
"format"];
4901 <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>
4902 <tr><td colspan=
"4" class=
"doc" id=
"matchesSelector0"><pre>Matches ObjC selectors whose name contains
4903 a substring matched by the given RegExp.
4904 matcher = objCMessageExpr(matchesSelector(
"loadHTMLStringmatches the outer message expr in the code below, but NOT the message
4905 invocation for self.bodyView.
4906 [self.bodyView loadHTMLString:html baseURL:NULL];
4908 If the matcher is used in clang-query, RegexFlags parameter
4909 should be passed as a quoted string. e.g: "NoFlags
".
4910 Flags can be combined with '|' example "IgnoreCase | BasicRegex
"
4914 <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>
4915 <tr><td colspan="4" class="doc
" id="numSelectorArgs0
"><pre>Matches when the selector has the specified number of arguments
4917 matcher = objCMessageExpr(numSelectorArgs(0));
4918 matches self.bodyView in the code below
4920 matcher = objCMessageExpr(numSelectorArgs(2));
4921 matches the invocation of "loadHTMLString:baseURL:
" but not that
4923 [self.bodyView loadHTMLString:html baseURL:NULL];
4927 <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>
4928 <tr><td colspan="4" class="doc
" id="isClassMethod0
"><pre>Returns true when the Objective-C method declaration is a class method.
4931 matcher = objcMethodDecl(isClassMethod())
4933 @interface I + (void)foo; @end
4935 @interface I - (void)bar; @end
4939 <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>
4940 <tr><td colspan="4" class="doc
" id="isDefinition2
"><pre>Matches if a declaration has a body attached.
4942 Example matches A, va, fa
4944 class B; // Doesn't match, as it has no body.
4946 extern int vb; // Doesn't match, as it doesn't define the variable.
4948 void fb(); // Doesn't match, as it has no body.
4950 - (void)ma; // Doesn't match, interface is declaration.
4956 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>>,
4957 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html
">ObjCMethodDecl</a>>
4961 <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>
4962 <tr><td colspan="4" class="doc
" id="isInstanceMethod0
"><pre>Returns true when the Objective-C method declaration is an instance method.
4965 matcher = objcMethodDecl(isInstanceMethod())
4967 @interface I - (void)bar; @end
4969 @interface I + (void)foo; @end
4973 <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>
4974 <tr><td colspan="4" class="doc
" id="hasDefaultArgument0
"><pre>Matches a declaration that has default arguments.
4976 Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
4978 void y(int val = 0) {}
4980 Deprecated. Use hasInitializer() instead to be able to
4981 match on the contents of the default argument. For example:
4983 void x(int val = 7) {}
4984 void y(int val = 42) {}
4985 parmVarDecl(hasInitializer(integerLiteral(equals(42))))
4986 matches the parameter of y
4989 parmVarDecl(hasInitializer(anything()))
4990 is equivalent to parmVarDecl(hasDefaultArgument()).
4994 <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>
4995 <tr><td colspan="4" class="doc
" id="isAtPosition0
"><pre>Matches the ParmVarDecl nodes that are at the N'th position in the parameter
4996 list. The parameter list could be that of either a block, function, or
5002 void f(int a, int b, int c) {
5005 ``parmVarDecl(isAtPosition(0))`` matches ``int a``.
5007 ``parmVarDecl(isAtPosition(1))`` matches ``int b``.
5011 <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>
5012 <tr><td colspan="4" class="doc
" id="asString0
"><pre>Matches if the matched type is represented by the given string.
5015 class Y { public: void x(); };
5016 void z() { Y* y; y->x(); }
5017 cxxMemberCallExpr(on(hasType(asString("class Y *
"))))
5022 <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>
5023 <tr><td colspan="4" class="doc
" id="equalsBoundNode3
"><pre>Matches if a node equals a previously bound node.
5025 Matches a node if it equals the node previously bound to ID.
5028 class X { int a; int b; };
5030 has(fieldDecl(hasName("a
"), hasType(type().bind("t
")))),
5031 has(fieldDecl(hasName("b
"), hasType(type(equalsBoundNode("t
"))))))
5032 matches the class X, as a and b have the same type.
5034 Note that when multiple matches are involved via forEach* matchers,
5035 equalsBoundNodes acts as a filter.
5038 forEachDescendant(varDecl().bind("d
")),
5039 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d
"))))))
5040 will trigger a match for each combination of variable declaration
5041 and reference to that variable declaration within a compound statement.
5045 <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>
5046 <tr><td colspan="4" class="doc
" id="hasLocalQualifiers0
"><pre>Matches QualType nodes that have local CV-qualifiers attached to
5047 the node, not hidden within a typedef.
5050 typedef const int const_int;
5055 varDecl(hasType(hasLocalQualifiers())) matches only j and k.
5056 i is const-qualified but the qualifier is not local.
5060 <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>
5061 <tr><td colspan="4" class="doc
" id="isAnyCharacter0
"><pre>Matches QualType nodes that are of character type.
5067 functionDecl(hasAnyParameter(hasType(isAnyCharacter())))
5068 matches "a(char)
", "b(wchar_t)
", but not "c(double)
".
5072 <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>
5073 <tr><td colspan="4" class="doc
" id="isAnyPointer0
"><pre>Matches QualType nodes that are of any pointer type; this includes
5074 the Objective-C object pointer type, which is different despite being
5075 syntactically similar.
5085 varDecl(hasType(isAnyPointer()))
5086 matches "int *i
" and "Foo *f
", but not "int j
".
5090 <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>
5091 <tr><td colspan="4" class="doc
" id="isConstQualified0
"><pre>Matches QualType nodes that are const-qualified, i.e., that
5092 include "top-level
" const.
5099 void e(int const) {};
5100 functionDecl(hasAnyParameter(hasType(isConstQualified())))
5101 matches "void b(int const)
", "void c(const int)
" and
5102 "void e(int const) {}
". It does not match d as there
5103 is no top-level const on the parameter type "const int *
".
5107 <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>
5108 <tr><td colspan="4" class="doc
" id="isInteger0
"><pre>Matches QualType nodes that are of integer type.
5114 functionDecl(hasAnyParameter(hasType(isInteger())))
5115 matches "a(int)
", "b(long)
", but not "c(double)
".
5119 <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>
5120 <tr><td colspan="4" class="doc
" id="isSignedInteger0
"><pre>Matches QualType nodes that are of signed integer type.
5124 void b(unsigned long);
5126 functionDecl(hasAnyParameter(hasType(isSignedInteger())))
5127 matches "a(int)
", but not "b(unsigned long)
" and "c(double)
".
5131 <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>
5132 <tr><td colspan="4" class="doc
" id="isUnsignedInteger0
"><pre>Matches QualType nodes that are of unsigned integer type.
5136 void b(unsigned long);
5138 functionDecl(hasAnyParameter(hasType(isUnsignedInteger())))
5139 matches "b(unsigned long)
", but not "a(int)
" and "c(double)
".
5143 <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>
5144 <tr><td colspan="4" class="doc
" id="isVolatileQualified0
"><pre>Matches QualType nodes that are volatile-qualified, i.e., that
5145 include "top-level
" volatile.
5149 void b(int volatile);
5150 void c(volatile int);
5151 void d(volatile int*);
5152 void e(int volatile) {};
5153 functionDecl(hasAnyParameter(hasType(isVolatileQualified())))
5154 matches "void b(int volatile)
", "void c(volatile int)
" and
5155 "void e(int volatile) {}
". It does not match d as there
5156 is no top-level volatile on the parameter type "volatile int *
".
5160 <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>
5161 <tr><td colspan="4" class="doc
" id="equalsBoundNode0
"><pre>Matches if a node equals a previously bound node.
5163 Matches a node if it equals the node previously bound to ID.
5166 class X { int a; int b; };
5168 has(fieldDecl(hasName("a
"), hasType(type().bind("t
")))),
5169 has(fieldDecl(hasName("b
"), hasType(type(equalsBoundNode("t
"))))))
5170 matches the class X, as a and b have the same type.
5172 Note that when multiple matches are involved via forEach* matchers,
5173 equalsBoundNodes acts as a filter.
5176 forEachDescendant(varDecl().bind("d
")),
5177 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d
"))))))
5178 will trigger a match for each combination of variable declaration
5179 and reference to that variable declaration within a compound statement.
5183 <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>
5184 <tr><td colspan="4" class="doc
" id="equalsNode1
"><pre>Matches if a node equals another node.
5186 Stmt has pointer identity in the AST.
5190 <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>
5191 <tr><td colspan="4" class="doc
" id="isExpandedFromMacro1
"><pre>Matches statements that are (transitively) expanded from the named macro.
5192 Does not match if only part of the statement is expanded from that macro or
5193 if different parts of the statement are expanded from different
5194 appearances of the macro.
5198 <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>
5199 <tr><td colspan="4" class="doc
" id="isExpansionInFileMatching1
"><pre>Matches AST nodes that were expanded within files whose name is
5200 partially matching a given regex.
5202 Example matches Y but not X
5203 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*
"))
5204 #include "ASTMatcher.h
"
5209 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>>
5211 If the matcher is used in clang-query, RegexFlags parameter
5212 should be passed as a quoted string. e.g: "NoFlags
".
5213 Flags can be combined with '|' example "IgnoreCase | BasicRegex
"
5217 <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>
5218 <tr><td colspan="4" class="doc
" id="isExpansionInMainFile1
"><pre>Matches AST nodes that were expanded within the main-file.
5220 Example matches X but not Y
5221 (matcher = cxxRecordDecl(isExpansionInMainFile())
5222 #include <Y.h>
5227 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>>
5231 <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>
5232 <tr><td colspan="4" class="doc
" id="isExpansionInSystemHeader1
"><pre>Matches AST nodes that were expanded within system-header-files.
5234 Example matches Y but not X
5235 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
5236 #include <SystemHeader.h>
5241 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>>
5245 <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>
5246 <tr><td colspan="4" class="doc
" id="isInTemplateInstantiation0
"><pre>Matches statements inside of a template instantiation.
5250 template<typename T> void A(T t) { T i; j += 42;}
5253 declStmt(isInTemplateInstantiation())
5254 matches 'int i;' and 'unsigned i'.
5255 unless(stmt(isInTemplateInstantiation()))
5256 will NOT match j += 42; as it's shared between the template definition and
5261 <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>
5262 <tr><td colspan="4" class="doc
" id="hasSize1
"><pre>Matches nodes that have the specified size.
5269 wchar_t *ws = L"abcd
";
5271 constantArrayType(hasSize(42))
5272 matches "int a[
42]
" and "int b[
2 *
21]
"
5273 stringLiteral(hasSize(4))
5274 matches "abcd
", L"abcd
"
5278 <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>
5279 <tr><td colspan="4" class="doc
" id="isClass0
"><pre>Matches TagDecl object that are spelled with "class.
"
5281 Example matches C, but not S, U or E.
5289 <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>
5290 <tr><td colspan="4" class="doc
" id="isDefinition0
"><pre>Matches if a declaration has a body attached.
5292 Example matches A, va, fa
5294 class B; // Doesn't match, as it has no body.
5296 extern int vb; // Doesn't match, as it doesn't define the variable.
5298 void fb(); // Doesn't match, as it has no body.
5300 - (void)ma; // Doesn't match, interface is declaration.
5306 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>>,
5307 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html
">ObjCMethodDecl</a>>
5311 <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>
5312 <tr><td colspan="4" class="doc
" id="isEnum0
"><pre>Matches TagDecl object that are spelled with "enum.
"
5314 Example matches E, but not C, S or U.
5322 <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>
5323 <tr><td colspan="4" class="doc
" id="isStruct0
"><pre>Matches TagDecl object that are spelled with "struct.
"
5325 Example matches S, but not C, U or E.
5333 <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>
5334 <tr><td colspan="4" class="doc
" id="isUnion0
"><pre>Matches TagDecl object that are spelled with "union.
"
5336 Example matches U, but not C, S or E.
5344 <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>
5345 <tr><td colspan="4" class="doc
" id="equalsIntegralValue0
"><pre>Matches a TemplateArgument of integral type with a given value.
5347 Note that 'Value' is a string as the template argument's value is
5348 an arbitrary precision integer. 'Value' must be euqal to the canonical
5349 representation of that integral value in base 10.
5352 template<int T> struct C {};
5354 classTemplateSpecializationDecl(
5355 hasAnyTemplateArgument(equalsIntegralValue("42")))
5356 matches the implicit instantiation of C in C<42>.
5360 <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>
5361 <tr><td colspan="4" class="doc
" id="isIntegral0
"><pre>Matches a TemplateArgument that is an integral value.
5364 template<int T> struct C {};
5366 classTemplateSpecializationDecl(
5367 hasAnyTemplateArgument(isIntegral()))
5368 matches the implicit instantiation of C in C<42>
5369 with isIntegral() matching 42.
5373 <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>
5374 <tr><td colspan="4" class="doc
" id="templateArgumentCountIs1
"><pre>Matches if the number of template arguments equals N.
5377 template<typename T> struct C {};
5379 classTemplateSpecializationDecl(templateArgumentCountIs(1))
5380 matches C<int>.
5384 <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>
5385 <tr><td colspan="4" class="doc
" id="isExpandedFromMacro2
"><pre>Matches statements that are (transitively) expanded from the named macro.
5386 Does not match if only part of the statement is expanded from that macro or
5387 if different parts of the statement are expanded from different
5388 appearances of the macro.
5392 <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>
5393 <tr><td colspan="4" class="doc
" id="isExpansionInFileMatching2
"><pre>Matches AST nodes that were expanded within files whose name is
5394 partially matching a given regex.
5396 Example matches Y but not X
5397 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*
"))
5398 #include "ASTMatcher.h
"
5403 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>>
5405 If the matcher is used in clang-query, RegexFlags parameter
5406 should be passed as a quoted string. e.g: "NoFlags
".
5407 Flags can be combined with '|' example "IgnoreCase | BasicRegex
"
5411 <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>
5412 <tr><td colspan="4" class="doc
" id="isExpansionInMainFile2
"><pre>Matches AST nodes that were expanded within the main-file.
5414 Example matches X but not Y
5415 (matcher = cxxRecordDecl(isExpansionInMainFile())
5416 #include <Y.h>
5421 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>>
5425 <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>
5426 <tr><td colspan="4" class="doc
" id="isExpansionInSystemHeader2
"><pre>Matches AST nodes that were expanded within system-header-files.
5428 Example matches Y but not X
5429 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
5430 #include <SystemHeader.h>
5435 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>>
5439 <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>
5440 <tr><td colspan="4" class="doc
" id="booleanType0
"><pre>Matches type bool.
5443 struct S { bool func(); };
5444 functionDecl(returns(booleanType()))
5445 matches "bool func();
"
5449 <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>
5450 <tr><td colspan="4" class="doc
" id="equalsBoundNode2
"><pre>Matches if a node equals a previously bound node.
5452 Matches a node if it equals the node previously bound to ID.
5455 class X { int a; int b; };
5457 has(fieldDecl(hasName("a
"), hasType(type().bind("t
")))),
5458 has(fieldDecl(hasName("b
"), hasType(type(equalsBoundNode("t
"))))))
5459 matches the class X, as a and b have the same type.
5461 Note that when multiple matches are involved via forEach* matchers,
5462 equalsBoundNodes acts as a filter.
5465 forEachDescendant(varDecl().bind("d
")),
5466 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d
"))))))
5467 will trigger a match for each combination of variable declaration
5468 and reference to that variable declaration within a compound statement.
5472 <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>
5473 <tr><td colspan="4" class="doc
" id="equalsNode2
"><pre>Matches if a node equals another node.
5475 Type has pointer identity in the AST.
5479 <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>
5480 <tr><td colspan="4" class="doc
" id="realFloatingPointType0
"><pre>Matches any real floating-point type (float, double, long double).
5485 realFloatingPointType()
5486 matches "float f
" but not "int i
"
5490 <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>
5491 <tr><td colspan="4" class="doc
" id="voidType0
"><pre>Matches type void.
5494 struct S { void func(); };
5495 functionDecl(returns(voidType()))
5496 matches "void func();
"
5500 <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>
5501 <tr><td colspan="4" class="doc
" id="ofKind0
"><pre>Matches unary expressions of a certain kind.
5505 int s = sizeof(x) + alignof(x)
5506 unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
5509 If the matcher is use from clang-query, UnaryExprOrTypeTrait parameter
5510 should be passed as a quoted string. e.g., ofKind("UETT_SizeOf
").
5514 <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>
5515 <tr><td colspan="4" class="doc
" id="hasAnyOperatorName3
"><pre>Matches operator expressions (binary or unary) that have any of the
5518 hasAnyOperatorName("+
", "-
")
5520 anyOf(hasOperatorName("+
"), hasOperatorName("-
"))
5524 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html
">UnaryOperator</a>></td><td class="name
" onclick="toggle('hasOperatorName3')
"><a name="hasOperatorName3Anchor
">hasOperatorName</a></td><td>std::string Name</td></tr>
5525 <tr><td colspan="4" class="doc
" id="hasOperatorName3
"><pre>Matches the operator Name of operator expressions (binary or
5528 Example matches a || b (matcher = binaryOperator(hasOperatorName("||
")))
5533 <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>
5534 <tr><td colspan="4" class="doc
" id="isArrow1
"><pre>Matches member expressions that are called with '->' as opposed
5537 Member calls on the implicit this pointer match as called with '->'.
5541 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
5542 template <class T> void f() { this->f<T>(); f<T>(); }
5546 template <class T>
5548 void x() { this->m; }
5550 memberExpr(isArrow())
5551 matches this->x, x, y.x, a, this->b
5552 cxxDependentScopeMemberExpr(isArrow())
5554 unresolvedMemberExpr(isArrow())
5555 matches this->f<T>, f<T>
5559 <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>
5560 <tr><td colspan="4" class="doc
" id="hasAutomaticStorageDuration0
"><pre>Matches a variable declaration that has automatic storage duration.
5562 Example matches x, but not y, z, or a.
5563 (matcher = varDecl(hasAutomaticStorageDuration())
5573 <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>
5574 <tr><td colspan="4" class="doc
" id="hasGlobalStorage0
"><pre>Matches a variable declaration that does not have local storage.
5576 Example matches y and z (matcher = varDecl(hasGlobalStorage())
5585 <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>
5586 <tr><td colspan="4" class="doc
" id="hasLocalStorage0
"><pre>Matches a variable declaration that has function scope and is a
5587 non-static local variable.
5589 Example matches x (matcher = varDecl(hasLocalStorage())
5598 <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>
5599 <tr><td colspan="4" class="doc
" id="hasStaticStorageDuration0
"><pre>Matches a variable declaration that has static storage duration.
5600 It includes the variable declared at namespace scope and those declared
5601 with "static
" and "extern
" storage class specifiers.
5611 varDecl(hasStaticStorageDuration())
5612 matches the function declaration y, a, b and c.
5616 <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>
5617 <tr><td colspan="4" class="doc
" id="hasThreadStorageDuration0
"><pre>Matches a variable declaration that has thread storage duration.
5619 Example matches z, but not x, z, or a.
5620 (matcher = varDecl(hasThreadStorageDuration())
5630 <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>
5631 <tr><td colspan="4" class="doc
" id="isConstexpr0
"><pre>Matches constexpr variable and function declarations,
5635 constexpr int foo = 42;
5636 constexpr int bar();
5637 void baz() { if constexpr(1 > 0) {} }
5638 varDecl(isConstexpr())
5639 matches the declaration of foo.
5640 functionDecl(isConstexpr())
5641 matches the declaration of bar.
5642 ifStmt(isConstexpr())
5643 matches the if statement in baz.
5647 <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>
5648 <tr><td colspan="4" class="doc
" id="isConstinit0
"><pre>Matches constinit variable declarations.
5651 constinit int foo = 42;
5652 constinit const char* bar = "bar
";
5654 [[clang::require_constant_initialization]] int xyz = 42;
5655 varDecl(isConstinit())
5656 matches the declaration of `foo` and `bar`, but not `baz` and `xyz`.
5660 <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>
5661 <tr><td colspan="4" class="doc
" id="isDefinition1
"><pre>Matches if a declaration has a body attached.
5663 Example matches A, va, fa
5665 class B; // Doesn't match, as it has no body.
5667 extern int vb; // Doesn't match, as it doesn't define the variable.
5669 void fb(); // Doesn't match, as it has no body.
5671 - (void)ma; // Doesn't match, interface is declaration.
5677 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>>,
5678 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html
">ObjCMethodDecl</a>>
5682 <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>
5683 <tr><td colspan="4" class="doc
" id="isExceptionVariable0
"><pre>Matches a variable declaration that is an exception variable from
5684 a C++ catch block, or an Objective-C statement.
5686 Example matches x (matcher = varDecl(isExceptionVariable())
5695 <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>
5696 <tr><td colspan="4" class="doc
" id="isExplicitTemplateSpecialization1
"><pre>Matches explicit template specializations of function, class, or
5697 static member variable template instantiations.
5700 template<typename T> void A(T t) { }
5701 template<> void A(int N) { }
5702 functionDecl(isExplicitTemplateSpecialization())
5703 matches the specialization A<int>().
5705 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>>
5709 <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>
5710 <tr><td colspan="4" class="doc
" id="isExternC1
"><pre>Matches extern "C
" function or variable declarations.
5713 extern "C
" void f() {}
5714 extern "C
" { void g() {} }
5716 extern "C
" int x = 1;
5717 extern "C
" int y = 2;
5719 functionDecl(isExternC())
5720 matches the declaration of f and g, but not the declaration of h.
5721 varDecl(isExternC())
5722 matches the declaration of x and y, but not the declaration of z.
5726 <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>
5727 <tr><td colspan="4" class="doc
" id="isInitCapture0
"><pre>Matches a variable serving as the implicit variable for a lambda init-
5730 Example matches x (matcher = varDecl(isInitCapture()))
5731 auto f = [x=3]() { return x; };
5735 <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>
5736 <tr><td colspan="4" class="doc
" id="isInline2
"><pre>Matches functions, variables and namespace declarations that are marked with
5743 inline namespace m {}
5746 functionDecl(isInline()) will match ::f().
5747 namespaceDecl(isInline()) will match n::m.
5748 varDecl(isInline()) will match Foo;
5752 <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>
5753 <tr><td colspan="4" class="doc
" id="isStaticLocal0
"><pre>Matches a static variable with local scope.
5755 Example matches y (matcher = varDecl(isStaticLocal()))
5764 <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>
5765 <tr><td colspan="4" class="doc
" id="isStaticStorageClass1
"><pre>Matches variable/function declarations that have "static
" storage
5766 class specifier ("static
" keyword) written in the source.
5773 functionDecl(isStaticStorageClass())
5774 matches the function declaration f.
5775 varDecl(isStaticStorageClass())
5776 matches the variable declaration i.
5780 <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>
5781 <tr><td colspan="4" class="doc
" id="isTemplateInstantiation1
"><pre>Matches template instantiations of function, class, or static
5782 member variable template instantiations.
5785 template <typename T> class X {}; class A {}; X<A> x;
5787 template <typename T> class X {}; class A {}; template class X<A>;
5789 template <typename T> class X {}; class A {}; extern template class X<A>;
5790 cxxRecordDecl(hasName("::X
"), isTemplateInstantiation())
5791 matches the template instantiation of X<A>.
5794 template <typename T> class X {}; class A {};
5795 template <> class X<A> {}; X<A> x;
5796 cxxRecordDecl(hasName("::X
"), isTemplateInstantiation())
5797 does not match, as X<A> is an explicit template specialization.
5799 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>>
5802 <!--END_NARROWING_MATCHERS -->
5805 <!-- ======================================================================= -->
5806 <h2 id="traversal-matchers
">AST Traversal Matchers</h2>
5807 <!-- ======================================================================= -->
5809 <p>Traversal matchers specify the relationship to other nodes that are
5810 reachable from the current node.</p>
5812 <p>Note that there are special traversal matchers (has, hasDescendant, forEach and
5813 forEachDescendant) which work on all nodes and allow users to write more generic
5814 match expressions.</p>
5817 <tr style="text-align:left
"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
5818 <!-- START_TRAVERSAL_MATCHERS -->
5820 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('binaryOperation0')
"><a name="binaryOperation0Anchor
">binaryOperation</a></td><td>Matcher<*>...Matcher<*></td></tr>
5821 <tr><td colspan="4" class="doc
" id="binaryOperation0
"><pre>Matches nodes which can be used with binary operators.
5825 might be represented in the clang AST as a binaryOperator, a
5826 cxxOperatorCallExpr or a cxxRewrittenBinaryOperator, depending on
5828 * whether the types of var1 and var2 are fundamental (binaryOperator) or at
5829 least one is a class type (cxxOperatorCallExpr)
5830 * whether the code appears in a template declaration, if at least one of the
5831 vars is a dependent-type (binaryOperator)
5832 * whether the code relies on a rewritten binary operator, such as a
5833 spaceship operator or an inverted equality operator
5834 (cxxRewrittenBinaryOperator)
5836 This matcher elides details in places where the matchers for the nodes are
5841 hasOperatorName("!=
"),
5842 hasLHS(expr().bind("lhs
")),
5843 hasRHS(expr().bind("rhs
"))
5845 matches each use of "!=
" in:
5847 bool operator!=(const S&) const;
5856 template<typename T>
5864 bool operator==(const HasOpEq &) const;
5877 bool operator<=>(const HasOpEq &) const;
5880 void use_spaceship()
5890 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('eachOf0')
"><a name="eachOf0Anchor
">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr>
5891 <tr><td colspan="4" class="doc
" id="eachOf0
"><pre>Matches if any of the given matchers matches.
5893 Unlike anyOf, eachOf will generate a match result for each
5894 matching submatcher.
5897 class A { int a; int b; };
5899 cxxRecordDecl(eachOf(has(fieldDecl(hasName("a
")).bind("v
")),
5900 has(fieldDecl(hasName("b
")).bind("v
"))))
5901 will generate two results binding "v
", the first of which binds
5902 the field declaration of a, the second the field declaration of
5905 Usable as: Any Matcher
5909 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('findAll0')
"><a name="findAll0Anchor
">findAll</a></td><td>Matcher<*> Matcher</td></tr>
5910 <tr><td colspan="4" class="doc
" id="findAll0
"><pre>Matches if the node or any descendant matches.
5912 Generates results for each match.
5915 class A { class B {}; class C {}; };
5917 cxxRecordDecl(hasName("::A
"),
5918 findAll(cxxRecordDecl(isDefinition()).bind("m
")))
5919 will generate results for A, B and C.
5921 Usable as: Any Matcher
5925 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('forEachDescendant0')
"><a name="forEachDescendant0Anchor
">forEachDescendant</a></td><td>Matcher<*></td></tr>
5926 <tr><td colspan="4" class="doc
" id="forEachDescendant0
"><pre>Matches AST nodes that have descendant AST nodes that match the
5929 Example matches X, A, A::X, B, B::C, B::C::X
5930 (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X
")))))
5932 class A { class X {}; }; // Matches A, because A::X is a class of name
5934 class B { class C { class X {}; }; };
5936 DescendantT must be an AST base type.
5938 As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
5939 each result that matches instead of only on the first one.
5941 Note: Recursively combined ForEachDescendant can cause many matches:
5942 cxxRecordDecl(forEachDescendant(cxxRecordDecl(
5943 forEachDescendant(cxxRecordDecl())
5945 will match 10 times (plus injected class name matches) on:
5946 class A { class B { class C { class D { class E {}; }; }; }; };
5948 Usable as: Any Matcher
5952 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('forEach0')
"><a name="forEach0Anchor
">forEach</a></td><td>Matcher<*></td></tr>
5953 <tr><td colspan="4" class="doc
" id="forEach0
"><pre>Matches AST nodes that have child AST nodes that match the
5956 Example matches X, Y, Y::X, Z::Y, Z::Y::X
5957 (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X
")))
5959 class Y { class X {}; }; // Matches Y, because Y::X is a class of name X
5961 class Z { class Y { class X {}; }; }; // Does not match Z.
5963 ChildT must be an AST base type.
5965 As opposed to 'has', 'forEach' will cause a match for each result that
5966 matches instead of only on the first one.
5968 Usable as: Any Matcher
5972 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('hasAncestor0')
"><a name="hasAncestor0Anchor
">hasAncestor</a></td><td>Matcher<*></td></tr>
5973 <tr><td colspan="4" class="doc
" id="hasAncestor0
"><pre>Matches AST nodes that have an ancestor that matches the provided
5977 void f() { if (true) { int x = 42; } }
5978 void g() { for (;;) { int x = 43; } }
5979 expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.
5981 Usable as: Any Matcher
5985 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('hasDescendant0')
"><a name="hasDescendant0Anchor
">hasDescendant</a></td><td>Matcher<*></td></tr>
5986 <tr><td colspan="4" class="doc
" id="hasDescendant0
"><pre>Matches AST nodes that have descendant AST nodes that match the
5989 Example matches X, Y, Z
5990 (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X
")))))
5991 class X {}; // Matches X, because X::X is a class of name X inside X.
5992 class Y { class X {}; };
5993 class Z { class Y { class X {}; }; };
5995 DescendantT must be an AST base type.
5997 Usable as: Any Matcher
6001 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('has0')
"><a name="has0Anchor
">has</a></td><td>Matcher<*></td></tr>
6002 <tr><td colspan="4" class="doc
" id="has0
"><pre>Matches AST nodes that have child AST nodes that match the
6005 Example matches X, Y
6006 (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X
")))
6007 class X {}; // Matches X, because X::X is a class of name X inside X.
6008 class Y { class X {}; };
6009 class Z { class Y { class X {}; }; }; // Does not match Z.
6011 ChildT must be an AST base type.
6013 Usable as: Any Matcher
6014 Note that has is direct matcher, so it also matches things like implicit
6015 casts and paren casts. If you are matching with expr then you should
6016 probably consider using ignoringParenImpCasts like:
6017 has(ignoringParenImpCasts(expr())).
6021 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('hasParent0')
"><a name="hasParent0Anchor
">hasParent</a></td><td>Matcher<*></td></tr>
6022 <tr><td colspan="4" class="doc
" id="hasParent0
"><pre>Matches AST nodes that have a parent that matches the provided
6026 void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
6027 compoundStmt(hasParent(ifStmt())) matches "{ int x =
43; }
".
6029 Usable as: Any Matcher
6033 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('invocation0')
"><a name="invocation0Anchor
">invocation</a></td><td>Matcher<*>...Matcher<*></td></tr>
6034 <tr><td colspan="4" class="doc
" id="invocation0
"><pre>Matches function calls and constructor calls
6036 Because CallExpr and CXXConstructExpr do not share a common
6037 base class with API accessing arguments etc, AST Matchers for code
6038 which should match both are typically duplicated. This matcher
6039 removes the need for duplication.
6042 struct ConstructorTakesInt
6044 ConstructorTakesInt(int i) {}
6047 void callTakesInt(int i)
6058 ConstructorTakesInt cti(42);
6062 invocation(hasArgument(0, integerLiteral(equals(42))))
6063 matches the expression in both doCall and doConstruct
6067 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('optionally0')
"><a name="optionally0Anchor
">optionally</a></td><td>Matcher<*></td></tr>
6068 <tr><td colspan="4" class="doc
" id="optionally0
"><pre>Matches any node regardless of the submatcher.
6070 However, optionally will retain any bindings generated by the submatcher.
6071 Useful when additional information which may or may not present about a main
6072 matching node is desired.
6081 fieldDecl(hasName("bar
")).bind("var
")
6083 will produce a result binding for both "record
" and "var
".
6084 The matcher will produce a "record
" binding for even if there is no data
6085 member named "bar
" in that class.
6087 Usable as: Any Matcher
6091 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('traverse0')
"><a name="traverse0Anchor
">traverse</a></td><td>TraversalKind TK, Matcher<*> InnerMatcher</td></tr>
6092 <tr><td colspan="4" class="doc
" id="traverse0
"><pre>Causes all nested matchers to be matched with the specified traversal kind.
6100 traverse(TK_IgnoreUnlessSpelledInSource,
6101 varDecl(hasInitializer(floatLiteral().bind("init
")))
6103 matches the variable declaration with "init
" bound to the "3.0".
6107 <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>
6108 <tr><td colspan="4" class="doc
" id="hasCondition5
"><pre>Matches the condition expression of an if statement, for loop,
6109 switch statement or conditional operator.
6111 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
6116 <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>
6117 <tr><td colspan="4" class="doc
" id="hasFalseExpression0
"><pre>Matches the false branch expression of a conditional operator
6118 (binary or ternary).
6126 <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>
6127 <tr><td colspan="4" class="doc
" id="hasTrueExpression0
"><pre>Matches the true branch expression of a conditional operator.
6129 Example 1 (conditional ternary operator): matches a
6132 Example 2 (conditional binary operator): matches opaqueValueExpr(condition)
6137 <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>
6138 <tr><td colspan="4" class="doc
" id="hasDeclaration15
"><pre>Matches a node if the declaration associated with that node
6139 matches the given matcher.
6141 The associated declaration is:
6142 - for type nodes, the declaration of the underlying type
6143 - for CallExpr, the declaration of the callee
6144 - for MemberExpr, the declaration of the referenced member
6145 - for CXXConstructExpr, the declaration of the constructor
6146 - for CXXNewExpr, the declaration of the operator new
6147 - for ObjCIvarExpr, the declaration of the ivar
6149 For type nodes, hasDeclaration will generally match the declaration of the
6154 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6155 typedefDecl. A common use case is to match the underlying, desugared type.
6156 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6157 varDecl(hasType(hasUnqualifiedDesugaredType(
6158 recordType(hasDeclaration(decl())))))
6159 In this matcher, the decl will match the CXXRecordDecl of class X.
6161 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>>,
6162 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>>,
6163 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>>,
6164 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>>,
6165 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>>,
6166 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>>,
6167 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
6171 <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>
6172 <tr><td colspan="4" class="doc
" id="hasBase0
"><pre>Matches the base expression of an array subscript expression.
6176 void f() { i[1] = 42; }
6177 arraySubscriptExpression(hasBase(implicitCastExpr(
6178 hasSourceExpression(declRefExpr()))))
6179 matches i[1] with the declRefExpr() matching i
6183 <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>
6184 <tr><td colspan="4" class="doc
" id="hasIndex0
"><pre>Matches the index expression of an array subscript expression.
6188 void f() { i[1] = 42; }
6189 arraySubscriptExpression(hasIndex(integerLiteral()))
6190 matches i[1] with the integerLiteral() matching 1
6194 <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>
6195 <tr><td colspan="4" class="doc
" id="hasLHS3
"><pre>Matches the left hand side of binary operator expressions.
6197 Example matches a (matcher = binaryOperator(hasLHS()))
6202 <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>
6203 <tr><td colspan="4" class="doc
" id="hasRHS3
"><pre>Matches the right hand side of binary operator expressions.
6205 Example matches b (matcher = binaryOperator(hasRHS()))
6210 <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>
6211 <tr><td colspan="4" class="doc
" id="hasElementType0
"><pre>Matches arrays and C99 complex types that have a specific element
6218 arrayType(hasElementType(builtinType()))
6221 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>>
6225 <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>
6226 <tr><td colspan="4" class="doc
" id="hasValueType0
"><pre>Matches atomic types with a specific value type.
6231 atomicType(hasValueType(isInteger()))
6232 matches "_Atomic(int) i
"
6234 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html
">AtomicType</a>>
6238 <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>
6239 <tr><td colspan="4" class="doc
" id="hasDeducedType0
"><pre>Matches AutoType nodes where the deduced type is a specific type.
6241 Note: There is no TypeLoc for the deduced type and thus no
6242 getDeducedLoc() matcher.
6247 autoType(hasDeducedType(isInteger()))
6250 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html
">AutoType</a>>
6254 <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>
6255 <tr><td colspan="4" class="doc
" id="hasAnyUsingShadowDecl0
"><pre>Matches any using shadow declaration.
6258 namespace X { void b(); }
6260 usingDecl(hasAnyUsingShadowDecl(hasName("b
"))))
6261 matches using X::b </pre></td></tr>
6264 <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>
6265 <tr><td colspan="4" class="doc
" id="hasEitherOperand0
"><pre>Matches if either the left hand side or the right hand side of a
6266 binary operator matches.
6270 <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>
6271 <tr><td colspan="4" class="doc
" id="hasLHS0
"><pre>Matches the left hand side of binary operator expressions.
6273 Example matches a (matcher = binaryOperator(hasLHS()))
6278 <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>
6279 <tr><td colspan="4" class="doc
" id="hasOperands0
"><pre>Matches if both matchers match with opposite sides of the binary operator.
6281 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
6282 integerLiteral(equals(2)))
6290 <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>
6291 <tr><td colspan="4" class="doc
" id="hasRHS0
"><pre>Matches the right hand side of binary operator expressions.
6293 Example matches b (matcher = binaryOperator(hasRHS()))
6298 <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>
6299 <tr><td colspan="4" class="doc
" id="forDecomposition0
"><pre>Matches the DecompositionDecl the binding belongs to.
6305 auto &[f, s, t] = arr;
6310 bindingDecl(hasName("f
"),
6311 forDecomposition(decompositionDecl())
6312 matches 'f' in 'auto &[f, s, t]'.
6316 <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>
6317 <tr><td colspan="4" class="doc
" id="hasAnyParameter2
"><pre>Matches any parameter of a function or an ObjC method declaration or a
6320 Does not match the 'this' parameter of a method.
6323 class X { void f(int x, int y, int z) {} };
6324 cxxMethodDecl(hasAnyParameter(hasName("y
")))
6325 matches f(int x, int y, int z) {}
6326 with hasAnyParameter(...)
6329 For ObjectiveC, given
6330 @interface I - (void) f:(int) y; @end
6332 the matcher objcMethodDecl(hasAnyParameter(hasName("y
")))
6333 matches the declaration of method f with hasParameter
6337 b = ^(int y) { printf("%d
", y) };
6339 the matcher blockDecl(hasAnyParameter(hasName("y
")))
6340 matches the declaration of the block b with hasParameter
6345 <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>
6346 <tr><td colspan="4" class="doc
" id="hasParameter2
"><pre>Matches the n'th parameter of a function or an ObjC method
6347 declaration or a block.
6350 class X { void f(int x) {} };
6351 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
6353 with hasParameter(...)
6356 For ObjectiveC, given
6357 @interface I - (void) f:(int) y; @end
6359 the matcher objcMethodDecl(hasParameter(0, hasName("y
")))
6360 matches the declaration of method f with hasParameter
6365 <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>
6366 <tr><td colspan="4" class="doc
" id="hasTypeLoc0
"><pre>Matches if the type location of a node matches the inner matcher.
6370 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
6374 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
6377 struct Foo { Foo(int, int); };
6379 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
6382 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>>,
6383 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>>,
6384 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>>,
6385 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
6386 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>>,
6387 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>>,
6388 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>>,
6389 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
6393 <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>
6394 <tr><td colspan="4" class="doc
" id="pointee0
"><pre>Narrows PointerType (and similar) matchers to those where the
6395 pointee matches a given matcher.
6401 pointerType(pointee(isConstQualified(), isInteger()))
6402 matches "int const *b
"
6404 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>>,
6405 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>>
6409 <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>
6410 <tr><td colspan="4" class="doc
" id="hasTypeLoc1
"><pre>Matches if the type location of a node matches the inner matcher.
6414 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
6418 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
6421 struct Foo { Foo(int, int); };
6423 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
6426 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>>,
6427 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>>,
6428 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>>,
6429 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
6430 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>>,
6431 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>>,
6432 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>>,
6433 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
6437 <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>
6438 <tr><td colspan="4" class="doc
" id="hasType8
"><pre>Overloaded to match the declaration of the expression's or value
6441 In case of a value declaration (for example a variable declaration),
6442 this resolves one layer of indirection. For example, in the value
6443 declaration "X x;
", cxxRecordDecl(hasName("X
")) matches the declaration of
6444 X, while varDecl(hasType(cxxRecordDecl(hasName("X
")))) matches the
6447 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
6448 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
6449 and friend class X (matcher = friendDecl(hasType("X
"))
6450 and public virtual X (matcher = cxxBaseSpecifier(hasType(
6451 cxxRecordDecl(hasName("X
"))))
6453 void y(X &x) { x; X z; }
6454 class Y { friend class X; };
6455 class Z : public virtual X {};
6457 Example matches class Derived
6458 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base
"))))))
6460 class Derived : Base {};
6462 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>>,
6463 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>
6467 <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>
6468 <tr><td colspan="4" class="doc
" id="hasType4
"><pre>Matches if the expression's or declaration's type matches a type
6471 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
6472 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
6473 and U (matcher = typedefDecl(hasType(asString("int
")))
6474 and friend class X (matcher = friendDecl(hasType("X
"))
6475 and public virtual X (matcher = cxxBaseSpecifier(hasType(
6476 asString("class X
")))
6478 void y(X &x) { x; X z; }
6480 class Y { friend class X; };
6481 class Z : public virtual X {};
6485 <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>
6486 <tr><td colspan="4" class="doc
" id="forEachArgumentWithParam1
"><pre>Matches all arguments and their respective ParmVarDecl.
6493 forEachArgumentWithParam(
6494 declRefExpr(to(varDecl(hasName("y
")))),
6495 parmVarDecl(hasType(isInteger()))
6498 with declRefExpr(...)
6500 and parmVarDecl(...)
6505 <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>
6506 <tr><td colspan="4" class="doc
" id="forEachArgumentWithParamType1
"><pre>Matches all arguments and their respective types for a CallExpr or
6507 CXXConstructExpr. It is very similar to forEachArgumentWithParam but
6508 it works on calls through function pointers as well.
6510 The difference is, that function pointers do not provide access to a
6511 ParmVarDecl, but only the QualType for each argument.
6517 void (*f_ptr)(int) = f;
6520 forEachArgumentWithParamType(
6521 declRefExpr(to(varDecl(hasName("y
")))),
6522 qualType(isInteger()).bind("type)
6524 matches f(y) and f_ptr(y)
6525 with declRefExpr(...)
6532 <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>
6533 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call
6534 expression, or an ObjC-message-send expression.
6537 void x(int, int, int) { int y; x(
1, y,
42); }
6538 callExpr(hasAnyArgument(declRefExpr()))
6540 with hasAnyArgument(...)
6543 For ObjectiveC, given
6544 @interface I - (void) f:(int) y; @end
6545 void foo(I *i) { [i f:
12]; }
6546 objcMessageExpr(hasAnyArgument(integerLiteral(equals(
12))))
6551 <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>
6552 <tr><td colspan=
"4" class=
"doc" id=
"hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor
6555 Example matches y in x(y)
6556 (matcher = callExpr(hasArgument(
0, declRefExpr())))
6557 void x(int) { int y; x(y); }
6561 <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>
6562 <tr><td colspan=
"4" class=
"doc" id=
"hasDeclaration13"><pre>Matches a node if the declaration associated with that node
6563 matches the given matcher.
6565 The associated declaration is:
6566 - for type nodes, the declaration of the underlying type
6567 - for CallExpr, the declaration of the callee
6568 - for MemberExpr, the declaration of the referenced member
6569 - for CXXConstructExpr, the declaration of the constructor
6570 - for CXXNewExpr, the declaration of the operator new
6571 - for ObjCIvarExpr, the declaration of the ivar
6573 For type nodes, hasDeclaration will generally match the declaration of the
6578 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6579 typedefDecl. A common use case is to match the underlying, desugared type.
6580 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6581 varDecl(hasType(hasUnqualifiedDesugaredType(
6582 recordType(hasDeclaration(decl())))))
6583 In this matcher, the decl will match the CXXRecordDecl of class X.
6585 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>>,
6586 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>>,
6587 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>>,
6588 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>>,
6589 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>>,
6590 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>>,
6591 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType
</a>>
6595 <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>
6596 <tr><td colspan=
"4" class=
"doc" id=
"forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition.
6599 class A { A() : i(
42), j(
42) {} int i; int j; };
6600 cxxConstructorDecl(forEachConstructorInitializer(
6601 forField(decl().bind(
"x"))
6603 will trigger two matches, binding for 'i' and 'j' respectively.
6607 <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>
6608 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyConstructorInitializer0"><pre>Matches a constructor initializer.
6615 cxxRecordDecl(has(cxxConstructorDecl(
6616 hasAnyConstructorInitializer(anything())
6618 record matches Foo, hasAnyConstructorInitializer matches foo_(
1)
6622 <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>
6623 <tr><td colspan=
"4" class=
"doc" id=
"forField0"><pre>Matches the field declaration of a constructor initializer.
6630 cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
6631 forField(hasName(
"foo_"))))))
6633 with forField matching foo_
6637 <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>
6638 <tr><td colspan=
"4" class=
"doc" id=
"hasTypeLoc2"><pre>Matches if the type location of a node matches the inner matcher.
6642 declaratorDecl(hasTypeLoc(loc(asString(
"int"))))
6646 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString(
"int"))))
6649 struct Foo { Foo(int, int); };
6651 cxxFunctionalCastExpr(hasTypeLoc(loc(asString(
"struct Foo"))))
6654 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>>,
6655 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>>,
6656 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>>,
6657 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>>,
6658 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>>,
6659 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>>,
6660 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>>,
6661 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl
</a>>
6665 <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>
6666 <tr><td colspan=
"4" class=
"doc" id=
"withInitializer0"><pre>Matches the initializer expression of a constructor initializer.
6673 cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
6674 withInitializer(integerLiteral(equals(
1)))))))
6676 with withInitializer matching (
1)
6680 <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>
6681 <tr><td colspan=
"4" class=
"doc" id=
"hasObjectExpression2"><pre>Matches a member expression where the object expression is matched by a
6682 given matcher. Implicit object expressions are included; that is, it matches
6683 use of implicit `this`.
6688 int f(X x) { x.m; return m; }
6690 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName(
"X")))))
6691 matches `x.m`, but not `m`; however,
6692 memberExpr(hasObjectExpression(hasType(pointsTo(
6693 cxxRecordDecl(hasName(
"X"))))))
6694 matches `m` (aka. `this-
>m`), but not `x.m`.
6698 <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>
6699 <tr><td colspan=
"4" class=
"doc" id=
"hasBody3"><pre></pre></td></tr>
6702 <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>
6703 <tr><td colspan=
"4" class=
"doc" id=
"hasInitStatement2"><pre>Matches selection statements with initializer.
6707 if (int i = foobar(); i
> 0) {}
6708 switch (int i = foobar(); i) {}
6709 for (auto
& a = get_range(); auto
& x : a) {}
6712 if (foobar()
> 0) {}
6713 switch (foobar()) {}
6714 for (auto
& x : get_range()) {}
6716 ifStmt(hasInitStatement(anything()))
6717 matches the if statement in foo but not in bar.
6718 switchStmt(hasInitStatement(anything()))
6719 matches the switch statement in foo but not in bar.
6720 cxxForRangeStmt(hasInitStatement(anything()))
6721 matches the range for statement in foo but not in bar.
6725 <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>
6726 <tr><td colspan=
"4" class=
"doc" id=
"hasLoopVariable0"><pre>Matches the initialization statement of a for loop.
6729 forStmt(hasLoopVariable(anything()))
6735 <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>
6736 <tr><td colspan=
"4" class=
"doc" id=
"hasRangeInit0"><pre>Matches the range initialization statement of a for loop.
6739 forStmt(hasRangeInit(anything()))
6745 <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>
6746 <tr><td colspan=
"4" class=
"doc" id=
"hasTypeLoc3"><pre>Matches if the type location of a node matches the inner matcher.
6750 declaratorDecl(hasTypeLoc(loc(asString(
"int"))))
6754 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString(
"int"))))
6757 struct Foo { Foo(int, int); };
6759 cxxFunctionalCastExpr(hasTypeLoc(loc(asString(
"struct Foo"))))
6762 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>>,
6763 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>>,
6764 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>>,
6765 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>>,
6766 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>>,
6767 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>>,
6768 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>>,
6769 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl
</a>>
6773 <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>
6774 <tr><td colspan=
"4" class=
"doc" id=
"onImplicitObjectArgument0"><pre>Matches on the implicit object argument of a member call expression. Unlike
6775 `on`, matches the argument directly without stripping away anything.
6778 class Y { public: void m(); };
6780 class X : public Y { void g(); };
6781 void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); }
6782 cxxMemberCallExpr(onImplicitObjectArgument(hasType(
6783 cxxRecordDecl(hasName(
"Y")))))
6784 matches `y.m()`, `x.m()` and (g()).m(), but not `x.g()`.
6785 cxxMemberCallExpr(on(callExpr()))
6786 does not match `(g()).m()`, because the parens are not ignored.
6788 FIXME: Overload to allow directly matching types?
6792 <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>
6793 <tr><td colspan=
"4" class=
"doc" id=
"on0"><pre>Matches on the implicit object argument of a member call expression, after
6794 stripping off any parentheses or implicit casts.
6797 class Y { public: void m(); };
6799 class X : public Y {};
6800 void z(Y y, X x) { y.m(); (g()).m(); x.m(); }
6801 cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName(
"Y")))))
6802 matches `y.m()` and `(g()).m()`.
6803 cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName(
"X")))))
6805 cxxMemberCallExpr(on(callExpr()))
6806 matches `(g()).m()`.
6808 FIXME: Overload to allow directly matching types?
6812 <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>
6813 <tr><td colspan=
"4" class=
"doc" id=
"thisPointerType1"><pre>Overloaded to match the type's declaration.
6817 <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>
6818 <tr><td colspan=
"4" class=
"doc" id=
"thisPointerType0"><pre>Matches if the type of the expression's implicit object argument either
6819 matches the InnerMatcher, or is a pointer to a type that matches the
6823 class Y { public: void m(); };
6824 class X : public Y { void g(); };
6825 void z() { Y y; y.m(); Y *p; p-
>m(); X x; x.m(); x.g(); }
6826 cxxMemberCallExpr(thisPointerType(hasDeclaration(
6827 cxxRecordDecl(hasName(
"Y")))))
6828 matches `y.m()`, `p-
>m()` and `x.m()`.
6829 cxxMemberCallExpr(thisPointerType(hasDeclaration(
6830 cxxRecordDecl(hasName(
"X")))))
6835 <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>
6836 <tr><td colspan=
"4" class=
"doc" id=
"forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may
6837 produce multiple matches.
6840 class A { virtual void f(); };
6841 class B : public A { void f(); };
6842 class C : public B { void f(); };
6843 cxxMethodDecl(ofClass(hasName(
"C")),
6844 forEachOverridden(cxxMethodDecl().bind(
"b"))).bind(
"d")
6845 matches once, with
"b" binding
"A::f" and
"d" binding
"C::f" (Note
6846 that B::f is not overridden by C::f).
6848 The check can produce multiple matches in case of multiple inheritance, e.g.
6849 class A1 { virtual void f(); };
6850 class A2 { virtual void f(); };
6851 class C : public A1, public A2 { void f(); };
6852 cxxMethodDecl(ofClass(hasName(
"C")),
6853 forEachOverridden(cxxMethodDecl().bind(
"b"))).bind(
"d")
6854 matches twice, once with
"b" binding
"A1::f" and
"d" binding
"C::f", and
6855 once with
"b" binding
"A2::f" and
"d" binding
"C::f".
6859 <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>
6860 <tr><td colspan=
"4" class=
"doc" id=
"ofClass0"><pre>Matches the class declaration that the given method declaration
6863 FIXME: Generalize this for other kinds of declarations.
6864 FIXME: What other kind of declarations would we need to generalize
6867 Example matches A() in the last line
6868 (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl(
6869 ofClass(hasName(
"A"))))))
6878 <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>
6879 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyPlacementArg0"><pre>Matches any placement new expression arguments.
6882 MyClass *p1 = new (Storage) MyClass();
6883 cxxNewExpr(hasAnyPlacementArg(anything()))
6884 matches the expression 'new (Storage,
16) MyClass()'.
6888 <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>
6889 <tr><td colspan=
"4" class=
"doc" id=
"hasArraySize0"><pre>Matches array new expressions with a given array size.
6892 MyClass *p1 = new MyClass[
10];
6893 cxxNewExpr(hasArraySize(integerLiteral(equals(
10))))
6894 matches the expression 'new MyClass[
10]'.
6898 <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>
6899 <tr><td colspan=
"4" class=
"doc" id=
"hasDeclaration12"><pre>Matches a node if the declaration associated with that node
6900 matches the given matcher.
6902 The associated declaration is:
6903 - for type nodes, the declaration of the underlying type
6904 - for CallExpr, the declaration of the callee
6905 - for MemberExpr, the declaration of the referenced member
6906 - for CXXConstructExpr, the declaration of the constructor
6907 - for CXXNewExpr, the declaration of the operator new
6908 - for ObjCIvarExpr, the declaration of the ivar
6910 For type nodes, hasDeclaration will generally match the declaration of the
6915 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6916 typedefDecl. A common use case is to match the underlying, desugared type.
6917 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6918 varDecl(hasType(hasUnqualifiedDesugaredType(
6919 recordType(hasDeclaration(decl())))))
6920 In this matcher, the decl will match the CXXRecordDecl of class X.
6922 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>>,
6923 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>>,
6924 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>>,
6925 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>>,
6926 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>>,
6927 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>>,
6928 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType
</a>>
6932 <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>
6933 <tr><td colspan=
"4" class=
"doc" id=
"hasPlacementArg0"><pre>Matches placement new expression arguments.
6936 MyClass *p1 = new (Storage,
16) MyClass();
6937 cxxNewExpr(hasPlacementArg(
1, integerLiteral(equals(
16))))
6938 matches the expression 'new (Storage,
16) MyClass()'.
6942 <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>
6943 <tr><td colspan=
"4" class=
"doc" id=
"hasTypeLoc4"><pre>Matches if the type location of a node matches the inner matcher.
6947 declaratorDecl(hasTypeLoc(loc(asString(
"int"))))
6951 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString(
"int"))))
6954 struct Foo { Foo(int, int); };
6956 cxxFunctionalCastExpr(hasTypeLoc(loc(asString(
"struct Foo"))))
6959 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>>,
6960 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>>,
6961 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>>,
6962 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>>,
6963 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>>,
6964 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>>,
6965 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>>,
6966 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl
</a>>
6970 <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>
6971 <tr><td colspan=
"4" class=
"doc" id=
"hasEitherOperand1"><pre>Matches if either the left hand side or the right hand side of a
6972 binary operator matches.
6976 <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>
6977 <tr><td colspan=
"4" class=
"doc" id=
"hasLHS1"><pre>Matches the left hand side of binary operator expressions.
6979 Example matches a (matcher = binaryOperator(hasLHS()))
6984 <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>
6985 <tr><td colspan=
"4" class=
"doc" id=
"hasOperands1"><pre>Matches if both matchers match with opposite sides of the binary operator.
6987 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(
1),
6988 integerLiteral(equals(
2)))
6996 <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>
6997 <tr><td colspan=
"4" class=
"doc" id=
"hasRHS1"><pre>Matches the right hand side of binary operator expressions.
6999 Example matches b (matcher = binaryOperator(hasRHS()))
7004 <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>
7005 <tr><td colspan=
"4" class=
"doc" id=
"hasUnaryOperand1"><pre>Matches if the operand of a unary operator matches.
7007 Example matches true (matcher = hasUnaryOperand(
7008 cxxBoolLiteral(equals(true))))
7013 <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>
7014 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyBase0"><pre>Matches C++ classes that have a direct or indirect base matching BaseSpecMatcher.
7017 matcher hasAnyBase(hasType(cxxRecordDecl(hasName(
"SpecialBase"))))
7022 class Proxy : SpecialBase {}; // matches Proxy
7023 class IndirectlyDerived : Proxy {}; //matches IndirectlyDerived
7025 FIXME: Refactor this and isDerivedFrom to reuse implementation.
7029 <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>
7030 <tr><td colspan=
"4" class=
"doc" id=
"hasDirectBase0"><pre>Matches C++ classes that have a direct base matching BaseSpecMatcher.
7033 matcher hasDirectBase(hasType(cxxRecordDecl(hasName(
"SpecialBase"))))
7038 class Proxy : SpecialBase {}; // matches Proxy
7039 class IndirectlyDerived : Proxy {}; // doesn't match
7043 <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>
7044 <tr><td colspan=
"4" class=
"doc" id=
"hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher.
7047 class A { void func(); };
7048 class B { void member(); };
7050 cxxRecordDecl(hasMethod(hasName(
"func"))) matches the declaration of
7055 <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>
7056 <tr><td colspan=
"4" class=
"doc" id=
"isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from a class
7057 matching Base, or Objective-C classes that directly or indirectly
7058 subclass a class matching Base.
7060 Note that a class is not considered to be derived from itself.
7062 Example matches Y, Z, C (Base == hasName(
"X"))
7064 class Y : public X {}; // directly derived
7065 class Z : public Y {}; // indirectly derived
7068 class C : public B {}; // derived from a typedef of X
7070 In the following example, Bar matches isDerivedFrom(hasName(
"X")):
7073 class Bar : public Foo {}; // derived from a type that X is a typedef of
7075 In the following example, Bar matches isDerivedFrom(hasName(
"NSObject"))
7076 @interface NSObject @end
7077 @interface Bar : NSObject @end
7079 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>>
7083 <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>
7084 <tr><td colspan=
"4" class=
"doc" id=
"isDirectlyDerivedFrom0"><pre>Matches C++ or Objective-C classes that are directly derived from a class
7087 Note that a class is not considered to be derived from itself.
7089 Example matches Y, C (Base == hasName(
"X"))
7091 class Y : public X {}; // directly derived
7092 class Z : public Y {}; // indirectly derived
7095 class C : public B {}; // derived from a typedef of X
7097 In the following example, Bar matches isDerivedFrom(hasName(
"X")):
7100 class Bar : public Foo {}; // derived from a type that X is a typedef of
7104 <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>
7105 <tr><td colspan=
"4" class=
"doc" id=
"isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly
7110 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator
</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>
7111 <tr><td colspan=
"4" class=
"doc" id=
"hasEitherOperand2"><pre>Matches if either the left hand side or the right hand side of a
7112 binary operator matches.
7116 <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>
7117 <tr><td colspan=
"4" class=
"doc" id=
"hasLHS2"><pre>Matches the left hand side of binary operator expressions.
7119 Example matches a (matcher = binaryOperator(hasLHS()))
7124 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXRewrittenBinaryOperator.html">CXXRewrittenBinaryOperator
</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>
7125 <tr><td colspan=
"4" class=
"doc" id=
"hasOperands2"><pre>Matches if both matchers match with opposite sides of the binary operator.
7127 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(
1),
7128 integerLiteral(equals(
2)))
7136 <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>
7137 <tr><td colspan=
"4" class=
"doc" id=
"hasRHS2"><pre>Matches the right hand side of binary operator expressions.
7139 Example matches b (matcher = binaryOperator(hasRHS()))
7144 <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>
7145 <tr><td colspan=
"4" class=
"doc" id=
"hasTypeLoc5"><pre>Matches if the type location of a node matches the inner matcher.
7149 declaratorDecl(hasTypeLoc(loc(asString(
"int"))))
7153 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString(
"int"))))
7156 struct Foo { Foo(int, int); };
7158 cxxFunctionalCastExpr(hasTypeLoc(loc(asString(
"struct Foo"))))
7161 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>>,
7162 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>>,
7163 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>>,
7164 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>>,
7165 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>>,
7166 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>>,
7167 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>>,
7168 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl
</a>>
7172 <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>
7173 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call
7174 expression, or an ObjC-message-send expression.
7177 void x(int, int, int) { int y; x(
1, y,
42); }
7178 callExpr(hasAnyArgument(declRefExpr()))
7180 with hasAnyArgument(...)
7183 For ObjectiveC, given
7184 @interface I - (void) f:(int) y; @end
7185 void foo(I *i) { [i f:
12]; }
7186 objcMessageExpr(hasAnyArgument(integerLiteral(equals(
12))))
7191 <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>
7192 <tr><td colspan=
"4" class=
"doc" id=
"hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor
7195 Example matches y in x(y)
7196 (matcher = callExpr(hasArgument(
0, declRefExpr())))
7197 void x(int) { int y; x(y); }
7201 <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>
7202 <tr><td colspan=
"4" class=
"doc" id=
"hasTypeLoc6"><pre>Matches if the type location of a node matches the inner matcher.
7206 declaratorDecl(hasTypeLoc(loc(asString(
"int"))))
7210 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString(
"int"))))
7213 struct Foo { Foo(int, int); };
7215 cxxFunctionalCastExpr(hasTypeLoc(loc(asString(
"struct Foo"))))
7218 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>>,
7219 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>>,
7220 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>>,
7221 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr
</a>>,
7222 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>>,
7223 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>>,
7224 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>>,
7225 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl
</a>>
7229 <tr><td>Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr
</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_1Decl.html">Decl
</a>> InnerMatcher
</td></tr>
7230 <tr><td colspan=
"4" class=
"doc" id=
"callee1"><pre>Matches if the call expression's callee's declaration matches the
7233 Example matches y.x() (matcher = callExpr(callee(
7234 cxxMethodDecl(hasName(
"x")))))
7235 class Y { public: void x(); };
7236 void z() { Y y; y.x(); }
7240 <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>
7241 <tr><td colspan=
"4" class=
"doc" id=
"callee0"><pre>Matches if the call expression's callee expression matches.
7244 class Y { void x() { this-
>x(); x(); Y y; y.x(); } };
7246 callExpr(callee(expr()))
7247 matches this-
>x(), x(), y.x(), f()
7249 matching this-
>x, x, y.x, f respectively
7251 Note: Callee cannot take the more general internal::Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>>
7252 because this introduces ambiguous overloads with calls to Callee taking a
7253 internal::Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>>, as the matcher hierarchy is purely
7254 implemented in terms of implicit casts.
7258 <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>
7259 <tr><td colspan=
"4" class=
"doc" id=
"forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl.
7266 forEachArgumentWithParam(
7267 declRefExpr(to(varDecl(hasName(
"y")))),
7268 parmVarDecl(hasType(isInteger()))
7271 with declRefExpr(...)
7273 and parmVarDecl(...)
7278 <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>
7279 <tr><td colspan=
"4" class=
"doc" id=
"forEachArgumentWithParamType0"><pre>Matches all arguments and their respective types for a CallExpr or
7280 CXXConstructExpr. It is very similar to forEachArgumentWithParam but
7281 it works on calls through function pointers as well.
7283 The difference is, that function pointers do not provide access to a
7284 ParmVarDecl, but only the QualType for each argument.
7290 void (*f_ptr)(int) = f;
7293 forEachArgumentWithParamType(
7294 declRefExpr(to(varDecl(hasName(
"y")))),
7295 qualType(isInteger()).bind(
"type)
7297 matches f(y) and f_ptr(y)
7298 with declRefExpr(...)
7305 <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>
7306 <tr><td colspan="4" class="doc
" id="hasAnyArgument0
"><pre>Matches any argument of a call expression or a constructor call
7307 expression, or an ObjC-message-send expression.
7310 void x(int, int, int) { int y; x(1, y, 42); }
7311 callExpr(hasAnyArgument(declRefExpr()))
7313 with hasAnyArgument(...)
7316 For ObjectiveC, given
7317 @interface I - (void) f:(int) y; @end
7318 void foo(I *i) { [i f:12]; }
7319 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
7324 <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>
7325 <tr><td colspan="4" class="doc
" id="hasArgument0
"><pre>Matches the n'th argument of a call expression or a constructor
7328 Example matches y in x(y)
7329 (matcher = callExpr(hasArgument(0, declRefExpr())))
7330 void x(int) { int y; x(y); }
7334 <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>
7335 <tr><td colspan="4" class="doc
" id="hasDeclaration14
"><pre>Matches a node if the declaration associated with that node
7336 matches the given matcher.
7338 The associated declaration is:
7339 - for type nodes, the declaration of the underlying type
7340 - for CallExpr, the declaration of the callee
7341 - for MemberExpr, the declaration of the referenced member
7342 - for CXXConstructExpr, the declaration of the constructor
7343 - for CXXNewExpr, the declaration of the operator new
7344 - for ObjCIvarExpr, the declaration of the ivar
7346 For type nodes, hasDeclaration will generally match the declaration of the
7351 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7352 typedefDecl. A common use case is to match the underlying, desugared type.
7353 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7354 varDecl(hasType(hasUnqualifiedDesugaredType(
7355 recordType(hasDeclaration(decl())))))
7356 In this matcher, the decl will match the CXXRecordDecl of class X.
7358 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>>,
7359 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>>,
7360 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>>,
7361 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>>,
7362 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>>,
7363 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>>,
7364 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
7368 <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>
7369 <tr><td colspan="4" class="doc
" id="hasCaseConstant0
"><pre>If the given case statement does not use the GNU case range
7370 extension, matches the constant given in the statement.
7373 switch (1) { case 1: case 1+1: case 3 ... 4: ; }
7374 caseStmt(hasCaseConstant(integerLiteral()))
7379 <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>
7380 <tr><td colspan="4" class="doc
" id="hasSourceExpression0
"><pre>Matches if the cast's source expression
7381 or opaque value's source expression matches the given matcher.
7383 Example 1: matches "a string
"
7384 (matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
7385 class URL { URL(string); };
7386 URL url = "a string
";
7388 Example 2: matches 'b' (matcher =
7389 opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
7394 <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>
7395 <tr><td colspan="4" class="doc
" id="hasAnyTemplateArgument0
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
7396 functionDecl that have at least one TemplateArgument matching the given
7400 template<typename T> class A {};
7401 template<> class A<double> {};
7404 template<typename T> f() {};
7405 void func() { f<int>(); };
7407 classTemplateSpecializationDecl(hasAnyTemplateArgument(
7408 refersToType(asString("int
"))))
7409 matches the specialization A<int>
7411 functionDecl(hasAnyTemplateArgument(refersToType(asString("int
"))))
7412 matches the specialization f<int>
7416 <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>
7417 <tr><td colspan="4" class="doc
" id="hasSpecializedTemplate0
"><pre>Matches the specialized template of a specialization declaration.
7420 template<typename T> class A {}; #1
7421 template<> class A<int> {}; #2
7422 classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl()))
7423 matches '#2' with classTemplateDecl() matching the class template
7424 declaration of 'A' at #1.
7428 <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>
7429 <tr><td colspan="4" class="doc
" id="hasTemplateArgument0
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
7430 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
7433 template<typename T, typename U> class A {};
7434 A<bool, int> b;
7435 A<int, bool> c;
7437 template<typename T> void f() {}
7438 void func() { f<int>(); };
7439 classTemplateSpecializationDecl(hasTemplateArgument(
7440 1, refersToType(asString("int
"))))
7441 matches the specialization A<bool, int>
7443 functionDecl(hasTemplateArgument(0, refersToType(asString("int
"))))
7444 matches the specialization f<int>
7448 <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>
7449 <tr><td colspan="4" class="doc
" id="hasTypeLoc7
"><pre>Matches if the type location of a node matches the inner matcher.
7453 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
7457 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
7460 struct Foo { Foo(int, int); };
7462 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
7465 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>>,
7466 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>>,
7467 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>>,
7468 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
7469 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>>,
7470 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>>,
7471 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>>,
7472 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
7476 <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>
7477 <tr><td colspan="4" class="doc
" id="hasElementType1
"><pre>Matches arrays and C99 complex types that have a specific element
7484 arrayType(hasElementType(builtinType()))
7487 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>>
7491 <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>
7492 <tr><td colspan="4" class="doc
" id="hasTypeLoc8
"><pre>Matches if the type location of a node matches the inner matcher.
7496 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
7500 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
7503 struct Foo { Foo(int, int); };
7505 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
7508 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>>,
7509 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>>,
7510 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>>,
7511 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
7512 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>>,
7513 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>>,
7514 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>>,
7515 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
7519 <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>
7520 <tr><td colspan="4" class="doc
" id="hasAnySubstatement0
"><pre>Matches compound statements where at least one substatement matches
7521 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
7525 hasAnySubstatement(compoundStmt())
7526 matches '{ {}; 1+2; }'
7532 <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>
7533 <tr><td colspan="4" class="doc
" id="hasDecayedType0
"><pre>Matches the decayed type, whoes decayed type matches InnerMatcher
7537 <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>
7538 <tr><td colspan="4" class="doc
" id="hasDeclaration11
"><pre>Matches a node if the declaration associated with that node
7539 matches the given matcher.
7541 The associated declaration is:
7542 - for type nodes, the declaration of the underlying type
7543 - for CallExpr, the declaration of the callee
7544 - for MemberExpr, the declaration of the referenced member
7545 - for CXXConstructExpr, the declaration of the constructor
7546 - for CXXNewExpr, the declaration of the operator new
7547 - for ObjCIvarExpr, the declaration of the ivar
7549 For type nodes, hasDeclaration will generally match the declaration of the
7554 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7555 typedefDecl. A common use case is to match the underlying, desugared type.
7556 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7557 varDecl(hasType(hasUnqualifiedDesugaredType(
7558 recordType(hasDeclaration(decl())))))
7559 In this matcher, the decl will match the CXXRecordDecl of class X.
7561 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>>,
7562 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>>,
7563 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>>,
7564 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>>,
7565 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>>,
7566 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>>,
7567 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
7571 <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>
7572 <tr><td colspan="4" class="doc
" id="hasTemplateArgumentLoc0
"><pre>Matches template specialization `TypeLoc`s where the n'th
7573 `TemplateArgumentLoc` matches the given `InnerMatcher`.
7576 template<typename T, typename U> class A {};
7577 A<double, int> b;
7578 A<int, double> c;
7579 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
7580 hasTypeLoc(loc(asString("double
")))))))
7581 matches `A<double, int> b`, but not `A<int, double> c`.
7585 <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>
7586 <tr><td colspan="4" class="doc
" id="throughUsingDecl0
"><pre>Matches if a node refers to a declaration through a specific
7587 using shadow declaration.
7590 namespace a { int f(); }
7593 declRefExpr(throughUsingDecl(anything()))
7596 namespace a { class X{}; }
7599 typeLoc(loc(usingType(throughUsingDecl(anything()))))
7602 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>>
7606 <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>
7607 <tr><td colspan="4" class="doc
" id="to0
"><pre>Matches a DeclRefExpr that refers to a declaration that matches the
7610 Example matches x in if(x)
7611 (matcher = declRefExpr(to(varDecl(hasName("x
")))))
7617 <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>
7618 <tr><td colspan="4" class="doc
" id="containsDeclaration0
"><pre>Matches the n'th declaration of a declaration statement.
7620 Note that this does not work for global declarations because the AST
7621 breaks up multiple-declaration DeclStmt's into multiple single-declaration
7623 Example: Given non-global declarations
7627 declStmt(containsDeclaration(
7628 0, varDecl(hasInitializer(anything()))))
7629 matches only 'int d = 2, e;', and
7630 declStmt(containsDeclaration(1, varDecl()))
7631 matches 'int a, b = 0' as well as 'int d = 2, e;'
7632 but 'int c;' is not matched.
7636 <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>
7637 <tr><td colspan="4" class="doc
" id="hasSingleDecl0
"><pre>Matches the Decl of a DeclStmt which has a single declaration.
7642 declStmt(hasSingleDecl(anything()))
7643 matches 'int c;' but not 'int a, b;'.
7647 <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>
7648 <tr><td colspan="4" class="doc
" id="hasTypeLoc9
"><pre>Matches if the type location of a node matches the inner matcher.
7652 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
7656 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
7659 struct Foo { Foo(int, int); };
7661 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
7664 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>>,
7665 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>>,
7666 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>>,
7667 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
7668 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>>,
7669 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>>,
7670 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>>,
7671 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
7675 <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>
7676 <tr><td colspan="4" class="doc
" id="hasDeclContext0
"><pre>Matches declarations whose declaration context, interpreted as a
7677 Decl, matches InnerMatcher.
7686 cxxRcordDecl(hasDeclContext(namedDecl(hasName("M
")))) matches the
7687 declaration of class D.
7691 <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>
7692 <tr><td colspan="4" class="doc
" id="hasUnderlyingType0
"><pre>Matches DecltypeType or UsingType nodes to find the underlying type.
7696 decltype(2.0) b = 2.0;
7697 decltypeType(hasUnderlyingType(isInteger()))
7698 matches the type of "a
"
7700 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>>
7704 <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>
7705 <tr><td colspan="4" class="doc
" id="hasAnyBinding0
"><pre>Matches any binding of a DecompositionDecl.
7711 auto &[f, s, t] = arr;
7716 decompositionDecl(hasAnyBinding(bindingDecl(hasName("f
").bind("fBinding
"))))
7717 matches the decomposition decl with 'f' bound to "fBinding
".
7721 <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>
7722 <tr><td colspan="4" class="doc
" id="hasBinding0
"><pre>Matches the Nth binding of a DecompositionDecl.
7728 auto &[f, s, t] = arr;
7733 decompositionDecl(hasBinding(0,
7734 bindingDecl(hasName("f
").bind("fBinding
"))))
7735 matches the decomposition decl with 'f' bound to "fBinding
".
7739 <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>
7740 <tr><td colspan="4" class="doc
" id="hasBody0
"><pre></pre></td></tr>
7743 <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>
7744 <tr><td colspan="4" class="doc
" id="hasCondition3
"><pre>Matches the condition expression of an if statement, for loop,
7745 switch statement or conditional operator.
7747 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
7752 <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>
7753 <tr><td colspan="4" class="doc
" id="hasNamedTypeLoc0
"><pre>Matches elaborated `TypeLoc`s that have a named `TypeLoc` matching
7757 template <typename T>
7759 class C<int> c;
7763 elaboratedTypeLoc(hasNamedTypeLoc(templateSpecializationTypeLoc()));
7764 matches the `TypeLoc` of the variable declaration of `c`, but not `d`.
7768 <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>
7769 <tr><td colspan="4" class="doc
" id="hasQualifier0
"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
7770 matches InnerMatcher if the qualifier exists.
7780 elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N
"))))
7781 matches the type of the variable declaration of d.
7785 <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>
7786 <tr><td colspan="4" class="doc
" id="namesType0
"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher.
7796 elaboratedType(namesType(recordType(
7797 hasDeclaration(namedDecl(hasName("D
")))))) matches the type of the variable
7802 <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>
7803 <tr><td colspan="4" class="doc
" id="hasDeclaration10
"><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_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>
7837 <tr><td colspan="4" class="doc
" id="hasDestinationType0
"><pre>Matches casts whose destination type matches a given matcher.
7839 (Note: Clang's AST refers to other conversions as "casts
" too, and calls
7840 actual casts "explicit
" casts.)
7844 <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>
7845 <tr><td colspan="4" class="doc
" id="hasTypeLoc10
"><pre>Matches if the type location of a node matches the inner matcher.
7849 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
7853 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
7856 struct Foo { Foo(int, int); };
7858 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
7861 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>>,
7862 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>>,
7863 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>>,
7864 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
7865 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>>,
7866 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>>,
7867 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>>,
7868 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
7872 <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>
7873 <tr><td colspan="4" class="doc
" id="hasType5
"><pre>Overloaded to match the declaration of the expression's or value
7876 In case of a value declaration (for example a variable declaration),
7877 this resolves one layer of indirection. For example, in the value
7878 declaration "X x;
", cxxRecordDecl(hasName("X
")) matches the declaration of
7879 X, while varDecl(hasType(cxxRecordDecl(hasName("X
")))) matches the
7882 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
7883 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
7884 and friend class X (matcher = friendDecl(hasType("X
"))
7885 and public virtual X (matcher = cxxBaseSpecifier(hasType(
7886 cxxRecordDecl(hasName("X
"))))
7888 void y(X &x) { x; X z; }
7889 class Y { friend class X; };
7890 class Z : public virtual X {};
7892 Example matches class Derived
7893 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base
"))))))
7895 class Derived : Base {};
7897 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>>,
7898 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>
7902 <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>
7903 <tr><td colspan="4" class="doc
" id="hasType0
"><pre>Matches if the expression's or declaration's type matches a type
7906 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
7907 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
7908 and U (matcher = typedefDecl(hasType(asString("int
")))
7909 and friend class X (matcher = friendDecl(hasType("X
"))
7910 and public virtual X (matcher = cxxBaseSpecifier(hasType(
7911 asString("class X
")))
7913 void y(X &x) { x; X z; }
7915 class Y { friend class X; };
7916 class Z : public virtual X {};
7920 <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>
7921 <tr><td colspan="4" class="doc
" id="ignoringElidableConstructorCall0
"><pre>Matches expressions that match InnerMatcher that are possibly wrapped in an
7922 elidable constructor and other corresponding bookkeeping nodes.
7924 In C++17, elidable copy constructors are no longer being generated in the
7925 AST as it is not permitted by the standard. They are, however, part of the
7926 AST in C++14 and earlier. So, a matcher must abstract over these differences
7927 to work in all language modes. This matcher skips elidable constructor-call
7928 AST nodes, `ExprWithCleanups` nodes wrapping elidable constructor-calls and
7929 various implicit nodes inside the constructor calls, all of which will not
7930 appear in the C++17 AST.
7940 ``varDecl(hasInitializer(ignoringElidableConstructorCall(callExpr())))``
7941 matches ``H D = G()`` in C++11 through C++17 (and beyond).
7945 <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>
7946 <tr><td colspan="4" class="doc
" id="ignoringImpCasts0
"><pre>Matches expressions that match InnerMatcher after any implicit casts
7949 Parentheses and explicit casts are not discarded.
7958 varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
7959 varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
7960 would match the declarations for a, b, c, and d, but not e.
7962 varDecl(hasInitializer(integerLiteral()))
7963 varDecl(hasInitializer(declRefExpr()))
7964 only match the declarations for a.
7968 <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>
7969 <tr><td colspan="4" class="doc
" id="ignoringImplicit0
"><pre>Matches expressions that match InnerMatcher after any implicit AST
7970 nodes are stripped off.
7972 Parentheses and explicit casts are not discarded.
7979 varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr())))
7980 would match the declarations for a, b, and c.
7982 varDecl(hasInitializer(cxxConstructExpr()))
7983 only match the declarations for b and c.
7987 <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>
7988 <tr><td colspan="4" class="doc
" id="ignoringParenCasts0
"><pre>Matches expressions that match InnerMatcher after parentheses and
7989 casts are stripped off.
7991 Implicit and non-C Style casts are also discarded.
7995 void* c = reinterpret_cast<char*>(0);
7998 varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
7999 would match the declarations for a, b, c, and d.
8001 varDecl(hasInitializer(integerLiteral()))
8002 only match the declaration for a.
8006 <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>
8007 <tr><td colspan="4" class="doc
" id="ignoringParenImpCasts0
"><pre>Matches expressions that match InnerMatcher after implicit casts and
8008 parentheses are stripped off.
8010 Explicit casts are not discarded.
8017 long e = ((long) 0l);
8019 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
8020 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
8021 would match the declarations for a, b, c, and d, but not e.
8023 varDecl(hasInitializer(integerLiteral()))
8024 varDecl(hasInitializer(declRefExpr()))
8025 would only match the declaration for a.
8029 <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>
8030 <tr><td colspan="4" class="doc
" id="ignoringParens1
"><pre>Overload ignoringParens for Expr.
8033 const char* str = ("my-string
");
8035 implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral())))
8036 would match the implicit cast resulting from the assignment.
8040 <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>
8041 <tr><td colspan="4" class="doc
" id="hasInClassInitializer0
"><pre>Matches non-static data members that have an in-class initializer.
8049 fieldDecl(hasInClassInitializer(integerLiteral(equals(2))))
8050 matches 'int a;' but not 'int b;'.
8051 fieldDecl(hasInClassInitializer(anything()))
8052 matches 'int a;' and 'int b;' but not 'int c;'.
8056 <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>
8057 <tr><td colspan="4" class="doc
" id="hasBody1
"><pre></pre></td></tr>
8060 <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>
8061 <tr><td colspan="4" class="doc
" id="hasCondition1
"><pre>Matches the condition expression of an if statement, for loop,
8062 switch statement or conditional operator.
8064 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8069 <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>
8070 <tr><td colspan="4" class="doc
" id="hasIncrement0
"><pre>Matches the increment statement of a for loop.
8073 forStmt(hasIncrement(unaryOperator(hasOperatorName("++
"))))
8075 for (x; x < N; ++x) { }
8079 <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>
8080 <tr><td colspan="4" class="doc
" id="hasLoopInit0
"><pre>Matches the initialization statement of a for loop.
8083 forStmt(hasLoopInit(declStmt()))
8084 matches 'int x = 0' in
8085 for (int x = 0; x < N; ++x) { }
8089 <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>
8090 <tr><td colspan="4" class="doc
" id="hasType6
"><pre>Overloaded to match the declaration of the expression's or value
8093 In case of a value declaration (for example a variable declaration),
8094 this resolves one layer of indirection. For example, in the value
8095 declaration "X x;
", cxxRecordDecl(hasName("X
")) matches the declaration of
8096 X, while varDecl(hasType(cxxRecordDecl(hasName("X
")))) matches the
8099 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
8100 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
8101 and friend class X (matcher = friendDecl(hasType("X
"))
8102 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8103 cxxRecordDecl(hasName("X
"))))
8105 void y(X &x) { x; X z; }
8106 class Y { friend class X; };
8107 class Z : public virtual X {};
8109 Example matches class Derived
8110 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base
"))))))
8112 class Derived : Base {};
8114 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>>,
8115 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>
8119 <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>
8120 <tr><td colspan="4" class="doc
" id="hasType1
"><pre>Matches if the expression's or declaration's type matches a type
8123 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
8124 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
8125 and U (matcher = typedefDecl(hasType(asString("int
")))
8126 and friend class X (matcher = friendDecl(hasType("X
"))
8127 and public virtual X (matcher = cxxBaseSpecifier(hasType(
8128 asString("class X
")))
8130 void y(X &x) { x; X z; }
8132 class Y { friend class X; };
8133 class Z : public virtual X {};
8137 <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>
8138 <tr><td colspan="4" class="doc
" id="hasAnyBody0
"><pre>Matches a function declaration that has a given body present in the AST.
8139 Note that this matcher matches all the declarations of a function whose
8140 body is present in the AST.
8146 functionDecl(hasAnyBody(compoundStmt()))
8147 matches both 'void f();'
8151 but does not match 'void g();'
8155 <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>
8156 <tr><td colspan="4" class="doc
" id="hasAnyParameter0
"><pre>Matches any parameter of a function or an ObjC method declaration or a
8159 Does not match the 'this' parameter of a method.
8162 class X { void f(int x, int y, int z) {} };
8163 cxxMethodDecl(hasAnyParameter(hasName("y
")))
8164 matches f(int x, int y, int z) {}
8165 with hasAnyParameter(...)
8168 For ObjectiveC, given
8169 @interface I - (void) f:(int) y; @end
8171 the matcher objcMethodDecl(hasAnyParameter(hasName("y
")))
8172 matches the declaration of method f with hasParameter
8176 b = ^(int y) { printf("%d
", y) };
8178 the matcher blockDecl(hasAnyParameter(hasName("y
")))
8179 matches the declaration of the block b with hasParameter
8184 <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>
8185 <tr><td colspan="4" class="doc
" id="hasAnyTemplateArgument2
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
8186 functionDecl that have at least one TemplateArgument matching the given
8190 template<typename T> class A {};
8191 template<> class A<double> {};
8194 template<typename T> f() {};
8195 void func() { f<int>(); };
8197 classTemplateSpecializationDecl(hasAnyTemplateArgument(
8198 refersToType(asString("int
"))))
8199 matches the specialization A<int>
8201 functionDecl(hasAnyTemplateArgument(refersToType(asString("int
"))))
8202 matches the specialization f<int>
8206 <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>
8207 <tr><td colspan="4" class="doc
" id="hasBody4
"><pre></pre></td></tr>
8210 <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>
8211 <tr><td colspan="4" class="doc
" id="hasExplicitSpecifier0
"><pre>Matches the expression in an explicit specifier if present in the given
8215 template<bool b>
8218 explicit S(double); // #2
8219 operator int(); // #3
8220 explicit operator bool(); // #4
8221 explicit(false) S(bool) // # 7
8222 explicit(true) S(char) // # 8
8223 explicit(b) S(S) // # 9
8225 S(int) -> S<true> // #5
8226 explicit S(double) -> S<false> // #6
8227 cxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8 and #9, but not #1 or #2.
8228 cxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or #4.
8229 cxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not match #5 or #6.
8233 <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>
8234 <tr><td colspan="4" class="doc
" id="hasParameter0
"><pre>Matches the n'th parameter of a function or an ObjC method
8235 declaration or a block.
8238 class X { void f(int x) {} };
8239 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
8241 with hasParameter(...)
8244 For ObjectiveC, given
8245 @interface I - (void) f:(int) y; @end
8247 the matcher objcMethodDecl(hasParameter(0, hasName("y
")))
8248 matches the declaration of method f with hasParameter
8253 <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>
8254 <tr><td colspan="4" class="doc
" id="hasReturnTypeLoc0
"><pre>Matches a function declared with the specified return `TypeLoc`.
8257 int f() { return 5; }
8259 functionDecl(hasReturnTypeLoc(loc(asString("int
"))))
8260 matches the declaration of `f`, but not `g`.
8264 <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>
8265 <tr><td colspan="4" class="doc
" id="hasTemplateArgument2
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
8266 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
8269 template<typename T, typename U> class A {};
8270 A<bool, int> b;
8271 A<int, bool> c;
8273 template<typename T> void f() {}
8274 void func() { f<int>(); };
8275 classTemplateSpecializationDecl(hasTemplateArgument(
8276 1, refersToType(asString("int
"))))
8277 matches the specialization A<bool, int>
8279 functionDecl(hasTemplateArgument(0, refersToType(asString("int
"))))
8280 matches the specialization f<int>
8284 <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>
8285 <tr><td colspan="4" class="doc
" id="returns0
"><pre>Matches the return type of a function declaration.
8288 class X { int f() { return 1; } };
8289 cxxMethodDecl(returns(asString("int
")))
8290 matches int f() { return 1; }
8294 <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>
8295 <tr><td colspan="4" class="doc
" id="hasCondition0
"><pre>Matches the condition expression of an if statement, for loop,
8296 switch statement or conditional operator.
8298 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8303 <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>
8304 <tr><td colspan="4" class="doc
" id="hasConditionVariableStatement0
"><pre>Matches the condition variable statement in an if statement.
8307 if (A* a = GetAPointer()) {}
8308 hasConditionVariableStatement(...)
8309 matches 'A* a = GetAPointer()'.
8313 <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>
8314 <tr><td colspan="4" class="doc
" id="hasElse0
"><pre>Matches the else-statement of an if statement.
8316 Examples matches the if statement
8317 (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true)))))
8318 if (false) false; else true;
8322 <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>
8323 <tr><td colspan="4" class="doc
" id="hasInitStatement0
"><pre>Matches selection statements with initializer.
8327 if (int i = foobar(); i > 0) {}
8328 switch (int i = foobar(); i) {}
8329 for (auto& a = get_range(); auto& x : a) {}
8332 if (foobar() > 0) {}
8333 switch (foobar()) {}
8334 for (auto& x : get_range()) {}
8336 ifStmt(hasInitStatement(anything()))
8337 matches the if statement in foo but not in bar.
8338 switchStmt(hasInitStatement(anything()))
8339 matches the switch statement in foo but not in bar.
8340 cxxForRangeStmt(hasInitStatement(anything()))
8341 matches the range for statement in foo but not in bar.
8345 <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>
8346 <tr><td colspan="4" class="doc
" id="hasThen0
"><pre>Matches the then-statement of an if statement.
8348 Examples matches the if statement
8349 (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true)))))
8350 if (false) true; else false;
8354 <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>
8355 <tr><td colspan="4" class="doc
" id="hasImplicitDestinationType0
"><pre>Matches implicit casts whose destination type matches a given
8358 FIXME: Unit test this matcher
8362 <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>
8363 <tr><td colspan="4" class="doc
" id="hasInit0
"><pre>Matches the n'th item of an initializer list expression.
8366 (matcher = initListExpr(hasInit(0, expr())))
8371 <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>
8372 <tr><td colspan="4" class="doc
" id="hasSyntacticForm0
"><pre>Matches the syntactic form of init list expressions
8373 (if expression have it).
8377 <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>
8378 <tr><td colspan="4" class="doc
" id="hasDeclaration9
"><pre>Matches a node if the declaration associated with that node
8379 matches the given matcher.
8381 The associated declaration is:
8382 - for type nodes, the declaration of the underlying type
8383 - for CallExpr, the declaration of the callee
8384 - for MemberExpr, the declaration of the referenced member
8385 - for CXXConstructExpr, the declaration of the constructor
8386 - for CXXNewExpr, the declaration of the operator new
8387 - for ObjCIvarExpr, the declaration of the ivar
8389 For type nodes, hasDeclaration will generally match the declaration of the
8394 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8395 typedefDecl. A common use case is to match the underlying, desugared type.
8396 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8397 varDecl(hasType(hasUnqualifiedDesugaredType(
8398 recordType(hasDeclaration(decl())))))
8399 In this matcher, the decl will match the CXXRecordDecl of class X.
8401 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>>,
8402 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>>,
8403 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>>,
8404 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>>,
8405 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>>,
8406 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>>,
8407 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
8411 <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>
8412 <tr><td colspan="4" class="doc
" id="hasDeclaration8
"><pre>Matches a node if the declaration associated with that node
8413 matches the given matcher.
8415 The associated declaration is:
8416 - for type nodes, the declaration of the underlying type
8417 - for CallExpr, the declaration of the callee
8418 - for MemberExpr, the declaration of the referenced member
8419 - for CXXConstructExpr, the declaration of the constructor
8420 - for CXXNewExpr, the declaration of the operator new
8421 - for ObjCIvarExpr, the declaration of the ivar
8423 For type nodes, hasDeclaration will generally match the declaration of the
8428 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8429 typedefDecl. A common use case is to match the underlying, desugared type.
8430 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8431 varDecl(hasType(hasUnqualifiedDesugaredType(
8432 recordType(hasDeclaration(decl())))))
8433 In this matcher, the decl will match the CXXRecordDecl of class X.
8435 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>>,
8436 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>>,
8437 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>>,
8438 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>>,
8439 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>>,
8440 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>>,
8441 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
8445 <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_1VarDecl.html
">VarDecl</a>> InnerMatcher</td></tr>
8446 <tr><td colspan="4" class="doc
" id="capturesVar0
"><pre>Matches a `LambdaCapture` that refers to the specified `VarDecl`. The
8447 `VarDecl` can be a separate variable that is captured by value or
8448 reference, or a synthesized variable if the capture has an initializer.
8454 auto g = [x = 1](){};
8457 lambdaExpr(hasAnyCapture(lambdaCapture(capturesVar(hasName("x
")))),
8458 capturesVar(hasName("x
")) matches `x` and `x = 1`.
8462 <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>
8463 <tr><td colspan="4" class="doc
" id="forEachLambdaCapture0
"><pre>Matches each lambda capture in a lambda expression.
8469 auto f = [=]() { return x + y + z; };
8471 lambdaExpr(forEachLambdaCapture(
8472 lambdaCapture(capturesVar(varDecl(hasType(isInteger()))))))
8473 will trigger two matches, binding for 'x' and 'y' respectively.
8477 <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>
8478 <tr><td colspan="4" class="doc
" id="hasAnyCapture0
"><pre>Matches any capture in a lambda expression.
8483 auto f = [=](){ return t; };
8485 lambdaExpr(hasAnyCapture(lambdaCapture())) and
8486 lambdaExpr(hasAnyCapture(lambdaCapture(refersToVarDecl(hasName("t
")))))
8487 both match `[=](){ return t; }`.
8491 <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>
8492 <tr><td colspan="4" class="doc
" id="hasDeclaration7
"><pre>Matches a node if the declaration associated with that node
8493 matches the given matcher.
8495 The associated declaration is:
8496 - for type nodes, the declaration of the underlying type
8497 - for CallExpr, the declaration of the callee
8498 - for MemberExpr, the declaration of the referenced member
8499 - for CXXConstructExpr, the declaration of the constructor
8500 - for CXXNewExpr, the declaration of the operator new
8501 - for ObjCIvarExpr, the declaration of the ivar
8503 For type nodes, hasDeclaration will generally match the declaration of the
8508 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8509 typedefDecl. A common use case is to match the underlying, desugared type.
8510 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8511 varDecl(hasType(hasUnqualifiedDesugaredType(
8512 recordType(hasDeclaration(decl())))))
8513 In this matcher, the decl will match the CXXRecordDecl of class X.
8515 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>>,
8516 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>>,
8517 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>>,
8518 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>>,
8519 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>>,
8520 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>>,
8521 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
8525 <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>
8526 <tr><td colspan="4" class="doc
" id="hasObjectExpression0
"><pre>Matches a member expression where the object expression is matched by a
8527 given matcher. Implicit object expressions are included; that is, it matches
8528 use of implicit `this`.
8533 int f(X x) { x.m; return m; }
8535 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X
")))))
8536 matches `x.m`, but not `m`; however,
8537 memberExpr(hasObjectExpression(hasType(pointsTo(
8538 cxxRecordDecl(hasName("X
"))))))
8539 matches `m` (aka. `this->m`), but not `x.m`.
8543 <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>
8544 <tr><td colspan="4" class="doc
" id="member0
"><pre>Matches a member expression where the member is matched by a
8548 struct { int first, second; } first, second;
8549 int i(second.first);
8550 int j(first.second);
8551 memberExpr(member(hasName("first
")))
8552 matches second.first
8553 but not first.second (because the member name there is "second
").
8557 <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>
8558 <tr><td colspan="4" class="doc
" id="pointee1
"><pre>Narrows PointerType (and similar) matchers to those where the
8559 pointee matches a given matcher.
8565 pointerType(pointee(isConstQualified(), isInteger()))
8566 matches "int const *b
"
8568 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>>,
8569 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>>
8573 <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>
8574 <tr><td colspan="4" class="doc
" id="hasUnderlyingDecl0
"><pre>Matches a NamedDecl whose underlying declaration matches the given
8578 namespace N { template<class T> void f(T t); }
8579 template <class T> void g() { using N::f; f(T()); }
8580 unresolvedLookupExpr(hasAnyDeclaration(
8581 namedDecl(hasUnderlyingDecl(hasName("::N::f
")))))
8582 matches the use of f in g() .
8586 <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>
8587 <tr><td colspan="4" class="doc
" id="hasPrefix1
"><pre>Matches on the prefix of a NestedNameSpecifierLoc.
8590 struct A { struct B { struct C {}; }; };
8592 nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A
")))))
8597 <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>
8598 <tr><td colspan="4" class="doc
" id="loc1
"><pre>Matches NestedNameSpecifierLocs for which the given inner
8599 NestedNameSpecifier-matcher matches.
8603 <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>
8604 <tr><td colspan="4" class="doc
" id="specifiesTypeLoc0
"><pre>Matches nested name specifier locs that specify a type matching the
8608 struct A { struct B { struct C {}; }; };
8610 nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
8611 hasDeclaration(cxxRecordDecl(hasName("A
")))))))
8616 <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>
8617 <tr><td colspan="4" class="doc
" id="hasPrefix0
"><pre>Matches on the prefix of a NestedNameSpecifier.
8620 struct A { struct B { struct C {}; }; };
8622 nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A
")))) and
8627 <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>
8628 <tr><td colspan="4" class="doc
" id="specifiesNamespace0
"><pre>Matches nested name specifiers that specify a namespace matching the
8629 given namespace matcher.
8632 namespace ns { struct A {}; }
8634 nestedNameSpecifier(specifiesNamespace(hasName("ns
")))
8639 <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>
8640 <tr><td colspan="4" class="doc
" id="specifiesType0
"><pre>Matches nested name specifiers that specify a type matching the
8641 given QualType matcher without qualifiers.
8644 struct A { struct B { struct C {}; }; };
8646 nestedNameSpecifier(specifiesType(
8647 hasDeclaration(cxxRecordDecl(hasName("A
")))
8653 <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>
8654 <tr><td colspan="4" class="doc
" id="hasAnyClause0
"><pre>Matches any clause in an OpenMP directive.
8658 #pragma omp parallel
8659 #pragma omp parallel default(none)
8661 ``ompExecutableDirective(hasAnyClause(anything()))`` matches
8662 ``omp parallel default(none)``.
8666 <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>
8667 <tr><td colspan="4" class="doc
" id="hasStructuredBlock0
"><pre>Matches the structured-block of the OpenMP executable directive
8669 Prerequisite: the executable directive must not be standalone directive.
8670 If it is, it will never match.
8674 #pragma omp parallel
8676 #pragma omp parallel
8679 ``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;``
8683 <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>
8684 <tr><td colspan="4" class="doc
" id="isDerivedFrom1
"><pre>Matches C++ classes that are directly or indirectly derived from a class
8685 matching Base, or Objective-C classes that directly or indirectly
8686 subclass a class matching Base.
8688 Note that a class is not considered to be derived from itself.
8690 Example matches Y, Z, C (Base == hasName("X
"))
8692 class Y : public X {}; // directly derived
8693 class Z : public Y {}; // indirectly derived
8696 class C : public B {}; // derived from a typedef of X
8698 In the following example, Bar matches isDerivedFrom(hasName("X
")):
8701 class Bar : public Foo {}; // derived from a type that X is a typedef of
8703 In the following example, Bar matches isDerivedFrom(hasName("NSObject
"))
8704 @interface NSObject @end
8705 @interface Bar : NSObject @end
8707 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>>
8711 <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>
8712 <tr><td colspan="4" class="doc
" id="isDirectlyDerivedFrom1
"><pre>Matches C++ or Objective-C classes that are directly derived from a class
8715 Note that a class is not considered to be derived from itself.
8717 Example matches Y, C (Base == hasName("X
"))
8719 class Y : public X {}; // directly derived
8720 class Z : public Y {}; // indirectly derived
8723 class C : public B {}; // derived from a typedef of X
8725 In the following example, Bar matches isDerivedFrom(hasName("X
")):
8728 class Bar : public Foo {}; // derived from a type that X is a typedef of
8732 <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>
8733 <tr><td colspan="4" class="doc
" id="isSameOrDerivedFrom1
"><pre>Similar to isDerivedFrom(), but also matches classes that directly
8738 <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>
8739 <tr><td colspan="4" class="doc
" id="hasAnyArgument3
"><pre>Matches any argument of a call expression or a constructor call
8740 expression, or an ObjC-message-send expression.
8743 void x(int, int, int) { int y; x(1, y, 42); }
8744 callExpr(hasAnyArgument(declRefExpr()))
8746 with hasAnyArgument(...)
8749 For ObjectiveC, given
8750 @interface I - (void) f:(int) y; @end
8751 void foo(I *i) { [i f:12]; }
8752 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
8757 <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>
8758 <tr><td colspan="4" class="doc
" id="hasArgument3
"><pre>Matches the n'th argument of a call expression or a constructor
8761 Example matches y in x(y)
8762 (matcher = callExpr(hasArgument(0, declRefExpr())))
8763 void x(int) { int y; x(y); }
8767 <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>
8768 <tr><td colspan="4" class="doc
" id="hasReceiver0
"><pre>Matches if the Objective-C message is sent to an instance,
8769 and the inner matcher matches on that instance.
8771 For example the method call in
8772 NSString *x = @"hello
";
8773 [x containsString:@"h
"];
8775 objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x
"))))))
8779 <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>
8780 <tr><td colspan="4" class="doc
" id="hasReceiverType0
"><pre>Matches on the receiver of an ObjectiveC Message expression.
8783 matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *
")));
8784 matches the [webView ...] message invocation.
8785 NSString *webViewJavaScript = ...
8786 UIWebView *webView = ...
8787 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript];
8791 <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>
8792 <tr><td colspan="4" class="doc
" id="hasAnyParameter1
"><pre>Matches any parameter of a function or an ObjC method declaration or a
8795 Does not match the 'this' parameter of a method.
8798 class X { void f(int x, int y, int z) {} };
8799 cxxMethodDecl(hasAnyParameter(hasName("y
")))
8800 matches f(int x, int y, int z) {}
8801 with hasAnyParameter(...)
8804 For ObjectiveC, given
8805 @interface I - (void) f:(int) y; @end
8807 the matcher objcMethodDecl(hasAnyParameter(hasName("y
")))
8808 matches the declaration of method f with hasParameter
8812 b = ^(int y) { printf("%d
", y) };
8814 the matcher blockDecl(hasAnyParameter(hasName("y
")))
8815 matches the declaration of the block b with hasParameter
8820 <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>
8821 <tr><td colspan="4" class="doc
" id="hasParameter1
"><pre>Matches the n'th parameter of a function or an ObjC method
8822 declaration or a block.
8825 class X { void f(int x) {} };
8826 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
8828 with hasParameter(...)
8831 For ObjectiveC, given
8832 @interface I - (void) f:(int) y; @end
8834 the matcher objcMethodDecl(hasParameter(0, hasName("y
")))
8835 matches the declaration of method f with hasParameter
8840 <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>
8841 <tr><td colspan="4" class="doc
" id="hasTypeLoc11
"><pre>Matches if the type location of a node matches the inner matcher.
8845 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
8849 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
8852 struct Foo { Foo(int, int); };
8854 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
8857 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>>,
8858 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>>,
8859 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>>,
8860 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
8861 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>>,
8862 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>>,
8863 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>>,
8864 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
8868 <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>
8869 <tr><td colspan="4" class="doc
" id="hasSourceExpression1
"><pre>Matches if the cast's source expression
8870 or opaque value's source expression matches the given matcher.
8872 Example 1: matches "a string
"
8873 (matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
8874 class URL { URL(string); };
8875 URL url = "a string
";
8877 Example 2: matches 'b' (matcher =
8878 opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
8883 <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>
8884 <tr><td colspan="4" class="doc
" id="hasAnyDeclaration0
"><pre>Matches an OverloadExpr if any of the declarations in the set of
8885 overloads matches the given matcher.
8888 template <typename T> void foo(T);
8889 template <typename T> void bar(T);
8890 template <typename T> void baz(T t) {
8894 unresolvedLookupExpr(hasAnyDeclaration(
8895 functionTemplateDecl(hasName("foo
"))))
8896 matches foo in foo(t); but not bar in bar(t);
8900 <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>
8901 <tr><td colspan="4" class="doc
" id="innerType0
"><pre>Matches ParenType nodes where the inner type is a specific type.
8904 int (*ptr_to_array)[4];
8905 int (*ptr_to_func)(int);
8907 varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
8908 ptr_to_func but not ptr_to_array.
8910 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html
">ParenType</a>>
8914 <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>
8915 <tr><td colspan="4" class="doc
" id="hasPointeeLoc0
"><pre>Matches pointer `TypeLoc`s that have a pointee `TypeLoc` matching
8920 pointerTypeLoc(hasPointeeLoc(loc(asString("int
"))))
8925 <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>
8926 <tr><td colspan="4" class="doc
" id="pointee2
"><pre>Narrows PointerType (and similar) matchers to those where the
8927 pointee matches a given matcher.
8933 pointerType(pointee(isConstQualified(), isInteger()))
8934 matches "int const *b
"
8936 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>>,
8937 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>>
8941 <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>
8942 <tr><td colspan="4" class="doc
" id="hasCanonicalType0
"><pre>Matches QualTypes whose canonical type matches InnerMatcher.
8945 typedef int &int_ref;
8949 varDecl(hasType(qualType(referenceType()))))) will not match the
8950 declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does.
8954 <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>
8955 <tr><td colspan="4" class="doc
" id="hasDeclaration6
"><pre>Matches a node if the declaration associated with that node
8956 matches the given matcher.
8958 The associated declaration is:
8959 - for type nodes, the declaration of the underlying type
8960 - for CallExpr, the declaration of the callee
8961 - for MemberExpr, the declaration of the referenced member
8962 - for CXXConstructExpr, the declaration of the constructor
8963 - for CXXNewExpr, the declaration of the operator new
8964 - for ObjCIvarExpr, the declaration of the ivar
8966 For type nodes, hasDeclaration will generally match the declaration of the
8971 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8972 typedefDecl. A common use case is to match the underlying, desugared type.
8973 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8974 varDecl(hasType(hasUnqualifiedDesugaredType(
8975 recordType(hasDeclaration(decl())))))
8976 In this matcher, the decl will match the CXXRecordDecl of class X.
8978 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>>,
8979 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>>,
8980 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>>,
8981 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>>,
8982 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>>,
8983 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>>,
8984 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
8988 <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>
8989 <tr><td colspan="4" class="doc
" id="ignoringParens0
"><pre>Matches types that match InnerMatcher after any parens are stripped.
8994 varDecl(hasType(pointerType(pointee(ignoringParens(functionType())))))
8995 would match the declaration for fp.
8999 <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>
9000 <tr><td colspan="4" class="doc
" id="pointsTo1
"><pre>Overloaded to match the pointee type's declaration.
9004 <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>
9005 <tr><td colspan="4" class="doc
" id="pointsTo0
"><pre>Matches if the matched type is a pointer type and the pointee type
9006 matches the specified matcher.
9008 Example matches y->x()
9009 (matcher = cxxMemberCallExpr(on(hasType(pointsTo
9010 cxxRecordDecl(hasName("Y
")))))))
9011 class Y { public: void x(); };
9012 void z() { Y *y; y->x(); }
9016 <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>
9017 <tr><td colspan="4" class="doc
" id="references1
"><pre>Overloaded to match the referenced type's declaration.
9021 <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>
9022 <tr><td colspan="4" class="doc
" id="references0
"><pre>Matches if the matched type is a reference type and the referenced
9023 type matches the specified matcher.
9025 Example matches X &x and const X &y
9026 (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X
"))))))
9036 <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>
9037 <tr><td colspan="4" class="doc
" id="hasUnqualifiedLoc0
"><pre>Matches `QualifiedTypeLoc`s that have an unqualified `TypeLoc` matching
9043 qualifiedTypeLoc(hasUnqualifiedLoc(pointerTypeLoc()))
9044 matches the `TypeLoc` of the variable declaration of `x`, but not `y`.
9048 <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>
9049 <tr><td colspan="4" class="doc
" id="hasDeclaration5
"><pre>Matches a node if the declaration associated with that node
9050 matches the given matcher.
9052 The associated declaration is:
9053 - for type nodes, the declaration of the underlying type
9054 - for CallExpr, the declaration of the callee
9055 - for MemberExpr, the declaration of the referenced member
9056 - for CXXConstructExpr, the declaration of the constructor
9057 - for CXXNewExpr, the declaration of the operator new
9058 - for ObjCIvarExpr, the declaration of the ivar
9060 For type nodes, hasDeclaration will generally match the declaration of the
9065 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9066 typedefDecl. A common use case is to match the underlying, desugared type.
9067 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9068 varDecl(hasType(hasUnqualifiedDesugaredType(
9069 recordType(hasDeclaration(decl())))))
9070 In this matcher, the decl will match the CXXRecordDecl of class X.
9072 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>>,
9073 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>>,
9074 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>>,
9075 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>>,
9076 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>>,
9077 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>>,
9078 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
9082 <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>
9083 <tr><td colspan="4" class="doc
" id="hasReferentLoc0
"><pre>Matches reference `TypeLoc`s that have a referent `TypeLoc` matching
9089 referenceTypeLoc(hasReferentLoc(loc(asString("int
"))))
9094 <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>
9095 <tr><td colspan="4" class="doc
" id="pointee3
"><pre>Narrows PointerType (and similar) matchers to those where the
9096 pointee matches a given matcher.
9102 pointerType(pointee(isConstQualified(), isInteger()))
9103 matches "int const *b
"
9105 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>>,
9106 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>>
9110 <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>
9111 <tr><td colspan="4" class="doc
" id="hasReturnValue0
"><pre>Matches the return value expression of a return statement
9115 hasReturnValue(binaryOperator())
9116 matches 'return a + b'
9117 with binaryOperator()
9122 <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>
9123 <tr><td colspan="4" class="doc
" id="hasAnySubstatement1
"><pre>Matches compound statements where at least one substatement matches
9124 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
9128 hasAnySubstatement(compoundStmt())
9129 matches '{ {}; 1+2; }'
9135 <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>
9136 <tr><td colspan="4" class="doc
" id="alignOfExpr0
"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
9141 <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>
9142 <tr><td colspan="4" class="doc
" id="forCallable0
"><pre>Matches declaration of the function, method, or block the statement
9146 F& operator=(const F& o) {
9147 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
9150 returnStmt(forCallable(functionDecl(hasName("operator=
"))))
9151 matches 'return *this'
9152 but does not match 'return v > 0'
9157 dispatch_sync(queue, ^{ int y = 2; });
9159 declStmt(forCallable(objcMethodDecl()))
9161 but does not match 'int y = 2'.
9162 whereas declStmt(forCallable(blockDecl()))
9164 but does not match 'int x = 1'.
9168 <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>
9169 <tr><td colspan="4" class="doc
" id="forFunction0
"><pre>Matches declaration of the function the statement belongs to.
9171 Deprecated. Use forCallable() to correctly handle the situation when
9172 the declaration is not a function (but a block or an Objective-C method).
9173 forFunction() not only fails to take non-functions into account but also
9174 may match the wrong declaration in their presence.
9177 F& operator=(const F& o) {
9178 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
9181 returnStmt(forFunction(hasName("operator=
")))
9182 matches 'return *this'
9183 but does not match 'return v > 0'
9187 <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>
9188 <tr><td colspan="4" class="doc
" id="sizeOfExpr0
"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
9193 <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>
9194 <tr><td colspan="4" class="doc
" id="hasReplacementType0
"><pre>Matches template type parameter substitutions that have a replacement
9195 type that matches the provided matcher.
9198 template <typename T>
9203 substTemplateTypeParmType(hasReplacementType(type())) matches int
9207 <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>
9208 <tr><td colspan="4" class="doc
" id="forEachSwitchCase0
"><pre>Matches each case or default statement belonging to the given switch
9209 statement. This matcher may produce multiple matches.
9212 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }
9213 switchStmt(forEachSwitchCase(caseStmt().bind("c
"))).bind("s
")
9214 matches four times, with "c
" binding each of "case
1:
", "case
2:
",
9215 "case
3:
" and "case
4:
", and "s
" respectively binding "switch (
1)
",
9216 "switch (
1)
", "switch (
2)
" and "switch (
2)
".
9220 <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>
9221 <tr><td colspan="4" class="doc
" id="hasCondition4
"><pre>Matches the condition expression of an if statement, for loop,
9222 switch statement or conditional operator.
9224 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
9229 <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>
9230 <tr><td colspan="4" class="doc
" id="hasInitStatement1
"><pre>Matches selection statements with initializer.
9234 if (int i = foobar(); i > 0) {}
9235 switch (int i = foobar(); i) {}
9236 for (auto& a = get_range(); auto& x : a) {}
9239 if (foobar() > 0) {}
9240 switch (foobar()) {}
9241 for (auto& x : get_range()) {}
9243 ifStmt(hasInitStatement(anything()))
9244 matches the if statement in foo but not in bar.
9245 switchStmt(hasInitStatement(anything()))
9246 matches the switch statement in foo but not in bar.
9247 cxxForRangeStmt(hasInitStatement(anything()))
9248 matches the range for statement in foo but not in bar.
9252 <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>
9253 <tr><td colspan="4" class="doc
" id="hasDeclaration4
"><pre>Matches a node if the declaration associated with that node
9254 matches the given matcher.
9256 The associated declaration is:
9257 - for type nodes, the declaration of the underlying type
9258 - for CallExpr, the declaration of the callee
9259 - for MemberExpr, the declaration of the referenced member
9260 - for CXXConstructExpr, the declaration of the constructor
9261 - for CXXNewExpr, the declaration of the operator new
9262 - for ObjCIvarExpr, the declaration of the ivar
9264 For type nodes, hasDeclaration will generally match the declaration of the
9269 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9270 typedefDecl. A common use case is to match the underlying, desugared type.
9271 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9272 varDecl(hasType(hasUnqualifiedDesugaredType(
9273 recordType(hasDeclaration(decl())))))
9274 In this matcher, the decl will match the CXXRecordDecl of class X.
9276 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>>,
9277 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>>,
9278 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>>,
9279 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>>,
9280 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>>,
9281 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>>,
9282 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
9286 <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>
9287 <tr><td colspan="4" class="doc
" id="hasTypeLoc12
"><pre>Matches if the type location of a node matches the inner matcher.
9291 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
9295 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
9298 struct Foo { Foo(int, int); };
9300 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
9303 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>>,
9304 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>>,
9305 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>>,
9306 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
9307 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>>,
9308 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>>,
9309 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>>,
9310 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
9314 <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>
9315 <tr><td colspan="4" class="doc
" id="isExpr0
"><pre>Matches a sugar TemplateArgument that refers to a certain expression.
9318 struct B { int next; };
9319 template<int(B::*next_ptr)> struct A {};
9320 A<&B::next> a;
9321 templateSpecializationType(hasAnyTemplateArgument(
9322 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next
"))))))))
9323 matches the specialization A<&B::next> with fieldDecl(...) matching
9328 <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>
9329 <tr><td colspan="4" class="doc
" id="refersToDeclaration0
"><pre>Matches a canonical TemplateArgument that refers to a certain
9333 struct B { int next; };
9334 template<int(B::*next_ptr)> struct A {};
9335 A<&B::next> a;
9336 classTemplateSpecializationDecl(hasAnyTemplateArgument(
9337 refersToDeclaration(fieldDecl(hasName("next
")))))
9338 matches the specialization A<&B::next> with fieldDecl(...) matching
9343 <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>
9344 <tr><td colspan="4" class="doc
" id="refersToIntegralType0
"><pre>Matches a TemplateArgument that refers to an integral type.
9347 template<int T> struct C {};
9349 classTemplateSpecializationDecl(
9350 hasAnyTemplateArgument(refersToIntegralType(asString("int
"))))
9351 matches the implicit instantiation of C in C<42>.
9355 <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>
9356 <tr><td colspan="4" class="doc
" id="refersToTemplate0
"><pre>Matches a TemplateArgument that refers to a certain template.
9359 template<template <typename> class S> class X {};
9360 template<typename T> class Y {};
9362 classTemplateSpecializationDecl(hasAnyTemplateArgument(
9363 refersToTemplate(templateName())))
9364 matches the specialization X<Y>
9368 <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>
9369 <tr><td colspan="4" class="doc
" id="refersToType0
"><pre>Matches a TemplateArgument that refers to a certain type.
9373 template<typename T> struct A {};
9375 classTemplateSpecializationDecl(hasAnyTemplateArgument(
9376 refersToType(class(hasName("X
")))))
9377 matches the specialization A<X>
9381 <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>
9382 <tr><td colspan="4" class="doc
" id="hasAnyTemplateArgumentLoc0
"><pre>Matches template specialization `TypeLoc`s that have at least one
9383 `TemplateArgumentLoc` matching the given `InnerMatcher`.
9386 template<typename T> class A {};
9388 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasAnyTemplateArgumentLoc(
9389 hasTypeLoc(loc(asString("int
")))))))
9390 matches `A<int> a`.
9394 <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>
9395 <tr><td colspan="4" class="doc
" id="hasTemplateArgumentLoc1
"><pre>Matches template specialization `TypeLoc`s where the n'th
9396 `TemplateArgumentLoc` matches the given `InnerMatcher`.
9399 template<typename T, typename U> class A {};
9400 A<double, int> b;
9401 A<int, double> c;
9402 varDecl(hasTypeLoc(templateSpecializationTypeLoc(hasTemplateArgumentLoc(0,
9403 hasTypeLoc(loc(asString("double
")))))))
9404 matches `A<double, int> b`, but not `A<int, double> c`.
9408 <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>
9409 <tr><td colspan="4" class="doc
" id="hasAnyTemplateArgument1
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
9410 functionDecl that have at least one TemplateArgument matching the given
9414 template<typename T> class A {};
9415 template<> class A<double> {};
9418 template<typename T> f() {};
9419 void func() { f<int>(); };
9421 classTemplateSpecializationDecl(hasAnyTemplateArgument(
9422 refersToType(asString("int
"))))
9423 matches the specialization A<int>
9425 functionDecl(hasAnyTemplateArgument(refersToType(asString("int
"))))
9426 matches the specialization f<int>
9430 <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>
9431 <tr><td colspan="4" class="doc
" id="hasDeclaration3
"><pre>Matches a node if the declaration associated with that node
9432 matches the given matcher.
9434 The associated declaration is:
9435 - for type nodes, the declaration of the underlying type
9436 - for CallExpr, the declaration of the callee
9437 - for MemberExpr, the declaration of the referenced member
9438 - for CXXConstructExpr, the declaration of the constructor
9439 - for CXXNewExpr, the declaration of the operator new
9440 - for ObjCIvarExpr, the declaration of the ivar
9442 For type nodes, hasDeclaration will generally match the declaration of the
9447 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9448 typedefDecl. A common use case is to match the underlying, desugared type.
9449 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9450 varDecl(hasType(hasUnqualifiedDesugaredType(
9451 recordType(hasDeclaration(decl())))))
9452 In this matcher, the decl will match the CXXRecordDecl of class X.
9454 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>>,
9455 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>>,
9456 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>>,
9457 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>>,
9458 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>>,
9459 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>>,
9460 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
9464 <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>
9465 <tr><td colspan="4" class="doc
" id="hasTemplateArgument1
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
9466 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
9469 template<typename T, typename U> class A {};
9470 A<bool, int> b;
9471 A<int, bool> c;
9473 template<typename T> void f() {}
9474 void func() { f<int>(); };
9475 classTemplateSpecializationDecl(hasTemplateArgument(
9476 1, refersToType(asString("int
"))))
9477 matches the specialization A<bool, int>
9479 functionDecl(hasTemplateArgument(0, refersToType(asString("int
"))))
9480 matches the specialization f<int>
9484 <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>
9485 <tr><td colspan="4" class="doc
" id="hasDeclaration2
"><pre>Matches a node if the declaration associated with that node
9486 matches the given matcher.
9488 The associated declaration is:
9489 - for type nodes, the declaration of the underlying type
9490 - for CallExpr, the declaration of the callee
9491 - for MemberExpr, the declaration of the referenced member
9492 - for CXXConstructExpr, the declaration of the constructor
9493 - for CXXNewExpr, the declaration of the operator new
9494 - for ObjCIvarExpr, the declaration of the ivar
9496 For type nodes, hasDeclaration will generally match the declaration of the
9501 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9502 typedefDecl. A common use case is to match the underlying, desugared type.
9503 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9504 varDecl(hasType(hasUnqualifiedDesugaredType(
9505 recordType(hasDeclaration(decl())))))
9506 In this matcher, the decl will match the CXXRecordDecl of class X.
9508 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>>,
9509 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>>,
9510 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>>,
9511 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>>,
9512 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>>,
9513 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>>,
9514 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
9518 <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>
9519 <tr><td colspan="4" class="doc
" id="loc0
"><pre>Matches TypeLocs for which the given inner
9520 QualType-matcher matches.
9524 <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>
9525 <tr><td colspan="4" class="doc
" id="hasTypeLoc13
"><pre>Matches if the type location of a node matches the inner matcher.
9529 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
9533 cxxTemporaryObjectExpr(hasTypeLoc(loc(asString("int
"))))
9536 struct Foo { Foo(int, int); };
9538 cxxFunctionalCastExpr(hasTypeLoc(loc(asString("struct Foo
"))))
9541 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>>,
9542 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>>,
9543 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>>,
9544 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html
">CXXUnresolvedConstructExpr</a>>,
9545 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>>,
9546 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>>,
9547 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>>,
9548 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html
">TypedefNameDecl</a>>
9552 <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>
9553 <tr><td colspan="4" class="doc
" id="hasType2
"><pre>Matches if the expression's or declaration's type matches a type
9556 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
9557 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
9558 and U (matcher = typedefDecl(hasType(asString("int
")))
9559 and friend class X (matcher = friendDecl(hasType("X
"))
9560 and public virtual X (matcher = cxxBaseSpecifier(hasType(
9561 asString("class X
")))
9563 void y(X &x) { x; X z; }
9565 class Y { friend class X; };
9566 class Z : public virtual X {};
9570 <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>
9571 <tr><td colspan="4" class="doc
" id="hasDeclaration1
"><pre>Matches a node if the declaration associated with that node
9572 matches the given matcher.
9574 The associated declaration is:
9575 - for type nodes, the declaration of the underlying type
9576 - for CallExpr, the declaration of the callee
9577 - for MemberExpr, the declaration of the referenced member
9578 - for CXXConstructExpr, the declaration of the constructor
9579 - for CXXNewExpr, the declaration of the operator new
9580 - for ObjCIvarExpr, the declaration of the ivar
9582 For type nodes, hasDeclaration will generally match the declaration of the
9587 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9588 typedefDecl. A common use case is to match the underlying, desugared type.
9589 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9590 varDecl(hasType(hasUnqualifiedDesugaredType(
9591 recordType(hasDeclaration(decl())))))
9592 In this matcher, the decl will match the CXXRecordDecl of class X.
9594 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>>,
9595 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>>,
9596 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>>,
9597 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>>,
9598 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>>,
9599 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>>,
9600 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
9604 <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>
9605 <tr><td colspan="4" class="doc
" id="hasUnqualifiedDesugaredType0
"><pre>Matches if the matched type matches the unqualified desugared
9606 type of the matched node.
9611 The matcher type(hasUnqualifiedDesugaredType(recordType())) matches
9616 <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>
9617 <tr><td colspan="4" class="doc
" id="hasArgumentOfType0
"><pre>Matches unary expressions that have a specific type of argument.
9620 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
9621 unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int
"))
9622 matches sizeof(a) and alignof(c)
9626 <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>
9627 <tr><td colspan="4" class="doc
" id="hasUnaryOperand0
"><pre>Matches if the operand of a unary operator matches.
9629 Example matches true (matcher = hasUnaryOperand(
9630 cxxBoolLiteral(equals(true))))
9635 <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>
9636 <tr><td colspan="4" class="doc
" id="hasObjectExpression1
"><pre>Matches a member expression where the object expression is matched by a
9637 given matcher. Implicit object expressions are included; that is, it matches
9638 use of implicit `this`.
9643 int f(X x) { x.m; return m; }
9645 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X
")))))
9646 matches `x.m`, but not `m`; however,
9647 memberExpr(hasObjectExpression(hasType(pointsTo(
9648 cxxRecordDecl(hasName("X
"))))))
9649 matches `m` (aka. `this->m`), but not `x.m`.
9653 <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>
9654 <tr><td colspan="4" class="doc
" id="hasDeclaration0
"><pre>Matches a node if the declaration associated with that node
9655 matches the given matcher.
9657 The associated declaration is:
9658 - for type nodes, the declaration of the underlying type
9659 - for CallExpr, the declaration of the callee
9660 - for MemberExpr, the declaration of the referenced member
9661 - for CXXConstructExpr, the declaration of the constructor
9662 - for CXXNewExpr, the declaration of the operator new
9663 - for ObjCIvarExpr, the declaration of the ivar
9665 For type nodes, hasDeclaration will generally match the declaration of the
9670 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
9671 typedefDecl. A common use case is to match the underlying, desugared type.
9672 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
9673 varDecl(hasType(hasUnqualifiedDesugaredType(
9674 recordType(hasDeclaration(decl())))))
9675 In this matcher, the decl will match the CXXRecordDecl of class X.
9677 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>>,
9678 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>>,
9679 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>>,
9680 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>>,
9681 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>>,
9682 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>>,
9683 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
9687 <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>
9688 <tr><td colspan="4" class="doc
" id="hasTargetDecl0
"><pre>Matches a using shadow declaration where the target declaration is
9689 matched by the given matcher.
9692 namespace X { int a; void b(); }
9695 usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
9696 matches using X::b but not using X::a </pre></td></tr>
9699 <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>
9700 <tr><td colspan="4" class="doc
" id="hasUnderlyingType1
"><pre>Matches DecltypeType or UsingType nodes to find the underlying type.
9704 decltype(2.0) b = 2.0;
9705 decltypeType(hasUnderlyingType(isInteger()))
9706 matches the type of "a
"
9708 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>>
9712 <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>
9713 <tr><td colspan="4" class="doc
" id="throughUsingDecl1
"><pre>Matches if a node refers to a declaration through a specific
9714 using shadow declaration.
9717 namespace a { int f(); }
9720 declRefExpr(throughUsingDecl(anything()))
9723 namespace a { class X{}; }
9726 typeLoc(loc(usingType(throughUsingDecl(anything()))))
9729 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>>
9733 <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>
9734 <tr><td colspan="4" class="doc
" id="hasType7
"><pre>Overloaded to match the declaration of the expression's or value
9737 In case of a value declaration (for example a variable declaration),
9738 this resolves one layer of indirection. For example, in the value
9739 declaration "X x;
", cxxRecordDecl(hasName("X
")) matches the declaration of
9740 X, while varDecl(hasType(cxxRecordDecl(hasName("X
")))) matches the
9743 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
9744 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
9745 and friend class X (matcher = friendDecl(hasType("X
"))
9746 and public virtual X (matcher = cxxBaseSpecifier(hasType(
9747 cxxRecordDecl(hasName("X
"))))
9749 void y(X &x) { x; X z; }
9750 class Y { friend class X; };
9751 class Z : public virtual X {};
9753 Example matches class Derived
9754 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base
"))))))
9756 class Derived : Base {};
9758 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>>,
9759 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>
9763 <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>
9764 <tr><td colspan="4" class="doc
" id="hasType3
"><pre>Matches if the expression's or declaration's type matches a type
9767 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
9768 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
9769 and U (matcher = typedefDecl(hasType(asString("int
")))
9770 and friend class X (matcher = friendDecl(hasType("X
"))
9771 and public virtual X (matcher = cxxBaseSpecifier(hasType(
9772 asString("class X
")))
9774 void y(X &x) { x; X z; }
9776 class Y { friend class X; };
9777 class Z : public virtual X {};
9781 <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>
9782 <tr><td colspan="4" class="doc
" id="hasInitializer0
"><pre>Matches a variable declaration that has an initializer expression
9783 that matches the given matcher.
9785 Example matches x (matcher = varDecl(hasInitializer(callExpr())))
9786 bool y() { return true; }
9791 <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>
9792 <tr><td colspan="4" class="doc
" id="hasSizeExpr0
"><pre>Matches VariableArrayType nodes that have a specific size
9799 variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
9800 varDecl(hasName("b
")))))))
9805 <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>
9806 <tr><td colspan="4" class="doc
" id="hasBody2
"><pre></pre></td></tr>
9809 <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>
9810 <tr><td colspan="4" class="doc
" id="hasCondition2
"><pre>Matches the condition expression of an if statement, for loop,
9811 switch statement or conditional operator.
9813 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
9817 <!--END_TRAVERSAL_MATCHERS -->