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_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>
577 <tr><td colspan=
"4" class=
"doc" id=
"cxxCtorInitializer0"><pre>Matches constructor initializers.
579 Examples matches i(
42).
587 <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>
588 <tr><td colspan=
"4" class=
"doc" id=
"accessSpecDecl0"><pre>Matches C++ access specifier declarations.
600 <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>
601 <tr><td colspan=
"4" class=
"doc" id=
"bindingDecl0"><pre>Matches binding declarations
602 Example matches foo and bar
603 (matcher = bindingDecl()
605 auto [foo, bar] = std::make_pair{
42,
42};
609 <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>
610 <tr><td colspan=
"4" class=
"doc" id=
"blockDecl0"><pre>Matches block declarations.
612 Example matches the declaration of the nameless block printing an input
621 <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>
622 <tr><td colspan=
"4" class=
"doc" id=
"classTemplateDecl0"><pre>Matches C++ class template declarations.
625 template
<class T
> class Z {};
629 <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>
630 <tr><td colspan=
"4" class=
"doc" id=
"classTemplatePartialSpecializationDecl0"><pre>Matches C++ class template partial specializations.
633 template
<class T1, class T2, int I
>
636 template
<class T, int I
>
637 class A
<T, T*, I
> {};
640 class A
<int, int,
1> {};
641 classTemplatePartialSpecializationDecl()
642 matches the specialization A
<T,T*,I
> but not A
<int,int,
1>
646 <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>
647 <tr><td colspan=
"4" class=
"doc" id=
"classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations.
650 template
<typename T
> class A {};
651 template
<> class A
<double
> {};
653 classTemplateSpecializationDecl()
654 matches the specializations A
<int
> and A
<double
>
658 <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>
659 <tr><td colspan=
"4" class=
"doc" id=
"cxxConstructorDecl0"><pre>Matches C++ constructor declarations.
661 Example matches Foo::Foo() and Foo::Foo(int)
671 <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>
672 <tr><td colspan=
"4" class=
"doc" id=
"cxxConversionDecl0"><pre>Matches conversion operator declarations.
674 Example matches the operator.
675 class X { operator int() const; };
679 <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>
680 <tr><td colspan=
"4" class=
"doc" id=
"cxxDeductionGuideDecl0"><pre>Matches user-defined and implicitly generated deduction guide.
682 Example matches the deduction guide.
683 template
<typename T
>
685 X(int) -
> X
<int
>;
689 <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>
690 <tr><td colspan=
"4" class=
"doc" id=
"cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations.
692 Example matches Foo::~Foo()
700 <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>
701 <tr><td colspan=
"4" class=
"doc" id=
"cxxMethodDecl0"><pre>Matches method declarations.
704 class X { void y(); };
708 <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>
709 <tr><td colspan=
"4" class=
"doc" id=
"cxxRecordDecl0"><pre>Matches C++ class declarations.
713 template
<class T
> class Z {};
717 <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>
718 <tr><td colspan=
"4" class=
"doc" id=
"decl0"><pre>Matches declarations.
720 Examples matches X, C, and the friend declaration inside C;
728 <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>
729 <tr><td colspan=
"4" class=
"doc" id=
"declaratorDecl0"><pre>Matches declarator declarations (field, variable, function
730 and non-type template parameter declarations).
739 <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>
740 <tr><td colspan=
"4" class=
"doc" id=
"decompositionDecl0"><pre>Matches decomposition-declarations.
742 Examples matches the declaration node with foo and bar, but not
744 (matcher = declStmt(has(decompositionDecl())))
747 auto [foo, bar] = std::make_pair{
42,
42};
751 <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>
752 <tr><td colspan=
"4" class=
"doc" id=
"enumConstantDecl0"><pre>Matches enum constants.
754 Example matches A, B, C
761 <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>
762 <tr><td colspan=
"4" class=
"doc" id=
"enumDecl0"><pre>Matches enum declarations.
771 <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>
772 <tr><td colspan=
"4" class=
"doc" id=
"fieldDecl0"><pre>Matches field declarations.
781 <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>
782 <tr><td colspan=
"4" class=
"doc" id=
"friendDecl0"><pre>Matches friend declarations.
785 class X { friend void foo(); };
787 matches 'friend void foo()'.
791 <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>
792 <tr><td colspan=
"4" class=
"doc" id=
"functionDecl0"><pre>Matches function declarations.
799 <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>
800 <tr><td colspan=
"4" class=
"doc" id=
"functionTemplateDecl0"><pre>Matches C++ function template declarations.
803 template
<class T
> void f(T t) {}
807 <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>
808 <tr><td colspan=
"4" class=
"doc" id=
"indirectFieldDecl0"><pre>Matches indirect field declarations.
811 struct X { struct { int a; }; };
817 <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>
818 <tr><td colspan=
"4" class=
"doc" id=
"labelDecl0"><pre>Matches a declaration of label.
828 <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>
829 <tr><td colspan=
"4" class=
"doc" id=
"linkageSpecDecl0"><pre>Matches a declaration of a linkage specification.
834 matches
"extern "C
" {}"
838 <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>
839 <tr><td colspan=
"4" class=
"doc" id=
"namedDecl0"><pre>Matches a declaration of anything that could have a name.
841 Example matches X, S, the anonymous union type, i, and U;
851 <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>
852 <tr><td colspan=
"4" class=
"doc" id=
"namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias.
856 namespace alias = ::test;
858 matches
"namespace alias" but not
"namespace test"
862 <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>
863 <tr><td colspan=
"4" class=
"doc" id=
"namespaceDecl0"><pre>Matches a declaration of a namespace.
869 matches
"namespace {}" and
"namespace test {}"
873 <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>
874 <tr><td colspan=
"4" class=
"doc" id=
"nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations.
877 template
<typename T, int N
> struct C {};
878 nonTypeTemplateParmDecl()
879 matches 'N', but not 'T'.
883 <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>
884 <tr><td colspan=
"4" class=
"doc" id=
"objcCategoryDecl0"><pre>Matches Objective-C category declarations.
886 Example matches Foo (Additions)
887 @interface Foo (Additions)
892 <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>
893 <tr><td colspan=
"4" class=
"doc" id=
"objcCategoryImplDecl0"><pre>Matches Objective-C category definitions.
895 Example matches Foo (Additions)
896 @implementation Foo (Additions)
901 <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>
902 <tr><td colspan=
"4" class=
"doc" id=
"objcImplementationDecl0"><pre>Matches Objective-C implementation declarations.
910 <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>
911 <tr><td colspan=
"4" class=
"doc" id=
"objcInterfaceDecl0"><pre>Matches Objective-C interface declarations.
919 <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>
920 <tr><td colspan=
"4" class=
"doc" id=
"objcIvarDecl0"><pre>Matches Objective-C instance variable declarations.
922 Example matches _enabled
923 @implementation Foo {
930 <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>
931 <tr><td colspan=
"4" class=
"doc" id=
"objcMethodDecl0"><pre>Matches Objective-C method declarations.
933 Example matches both declaration and definition of -[Foo method]
944 <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>
945 <tr><td colspan=
"4" class=
"doc" id=
"objcPropertyDecl0"><pre>Matches Objective-C property declarations.
947 Example matches enabled
949 @property BOOL enabled;
954 <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>
955 <tr><td colspan=
"4" class=
"doc" id=
"objcProtocolDecl0"><pre>Matches Objective-C protocol declarations.
957 Example matches FooDelegate
958 @protocol FooDelegate
963 <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>
964 <tr><td colspan=
"4" class=
"doc" id=
"parmVarDecl0"><pre>Matches parameter variable declarations.
973 <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>
974 <tr><td colspan=
"4" class=
"doc" id=
"recordDecl0"><pre>Matches class, struct, and union declarations.
976 Example matches X, Z, U, and S
978 template
<class T
> class Z {};
984 <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>
985 <tr><td colspan=
"4" class=
"doc" id=
"staticAssertDecl0"><pre>Matches a C++ static_assert declaration.
990 static_assert(sizeof(S) == sizeof(int))
995 static_assert(sizeof(S) == sizeof(int));
999 <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>
1000 <tr><td colspan=
"4" class=
"doc" id=
"tagDecl0"><pre>Matches tag declarations.
1002 Example matches X, Z, U, S, E
1004 template
<class T
> class Z {};
1013 <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>
1014 <tr><td colspan=
"4" class=
"doc" id=
"templateTemplateParmDecl0"><pre>Matches template template parameter declarations.
1017 template
<template
<typename
> class Z, int N
> struct C {};
1018 templateTypeParmDecl()
1019 matches 'Z', but not 'N'.
1023 <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>
1024 <tr><td colspan=
"4" class=
"doc" id=
"templateTypeParmDecl0"><pre>Matches template type parameter declarations.
1027 template
<typename T, int N
> struct C {};
1028 templateTypeParmDecl()
1029 matches 'T', but not 'N'.
1033 <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>
1034 <tr><td colspan=
"4" class=
"doc" id=
"translationUnitDecl0"><pre>Matches the top declaration context.
1041 decl(hasDeclContext(translationUnitDecl()))
1042 matches
"int X", but not
"int Y".
1046 <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>
1047 <tr><td colspan=
"4" class=
"doc" id=
"typeAliasDecl0"><pre>Matches type alias declarations.
1053 matches
"using Y = int", but not
"typedef int X"
1057 <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>
1058 <tr><td colspan=
"4" class=
"doc" id=
"typeAliasTemplateDecl0"><pre>Matches type alias template declarations.
1060 typeAliasTemplateDecl() matches
1061 template
<typename T
>
1062 using Y = X
<T
>;
1066 <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>
1067 <tr><td colspan=
"4" class=
"doc" id=
"typedefDecl0"><pre>Matches typedef declarations.
1073 matches
"typedef int X", but not
"using Y = int"
1077 <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>
1078 <tr><td colspan=
"4" class=
"doc" id=
"typedefNameDecl0"><pre>Matches typedef name declarations.
1084 matches
"typedef int X" and
"using Y = int"
1088 <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>
1089 <tr><td colspan=
"4" class=
"doc" id=
"unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the
1093 template
<typename T
>
1094 struct Base { typedef T Foo; };
1096 template
<typename T
>
1097 struct S : private Base
<T
> {
1098 using typename Base
<T
>::Foo;
1100 unresolvedUsingTypenameDecl()
1101 matches using Base
<T
>::Foo
</pre></td></tr>
1104 <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>
1105 <tr><td colspan=
"4" class=
"doc" id=
"unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations.
1108 template
<typename X
>
1109 class C : private X {
1112 unresolvedUsingValueDecl()
1113 matches using X::x
</pre></td></tr>
1116 <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>
1117 <tr><td colspan=
"4" class=
"doc" id=
"usingDecl0"><pre>Matches using declarations.
1120 namespace X { int x; }
1123 matches using X::x
</pre></td></tr>
1126 <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>
1127 <tr><td colspan=
"4" class=
"doc" id=
"usingDirectiveDecl0"><pre>Matches using namespace declarations.
1130 namespace X { int x; }
1132 usingDirectiveDecl()
1133 matches using namespace X
</pre></td></tr>
1136 <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>
1137 <tr><td colspan=
"4" class=
"doc" id=
"valueDecl0"><pre>Matches any value declaration.
1139 Example matches A, B, C and F
1145 <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>
1146 <tr><td colspan=
"4" class=
"doc" id=
"varDecl0"><pre>Matches variable declarations.
1148 Note: this does not match declarations of member variables, which are
1149 "field" declarations in Clang parlance.
1156 <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>
1157 <tr><td colspan=
"4" class=
"doc" id=
"nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc.
1161 <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>
1162 <tr><td colspan=
"4" class=
"doc" id=
"nestedNameSpecifier0"><pre>Matches nested name specifiers.
1166 struct A { static void f(); };
1168 void g() { A::f(); }
1171 nestedNameSpecifier()
1172 matches
"ns::" and both
"A::"
1176 <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>
1177 <tr><td colspan=
"4" class=
"doc" id=
"ompDefaultClause0"><pre>Matches OpenMP ``default`` clause.
1181 #pragma omp parallel default(none)
1182 #pragma omp parallel default(shared)
1183 #pragma omp parallel default(firstprivate)
1184 #pragma omp parallel
1186 ``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``, and
1187 ``default(firstprivate)``
1191 <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>
1192 <tr><td colspan=
"4" class=
"doc" id=
"qualType0"><pre>Matches QualTypes in the clang AST.
1196 <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>
1197 <tr><td colspan=
"4" class=
"doc" id=
"addrLabelExpr0"><pre>Matches address of label statements (GNU extension).
1201 void *ptr =
&&FOO;
1204 matches '
&&FOO'
1208 <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>
1209 <tr><td colspan=
"4" class=
"doc" id=
"arraySubscriptExpr0"><pre>Matches array subscript expressions.
1213 arraySubscriptExpr()
1218 <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>
1219 <tr><td colspan=
"4" class=
"doc" id=
"asmStmt0"><pre>Matches asm statements.
1224 matches '__asm(
"mov al, 2")'
1228 <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>
1229 <tr><td colspan=
"4" class=
"doc" id=
"atomicExpr0"><pre>Matches atomic builtins.
1230 Example matches __atomic_load_n(ptr,
1)
1231 void foo() { int *ptr; __atomic_load_n(ptr,
1); }
1235 <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>
1236 <tr><td colspan=
"4" class=
"doc" id=
"autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement.
1242 autoreleasePoolStmt(stmt()) matches the declaration of
"x"
1243 inside the autorelease pool.
1247 <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>
1248 <tr><td colspan=
"4" class=
"doc" id=
"binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension).
1250 Example matches a ?: b
1255 <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>
1256 <tr><td colspan=
"4" class=
"doc" id=
"binaryOperator0"><pre>Matches binary operator expressions.
1258 Example matches a || b
1260 See also the binaryOperation() matcher for more-general matching.
1264 <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>
1265 <tr><td colspan=
"4" class=
"doc" id=
"blockExpr0"><pre>Matches a reference to a block.
1267 Example: matches
"^{}":
1272 <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>
1273 <tr><td colspan=
"4" class=
"doc" id=
"breakStmt0"><pre>Matches break statements.
1276 while (true) { break; }
1282 <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>
1283 <tr><td colspan=
"4" class=
"doc" id=
"cStyleCastExpr0"><pre>Matches a C-style cast expression.
1285 Example: Matches (int)
2.2f in
1290 <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>
1291 <tr><td colspan=
"4" class=
"doc" id=
"callExpr0"><pre>Matches call expressions.
1293 Example matches x.y() and y()
1300 <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>
1301 <tr><td colspan=
"4" class=
"doc" id=
"caseStmt0"><pre>Matches case statements inside switch statements.
1304 switch(a) { case
42: break; default: break; }
1310 <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>
1311 <tr><td colspan=
"4" class=
"doc" id=
"castExpr0"><pre>Matches any cast nodes of Clang's AST.
1313 Example: castExpr() matches each of the following:
1315 const_cast
<Expr *
>(SubExpr);
1323 <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>
1324 <tr><td colspan=
"4" class=
"doc" id=
"characterLiteral0"><pre>Matches character literals (also matches wchar_t).
1326 Not matching Hex-encoded chars (e.g.
0x1234, which is a IntegerLiteral),
1329 Example matches 'a', L'a'
1335 <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>
1336 <tr><td colspan=
"4" class=
"doc" id=
"chooseExpr0"><pre>Matches GNU __builtin_choose_expr.
1340 <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>
1341 <tr><td colspan=
"4" class=
"doc" id=
"coawaitExpr0"><pre>Matches co_await expressions.
1346 matches 'co_await
1'
1350 <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>
1351 <tr><td colspan=
"4" class=
"doc" id=
"compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals
1353 Example match: {
1}, (
1,
2)
1355 vector int myvec = (vector int)(
1,
2);
1359 <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>
1360 <tr><td colspan=
"4" class=
"doc" id=
"compoundStmt0"><pre>Matches compound statements.
1362 Example matches '{}' and '{{}}' in 'for (;;) {{}}'
1367 <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>
1368 <tr><td colspan=
"4" class=
"doc" id=
"conditionalOperator0"><pre>Matches conditional operator expressions.
1370 Example matches a ? b : c
1375 <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>
1376 <tr><td colspan=
"4" class=
"doc" id=
"constantExpr0"><pre>Matches a constant expression wrapper.
1378 Example matches the constant in the case statement:
1379 (matcher = constantExpr())
1386 <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>
1387 <tr><td colspan=
"4" class=
"doc" id=
"continueStmt0"><pre>Matches continue statements.
1390 while (true) { continue; }
1396 <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>
1397 <tr><td colspan=
"4" class=
"doc" id=
"coreturnStmt0"><pre>Matches co_return statements.
1400 while (true) { co_return; }
1406 <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>
1407 <tr><td colspan=
"4" class=
"doc" id=
"coyieldExpr0"><pre>Matches co_yield expressions.
1412 matches 'co_yield
1'
1416 <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>
1417 <tr><td colspan=
"4" class=
"doc" id=
"cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression.
1420 kernel
<<<i,j
>>>();
1424 <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>
1425 <tr><td colspan=
"4" class=
"doc" id=
"cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created.
1427 Example matches FunctionTakesString(GetStringByValue())
1428 (matcher = cxxBindTemporaryExpr())
1429 FunctionTakesString(GetStringByValue());
1430 FunctionTakesStringByPointer(GetStringPointer());
1434 <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>
1435 <tr><td colspan=
"4" class=
"doc" id=
"cxxBoolLiteral0"><pre>Matches bool literals.
1437 Example matches true
1442 <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>
1443 <tr><td colspan=
"4" class=
"doc" id=
"cxxCatchStmt0"><pre>Matches catch statements.
1445 try {} catch(int i) {}
1447 matches 'catch(int i)'
1451 <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>
1452 <tr><td colspan=
"4" class=
"doc" id=
"cxxConstCastExpr0"><pre>Matches a const_cast expression.
1454 Example: Matches const_cast
<int*
>(
&r) in
1456 const int
&r(n);
1457 int* p = const_cast
<int*
>(
&r);
1461 <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>
1462 <tr><td colspan=
"4" class=
"doc" id=
"cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones).
1464 Example matches string(ptr, n) and ptr within arguments of f
1465 (matcher = cxxConstructExpr())
1466 void f(const string
&a, const string
&b);
1469 f(string(ptr, n), ptr);
1473 <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>
1474 <tr><td colspan=
"4" class=
"doc" id=
"cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site.
1476 Example matches the CXXDefaultArgExpr placeholder inserted for the
1477 default value of the second parameter in the call expression f(
42)
1478 (matcher = cxxDefaultArgExpr())
1479 void f(int x, int y =
0);
1484 <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>
1485 <tr><td colspan=
"4" class=
"doc" id=
"cxxDeleteExpr0"><pre>Matches delete expressions.
1494 <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>
1495 <tr><td colspan=
"4" class=
"doc" id=
"cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be
1496 resolved because the base expression or the member name was dependent.
1499 template
<class T
> void f() { T t; t.g(); }
1500 cxxDependentScopeMemberExpr()
1505 <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>
1506 <tr><td colspan=
"4" class=
"doc" id=
"cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression.
1509 cxxDynamicCastExpr()
1511 dynamic_cast
<D*
>(
&b);
1513 struct B { virtual ~B() {} }; struct D : B {};
1515 D* p = dynamic_cast
<D*
>(
&b);
1519 <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>
1520 <tr><td colspan=
"4" class=
"doc" id=
"cxxForRangeStmt0"><pre>Matches range-based for statements.
1522 cxxForRangeStmt() matches 'for (auto a : i)'
1523 int i[] = {
1,
2,
3}; for (auto a : i);
1524 for(int j =
0; j
< 5; ++j);
1528 <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>
1529 <tr><td colspan=
"4" class=
"doc" id=
"cxxFunctionalCastExpr0"><pre>Matches functional cast expressions
1531 Example: Matches Foo(bar);
1538 <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>
1539 <tr><td colspan=
"4" class=
"doc" id=
"cxxMemberCallExpr0"><pre>Matches member call expressions.
1541 Example matches x.y()
1547 <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>
1548 <tr><td colspan=
"4" class=
"doc" id=
"cxxNewExpr0"><pre>Matches new expressions.
1557 <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>
1558 <tr><td colspan=
"4" class=
"doc" id=
"cxxNoexceptExpr0"><pre>Matches noexcept expressions.
1562 bool b() noexcept(true);
1563 bool c() noexcept(false);
1564 bool d() noexcept(noexcept(a()));
1565 bool e = noexcept(b()) || noexcept(c());
1567 matches `noexcept(a())`, `noexcept(b())` and `noexcept(c())`.
1568 doesn't match the noexcept specifier in the declarations a, b, c or d.
1572 <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>
1573 <tr><td colspan=
"4" class=
"doc" id=
"cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal.
1577 <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>
1578 <tr><td colspan=
"4" class=
"doc" id=
"cxxOperatorCallExpr0"><pre>Matches overloaded operator calls.
1580 Note that if an operator isn't overloaded, it won't match. Instead, use
1581 binaryOperator matcher.
1582 Currently it does not match operators such as new delete.
1583 FIXME: figure out why these do not match?
1585 Example matches both operator
<<((o
<< b), c) and operator
<<(o, b)
1586 (matcher = cxxOperatorCallExpr())
1587 ostream
&operator
<< (ostream
&out, int i) { };
1588 ostream
&o; int b =
1, c =
1;
1589 o
<< b
<< c;
1590 See also the binaryOperation() matcher for more-general matching of binary
1591 uses of this AST node.
1595 <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>
1596 <tr><td colspan=
"4" class=
"doc" id=
"cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression.
1598 Either the source expression or the destination type can be matched
1599 using has(), but hasDestinationType() is more specific and can be
1602 Example matches reinterpret_cast
<char*
>(
&p) in
1603 void* p = reinterpret_cast
<char*
>(
&p);
1607 <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>
1608 <tr><td colspan=
"4" class=
"doc" id=
"cxxRewrittenBinaryOperator0"><pre>Matches rewritten binary operators
1610 Example matches use of
"<":
1611 #include
<compare
>
1612 struct HasSpaceshipMem {
1614 constexpr auto operator
<=
>(const HasSpaceshipMem
&) const = default;
1617 HasSpaceshipMem hs1, hs2;
1621 See also the binaryOperation() matcher for more-general matching
1626 <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>
1627 <tr><td colspan=
"4" class=
"doc" id=
"cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression.
1629 See also: hasDestinationType
1630 See also: reinterpretCast
1635 static_cast
<long
>(
8)
1637 long eight(static_cast
<long
>(
8));
1641 <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>
1642 <tr><td colspan=
"4" class=
"doc" id=
"cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions.
1645 std::vector
<int
> a({
1,
2,
3 });
1646 std::vector
<int
> b = {
4,
5 };
1648 std::pair
<int, int
> d = {
8,
9 };
1649 cxxStdInitializerListExpr()
1650 matches
"{ 1, 2, 3 }" and
"{ 4, 5 }"
1654 <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>
1655 <tr><td colspan=
"4" class=
"doc" id=
"cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N !=
1 arguments
1657 Example: Matches Foo(bar, bar)
1658 Foo h = Foo(bar, bar);
1662 <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>
1663 <tr><td colspan=
"4" class=
"doc" id=
"cxxThisExpr0"><pre>Matches implicit and explicit this expressions.
1665 Example matches the implicit this expression in
"return i".
1666 (matcher = cxxThisExpr())
1669 int f() { return i; }
1674 <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>
1675 <tr><td colspan=
"4" class=
"doc" id=
"cxxThrowExpr0"><pre>Matches throw expressions.
1677 try { throw
5; } catch(int i) {}
1683 <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>
1684 <tr><td colspan=
"4" class=
"doc" id=
"cxxTryStmt0"><pre>Matches try statements.
1686 try {} catch(int i) {}
1692 <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>
1693 <tr><td colspan=
"4" class=
"doc" id=
"cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions.
1695 Example matches T(t) in return statement of f
1696 (matcher = cxxUnresolvedConstructExpr())
1697 template
<typename T
>
1698 void f(const T
& t) { return T(t); }
1702 <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>
1703 <tr><td colspan=
"4" class=
"doc" id=
"declRefExpr0"><pre>Matches expressions that refer to declarations.
1705 Example matches x in if (x)
1711 <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>
1712 <tr><td colspan=
"4" class=
"doc" id=
"declStmt0"><pre>Matches declaration statements.
1721 <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>
1722 <tr><td colspan=
"4" class=
"doc" id=
"defaultStmt0"><pre>Matches default statements inside switch statements.
1725 switch(a) { case
42: break; default: break; }
1731 <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>
1732 <tr><td colspan=
"4" class=
"doc" id=
"dependentCoawaitExpr0"><pre>Matches co_await expressions where the type of the promise is dependent
1736 <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>
1737 <tr><td colspan=
"4" class=
"doc" id=
"designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99
6.7.8].
1739 Example: Matches { [
2].y =
1.0, [
0].x =
1.0 }
1740 point ptarray[
10] = { [
2].y =
1.0, [
0].x =
1.0 };
1744 <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>
1745 <tr><td colspan=
"4" class=
"doc" id=
"doStmt0"><pre>Matches do statements.
1750 matches 'do {} while(true)'
1754 <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>
1755 <tr><td colspan=
"4" class=
"doc" id=
"explicitCastExpr0"><pre>Matches explicit cast expressions.
1757 Matches any cast expression written in user code, whether it be a
1758 C-style cast, a functional-style cast, or a keyword cast.
1760 Does not match implicit conversions.
1762 Note: the name
"explicitCast" is chosen to match Clang's terminology, as
1763 Clang uses the term
"cast" to apply to implicit conversions as well as to
1764 actual cast expressions.
1766 See also: hasDestinationType.
1768 Example: matches all five of the casts in
1769 int((int)(reinterpret_cast
<int
>(static_cast
<int
>(const_cast
<int
>(
42)))))
1770 but does not match the implicit conversion in
1775 <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>
1776 <tr><td colspan=
"4" class=
"doc" id=
"expr0"><pre>Matches expressions.
1783 <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>
1784 <tr><td colspan=
"4" class=
"doc" id=
"exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end
1785 of the sub-expression's evaluation.
1787 Example matches std::string()
1788 const std::string str = std::string();
1792 <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>
1793 <tr><td colspan=
"4" class=
"doc" id=
"fixedPointLiteral0"><pre>Matches fixed point literals
1797 <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>
1798 <tr><td colspan=
"4" class=
"doc" id=
"floatLiteral0"><pre>Matches float literals of all sizes / encodings, e.g.
1799 1.0,
1.0f,
1.0L and
1e10.
1801 Does not match implicit conversions such as
1806 <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>
1807 <tr><td colspan=
"4" class=
"doc" id=
"forStmt0"><pre>Matches for statements.
1809 Example matches 'for (;;) {}'
1811 int i[] = {
1,
2,
3}; for (auto a : i);
1815 <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>
1816 <tr><td colspan=
"4" class=
"doc" id=
"genericSelectionExpr0"><pre>Matches C11 _Generic expression.
1820 <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>
1821 <tr><td colspan=
"4" class=
"doc" id=
"gnuNullExpr0"><pre>Matches GNU __null expression.
1825 <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>
1826 <tr><td colspan=
"4" class=
"doc" id=
"gotoStmt0"><pre>Matches goto statements.
1836 <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>
1837 <tr><td colspan=
"4" class=
"doc" id=
"ifStmt0"><pre>Matches if statements.
1839 Example matches 'if (x) {}'
1844 <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>
1845 <tr><td colspan=
"4" class=
"doc" id=
"imaginaryLiteral0"><pre>Matches imaginary literals, which are based on integer and floating
1846 point literals e.g.:
1i,
1.0i
1850 <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>
1851 <tr><td colspan=
"4" class=
"doc" id=
"implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST.
1853 This matches many different places, including function call return value
1854 eliding, as well as any type conversions.
1858 <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>
1859 <tr><td colspan=
"4" class=
"doc" id=
"implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions.
1862 point ptarray[
10] = { [
2].y =
1.0, [
2].x =
2.0, [
0].x =
1.0 };
1863 implicitValueInitExpr()
1864 matches
"[0].y" (implicitly)
1868 <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>
1869 <tr><td colspan=
"4" class=
"doc" id=
"initListExpr0"><pre>Matches init list expressions.
1873 struct B { int x, y; };
1876 matches
"{ 1, 2 }" and
"{ 5, 6 }"
1880 <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>
1881 <tr><td colspan=
"4" class=
"doc" id=
"integerLiteral0"><pre>Matches integer literals of all sizes / encodings, e.g.
1884 Does not match character-encoded integers such as L'a'.
1888 <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>
1889 <tr><td colspan=
"4" class=
"doc" id=
"labelStmt0"><pre>Matches label statements.
1899 <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>
1900 <tr><td colspan=
"4" class=
"doc" id=
"lambdaExpr0"><pre>Matches lambda expressions.
1902 Example matches [
&](){return
5;}
1903 [
&](){return
5;}
1907 <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>
1908 <tr><td colspan=
"4" class=
"doc" id=
"materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized.
1911 struct T {void func();};
1914 materializeTemporaryExpr() matches 'f()' in these statements
1923 <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>
1924 <tr><td colspan=
"4" class=
"doc" id=
"memberExpr0"><pre>Matches member expressions.
1928 void x() { this-
>x(); x(); Y y; y.x(); a; this-
>b; Y::b; }
1929 int a; static int b;
1932 matches this-
>x, x, y.x, a, this-
>b
1936 <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>
1937 <tr><td colspan=
"4" class=
"doc" id=
"nullStmt0"><pre>Matches null statements.
1941 matches the second ';'
1945 <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>
1946 <tr><td colspan=
"4" class=
"doc" id=
"objcCatchStmt0"><pre>Matches Objective-C @catch statements.
1948 Example matches @catch
1954 <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>
1955 <tr><td colspan=
"4" class=
"doc" id=
"objcFinallyStmt0"><pre>Matches Objective-C @finally statements.
1957 Example matches @finally
1963 <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>
1964 <tr><td colspan=
"4" class=
"doc" id=
"objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar.
1966 Example: matches
"a" in
"init" method:
1976 <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>
1977 <tr><td colspan=
"4" class=
"doc" id=
"objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions.
1979 The innermost message send invokes the
"alloc" class method on the
1980 NSString class, while the outermost message send invokes the
1981 "initWithString" instance method on the object returned from
1982 NSString's
"alloc". This matcher should match both message sends.
1983 [[NSString alloc] initWithString:@
"Hello"]
1987 <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>
1988 <tr><td colspan=
"4" class=
"doc" id=
"objcThrowStmt0"><pre>Matches Objective-C statements.
1990 Example matches @throw obj;
1994 <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>
1995 <tr><td colspan=
"4" class=
"doc" id=
"objcTryStmt0"><pre>Matches Objective-C @try statements.
1997 Example matches @try
2003 <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>
2004 <tr><td colspan=
"4" class=
"doc" id=
"ompExecutableDirective0"><pre>Matches any ``#pragma omp`` executable directive.
2008 #pragma omp parallel
2009 #pragma omp parallel default(none)
2010 #pragma omp taskyield
2012 ``ompExecutableDirective()`` matches ``omp parallel``,
2013 ``omp parallel default(none)`` and ``omp taskyield``.
2017 <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>
2018 <tr><td colspan=
"4" class=
"doc" id=
"opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers
2019 to reference another expressions and can be met
2020 in BinaryConditionalOperators, for example.
2027 <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>
2028 <tr><td colspan=
"4" class=
"doc" id=
"parenExpr0"><pre>Matches parentheses used in expressions.
2030 Example matches (foo() +
1)
2031 int foo() { return
1; }
2032 int a = (foo() +
1);
2036 <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>
2037 <tr><td colspan=
"4" class=
"doc" id=
"parenListExpr0"><pre>Matches paren list expressions.
2038 ParenListExprs don't have a predefined type and are used for late parsing.
2039 In the final AST, they can be met in template declarations.
2042 template
<typename T
> class X {
2045 int a =
0, b =
1; int i = (a, b);
2048 parenListExpr() matches
"*this" but NOT matches (a, b) because (a, b)
2049 has a predefined type and is a ParenExpr, not a ParenListExpr.
2053 <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>
2054 <tr><td colspan=
"4" class=
"doc" id=
"predefinedExpr0"><pre>Matches predefined identifier expressions [C99
6.4.2.2].
2056 Example: Matches __func__
2057 printf(
"%s", __func__);
2061 <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>
2062 <tr><td colspan=
"4" class=
"doc" id=
"returnStmt0"><pre>Matches return statements.
2071 <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>
2072 <tr><td colspan=
"4" class=
"doc" id=
"stmt0"><pre>Matches statements.
2077 matches both the compound statement '{ ++a; }' and '++a'.
2081 <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>
2082 <tr><td colspan=
"4" class=
"doc" id=
"stmtExpr0"><pre>Matches statement expression (GNU extension).
2084 Example match: ({ int X =
4; X; })
2085 int C = ({ int X =
4; X; });
2089 <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>
2090 <tr><td colspan=
"4" class=
"doc" id=
"stringLiteral0"><pre>Matches string literals (also matches wide string literals).
2092 Example matches
"abcd", L
"abcd"
2094 wchar_t *ws = L
"abcd";
2098 <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>
2099 <tr><td colspan=
"4" class=
"doc" id=
"substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters.
2102 template
<int N
>
2103 struct A { static const int n = N; };
2104 struct B : public A
<42> {};
2105 substNonTypeTemplateParmExpr()
2106 matches
"N" in the right-hand side of
"static const int n = N;"
2110 <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>
2111 <tr><td colspan=
"4" class=
"doc" id=
"switchCase0"><pre>Matches case and default statements inside switch statements.
2114 switch(a) { case
42: break; default: break; }
2116 matches 'case
42:' and 'default:'.
2120 <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>
2121 <tr><td colspan=
"4" class=
"doc" id=
"switchStmt0"><pre>Matches switch statements.
2124 switch(a) { case
42: break; default: break; }
2126 matches 'switch(a)'.
2130 <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>
2131 <tr><td colspan=
"4" class=
"doc" id=
"unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++
11) and vec_step (OpenCL)
2135 int y = sizeof(x) + alignof(x);
2136 unaryExprOrTypeTraitExpr()
2137 matches sizeof(x) and alignof(x)
2141 <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>
2142 <tr><td colspan=
"4" class=
"doc" id=
"unaryOperator0"><pre>Matches unary operator expressions.
2149 <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>
2150 <tr><td colspan=
"4" class=
"doc" id=
"unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing
2151 but could not be resolved to a specific declaration.
2154 template
<typename T
>
2155 T foo() { T a; return a; }
2156 template
<typename T
>
2160 unresolvedLookupExpr()
2161 matches foo
<T
>()
</pre></td></tr>
2164 <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>
2165 <tr><td colspan=
"4" class=
"doc" id=
"unresolvedMemberExpr0"><pre>Matches unresolved member expressions.
2169 template
<class T
> void f();
2172 template
<class T
> void h() { X x; x.f
<T
>(); x.g(); }
2173 unresolvedMemberExpr()
2174 matches x.f
<T
>
2178 <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>
2179 <tr><td colspan=
"4" class=
"doc" id=
"userDefinedLiteral0"><pre>Matches user defined literal operator call.
2181 Example match:
"foo"_suffix
2185 <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>
2186 <tr><td colspan=
"4" class=
"doc" id=
"whileStmt0"><pre>Matches while statements.
2191 matches 'while (true) {}'.
2195 <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>
2196 <tr><td colspan=
"4" class=
"doc" id=
"templateArgumentLoc0"><pre>Matches template arguments (with location info).
2199 template
<typename T
> struct C {};
2201 templateArgumentLoc()
2202 matches 'int' in C
<int
>.
2206 <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>
2207 <tr><td colspan=
"4" class=
"doc" id=
"templateArgument0"><pre>Matches template arguments.
2210 template
<typename T
> struct C {};
2213 matches 'int' in C
<int
>.
2217 <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>
2218 <tr><td colspan=
"4" class=
"doc" id=
"templateName0"><pre>Matches template name.
2221 template
<typename T
> class X { };
2224 matches 'X' in X
<int
>.
2228 <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>
2229 <tr><td colspan=
"4" class=
"doc" id=
"typeLoc0"><pre>Matches TypeLocs in the clang AST.
2233 <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>
2234 <tr><td colspan=
"4" class=
"doc" id=
"arrayType0"><pre>Matches all kinds of arrays.
2239 void f() { int c[a[
0]]; }
2241 matches
"int a[]",
"int b[4]" and
"int c[a[0]]";
2245 <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>
2246 <tr><td colspan=
"4" class=
"doc" id=
"atomicType0"><pre>Matches atomic types.
2251 matches
"_Atomic(int) i"
2255 <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>
2256 <tr><td colspan=
"4" class=
"doc" id=
"autoType0"><pre>Matches types nodes representing C++
11 auto types.
2261 for (auto i : v) { }
2263 matches
"auto n" and
"auto i"
2267 <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>
2268 <tr><td colspan=
"4" class=
"doc" id=
"blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as
2271 The pointee is always required to be a FunctionType.
2275 <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>
2276 <tr><td colspan=
"4" class=
"doc" id=
"builtinType0"><pre>Matches builtin Types.
2285 matches
"int b",
"float c" and
"bool d"
2289 <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>
2290 <tr><td colspan=
"4" class=
"doc" id=
"complexType0"><pre>Matches C99 complex types.
2295 matches
"_Complex float f"
2299 <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>
2300 <tr><td colspan=
"4" class=
"doc" id=
"constantArrayType0"><pre>Matches C arrays with a specified constant size.
2313 <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>
2314 <tr><td colspan=
"4" class=
"doc" id=
"decayedType0"><pre>Matches decayed type
2315 Example matches i[] in declaration of f.
2316 (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType())))))
2317 Example matches i[
1].
2318 (matcher = expr(hasType(decayedType(hasDecayedType(pointerType())))))
2325 <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>
2326 <tr><td colspan=
"4" class=
"doc" id=
"decltypeType0"><pre>Matches types nodes representing C++
11 decltype(
<expr
>) types.
2331 decltype(i + j) result = i + j;
2333 matches
"decltype(i + j)"
2337 <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>
2338 <tr><td colspan=
"4" class=
"doc" id=
"deducedTemplateSpecializationType0"><pre>Matches C++
17 deduced template specialization types, e.g. deduced class
2342 template
<typename T
>
2343 class C { public: C(T); };
2346 deducedTemplateSpecializationType() matches the type in the declaration
2351 <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>
2352 <tr><td colspan=
"4" class=
"doc" id=
"dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression.
2355 template
<typename T, int Size
>
2359 dependentSizedArrayType
2360 matches
"T data[Size]"
2364 <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>
2365 <tr><td colspan=
"4" class=
"doc" id=
"elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a
2379 elaboratedType() matches the type of the variable declarations of both
2384 <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>
2385 <tr><td colspan=
"4" class=
"doc" id=
"enumType0"><pre>Matches enum types.
2389 enum class S { Red };
2394 enumType() matches the type of the variable declarations of both c and
2399 <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>
2400 <tr><td colspan=
"4" class=
"doc" id=
"functionProtoType0"><pre>Matches FunctionProtoType nodes.
2406 matches
"int (*f)(int)" and the type of
"g" in C++ mode.
2407 In C mode,
"g" is not matched because it does not contain a prototype.
2411 <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>
2412 <tr><td colspan=
"4" class=
"doc" id=
"functionType0"><pre>Matches FunctionType nodes.
2418 matches
"int (*f)(int)" and the type of
"g".
2422 <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>
2423 <tr><td colspan=
"4" class=
"doc" id=
"incompleteArrayType0"><pre>Matches C arrays with unspecified size.
2428 void f(int c[]) { int d[a[
0]]; };
2429 incompleteArrayType()
2430 matches
"int a[]" and
"int c[]"
2434 <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>
2435 <tr><td colspan=
"4" class=
"doc" id=
"injectedClassNameType0"><pre>Matches injected class name types.
2437 Example matches S s, but not S
<T
> s.
2438 (matcher = parmVarDecl(hasType(injectedClassNameType())))
2439 template
<typename T
> struct S {
2441 void g(S
<T
> s);
2446 <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>
2447 <tr><td colspan=
"4" class=
"doc" id=
"lValueReferenceType0"><pre>Matches lvalue reference types.
2452 int
&&c =
1;
2454 auto
&&e = c;
2455 auto
&&f =
2;
2458 lValueReferenceType() matches the types of b, d, and e. e is
2459 matched since the type is deduced as int
& by reference collapsing rules.
2463 <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>
2464 <tr><td colspan=
"4" class=
"doc" id=
"memberPointerType0"><pre>Matches member pointer types.
2473 <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>
2474 <tr><td colspan=
"4" class=
"doc" id=
"objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from
2475 a pointer type, despite being syntactically similar.
2484 matches
"Foo *f", but does not match
"int *a".
2488 <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>
2489 <tr><td colspan=
"4" class=
"doc" id=
"parenType0"><pre>Matches ParenType nodes.
2492 int (*ptr_to_array)[
4];
2493 int *array_of_ptrs[
4];
2495 varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not
2500 <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>
2501 <tr><td colspan=
"4" class=
"doc" id=
"pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer
2513 matches
"int *a", but does not match
"Foo *f".
2517 <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>
2518 <tr><td colspan=
"4" class=
"doc" id=
"rValueReferenceType0"><pre>Matches rvalue reference types.
2523 int
&&c =
1;
2525 auto
&&e = c;
2526 auto
&&f =
2;
2529 rValueReferenceType() matches the types of c and f. e is not
2530 matched as it is deduced to int
& by reference collapsing rules.
2534 <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>
2535 <tr><td colspan=
"4" class=
"doc" id=
"recordType0"><pre>Matches record types (e.g. structs, classes).
2544 recordType() matches the type of the variable declarations of both c
2549 <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>
2550 <tr><td colspan=
"4" class=
"doc" id=
"referenceType0"><pre>Matches both lvalue and rvalue reference types.
2555 int
&&c =
1;
2557 auto
&&e = c;
2558 auto
&&f =
2;
2561 referenceType() matches the types of b, c, d, e, and f.
2565 <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>
2566 <tr><td colspan=
"4" class=
"doc" id=
"substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a
2567 template type parameter.
2570 template
<typename T
>
2575 substTemplateTypeParmType() matches the type of 't' but not '
1'
2579 <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>
2580 <tr><td colspan=
"4" class=
"doc" id=
"tagType0"><pre>Matches tag types (record and enum types).
2589 tagType() matches the type of the variable declarations of both e
2594 <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>
2595 <tr><td colspan=
"4" class=
"doc" id=
"templateSpecializationType0"><pre>Matches template specialization types.
2598 template
<typename T
>
2601 template class C
<int
>; // A
2602 C
<char
> var; // B
2604 templateSpecializationType() matches the type of the explicit
2605 instantiation in A and the type of the variable declaration in B.
2609 <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>
2610 <tr><td colspan=
"4" class=
"doc" id=
"templateTypeParmType0"><pre>Matches template type parameter types.
2612 Example matches T, but not int.
2613 (matcher = templateTypeParmType())
2614 template
<typename T
> void f(int i);
2618 <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>
2619 <tr><td colspan=
"4" class=
"doc" id=
"type0"><pre>Matches Types in the clang AST.
2623 <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>
2624 <tr><td colspan=
"4" class=
"doc" id=
"typedefType0"><pre>Matches typedef types.
2629 matches
"typedef int X"
2633 <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>
2634 <tr><td colspan=
"4" class=
"doc" id=
"unaryTransformType0"><pre>Matches types nodes representing unary type transformations.
2637 typedef __underlying_type(T) type;
2638 unaryTransformType()
2639 matches
"__underlying_type(T)"
2643 <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>
2644 <tr><td colspan=
"4" class=
"doc" id=
"variableArrayType0"><pre>Matches C arrays with a specified size that is not an
2645 integer-constant-expression.
2654 matches
"int c[a[0]]"
2657 <!--END_DECL_MATCHERS -->
2660 <!-- ======================================================================= -->
2661 <h2 id=
"narrowing-matchers">Narrowing Matchers
</h2>
2662 <!-- ======================================================================= -->
2664 <p>Narrowing matchers match certain attributes on the current node, thus
2665 narrowing down the set of nodes of the current type to match on.
</p>
2667 <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless)
2668 which allow users to create more powerful match expressions.
</p>
2671 <tr style=
"text-align:left"><th>Return type
</th><th>Name
</th><th>Parameters
</th></tr>
2672 <!-- START_NARROWING_MATCHERS -->
2674 <tr><td>Matcher
<*
></td><td class=
"name" onclick=
"toggle('allOf0')"><a name=
"allOf0Anchor">allOf
</a></td><td>Matcher
<*
>, ..., Matcher
<*
></td></tr>
2675 <tr><td colspan=
"4" class=
"doc" id=
"allOf0"><pre>Matches if all given matchers match.
2677 Usable as: Any Matcher
2681 <tr><td>Matcher
<*
></td><td class=
"name" onclick=
"toggle('anyOf0')"><a name=
"anyOf0Anchor">anyOf
</a></td><td>Matcher
<*
>, ..., Matcher
<*
></td></tr>
2682 <tr><td colspan=
"4" class=
"doc" id=
"anyOf0"><pre>Matches if any of the given matchers matches.
2684 Usable as: Any Matcher
2688 <tr><td>Matcher
<*
></td><td class=
"name" onclick=
"toggle('anything0')"><a name=
"anything0Anchor">anything
</a></td><td></td></tr>
2689 <tr><td colspan=
"4" class=
"doc" id=
"anything0"><pre>Matches any node.
2691 Useful when another matcher requires a child matcher, but there's no
2692 additional constraint. This will often be used with an explicit conversion
2693 to an internal::Matcher
<> type such as TypeMatcher.
2695 Example: DeclarationMatcher(anything()) matches all declarations, e.g.,
2696 "int* p" and
"void f()" in
2700 Usable as: Any Matcher
2704 <tr><td><em>unspecified
</em></td><td class=
"name" onclick=
"toggle('mapAnyOf0')"><a name=
"mapAnyOf0Anchor">mapAnyOf
</a></td><td>nodeMatcherFunction...
</td></tr>
2705 <tr><td colspan=
"4" class=
"doc" id=
"mapAnyOf0"><pre>Matches any of the NodeMatchers with InnerMatchers nested within
2711 mapAnyOf(ifStmt, forStmt).with(
2712 hasCondition(cxxBoolLiteralExpr(equals(true)))
2714 matches the if and the for. It is equivalent to:
2715 auto trueCond = hasCondition(cxxBoolLiteralExpr(equals(true)));
2717 ifStmt(trueCond).bind(
"trueCond"),
2718 forStmt(trueCond).bind(
"trueCond")
2721 The with() chain-call accepts zero or more matchers which are combined
2722 as-if with allOf() in each of the node matchers.
2723 Usable as: Any Matcher
2727 <tr><td>Matcher
<*
></td><td class=
"name" onclick=
"toggle('unless0')"><a name=
"unless0Anchor">unless
</a></td><td>Matcher
<*
></td></tr>
2728 <tr><td colspan=
"4" class=
"doc" id=
"unless0"><pre>Matches if the provided matcher does not match.
2730 Example matches Y (matcher = cxxRecordDecl(unless(hasName(
"X"))))
2734 Usable as: Any Matcher
2738 <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>
2739 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOperatorName0"><pre>Matches operator expressions (binary or unary) that have any of the
2742 hasAnyOperatorName(
"+",
"-")
2744 anyOf(hasOperatorName(
"+"), hasOperatorName(
"-"))
2748 <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>
2749 <tr><td colspan=
"4" class=
"doc" id=
"hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or
2752 Example matches a || b (matcher = binaryOperator(hasOperatorName(
"||")))
2757 <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>
2758 <tr><td colspan=
"4" class=
"doc" id=
"isAssignmentOperator0"><pre>Matches all kinds of assignment operators.
2760 Example
1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
2764 Example
2: matches s1 = s2
2765 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
2766 struct S { S
& operator=(const S
&); };
2767 void x() { S s1, s2; s1 = s2; }
2771 <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>
2772 <tr><td colspan=
"4" class=
"doc" id=
"isComparisonOperator0"><pre>Matches comparison operators.
2774 Example
1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
2778 Example
2: matches s1
< s2
2779 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
2780 struct S { bool operator
<(const S
& other); };
2781 void x(S s1, S s2) { bool b1 = s1
< s2; }
2785 <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>
2786 <tr><td colspan=
"4" class=
"doc" id=
"isPrivate1"><pre>Matches private C++ declarations and C++ base specifers that specify private
2793 private: int c; // fieldDecl(isPrivate()) matches 'c'
2797 struct Derived1 : private Base {}; // matches 'Base'
2798 class Derived2 : Base {}; // matches 'Base'
2802 <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>
2803 <tr><td colspan=
"4" class=
"doc" id=
"isProtected1"><pre>Matches protected C++ declarations and C++ base specifers that specify
2804 protected inheritance.
2809 protected: int b; // fieldDecl(isProtected()) matches 'b'
2814 class Derived : protected Base {}; // matches 'Base'
2818 <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>
2819 <tr><td colspan=
"4" class=
"doc" id=
"isPublic1"><pre>Matches public C++ declarations and C++ base specifers that specify public
2824 public: int a; // fieldDecl(isPublic()) matches 'a'
2830 class Derived1 : public Base {}; // matches 'Base'
2831 struct Derived2 : Base {}; // matches 'Base'
2835 <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>
2836 <tr><td colspan=
"4" class=
"doc" id=
"isVirtual1"><pre>Matches declarations of virtual methods and C++ base specifers that specify
2837 virtual inheritance.
2842 virtual void x(); // matches x
2847 class DirectlyDerived : virtual Base {}; // matches Base
2848 class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
2850 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>>
2854 <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>
2855 <tr><td colspan=
"4" class=
"doc" id=
"equals5"><pre></pre></td></tr>
2858 <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>
2859 <tr><td colspan=
"4" class=
"doc" id=
"equals2"><pre>Matches literals that are equal to the given value of type ValueT.
2862 f('false,
3.14,
42);
2863 characterLiteral(equals(
0))
2864 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(
0))
2866 floatLiteral(equals(
3.14)) and floatLiteral(equals(
314e-2))
2868 integerLiteral(equals(
42))
2871 Note that you cannot directly match a negative numeric literal because the
2872 minus sign is not part of the literal: It is a unary operator whose operand
2873 is the positive numeric literal. Instead, you must use a unaryOperator()
2874 matcher to match the minus sign:
2876 unaryOperator(hasOperatorName(
"-"),
2877 hasUnaryOperand(integerLiteral(equals(
13))))
2879 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>>,
2880 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>>
2884 <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>
2885 <tr><td colspan=
"4" class=
"doc" id=
"equals11"><pre></pre></td></tr>
2888 <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>
2889 <tr><td colspan=
"4" class=
"doc" id=
"equals8"><pre></pre></td></tr>
2892 <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>
2893 <tr><td colspan=
"4" class=
"doc" id=
"isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler.
2903 cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int).
2907 <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>
2908 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has
2909 a specific number of arguments (including absent default arguments).
2911 Example matches f(
0,
0) (matcher = callExpr(argumentCountIs(
2)))
2912 void f(int x, int y);
2917 <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>
2918 <tr><td colspan=
"4" class=
"doc" id=
"isListInitialization0"><pre>Matches a constructor call expression which uses list initialization.
2922 <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>
2923 <tr><td colspan=
"4" class=
"doc" id=
"requiresZeroInitialization0"><pre>Matches a constructor call expression which requires
2924 zero initialization.
2928 struct point { double x; double y; };
2929 point pt[
2] = { {
1.0,
2.0 } };
2931 initListExpr(has(cxxConstructExpr(requiresZeroInitialization()))
2932 will match the implicit array filler for pt[
1].
2936 <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>
2937 <tr><td colspan=
"4" class=
"doc" id=
"isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors.
2942 S(const S
&); // #
2
2943 S(S
&&); // #
3
2945 cxxConstructorDecl(isCopyConstructor()) will match #
2, but not #
1 or #
3.
2949 <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>
2950 <tr><td colspan=
"4" class=
"doc" id=
"isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors.
2955 S(const S
&); // #
2
2956 S(S
&&); // #
3
2958 cxxConstructorDecl(isDefaultConstructor()) will match #
1, but not #
2 or #
3.
2962 <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>
2963 <tr><td colspan=
"4" class=
"doc" id=
"isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor.
2969 S(S
&&) : S() {} // #
3
2971 S::S() : S(
0) {} // #
4
2972 cxxConstructorDecl(isDelegatingConstructor()) will match #
3 and #
4, but not
2977 <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>
2978 <tr><td colspan=
"4" class=
"doc" id=
"isExplicit0"><pre>Matches constructor, conversion function, and deduction guide declarations
2979 that have an explicit specifier if this explicit specifier is resolved to
2983 template
<bool b
>
2986 explicit S(double); // #
2
2987 operator int(); // #
3
2988 explicit operator bool(); // #
4
2989 explicit(false) S(bool) // #
7
2990 explicit(true) S(char) // #
8
2991 explicit(b) S(S) // #
9
2993 S(int) -
> S
<true
> // #
5
2994 explicit S(double) -
> S
<false
> // #
6
2995 cxxConstructorDecl(isExplicit()) will match #
2 and #
8, but not #
1, #
7 or #
9.
2996 cxxConversionDecl(isExplicit()) will match #
4, but not #
3.
2997 cxxDeductionGuideDecl(isExplicit()) will match #
6, but not #
5.
3001 <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>
3002 <tr><td colspan=
"4" class=
"doc" id=
"isMoveConstructor0"><pre>Matches constructor declarations that are move constructors.
3007 S(const S
&); // #
2
3008 S(S
&&); // #
3
3010 cxxConstructorDecl(isMoveConstructor()) will match #
3, but not #
1 or #
2.
3014 <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>
3015 <tr><td colspan=
"4" class=
"doc" id=
"isExplicit1"><pre>Matches constructor, conversion function, and deduction guide declarations
3016 that have an explicit specifier if this explicit specifier is resolved to
3020 template
<bool b
>
3023 explicit S(double); // #
2
3024 operator int(); // #
3
3025 explicit operator bool(); // #
4
3026 explicit(false) S(bool) // #
7
3027 explicit(true) S(char) // #
8
3028 explicit(b) S(S) // #
9
3030 S(int) -
> S
<true
> // #
5
3031 explicit S(double) -
> S
<false
> // #
6
3032 cxxConstructorDecl(isExplicit()) will match #
2 and #
8, but not #
1, #
7 or #
9.
3033 cxxConversionDecl(isExplicit()) will match #
4, but not #
3.
3034 cxxDeductionGuideDecl(isExplicit()) will match #
6, but not #
5.
3038 <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>
3039 <tr><td colspan=
"4" class=
"doc" id=
"isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as
3040 opposed to a member.
3051 cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer()))
3052 will match E(), but not match D(int).
3056 <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>
3057 <tr><td colspan=
"4" class=
"doc" id=
"isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as
3069 cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer()))
3070 will match D(int), but not match E().
3074 <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>
3075 <tr><td colspan=
"4" class=
"doc" id=
"isWritten0"><pre>Matches a constructor initializer if it is explicitly written in
3076 code (as opposed to implicitly added by the compiler).
3081 Foo(int) : foo_(
"A") { }
3084 cxxConstructorDecl(hasAnyConstructorInitializer(isWritten()))
3085 will match Foo(int), but not Foo()
3089 <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>
3090 <tr><td colspan=
"4" class=
"doc" id=
"isExplicit2"><pre>Matches constructor, conversion function, and deduction guide declarations
3091 that have an explicit specifier if this explicit specifier is resolved to
3095 template
<bool b
>
3098 explicit S(double); // #
2
3099 operator int(); // #
3
3100 explicit operator bool(); // #
4
3101 explicit(false) S(bool) // #
7
3102 explicit(true) S(char) // #
8
3103 explicit(b) S(S) // #
9
3105 S(int) -
> S
<true
> // #
5
3106 explicit S(double) -
> S
<false
> // #
6
3107 cxxConstructorDecl(isExplicit()) will match #
2 and #
8, but not #
1, #
7 or #
9.
3108 cxxConversionDecl(isExplicit()) will match #
4, but not #
3.
3109 cxxDeductionGuideDecl(isExplicit()) will match #
6, but not #
5.
3113 <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>
3114 <tr><td colspan=
"4" class=
"doc" id=
"hasMemberName0"><pre>Matches template-dependent, but known, member names.
3116 In template declarations, dependent members are not resolved and so can
3117 not be matched to particular named declarations.
3119 This matcher allows to match on the known name of members.
3122 template
<typename T
>
3126 template
<typename T
>
3131 cxxDependentScopeMemberExpr(hasMemberName(
"mem")) matches `s.mem()`
3135 <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>
3136 <tr><td colspan=
"4" class=
"doc" id=
"isArrow2"><pre>Matches member expressions that are called with '-
>' as opposed
3139 Member calls on the implicit this pointer match as called with '-
>'.
3143 void x() { this-
>x(); x(); Y y; y.x(); a; this-
>b; Y::b; }
3144 template
<class T
> void f() { this-
>f
<T
>(); f
<T
>(); }
3148 template
<class T
>
3150 void x() { this-
>m; }
3152 memberExpr(isArrow())
3153 matches this-
>x, x, y.x, a, this-
>b
3154 cxxDependentScopeMemberExpr(isArrow())
3156 unresolvedMemberExpr(isArrow())
3157 matches this-
>f
<T
>, f
<T
>
3161 <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>
3162 <tr><td colspan=
"4" class=
"doc" id=
"memberHasSameNameAsBoundNode0"><pre>Matches template-dependent, but known, member names against an already-bound
3165 In template declarations, dependent members are not resolved and so can
3166 not be matched to particular named declarations.
3168 This matcher allows to match on the name of already-bound VarDecl, FieldDecl
3169 and CXXMethodDecl nodes.
3172 template
<typename T
>
3176 template
<typename T
>
3183 cxxDependentScopeMemberExpr(
3184 hasObjectExpression(declRefExpr(hasType(templateSpecializationType(
3185 hasDeclaration(classTemplateDecl(has(cxxRecordDecl(has(
3186 cxxMethodDecl(hasName(
"mem")).bind(
"templMem")
3189 memberHasSameNameAsBoundNode(
"templMem")
3192 first matches and binds the @c mem member of the @c S template, then
3193 compares its name to the usage in @c s.mem() in the @c x function template
3197 <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>
3198 <tr><td colspan=
"4" class=
"doc" id=
"isConst0"><pre>Matches if the given method declaration is const.
3206 cxxMethodDecl(isConst()) matches A::foo() but not A::bar()
3210 <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>
3211 <tr><td colspan=
"4" class=
"doc" id=
"isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment
3216 A
&operator=(const A
&);
3217 A
&operator=(A
&&);
3220 cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not
3225 <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>
3226 <tr><td colspan=
"4" class=
"doc" id=
"isFinal1"><pre>Matches if the given method or class declaration is final.
3238 matches A and C::f, but not B, C, or B::f
3242 <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>
3243 <tr><td colspan=
"4" class=
"doc" id=
"isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment
3248 A
&operator=(const A
&);
3249 A
&operator=(A
&&);
3252 cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not
3257 <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>
3258 <tr><td colspan=
"4" class=
"doc" id=
"isOverride0"><pre>Matches if the given method declaration overrides another method.
3265 class B : public A {
3273 <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>
3274 <tr><td colspan=
"4" class=
"doc" id=
"isPure0"><pre>Matches if the given method declaration is pure.
3279 virtual void x() =
0;
3285 <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>
3286 <tr><td colspan=
"4" class=
"doc" id=
"isUserProvided0"><pre>Matches method declarations that are user-provided.
3291 S(const S
&) = default; // #
2
3292 S(S
&&) = delete; // #
3
3294 cxxConstructorDecl(isUserProvided()) will match #
1, but not #
2 or #
3.
3298 <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>
3299 <tr><td colspan=
"4" class=
"doc" id=
"isVirtual0"><pre>Matches declarations of virtual methods and C++ base specifers that specify
3300 virtual inheritance.
3305 virtual void x(); // matches x
3310 class DirectlyDerived : virtual Base {}; // matches Base
3311 class IndirectlyDerived : DirectlyDerived, Base {}; // matches Base
3313 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>>
3317 <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>
3318 <tr><td colspan=
"4" class=
"doc" id=
"isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit
"virtual".
3325 class B : public A {
3329 matches A::x but not B::x
3333 <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>
3334 <tr><td colspan=
"4" class=
"doc" id=
"isArray0"><pre>Matches array new expressions.
3337 MyClass *p1 = new MyClass[
10];
3338 cxxNewExpr(isArray())
3339 matches the expression 'new MyClass[
10]'.
3343 <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>
3344 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOperatorName1"><pre>Matches operator expressions (binary or unary) that have any of the
3347 hasAnyOperatorName(
"+",
"-")
3349 anyOf(hasOperatorName(
"+"), hasOperatorName(
"-"))
3353 <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>
3354 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOverloadedOperatorName0"><pre>Matches overloaded operator names.
3356 Matches overloaded operator names specified in strings without the
3357 "operator" prefix: e.g.
"<<".
3359 hasAnyOverloadedOperatorName(
"+",
"-")
3361 anyOf(hasOverloadedOperatorName(
"+"), hasOverloadedOperatorName(
"-"))
3365 <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>
3366 <tr><td colspan=
"4" class=
"doc" id=
"hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or
3369 Example matches a || b (matcher = binaryOperator(hasOperatorName(
"||")))
3374 <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>
3375 <tr><td colspan=
"4" class=
"doc" id=
"hasOverloadedOperatorName1"><pre>Matches overloaded operator names.
3377 Matches overloaded operator names specified in strings without the
3378 "operator" prefix: e.g.
"<<".
3381 class A { int operator*(); };
3382 const A
&operator
<<(const A
&a, const A
&b);
3384 a
<< a; //
<-- This matches
3386 cxxOperatorCallExpr(hasOverloadedOperatorName(
"<<"))) matches the
3388 cxxRecordDecl(hasMethod(hasOverloadedOperatorName(
"*")))
3389 matches the declaration of A.
3391 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>>
3395 <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>
3396 <tr><td colspan=
"4" class=
"doc" id=
"isAssignmentOperator1"><pre>Matches all kinds of assignment operators.
3398 Example
1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3402 Example
2: matches s1 = s2
3403 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3404 struct S { S
& operator=(const S
&); };
3405 void x() { S s1, s2; s1 = s2; }
3409 <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>
3410 <tr><td colspan=
"4" class=
"doc" id=
"isComparisonOperator1"><pre>Matches comparison operators.
3412 Example
1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3416 Example
2: matches s1
< s2
3417 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3418 struct S { bool operator
<(const S
& other); };
3419 void x(S s1, S s2) { bool b1 = s1
< s2; }
3423 <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>
3424 <tr><td colspan=
"4" class=
"doc" id=
"hasDefinition0"><pre>Matches a class declaration that is defined.
3426 Example matches x (matcher = cxxRecordDecl(hasDefinition()))
3432 <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>
3433 <tr><td colspan=
"4" class=
"doc" id=
"isDerivedFrom2"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
3437 <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>
3438 <tr><td colspan=
"4" class=
"doc" id=
"isDirectlyDerivedFrom2"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
3442 <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>
3443 <tr><td colspan=
"4" class=
"doc" id=
"isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or
3444 static member variable template instantiations.
3447 template
<typename T
> void A(T t) { }
3448 template
<> void A(int N) { }
3449 functionDecl(isExplicitTemplateSpecialization())
3450 matches the specialization A
<int
>().
3452 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>>
3456 <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>
3457 <tr><td colspan=
"4" class=
"doc" id=
"isFinal0"><pre>Matches if the given method or class declaration is final.
3469 matches A and C::f, but not B, C, or B::f
3473 <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>
3474 <tr><td colspan=
"4" class=
"doc" id=
"isLambda0"><pre>Matches the generated class of lambda expressions.
3479 cxxRecordDecl(isLambda()) matches the implicit class declaration of
3484 <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>
3485 <tr><td colspan=
"4" class=
"doc" id=
"isSameOrDerivedFrom2"><pre>Overloaded method as shortcut for
3486 isSameOrDerivedFrom(hasName(...)).
3490 <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>
3491 <tr><td colspan=
"4" class=
"doc" id=
"isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static
3492 member variable template instantiations.
3495 template
<typename T
> class X {}; class A {}; X
<A
> x;
3497 template
<typename T
> class X {}; class A {}; template class X
<A
>;
3499 template
<typename T
> class X {}; class A {}; extern template class X
<A
>;
3500 cxxRecordDecl(hasName(
"::X"), isTemplateInstantiation())
3501 matches the template instantiation of X
<A
>.
3504 template
<typename T
> class X {}; class A {};
3505 template
<> class X
<A
> {}; X
<A
> x;
3506 cxxRecordDecl(hasName(
"::X"), isTemplateInstantiation())
3507 does not match, as X
<A
> is an explicit template specialization.
3509 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>>
3513 <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>
3514 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOperatorName2"><pre>Matches operator expressions (binary or unary) that have any of the
3517 hasAnyOperatorName(
"+",
"-")
3519 anyOf(hasOperatorName(
"+"), hasOperatorName(
"-"))
3523 <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>
3524 <tr><td colspan=
"4" class=
"doc" id=
"hasOperatorName2"><pre>Matches the operator Name of operator expressions (binary or
3527 Example matches a || b (matcher = binaryOperator(hasOperatorName(
"||")))
3532 <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>
3533 <tr><td colspan=
"4" class=
"doc" id=
"isAssignmentOperator2"><pre>Matches all kinds of assignment operators.
3535 Example
1: matches a += b (matcher = binaryOperator(isAssignmentOperator()))
3539 Example
2: matches s1 = s2
3540 (matcher = cxxOperatorCallExpr(isAssignmentOperator()))
3541 struct S { S
& operator=(const S
&); };
3542 void x() { S s1, s2; s1 = s2; }
3546 <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>
3547 <tr><td colspan=
"4" class=
"doc" id=
"isComparisonOperator2"><pre>Matches comparison operators.
3549 Example
1: matches a == b (matcher = binaryOperator(isComparisonOperator()))
3553 Example
2: matches s1
< s2
3554 (matcher = cxxOperatorCallExpr(isComparisonOperator()))
3555 struct S { bool operator
<(const S
& other); };
3556 void x(S s1, S s2) { bool b1 = s1
< s2; }
3560 <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>
3561 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has
3562 a specific number of arguments (including absent default arguments).
3564 Example matches f(
0,
0) (matcher = callExpr(argumentCountIs(
2)))
3565 void f(int x, int y);
3570 <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>
3571 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has
3572 a specific number of arguments (including absent default arguments).
3574 Example matches f(
0,
0) (matcher = callExpr(argumentCountIs(
2)))
3575 void f(int x, int y);
3580 <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>
3581 <tr><td colspan=
"4" class=
"doc" id=
"usesADL0"><pre>Matches call expressions which were resolved using ADL.
3583 Example matches y(x) but not y(
42) or NS::y(x).
3594 NS::y(x); // Doesn't match
3595 y(
42); // Doesn't match
3597 y(x); // Found by both unqualified lookup and ADL, doesn't match
3602 <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>
3603 <tr><td colspan=
"4" class=
"doc" id=
"hasCastKind0"><pre>Matches casts that has a given cast kind.
3605 Example: matches the implicit cast around
0
3606 (matcher = castExpr(hasCastKind(CK_NullToPointer)))
3609 If the matcher is use from clang-query, CastKind parameter
3610 should be passed as a quoted string. e.g., hasCastKind(
"CK_NullToPointer").
3614 <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>
3615 <tr><td colspan=
"4" class=
"doc" id=
"equals4"><pre></pre></td></tr>
3618 <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>
3619 <tr><td colspan=
"4" class=
"doc" id=
"equals3"><pre>Matches literals that are equal to the given value of type ValueT.
3622 f('false,
3.14,
42);
3623 characterLiteral(equals(
0))
3624 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(
0))
3626 floatLiteral(equals(
3.14)) and floatLiteral(equals(
314e-2))
3628 integerLiteral(equals(
42))
3631 Note that you cannot directly match a negative numeric literal because the
3632 minus sign is not part of the literal: It is a unary operator whose operand
3633 is the positive numeric literal. Instead, you must use a unaryOperator()
3634 matcher to match the minus sign:
3636 unaryOperator(hasOperatorName(
"-"),
3637 hasUnaryOperand(integerLiteral(equals(
13))))
3639 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>>,
3640 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>>
3644 <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>
3645 <tr><td colspan=
"4" class=
"doc" id=
"equals10"><pre></pre></td></tr>
3648 <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>
3649 <tr><td colspan=
"4" class=
"doc" id=
"equals7"><pre></pre></td></tr>
3652 <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>
3653 <tr><td colspan=
"4" class=
"doc" id=
"templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N.
3656 template
<typename T
> struct C {};
3658 classTemplateSpecializationDecl(templateArgumentCountIs(
1))
3659 matches C
<int
>.
3663 <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>
3664 <tr><td colspan=
"4" class=
"doc" id=
"statementCountIs0"><pre>Checks that a compound statement contains a specific number of
3669 compoundStmt(statementCountIs(
0)))
3671 but does not match the outer compound statement.
3675 <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>
3676 <tr><td colspan=
"4" class=
"doc" id=
"hasSize0"><pre>Matches nodes that have the specified size.
3683 wchar_t *ws = L
"abcd";
3685 constantArrayType(hasSize(
42))
3686 matches
"int a[42]" and
"int b[2 * 21]"
3687 stringLiteral(hasSize(
4))
3688 matches
"abcd", L
"abcd"
3692 <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>
3693 <tr><td colspan=
"4" class=
"doc" id=
"declCountIs0"><pre>Matches declaration statements that contain a specific number of
3701 matches 'int a, b;' and 'int d =
2, e;', but not 'int c;'.
3705 <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>
3706 <tr><td colspan=
"4" class=
"doc" id=
"equalsBoundNode1"><pre>Matches if a node equals a previously bound node.
3708 Matches a node if it equals the node previously bound to ID.
3711 class X { int a; int b; };
3713 has(fieldDecl(hasName(
"a"), hasType(type().bind(
"t")))),
3714 has(fieldDecl(hasName(
"b"), hasType(type(equalsBoundNode(
"t"))))))
3715 matches the class X, as a and b have the same type.
3717 Note that when multiple matches are involved via forEach* matchers,
3718 equalsBoundNodes acts as a filter.
3721 forEachDescendant(varDecl().bind(
"d")),
3722 forEachDescendant(declRefExpr(to(decl(equalsBoundNode(
"d"))))))
3723 will trigger a match for each combination of variable declaration
3724 and reference to that variable declaration within a compound statement.
3728 <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>
3729 <tr><td colspan=
"4" class=
"doc" id=
"equalsNode0"><pre>Matches if a node equals another node.
3731 Decl has pointer identity in the AST.
3735 <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>
3736 <tr><td colspan=
"4" class=
"doc" id=
"hasAttr0"><pre>Matches declaration that has a given attribute.
3739 __attribute__((device)) void f() { ... }
3740 decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of
3741 f. If the matcher is used from clang-query, attr::Kind parameter should be
3742 passed as a quoted string. e.g., hasAttr(
"attr::CUDADevice").
3746 <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>
3747 <tr><td colspan=
"4" class=
"doc" id=
"isExpandedFromMacro0"><pre>Matches statements that are (transitively) expanded from the named macro.
3748 Does not match if only part of the statement is expanded from that macro or
3749 if different parts of the the statement are expanded from different
3750 appearances of the macro.
3754 <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>
3755 <tr><td colspan=
"4" class=
"doc" id=
"isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is
3756 partially matching a given regex.
3758 Example matches Y but not X
3759 (matcher = cxxRecordDecl(isExpansionInFileMatching(
"AST.*"))
3760 #include
"ASTMatcher.h"
3765 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>>
3767 If the matcher is used in clang-query, RegexFlags parameter
3768 should be passed as a quoted string. e.g:
"NoFlags".
3769 Flags can be combined with '|' example
"IgnoreCase | BasicRegex"
3773 <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>
3774 <tr><td colspan=
"4" class=
"doc" id=
"isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file.
3776 Example matches X but not Y
3777 (matcher = cxxRecordDecl(isExpansionInMainFile())
3778 #include
<Y.h
>
3783 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>>
3787 <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>
3788 <tr><td colspan=
"4" class=
"doc" id=
"isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files.
3790 Example matches Y but not X
3791 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
3792 #include
<SystemHeader.h
>
3797 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>>
3801 <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>
3802 <tr><td colspan=
"4" class=
"doc" id=
"isImplicit0"><pre>Matches a declaration that has been implicitly added
3803 by the compiler (eg. implicit default/copy constructors).
3807 <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>
3808 <tr><td colspan=
"4" class=
"doc" id=
"isInStdNamespace0"><pre>Matches declarations in the namespace `std`, but not in nested namespaces.
3819 inline namespace __1 {
3820 class vector {}; // #
1
3821 namespace experimental {
3826 cxxRecordDecl(hasName(
"vector"), isInStdNamespace()) will match only #
1.
3830 <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>
3831 <tr><td colspan=
"4" class=
"doc" id=
"isInstantiated0"><pre>Matches declarations that are template instantiations or are inside
3832 template instantiations.
3835 template
<typename T
> void A(T t) { T i; }
3838 functionDecl(isInstantiated())
3839 matches 'A(int) {...};' and 'A(unsigned) {...}'.
3843 <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>
3844 <tr><td colspan=
"4" class=
"doc" id=
"isPrivate0"><pre>Matches private C++ declarations and C++ base specifers that specify private
3851 private: int c; // fieldDecl(isPrivate()) matches 'c'
3855 struct Derived1 : private Base {}; // matches 'Base'
3856 class Derived2 : Base {}; // matches 'Base'
3860 <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>
3861 <tr><td colspan=
"4" class=
"doc" id=
"isProtected0"><pre>Matches protected C++ declarations and C++ base specifers that specify
3862 protected inheritance.
3867 protected: int b; // fieldDecl(isProtected()) matches 'b'
3872 class Derived : protected Base {}; // matches 'Base'
3876 <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>
3877 <tr><td colspan=
"4" class=
"doc" id=
"isPublic0"><pre>Matches public C++ declarations and C++ base specifers that specify public
3882 public: int a; // fieldDecl(isPublic()) matches 'a'
3888 class Derived1 : public Base {}; // matches 'Base'
3889 struct Derived2 : Base {}; // matches 'Base'
3893 <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>
3894 <tr><td colspan=
"4" class=
"doc" id=
"designatorCountIs0"><pre>Matches designated initializer expressions that contain
3895 a specific number of designators.
3898 point ptarray[
10] = { [
2].y =
1.0, [
0].x =
1.0 };
3899 point ptarray2[
10] = { [
2].y =
1.0, [
2].x =
0.0, [
0].x =
1.0 };
3900 designatorCountIs(
2)
3901 matches '{ [
2].y =
1.0, [
0].x =
1.0 }',
3902 but not '{ [
2].y =
1.0, [
2].x =
0.0, [
0].x =
1.0 }'.
3906 <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>
3907 <tr><td colspan=
"4" class=
"doc" id=
"isScoped0"><pre>Matches C++
11 scoped enum declaration.
3909 Example matches Y (matcher = enumDecl(isScoped()))
3915 <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>
3916 <tr><td colspan=
"4" class=
"doc" id=
"isInstantiationDependent0"><pre>Matches expressions that are instantiation-dependent even if it is
3917 neither type- nor value-dependent.
3919 In the following example, the expression sizeof(sizeof(T() + T()))
3920 is instantiation-dependent (since it involves a template parameter T),
3921 but is neither type- nor value-dependent, since the type of the inner
3922 sizeof is known (std::size_t) and therefore the size of the outer
3924 template
<typename T
>
3925 void f(T x, T y) { sizeof(sizeof(T() + T()); }
3926 expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T())
3930 <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>
3931 <tr><td colspan=
"4" class=
"doc" id=
"isTypeDependent0"><pre>Matches expressions that are type-dependent because the template type
3932 is not yet instantiated.
3934 For example, the expressions
"x" and
"x + y" are type-dependent in
3935 the following code, but
"y" is not type-dependent:
3936 template
<typename T
>
3937 void add(T x, int y) {
3940 expr(isTypeDependent()) matches x + y
3944 <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>
3945 <tr><td colspan=
"4" class=
"doc" id=
"isValueDependent0"><pre>Matches expression that are value-dependent because they contain a
3946 non-type template parameter.
3948 For example, the array bound of
"Chars" in the following example is
3950 template
<int Size
> int f() { return Size; }
3951 expr(isValueDependent()) matches return Size
3955 <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>
3956 <tr><td colspan=
"4" class=
"doc" id=
"nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as
3957 GNU's __null, C++
11's nullptr, or C's NULL macro.
3962 void *v3 = __null; // GNU extension
3963 char *cp = (char *)
0;
3966 expr(nullPointerConstant())
3967 matches the initializer for v1, v2, v3, cp, and ip. Does not match the
3972 <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>
3973 <tr><td colspan=
"4" class=
"doc" id=
"hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified
3982 fieldDecl(hasBitWidth(
2))
3983 matches 'int a;' and 'int c;' but not 'int b;'.
3987 <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>
3988 <tr><td colspan=
"4" class=
"doc" id=
"isBitField0"><pre>Matches non-static data members that are bit-fields.
3995 fieldDecl(isBitField())
3996 matches 'int a;' but not 'int b;'.
4000 <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>
4001 <tr><td colspan=
"4" class=
"doc" id=
"equals1"><pre>Matches literals that are equal to the given value of type ValueT.
4004 f('false,
3.14,
42);
4005 characterLiteral(equals(
0))
4006 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(
0))
4008 floatLiteral(equals(
3.14)) and floatLiteral(equals(
314e-2))
4010 integerLiteral(equals(
42))
4013 Note that you cannot directly match a negative numeric literal because the
4014 minus sign is not part of the literal: It is a unary operator whose operand
4015 is the positive numeric literal. Instead, you must use a unaryOperator()
4016 matcher to match the minus sign:
4018 unaryOperator(hasOperatorName(
"-"),
4019 hasUnaryOperand(integerLiteral(equals(
13))))
4021 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>>,
4022 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>>
4026 <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>
4027 <tr><td colspan=
"4" class=
"doc" id=
"equals12"><pre></pre></td></tr>
4030 <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>
4031 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyOverloadedOperatorName1"><pre>Matches overloaded operator names.
4033 Matches overloaded operator names specified in strings without the
4034 "operator" prefix: e.g.
"<<".
4036 hasAnyOverloadedOperatorName(
"+",
"-")
4038 anyOf(hasOverloadedOperatorName(
"+"), hasOverloadedOperatorName(
"-"))
4042 <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>
4043 <tr><td colspan=
"4" class=
"doc" id=
"hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification.
4048 void h() noexcept(true);
4049 void i() noexcept(false);
4051 void k() throw(int);
4052 void l() throw(...);
4053 functionDecl(hasDynamicExceptionSpec()) and
4054 functionProtoType(hasDynamicExceptionSpec())
4055 match the declarations of j, k, and l, but not f, g, h, or i.
4059 <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>
4060 <tr><td colspan=
"4" class=
"doc" id=
"hasOverloadedOperatorName0"><pre>Matches overloaded operator names.
4062 Matches overloaded operator names specified in strings without the
4063 "operator" prefix: e.g.
"<<".
4066 class A { int operator*(); };
4067 const A
&operator
<<(const A
&a, const A
&b);
4069 a
<< a; //
<-- This matches
4071 cxxOperatorCallExpr(hasOverloadedOperatorName(
"<<"))) matches the
4073 cxxRecordDecl(hasMethod(hasOverloadedOperatorName(
"*")))
4074 matches the declaration of A.
4076 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>>
4080 <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>
4081 <tr><td colspan=
"4" class=
"doc" id=
"hasTrailingReturn0"><pre>Matches a function declared with a trailing return type.
4083 Example matches Y (matcher = functionDecl(hasTrailingReturn()))
4085 auto Y() -
> int {}
4089 <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>
4090 <tr><td colspan=
"4" class=
"doc" id=
"isConstexpr1"><pre>Matches constexpr variable and function declarations,
4094 constexpr int foo =
42;
4095 constexpr int bar();
4096 void baz() { if constexpr(
1 > 0) {} }
4097 varDecl(isConstexpr())
4098 matches the declaration of foo.
4099 functionDecl(isConstexpr())
4100 matches the declaration of bar.
4101 ifStmt(isConstexpr())
4102 matches the if statement in baz.
4106 <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>
4107 <tr><td colspan=
"4" class=
"doc" id=
"isDefaulted0"><pre>Matches defaulted function declarations.
4111 class B { ~B() = default; };
4112 functionDecl(isDefaulted())
4113 matches the declaration of ~B, but not ~A.
4117 <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>
4118 <tr><td colspan=
"4" class=
"doc" id=
"isDefinition3"><pre>Matches if a declaration has a body attached.
4120 Example matches A, va, fa
4122 class B; // Doesn't match, as it has no body.
4124 extern int vb; // Doesn't match, as it doesn't define the variable.
4126 void fb(); // Doesn't match, as it has no body.
4128 - (void)ma; // Doesn't match, interface is declaration.
4134 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>>,
4135 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl
</a>>
4139 <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>
4140 <tr><td colspan=
"4" class=
"doc" id=
"isDeleted0"><pre>Matches deleted function declarations.
4144 void DeletedFunc() = delete;
4145 functionDecl(isDeleted())
4146 matches the declaration of DeletedFunc, but not Func.
4150 <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>
4151 <tr><td colspan=
"4" class=
"doc" id=
"isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or
4152 static member variable template instantiations.
4155 template
<typename T
> void A(T t) { }
4156 template
<> void A(int N) { }
4157 functionDecl(isExplicitTemplateSpecialization())
4158 matches the specialization A
<int
>().
4160 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>>
4164 <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>
4165 <tr><td colspan=
"4" class=
"doc" id=
"isExternC0"><pre>Matches extern
"C" function or variable declarations.
4168 extern
"C" void f() {}
4169 extern
"C" { void g() {} }
4171 extern
"C" int x =
1;
4172 extern
"C" int y =
2;
4174 functionDecl(isExternC())
4175 matches the declaration of f and g, but not the declaration of h.
4176 varDecl(isExternC())
4177 matches the declaration of x and y, but not the declaration of z.
4181 <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>
4182 <tr><td colspan=
"4" class=
"doc" id=
"isInline1"><pre>Matches function and namespace declarations that are marked with
4189 inline namespace m {}
4191 functionDecl(isInline()) will match ::f().
4192 namespaceDecl(isInline()) will match n::m.
4196 <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>
4197 <tr><td colspan=
"4" class=
"doc" id=
"isMain0"><pre>Determines whether the function is
"main", which is the entry point
4198 into an executable program.
4202 <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>
4203 <tr><td colspan=
"4" class=
"doc" id=
"isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute.
4207 [[noreturn]] void a();
4208 __attribute__((noreturn)) void b();
4209 struct c { [[noreturn]] c(); };
4210 functionDecl(isNoReturn())
4211 matches all of those except
4216 <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>
4217 <tr><td colspan=
"4" class=
"doc" id=
"isNoThrow0"><pre>Matches functions that have a non-throwing exception specification.
4223 void i() throw(int);
4224 void j() noexcept(false);
4225 functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
4226 match the declarations of g, and h, but not f, i or j.
4230 <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>
4231 <tr><td colspan=
"4" class=
"doc" id=
"isStaticStorageClass0"><pre>Matches variable/function declarations that have
"static" storage
4232 class specifier (
"static" keyword) written in the source.
4239 functionDecl(isStaticStorageClass())
4240 matches the function declaration f.
4241 varDecl(isStaticStorageClass())
4242 matches the variable declaration i.
4246 <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>
4247 <tr><td colspan=
"4" class=
"doc" id=
"isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static
4248 member variable template instantiations.
4251 template
<typename T
> class X {}; class A {}; X
<A
> x;
4253 template
<typename T
> class X {}; class A {}; template class X
<A
>;
4255 template
<typename T
> class X {}; class A {}; extern template class X
<A
>;
4256 cxxRecordDecl(hasName(
"::X"), isTemplateInstantiation())
4257 matches the template instantiation of X
<A
>.
4260 template
<typename T
> class X {}; class A {};
4261 template
<> class X
<A
> {}; X
<A
> x;
4262 cxxRecordDecl(hasName(
"::X"), isTemplateInstantiation())
4263 does not match, as X
<A
> is an explicit template specialization.
4265 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>>
4269 <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>
4270 <tr><td colspan=
"4" class=
"doc" id=
"isVariadic0"><pre>Matches if a function declaration is variadic.
4272 Example matches f, but not g or h. The function i will not match, even when
4276 template
<typename... Ts
> void h(Ts...);
4281 <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>
4282 <tr><td colspan=
"4" class=
"doc" id=
"isWeak0"><pre>Matches weak function declarations.
4285 void foo() __attribute__((__weakref__(
"__foo")));
4287 functionDecl(isWeak())
4288 matches the weak declaration
"foo", but not
"bar".
4292 <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>
4293 <tr><td colspan=
"4" class=
"doc" id=
"parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
4294 specific parameter count.
4298 void g(int i, int j) {}
4299 void h(int i, int j);
4301 void k(int x, int y, int z, ...);
4302 functionDecl(parameterCountIs(
2))
4304 functionProtoType(parameterCountIs(
2))
4306 functionProtoType(parameterCountIs(
3))
4311 <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>
4312 <tr><td colspan=
"4" class=
"doc" id=
"hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification.
4317 void h() noexcept(true);
4318 void i() noexcept(false);
4320 void k() throw(int);
4321 void l() throw(...);
4322 functionDecl(hasDynamicExceptionSpec()) and
4323 functionProtoType(hasDynamicExceptionSpec())
4324 match the declarations of j, k, and l, but not f, g, h, or i.
4328 <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>
4329 <tr><td colspan=
"4" class=
"doc" id=
"isNoThrow1"><pre>Matches functions that have a non-throwing exception specification.
4335 void i() throw(int);
4336 void j() noexcept(false);
4337 functionDecl(isNoThrow()) and functionProtoType(isNoThrow())
4338 match the declarations of g, and h, but not f, i or j.
4342 <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>
4343 <tr><td colspan=
"4" class=
"doc" id=
"parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a
4344 specific parameter count.
4348 void g(int i, int j) {}
4349 void h(int i, int j);
4351 void k(int x, int y, int z, ...);
4352 functionDecl(parameterCountIs(
2))
4354 functionProtoType(parameterCountIs(
2))
4356 functionProtoType(parameterCountIs(
3))
4361 <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>
4362 <tr><td colspan=
"4" class=
"doc" id=
"isConstexpr2"><pre>Matches constexpr variable and function declarations,
4366 constexpr int foo =
42;
4367 constexpr int bar();
4368 void baz() { if constexpr(
1 > 0) {} }
4369 varDecl(isConstexpr())
4370 matches the declaration of foo.
4371 functionDecl(isConstexpr())
4372 matches the declaration of bar.
4373 ifStmt(isConstexpr())
4374 matches the if statement in baz.
4378 <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>
4379 <tr><td colspan=
"4" class=
"doc" id=
"equals6"><pre></pre></td></tr>
4382 <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>
4383 <tr><td colspan=
"4" class=
"doc" id=
"equals0"><pre>Matches literals that are equal to the given value of type ValueT.
4386 f('false,
3.14,
42);
4387 characterLiteral(equals(
0))
4388 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(
0))
4390 floatLiteral(equals(
3.14)) and floatLiteral(equals(
314e-2))
4392 integerLiteral(equals(
42))
4395 Note that you cannot directly match a negative numeric literal because the
4396 minus sign is not part of the literal: It is a unary operator whose operand
4397 is the positive numeric literal. Instead, you must use a unaryOperator()
4398 matcher to match the minus sign:
4400 unaryOperator(hasOperatorName(
"-"),
4401 hasUnaryOperand(integerLiteral(equals(
13))))
4403 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>>,
4404 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>>
4408 <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>
4409 <tr><td colspan=
"4" class=
"doc" id=
"equals13"><pre></pre></td></tr>
4412 <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>
4413 <tr><td colspan=
"4" class=
"doc" id=
"equals9"><pre></pre></td></tr>
4416 <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>
4417 <tr><td colspan=
"4" class=
"doc" id=
"isArrow0"><pre>Matches member expressions that are called with '-
>' as opposed
4420 Member calls on the implicit this pointer match as called with '-
>'.
4424 void x() { this-
>x(); x(); Y y; y.x(); a; this-
>b; Y::b; }
4425 template
<class T
> void f() { this-
>f
<T
>(); f
<T
>(); }
4429 template
<class T
>
4431 void x() { this-
>m; }
4433 memberExpr(isArrow())
4434 matches this-
>x, x, y.x, a, this-
>b
4435 cxxDependentScopeMemberExpr(isArrow())
4437 unresolvedMemberExpr(isArrow())
4438 matches this-
>f
<T
>, f
<T
>
4442 <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>
4443 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names.
4445 This matcher is only provided as a performance optimization of hasName.
4447 is equivalent to, but faster than
4448 anyOf(hasName(a), hasName(b), hasName(c))
4452 <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>
4453 <tr><td colspan=
"4" class=
"doc" id=
"hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage.
4455 Example matches only z (matcher = varDecl(hasExternalFormalLinkage()))
4462 Example matches f() because it has external formal linkage despite being
4463 unique to the translation unit as though it has internal likage
4464 (matcher = functionDecl(hasExternalFormalLinkage()))
4472 <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>
4473 <tr><td colspan=
"4" class=
"doc" id=
"hasName0"><pre>Matches NamedDecl nodes that have the specified name.
4475 Supports specifying enclosing namespaces or classes by prefixing the name
4476 with '
<enclosing
>::'.
4477 Does not match typedefs of an underlying type with the given name.
4479 Example matches X (Name ==
"X")
4482 Example matches X (Name is one of
"::a::b::X",
"a::b::X",
"b::X",
"X")
4483 namespace a { namespace b { class X; } }
4487 <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>
4488 <tr><td colspan=
"4" class=
"doc" id=
"matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain
4489 a substring matched by the given RegExp.
4491 Supports specifying enclosing namespaces or classes by
4492 prefixing the name with '
<enclosing
>::'. Does not match typedefs
4493 of an underlying type with the given name.
4495 Example matches X (regexp ==
"::X")
4498 Example matches X (regexp is one of
"::X",
"^foo::.*X", among others)
4499 namespace foo { namespace bar { class X; } }
4501 If the matcher is used in clang-query, RegexFlags parameter
4502 should be passed as a quoted string. e.g:
"NoFlags".
4503 Flags can be combined with '|' example
"IgnoreCase | BasicRegex"
4507 <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>
4508 <tr><td colspan=
"4" class=
"doc" id=
"isAnonymous0"><pre>Matches anonymous namespace declarations.
4514 namespaceDecl(isAnonymous()) will match #
1 but not ::n.
4518 <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>
4519 <tr><td colspan=
"4" class=
"doc" id=
"isInline0"><pre>Matches function and namespace declarations that are marked with
4526 inline namespace m {}
4528 functionDecl(isInline()) will match ::f().
4529 namespaceDecl(isInline()) will match n::m.
4533 <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>
4534 <tr><td colspan=
"4" class=
"doc" id=
"isFirstPrivateKind0"><pre>Matches if the OpenMP ``default`` clause has ``firstprivate`` kind
4539 #pragma omp parallel
4540 #pragma omp parallel default(none)
4541 #pragma omp parallel default(shared)
4542 #pragma omp parallel default(firstprivate)
4544 ``ompDefaultClause(isFirstPrivateKind())`` matches only
4545 ``default(firstprivate)``.
4549 <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>
4550 <tr><td colspan=
"4" class=
"doc" id=
"isNoneKind0"><pre>Matches if the OpenMP ``default`` clause has ``none`` kind specified.
4554 #pragma omp parallel
4555 #pragma omp parallel default(none)
4556 #pragma omp parallel default(shared)
4557 #pragma omp parallel default(firstprivate)
4559 ``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
4563 <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>
4564 <tr><td colspan=
"4" class=
"doc" id=
"isSharedKind0"><pre>Matches if the OpenMP ``default`` clause has ``shared`` kind specified.
4568 #pragma omp parallel
4569 #pragma omp parallel default(none)
4570 #pragma omp parallel default(shared)
4571 #pragma omp parallel default(firstprivate)
4573 ``ompDefaultClause(isSharedKind())`` matches only ``default(shared)``.
4577 <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>
4578 <tr><td colspan=
"4" class=
"doc" id=
"isAllowedToContainClauseKind0"><pre>Matches if the OpenMP directive is allowed to contain the specified OpenMP
4583 #pragma omp parallel
4584 #pragma omp parallel for
4587 `ompExecutableDirective(isAllowedToContainClause(OMPC_default))`` matches
4588 ``omp parallel`` and ``omp parallel for``.
4590 If the matcher is use from clang-query, ``OpenMPClauseKind`` parameter
4591 should be passed as a quoted string. e.g.,
4592 ``isAllowedToContainClauseKind(
"OMPC_default").``
4596 <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>
4597 <tr><td colspan=
"4" class=
"doc" id=
"isStandaloneDirective0"><pre>Matches standalone OpenMP directives,
4598 i.e., directives that can't have a structured block.
4602 #pragma omp parallel
4604 #pragma omp taskyield
4606 ``ompExecutableDirective(isStandaloneDirective()))`` matches
4611 <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>
4612 <tr><td colspan=
"4" class=
"doc" id=
"isDerivedFrom3"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)).
4616 <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>
4617 <tr><td colspan=
"4" class=
"doc" id=
"isDirectlyDerivedFrom3"><pre>Overloaded method as shortcut for isDirectlyDerivedFrom(hasName(...)).
4621 <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>
4622 <tr><td colspan=
"4" class=
"doc" id=
"isSameOrDerivedFrom3"><pre>Overloaded method as shortcut for
4623 isSameOrDerivedFrom(hasName(...)).
4627 <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>
4628 <tr><td colspan=
"4" class=
"doc" id=
"argumentCountIs3"><pre>Checks that a call expression or a constructor call expression has
4629 a specific number of arguments (including absent default arguments).
4631 Example matches f(
0,
0) (matcher = callExpr(argumentCountIs(
2)))
4632 void f(int x, int y);
4637 <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>
4638 <tr><td colspan=
"4" class=
"doc" id=
"hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the
4639 Selector.getAsString()
4641 matcher = objCMessageExpr(hasSelector(
"methodA:",
"methodB:"));
4642 matches both of the expressions below:
4643 [myObj methodA:argA];
4644 [myObj methodB:argB];
4648 <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>
4649 <tr><td colspan=
"4" class=
"doc" id=
"hasKeywordSelector0"><pre>Matches when the selector is a keyword selector
4651 objCMessageExpr(hasKeywordSelector()) matches the generated setFrame
4652 message expression in
4654 UIWebView *webView = ...;
4655 CGRect bodyFrame = webView.frame;
4656 bodyFrame.size.height = self.bodyContentHeight;
4657 webView.frame = bodyFrame;
4658 // ^---- matches here
4662 <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>
4663 <tr><td colspan=
"4" class=
"doc" id=
"hasNullSelector0"><pre>Matches when the selector is the empty selector
4665 Matches only when the selector of the objCMessageExpr is NULL. This may
4666 represent an error condition in the tree!
4670 <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>
4671 <tr><td colspan=
"4" class=
"doc" id=
"hasSelector0"><pre>Matches when BaseName == Selector.getAsString()
4673 matcher = objCMessageExpr(hasSelector(
"loadHTMLString:baseURL:"));
4674 matches the outer message expr in the code below, but NOT the message
4675 invocation for self.bodyView.
4676 [self.bodyView loadHTMLString:html baseURL:NULL];
4680 <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>
4681 <tr><td colspan=
"4" class=
"doc" id=
"hasUnarySelector0"><pre>Matches when the selector is a Unary Selector
4683 matcher = objCMessageExpr(matchesSelector(hasUnarySelector());
4684 matches self.bodyView in the code below, but NOT the outer message
4685 invocation of
"loadHTMLString:baseURL:".
4686 [self.bodyView loadHTMLString:html baseURL:NULL];
4690 <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>
4691 <tr><td colspan=
"4" class=
"doc" id=
"isClassMessage0"><pre>Returns true when the Objective-C message is sent to a class.
4694 matcher = objcMessageExpr(isClassMessage())
4696 [NSString stringWithFormat:@
"format"];
4698 NSString *x = @
"hello";
4699 [x containsString:@
"h"];
4703 <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>
4704 <tr><td colspan=
"4" class=
"doc" id=
"isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance.
4707 matcher = objcMessageExpr(isInstanceMessage())
4709 NSString *x = @
"hello";
4710 [x containsString:@
"h"];
4712 [NSString stringWithFormat:@
"format"];
4716 <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>
4717 <tr><td colspan=
"4" class=
"doc" id=
"matchesSelector0"><pre>Matches ObjC selectors whose name contains
4718 a substring matched by the given RegExp.
4719 matcher = objCMessageExpr(matchesSelector(
"loadHTMLStringmatches the outer message expr in the code below, but NOT the message
4720 invocation for self.bodyView.
4721 [self.bodyView loadHTMLString:html baseURL:NULL];
4723 If the matcher is used in clang-query, RegexFlags parameter
4724 should be passed as a quoted string. e.g: "NoFlags
".
4725 Flags can be combined with '|' example "IgnoreCase | BasicRegex
"
4729 <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>
4730 <tr><td colspan="4" class="doc
" id="numSelectorArgs0
"><pre>Matches when the selector has the specified number of arguments
4732 matcher = objCMessageExpr(numSelectorArgs(0));
4733 matches self.bodyView in the code below
4735 matcher = objCMessageExpr(numSelectorArgs(2));
4736 matches the invocation of "loadHTMLString:baseURL:
" but not that
4738 [self.bodyView loadHTMLString:html baseURL:NULL];
4742 <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>
4743 <tr><td colspan="4" class="doc
" id="isClassMethod0
"><pre>Returns true when the Objective-C method declaration is a class method.
4746 matcher = objcMethodDecl(isClassMethod())
4748 @interface I + (void)foo; @end
4750 @interface I - (void)bar; @end
4754 <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>
4755 <tr><td colspan="4" class="doc
" id="isDefinition2
"><pre>Matches if a declaration has a body attached.
4757 Example matches A, va, fa
4759 class B; // Doesn't match, as it has no body.
4761 extern int vb; // Doesn't match, as it doesn't define the variable.
4763 void fb(); // Doesn't match, as it has no body.
4765 - (void)ma; // Doesn't match, interface is declaration.
4771 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>>,
4772 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html
">ObjCMethodDecl</a>>
4776 <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>
4777 <tr><td colspan="4" class="doc
" id="isInstanceMethod0
"><pre>Returns true when the Objective-C method declaration is an instance method.
4780 matcher = objcMethodDecl(isInstanceMethod())
4782 @interface I - (void)bar; @end
4784 @interface I + (void)foo; @end
4788 <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>
4789 <tr><td colspan="4" class="doc
" id="hasDefaultArgument0
"><pre>Matches a declaration that has default arguments.
4791 Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
4793 void y(int val = 0) {}
4795 Deprecated. Use hasInitializer() instead to be able to
4796 match on the contents of the default argument. For example:
4798 void x(int val = 7) {}
4799 void y(int val = 42) {}
4800 parmVarDecl(hasInitializer(integerLiteral(equals(42))))
4801 matches the parameter of y
4804 parmVarDecl(hasInitializer(anything()))
4805 is equivalent to parmVarDecl(hasDefaultArgument()).
4809 <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>
4810 <tr><td colspan="4" class="doc
" id="isAtPosition0
"><pre>Matches the ParmVarDecl nodes that are at the N'th position in the parameter
4811 list. The parameter list could be that of either a block, function, or
4817 void f(int a, int b, int c) {
4820 ``parmVarDecl(isAtPosition(0))`` matches ``int a``.
4822 ``parmVarDecl(isAtPosition(1))`` matches ``int b``.
4826 <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>
4827 <tr><td colspan="4" class="doc
" id="asString0
"><pre>Matches if the matched type is represented by the given string.
4830 class Y { public: void x(); };
4831 void z() { Y* y; y->x(); }
4832 cxxMemberCallExpr(on(hasType(asString("class Y *
"))))
4837 <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>
4838 <tr><td colspan="4" class="doc
" id="equalsBoundNode3
"><pre>Matches if a node equals a previously bound node.
4840 Matches a node if it equals the node previously bound to ID.
4843 class X { int a; int b; };
4845 has(fieldDecl(hasName("a
"), hasType(type().bind("t
")))),
4846 has(fieldDecl(hasName("b
"), hasType(type(equalsBoundNode("t
"))))))
4847 matches the class X, as a and b have the same type.
4849 Note that when multiple matches are involved via forEach* matchers,
4850 equalsBoundNodes acts as a filter.
4853 forEachDescendant(varDecl().bind("d
")),
4854 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d
"))))))
4855 will trigger a match for each combination of variable declaration
4856 and reference to that variable declaration within a compound statement.
4860 <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>
4861 <tr><td colspan="4" class="doc
" id="hasLocalQualifiers0
"><pre>Matches QualType nodes that have local CV-qualifiers attached to
4862 the node, not hidden within a typedef.
4865 typedef const int const_int;
4870 varDecl(hasType(hasLocalQualifiers())) matches only j and k.
4871 i is const-qualified but the qualifier is not local.
4875 <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>
4876 <tr><td colspan="4" class="doc
" id="isAnyCharacter0
"><pre>Matches QualType nodes that are of character type.
4882 functionDecl(hasAnyParameter(hasType(isAnyCharacter())))
4883 matches "a(char)
", "b(wchar_t)
", but not "c(double)
".
4887 <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>
4888 <tr><td colspan="4" class="doc
" id="isAnyPointer0
"><pre>Matches QualType nodes that are of any pointer type; this includes
4889 the Objective-C object pointer type, which is different despite being
4890 syntactically similar.
4900 varDecl(hasType(isAnyPointer()))
4901 matches "int *i
" and "Foo *f
", but not "int j
".
4905 <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>
4906 <tr><td colspan="4" class="doc
" id="isConstQualified0
"><pre>Matches QualType nodes that are const-qualified, i.e., that
4907 include "top-level
" const.
4914 void e(int const) {};
4915 functionDecl(hasAnyParameter(hasType(isConstQualified())))
4916 matches "void b(int const)
", "void c(const int)
" and
4917 "void e(int const) {}
". It does not match d as there
4918 is no top-level const on the parameter type "const int *
".
4922 <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>
4923 <tr><td colspan="4" class="doc
" id="isInteger0
"><pre>Matches QualType nodes that are of integer type.
4929 functionDecl(hasAnyParameter(hasType(isInteger())))
4930 matches "a(int)
", "b(long)
", but not "c(double)
".
4934 <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>
4935 <tr><td colspan="4" class="doc
" id="isSignedInteger0
"><pre>Matches QualType nodes that are of signed integer type.
4939 void b(unsigned long);
4941 functionDecl(hasAnyParameter(hasType(isSignedInteger())))
4942 matches "a(int)
", but not "b(unsigned long)
" and "c(double)
".
4946 <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>
4947 <tr><td colspan="4" class="doc
" id="isUnsignedInteger0
"><pre>Matches QualType nodes that are of unsigned integer type.
4951 void b(unsigned long);
4953 functionDecl(hasAnyParameter(hasType(isUnsignedInteger())))
4954 matches "b(unsigned long)
", but not "a(int)
" and "c(double)
".
4958 <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>
4959 <tr><td colspan="4" class="doc
" id="isVolatileQualified0
"><pre>Matches QualType nodes that are volatile-qualified, i.e., that
4960 include "top-level
" volatile.
4964 void b(int volatile);
4965 void c(volatile int);
4966 void d(volatile int*);
4967 void e(int volatile) {};
4968 functionDecl(hasAnyParameter(hasType(isVolatileQualified())))
4969 matches "void b(int volatile)
", "void c(volatile int)
" and
4970 "void e(int volatile) {}
". It does not match d as there
4971 is no top-level volatile on the parameter type "volatile int *
".
4975 <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>
4976 <tr><td colspan="4" class="doc
" id="equalsBoundNode0
"><pre>Matches if a node equals a previously bound node.
4978 Matches a node if it equals the node previously bound to ID.
4981 class X { int a; int b; };
4983 has(fieldDecl(hasName("a
"), hasType(type().bind("t
")))),
4984 has(fieldDecl(hasName("b
"), hasType(type(equalsBoundNode("t
"))))))
4985 matches the class X, as a and b have the same type.
4987 Note that when multiple matches are involved via forEach* matchers,
4988 equalsBoundNodes acts as a filter.
4991 forEachDescendant(varDecl().bind("d
")),
4992 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d
"))))))
4993 will trigger a match for each combination of variable declaration
4994 and reference to that variable declaration within a compound statement.
4998 <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>
4999 <tr><td colspan="4" class="doc
" id="equalsNode1
"><pre>Matches if a node equals another node.
5001 Stmt has pointer identity in the AST.
5005 <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>
5006 <tr><td colspan="4" class="doc
" id="isExpandedFromMacro1
"><pre>Matches statements that are (transitively) expanded from the named macro.
5007 Does not match if only part of the statement is expanded from that macro or
5008 if different parts of the the statement are expanded from different
5009 appearances of the macro.
5013 <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>
5014 <tr><td colspan="4" class="doc
" id="isExpansionInFileMatching1
"><pre>Matches AST nodes that were expanded within files whose name is
5015 partially matching a given regex.
5017 Example matches Y but not X
5018 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*
"))
5019 #include "ASTMatcher.h
"
5024 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>>
5026 If the matcher is used in clang-query, RegexFlags parameter
5027 should be passed as a quoted string. e.g: "NoFlags
".
5028 Flags can be combined with '|' example "IgnoreCase | BasicRegex
"
5032 <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>
5033 <tr><td colspan="4" class="doc
" id="isExpansionInMainFile1
"><pre>Matches AST nodes that were expanded within the main-file.
5035 Example matches X but not Y
5036 (matcher = cxxRecordDecl(isExpansionInMainFile())
5037 #include <Y.h>
5042 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>>
5046 <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>
5047 <tr><td colspan="4" class="doc
" id="isExpansionInSystemHeader1
"><pre>Matches AST nodes that were expanded within system-header-files.
5049 Example matches Y but not X
5050 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
5051 #include <SystemHeader.h>
5056 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>>
5060 <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>
5061 <tr><td colspan="4" class="doc
" id="isInTemplateInstantiation0
"><pre>Matches statements inside of a template instantiation.
5065 template<typename T> void A(T t) { T i; j += 42;}
5068 declStmt(isInTemplateInstantiation())
5069 matches 'int i;' and 'unsigned i'.
5070 unless(stmt(isInTemplateInstantiation()))
5071 will NOT match j += 42; as it's shared between the template definition and
5076 <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>
5077 <tr><td colspan="4" class="doc
" id="hasSize1
"><pre>Matches nodes that have the specified size.
5084 wchar_t *ws = L"abcd
";
5086 constantArrayType(hasSize(42))
5087 matches "int a[
42]
" and "int b[
2 *
21]
"
5088 stringLiteral(hasSize(4))
5089 matches "abcd
", L"abcd
"
5093 <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>
5094 <tr><td colspan="4" class="doc
" id="isClass0
"><pre>Matches TagDecl object that are spelled with "class.
"
5096 Example matches C, but not S, U or E.
5104 <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>
5105 <tr><td colspan="4" class="doc
" id="isDefinition0
"><pre>Matches if a declaration has a body attached.
5107 Example matches A, va, fa
5109 class B; // Doesn't match, as it has no body.
5111 extern int vb; // Doesn't match, as it doesn't define the variable.
5113 void fb(); // Doesn't match, as it has no body.
5115 - (void)ma; // Doesn't match, interface is declaration.
5121 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>>,
5122 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html
">ObjCMethodDecl</a>>
5126 <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>
5127 <tr><td colspan="4" class="doc
" id="isEnum0
"><pre>Matches TagDecl object that are spelled with "enum.
"
5129 Example matches E, but not C, S or U.
5137 <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>
5138 <tr><td colspan="4" class="doc
" id="isStruct0
"><pre>Matches TagDecl object that are spelled with "struct.
"
5140 Example matches S, but not C, U or E.
5148 <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>
5149 <tr><td colspan="4" class="doc
" id="isUnion0
"><pre>Matches TagDecl object that are spelled with "union.
"
5151 Example matches U, but not C, S or E.
5159 <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>
5160 <tr><td colspan="4" class="doc
" id="equalsIntegralValue0
"><pre>Matches a TemplateArgument of integral type with a given value.
5162 Note that 'Value' is a string as the template argument's value is
5163 an arbitrary precision integer. 'Value' must be euqal to the canonical
5164 representation of that integral value in base 10.
5167 template<int T> struct C {};
5169 classTemplateSpecializationDecl(
5170 hasAnyTemplateArgument(equalsIntegralValue("42")))
5171 matches the implicit instantiation of C in C<42>.
5175 <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>
5176 <tr><td colspan="4" class="doc
" id="isIntegral0
"><pre>Matches a TemplateArgument that is an integral value.
5179 template<int T> struct C {};
5181 classTemplateSpecializationDecl(
5182 hasAnyTemplateArgument(isIntegral()))
5183 matches the implicit instantiation of C in C<42>
5184 with isIntegral() matching 42.
5188 <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>
5189 <tr><td colspan="4" class="doc
" id="templateArgumentCountIs1
"><pre>Matches if the number of template arguments equals N.
5192 template<typename T> struct C {};
5194 classTemplateSpecializationDecl(templateArgumentCountIs(1))
5195 matches C<int>.
5199 <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>
5200 <tr><td colspan="4" class="doc
" id="isExpandedFromMacro2
"><pre>Matches statements that are (transitively) expanded from the named macro.
5201 Does not match if only part of the statement is expanded from that macro or
5202 if different parts of the the statement are expanded from different
5203 appearances of the macro.
5207 <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>
5208 <tr><td colspan="4" class="doc
" id="isExpansionInFileMatching2
"><pre>Matches AST nodes that were expanded within files whose name is
5209 partially matching a given regex.
5211 Example matches Y but not X
5212 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*
"))
5213 #include "ASTMatcher.h
"
5218 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>>
5220 If the matcher is used in clang-query, RegexFlags parameter
5221 should be passed as a quoted string. e.g: "NoFlags
".
5222 Flags can be combined with '|' example "IgnoreCase | BasicRegex
"
5226 <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>
5227 <tr><td colspan="4" class="doc
" id="isExpansionInMainFile2
"><pre>Matches AST nodes that were expanded within the main-file.
5229 Example matches X but not Y
5230 (matcher = cxxRecordDecl(isExpansionInMainFile())
5231 #include <Y.h>
5236 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>>
5240 <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>
5241 <tr><td colspan="4" class="doc
" id="isExpansionInSystemHeader2
"><pre>Matches AST nodes that were expanded within system-header-files.
5243 Example matches Y but not X
5244 (matcher = cxxRecordDecl(isExpansionInSystemHeader())
5245 #include <SystemHeader.h>
5250 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>>
5254 <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>
5255 <tr><td colspan="4" class="doc
" id="booleanType0
"><pre>Matches type bool.
5258 struct S { bool func(); };
5259 functionDecl(returns(booleanType()))
5260 matches "bool func();
"
5264 <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>
5265 <tr><td colspan="4" class="doc
" id="equalsBoundNode2
"><pre>Matches if a node equals a previously bound node.
5267 Matches a node if it equals the node previously bound to ID.
5270 class X { int a; int b; };
5272 has(fieldDecl(hasName("a
"), hasType(type().bind("t
")))),
5273 has(fieldDecl(hasName("b
"), hasType(type(equalsBoundNode("t
"))))))
5274 matches the class X, as a and b have the same type.
5276 Note that when multiple matches are involved via forEach* matchers,
5277 equalsBoundNodes acts as a filter.
5280 forEachDescendant(varDecl().bind("d
")),
5281 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d
"))))))
5282 will trigger a match for each combination of variable declaration
5283 and reference to that variable declaration within a compound statement.
5287 <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>
5288 <tr><td colspan="4" class="doc
" id="equalsNode2
"><pre>Matches if a node equals another node.
5290 Type has pointer identity in the AST.
5294 <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>
5295 <tr><td colspan="4" class="doc
" id="realFloatingPointType0
"><pre>Matches any real floating-point type (float, double, long double).
5300 realFloatingPointType()
5301 matches "float f
" but not "int i
"
5305 <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>
5306 <tr><td colspan="4" class="doc
" id="voidType0
"><pre>Matches type void.
5309 struct S { void func(); };
5310 functionDecl(returns(voidType()))
5311 matches "void func();
"
5315 <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>
5316 <tr><td colspan="4" class="doc
" id="ofKind0
"><pre>Matches unary expressions of a certain kind.
5320 int s = sizeof(x) + alignof(x)
5321 unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf))
5324 If the matcher is use from clang-query, UnaryExprOrTypeTrait parameter
5325 should be passed as a quoted string. e.g., ofKind("UETT_SizeOf
").
5329 <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>
5330 <tr><td colspan="4" class="doc
" id="hasAnyOperatorName3
"><pre>Matches operator expressions (binary or unary) that have any of the
5333 hasAnyOperatorName("+
", "-
")
5335 anyOf(hasOperatorName("+
"), hasOperatorName("-
"))
5339 <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>
5340 <tr><td colspan="4" class="doc
" id="hasOperatorName3
"><pre>Matches the operator Name of operator expressions (binary or
5343 Example matches a || b (matcher = binaryOperator(hasOperatorName("||
")))
5348 <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>
5349 <tr><td colspan="4" class="doc
" id="isArrow1
"><pre>Matches member expressions that are called with '->' as opposed
5352 Member calls on the implicit this pointer match as called with '->'.
5356 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; }
5357 template <class T> void f() { this->f<T>(); f<T>(); }
5361 template <class T>
5363 void x() { this->m; }
5365 memberExpr(isArrow())
5366 matches this->x, x, y.x, a, this->b
5367 cxxDependentScopeMemberExpr(isArrow())
5369 unresolvedMemberExpr(isArrow())
5370 matches this->f<T>, f<T>
5374 <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>
5375 <tr><td colspan="4" class="doc
" id="hasAutomaticStorageDuration0
"><pre>Matches a variable declaration that has automatic storage duration.
5377 Example matches x, but not y, z, or a.
5378 (matcher = varDecl(hasAutomaticStorageDuration())
5388 <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>
5389 <tr><td colspan="4" class="doc
" id="hasGlobalStorage0
"><pre>Matches a variable declaration that does not have local storage.
5391 Example matches y and z (matcher = varDecl(hasGlobalStorage())
5400 <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>
5401 <tr><td colspan="4" class="doc
" id="hasLocalStorage0
"><pre>Matches a variable declaration that has function scope and is a
5402 non-static local variable.
5404 Example matches x (matcher = varDecl(hasLocalStorage())
5413 <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>
5414 <tr><td colspan="4" class="doc
" id="hasStaticStorageDuration0
"><pre>Matches a variable declaration that has static storage duration.
5415 It includes the variable declared at namespace scope and those declared
5416 with "static
" and "extern
" storage class specifiers.
5426 varDecl(hasStaticStorageDuration())
5427 matches the function declaration y, a, b and c.
5431 <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>
5432 <tr><td colspan="4" class="doc
" id="hasThreadStorageDuration0
"><pre>Matches a variable declaration that has thread storage duration.
5434 Example matches z, but not x, z, or a.
5435 (matcher = varDecl(hasThreadStorageDuration())
5445 <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>
5446 <tr><td colspan="4" class="doc
" id="isConstexpr0
"><pre>Matches constexpr variable and function declarations,
5450 constexpr int foo = 42;
5451 constexpr int bar();
5452 void baz() { if constexpr(1 > 0) {} }
5453 varDecl(isConstexpr())
5454 matches the declaration of foo.
5455 functionDecl(isConstexpr())
5456 matches the declaration of bar.
5457 ifStmt(isConstexpr())
5458 matches the if statement in baz.
5462 <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>
5463 <tr><td colspan="4" class="doc
" id="isDefinition1
"><pre>Matches if a declaration has a body attached.
5465 Example matches A, va, fa
5467 class B; // Doesn't match, as it has no body.
5469 extern int vb; // Doesn't match, as it doesn't define the variable.
5471 void fb(); // Doesn't match, as it has no body.
5473 - (void)ma; // Doesn't match, interface is declaration.
5479 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>>,
5480 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html
">ObjCMethodDecl</a>>
5484 <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>
5485 <tr><td colspan="4" class="doc
" id="isExceptionVariable0
"><pre>Matches a variable declaration that is an exception variable from
5486 a C++ catch block, or an Objective-C statement.
5488 Example matches x (matcher = varDecl(isExceptionVariable())
5497 <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>
5498 <tr><td colspan="4" class="doc
" id="isExplicitTemplateSpecialization1
"><pre>Matches explicit template specializations of function, class, or
5499 static member variable template instantiations.
5502 template<typename T> void A(T t) { }
5503 template<> void A(int N) { }
5504 functionDecl(isExplicitTemplateSpecialization())
5505 matches the specialization A<int>().
5507 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>>
5511 <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>
5512 <tr><td colspan="4" class="doc
" id="isExternC1
"><pre>Matches extern "C
" function or variable declarations.
5515 extern "C
" void f() {}
5516 extern "C
" { void g() {} }
5518 extern "C
" int x = 1;
5519 extern "C
" int y = 2;
5521 functionDecl(isExternC())
5522 matches the declaration of f and g, but not the declaration of h.
5523 varDecl(isExternC())
5524 matches the declaration of x and y, but not the declaration of z.
5528 <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>
5529 <tr><td colspan="4" class="doc
" id="isStaticLocal0
"><pre>Matches a static variable with local scope.
5531 Example matches y (matcher = varDecl(isStaticLocal()))
5540 <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>
5541 <tr><td colspan="4" class="doc
" id="isStaticStorageClass1
"><pre>Matches variable/function declarations that have "static
" storage
5542 class specifier ("static
" keyword) written in the source.
5549 functionDecl(isStaticStorageClass())
5550 matches the function declaration f.
5551 varDecl(isStaticStorageClass())
5552 matches the variable declaration i.
5556 <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>
5557 <tr><td colspan="4" class="doc
" id="isTemplateInstantiation1
"><pre>Matches template instantiations of function, class, or static
5558 member variable template instantiations.
5561 template <typename T> class X {}; class A {}; X<A> x;
5563 template <typename T> class X {}; class A {}; template class X<A>;
5565 template <typename T> class X {}; class A {}; extern template class X<A>;
5566 cxxRecordDecl(hasName("::X
"), isTemplateInstantiation())
5567 matches the template instantiation of X<A>.
5570 template <typename T> class X {}; class A {};
5571 template <> class X<A> {}; X<A> x;
5572 cxxRecordDecl(hasName("::X
"), isTemplateInstantiation())
5573 does not match, as X<A> is an explicit template specialization.
5575 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>>
5578 <!--END_NARROWING_MATCHERS -->
5581 <!-- ======================================================================= -->
5582 <h2 id="traversal-matchers
">AST Traversal Matchers</h2>
5583 <!-- ======================================================================= -->
5585 <p>Traversal matchers specify the relationship to other nodes that are
5586 reachable from the current node.</p>
5588 <p>Note that there are special traversal matchers (has, hasDescendant, forEach and
5589 forEachDescendant) which work on all nodes and allow users to write more generic
5590 match expressions.</p>
5593 <tr style="text-align:left
"><th>Return type</th><th>Name</th><th>Parameters</th></tr>
5594 <!-- START_TRAVERSAL_MATCHERS -->
5596 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('binaryOperation0')
"><a name="binaryOperation0Anchor
">binaryOperation</a></td><td>Matcher<*>...Matcher<*></td></tr>
5597 <tr><td colspan="4" class="doc
" id="binaryOperation0
"><pre>Matches nodes which can be used with binary operators.
5601 might be represented in the clang AST as a binaryOperator, a
5602 cxxOperatorCallExpr or a cxxRewrittenBinaryOperator, depending on
5604 * whether the types of var1 and var2 are fundamental (binaryOperator) or at
5605 least one is a class type (cxxOperatorCallExpr)
5606 * whether the code appears in a template declaration, if at least one of the
5607 vars is a dependent-type (binaryOperator)
5608 * whether the code relies on a rewritten binary operator, such as a
5609 spaceship operator or an inverted equality operator
5610 (cxxRewrittenBinaryOperator)
5612 This matcher elides details in places where the matchers for the nodes are
5617 hasOperatorName("!=
"),
5618 hasLHS(expr().bind("lhs
")),
5619 hasRHS(expr().bind("rhs
"))
5621 matches each use of "!=
" in:
5623 bool operator!=(const S&) const;
5632 template<typename T>
5640 bool operator==(const HasOpEq &) const;
5653 bool operator<=>(const HasOpEq &) const;
5656 void use_spaceship()
5666 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('eachOf0')
"><a name="eachOf0Anchor
">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr>
5667 <tr><td colspan="4" class="doc
" id="eachOf0
"><pre>Matches if any of the given matchers matches.
5669 Unlike anyOf, eachOf will generate a match result for each
5670 matching submatcher.
5673 class A { int a; int b; };
5675 cxxRecordDecl(eachOf(has(fieldDecl(hasName("a
")).bind("v
")),
5676 has(fieldDecl(hasName("b
")).bind("v
"))))
5677 will generate two results binding "v
", the first of which binds
5678 the field declaration of a, the second the field declaration of
5681 Usable as: Any Matcher
5685 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('findAll0')
"><a name="findAll0Anchor
">findAll</a></td><td>Matcher<*> Matcher</td></tr>
5686 <tr><td colspan="4" class="doc
" id="findAll0
"><pre>Matches if the node or any descendant matches.
5688 Generates results for each match.
5691 class A { class B {}; class C {}; };
5693 cxxRecordDecl(hasName("::A
"),
5694 findAll(cxxRecordDecl(isDefinition()).bind("m
")))
5695 will generate results for A, B and C.
5697 Usable as: Any Matcher
5701 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('forEachDescendant0')
"><a name="forEachDescendant0Anchor
">forEachDescendant</a></td><td>Matcher<*></td></tr>
5702 <tr><td colspan="4" class="doc
" id="forEachDescendant0
"><pre>Matches AST nodes that have descendant AST nodes that match the
5705 Example matches X, A, A::X, B, B::C, B::C::X
5706 (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X
")))))
5708 class A { class X {}; }; // Matches A, because A::X is a class of name
5710 class B { class C { class X {}; }; };
5712 DescendantT must be an AST base type.
5714 As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for
5715 each result that matches instead of only on the first one.
5717 Note: Recursively combined ForEachDescendant can cause many matches:
5718 cxxRecordDecl(forEachDescendant(cxxRecordDecl(
5719 forEachDescendant(cxxRecordDecl())
5721 will match 10 times (plus injected class name matches) on:
5722 class A { class B { class C { class D { class E {}; }; }; }; };
5724 Usable as: Any Matcher
5728 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('forEach0')
"><a name="forEach0Anchor
">forEach</a></td><td>Matcher<*></td></tr>
5729 <tr><td colspan="4" class="doc
" id="forEach0
"><pre>Matches AST nodes that have child AST nodes that match the
5732 Example matches X, Y, Y::X, Z::Y, Z::Y::X
5733 (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X
")))
5735 class Y { class X {}; }; // Matches Y, because Y::X is a class of name X
5737 class Z { class Y { class X {}; }; }; // Does not match Z.
5739 ChildT must be an AST base type.
5741 As opposed to 'has', 'forEach' will cause a match for each result that
5742 matches instead of only on the first one.
5744 Usable as: Any Matcher
5748 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('hasAncestor0')
"><a name="hasAncestor0Anchor
">hasAncestor</a></td><td>Matcher<*></td></tr>
5749 <tr><td colspan="4" class="doc
" id="hasAncestor0
"><pre>Matches AST nodes that have an ancestor that matches the provided
5753 void f() { if (true) { int x = 42; } }
5754 void g() { for (;;) { int x = 43; } }
5755 expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43.
5757 Usable as: Any Matcher
5761 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('hasDescendant0')
"><a name="hasDescendant0Anchor
">hasDescendant</a></td><td>Matcher<*></td></tr>
5762 <tr><td colspan="4" class="doc
" id="hasDescendant0
"><pre>Matches AST nodes that have descendant AST nodes that match the
5765 Example matches X, Y, Z
5766 (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X
")))))
5767 class X {}; // Matches X, because X::X is a class of name X inside X.
5768 class Y { class X {}; };
5769 class Z { class Y { class X {}; }; };
5771 DescendantT must be an AST base type.
5773 Usable as: Any Matcher
5777 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('has0')
"><a name="has0Anchor
">has</a></td><td>Matcher<*></td></tr>
5778 <tr><td colspan="4" class="doc
" id="has0
"><pre>Matches AST nodes that have child AST nodes that match the
5781 Example matches X, Y
5782 (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X
")))
5783 class X {}; // Matches X, because X::X is a class of name X inside X.
5784 class Y { class X {}; };
5785 class Z { class Y { class X {}; }; }; // Does not match Z.
5787 ChildT must be an AST base type.
5789 Usable as: Any Matcher
5790 Note that has is direct matcher, so it also matches things like implicit
5791 casts and paren casts. If you are matching with expr then you should
5792 probably consider using ignoringParenImpCasts like:
5793 has(ignoringParenImpCasts(expr())).
5797 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('hasParent0')
"><a name="hasParent0Anchor
">hasParent</a></td><td>Matcher<*></td></tr>
5798 <tr><td colspan="4" class="doc
" id="hasParent0
"><pre>Matches AST nodes that have a parent that matches the provided
5802 void f() { for (;;) { int x = 42; if (true) { int x = 43; } } }
5803 compoundStmt(hasParent(ifStmt())) matches "{ int x =
43; }
".
5805 Usable as: Any Matcher
5809 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('invocation0')
"><a name="invocation0Anchor
">invocation</a></td><td>Matcher<*>...Matcher<*></td></tr>
5810 <tr><td colspan="4" class="doc
" id="invocation0
"><pre>Matches function calls and constructor calls
5812 Because CallExpr and CXXConstructExpr do not share a common
5813 base class with API accessing arguments etc, AST Matchers for code
5814 which should match both are typically duplicated. This matcher
5815 removes the need for duplication.
5818 struct ConstructorTakesInt
5820 ConstructorTakesInt(int i) {}
5823 void callTakesInt(int i)
5834 ConstructorTakesInt cti(42);
5838 invocation(hasArgument(0, integerLiteral(equals(42))))
5839 matches the expression in both doCall and doConstruct
5843 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('optionally0')
"><a name="optionally0Anchor
">optionally</a></td><td>Matcher<*></td></tr>
5844 <tr><td colspan="4" class="doc
" id="optionally0
"><pre>Matches any node regardless of the submatcher.
5846 However, optionally will retain any bindings generated by the submatcher.
5847 Useful when additional information which may or may not present about a main
5848 matching node is desired.
5857 fieldDecl(hasName("bar
")).bind("var
")
5859 will produce a result binding for both "record
" and "var
".
5860 The matcher will produce a "record
" binding for even if there is no data
5861 member named "bar
" in that class.
5863 Usable as: Any Matcher
5867 <tr><td>Matcher<*></td><td class="name
" onclick="toggle('traverse0')
"><a name="traverse0Anchor
">traverse</a></td><td>TraversalKind TK, Matcher<*> InnerMatcher</td></tr>
5868 <tr><td colspan="4" class="doc
" id="traverse0
"><pre>Causes all nested matchers to be matched with the specified traversal kind.
5876 traverse(TK_IgnoreUnlessSpelledInSource,
5877 varDecl(hasInitializer(floatLiteral().bind("init
")))
5879 matches the variable declaration with "init
" bound to the "3.0".
5883 <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>
5884 <tr><td colspan="4" class="doc
" id="hasCondition5
"><pre>Matches the condition expression of an if statement, for loop,
5885 switch statement or conditional operator.
5887 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
5892 <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>
5893 <tr><td colspan="4" class="doc
" id="hasFalseExpression0
"><pre>Matches the false branch expression of a conditional operator
5894 (binary or ternary).
5902 <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>
5903 <tr><td colspan="4" class="doc
" id="hasTrueExpression0
"><pre>Matches the true branch expression of a conditional operator.
5905 Example 1 (conditional ternary operator): matches a
5908 Example 2 (conditional binary operator): matches opaqueValueExpr(condition)
5913 <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>
5914 <tr><td colspan="4" class="doc
" id="hasDeclaration15
"><pre>Matches a node if the declaration associated with that node
5915 matches the given matcher.
5917 The associated declaration is:
5918 - for type nodes, the declaration of the underlying type
5919 - for CallExpr, the declaration of the callee
5920 - for MemberExpr, the declaration of the referenced member
5921 - for CXXConstructExpr, the declaration of the constructor
5922 - for CXXNewExpr, the declaration of the operator new
5923 - for ObjCIvarExpr, the declaration of the ivar
5925 For type nodes, hasDeclaration will generally match the declaration of the
5930 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
5931 typedefDecl. A common use case is to match the underlying, desugared type.
5932 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
5933 varDecl(hasType(hasUnqualifiedDesugaredType(
5934 recordType(hasDeclaration(decl())))))
5935 In this matcher, the decl will match the CXXRecordDecl of class X.
5937 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>>,
5938 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>>,
5939 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>>,
5940 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>>,
5941 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>>,
5942 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>>,
5943 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
5947 <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>
5948 <tr><td colspan="4" class="doc
" id="hasBase0
"><pre>Matches the base expression of an array subscript expression.
5952 void f() { i[1] = 42; }
5953 arraySubscriptExpression(hasBase(implicitCastExpr(
5954 hasSourceExpression(declRefExpr()))))
5955 matches i[1] with the declRefExpr() matching i
5959 <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>
5960 <tr><td colspan="4" class="doc
" id="hasIndex0
"><pre>Matches the index expression of an array subscript expression.
5964 void f() { i[1] = 42; }
5965 arraySubscriptExpression(hasIndex(integerLiteral()))
5966 matches i[1] with the integerLiteral() matching 1
5970 <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>
5971 <tr><td colspan="4" class="doc
" id="hasLHS3
"><pre>Matches the left hand side of binary operator expressions.
5973 Example matches a (matcher = binaryOperator(hasLHS()))
5978 <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>
5979 <tr><td colspan="4" class="doc
" id="hasRHS3
"><pre>Matches the right hand side of binary operator expressions.
5981 Example matches b (matcher = binaryOperator(hasRHS()))
5986 <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>
5987 <tr><td colspan="4" class="doc
" id="hasElementType0
"><pre>Matches arrays and C99 complex types that have a specific element
5994 arrayType(hasElementType(builtinType()))
5997 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>>
6001 <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>
6002 <tr><td colspan="4" class="doc
" id="hasValueType0
"><pre>Matches atomic types with a specific value type.
6007 atomicType(hasValueType(isInteger()))
6008 matches "_Atomic(int) i
"
6010 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html
">AtomicType</a>>
6014 <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>
6015 <tr><td colspan="4" class="doc
" id="hasDeducedType0
"><pre>Matches AutoType nodes where the deduced type is a specific type.
6017 Note: There is no TypeLoc for the deduced type and thus no
6018 getDeducedLoc() matcher.
6023 autoType(hasDeducedType(isInteger()))
6026 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html
">AutoType</a>>
6030 <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>
6031 <tr><td colspan="4" class="doc
" id="hasEitherOperand0
"><pre>Matches if either the left hand side or the right hand side of a
6032 binary operator matches.
6036 <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>
6037 <tr><td colspan="4" class="doc
" id="hasLHS0
"><pre>Matches the left hand side of binary operator expressions.
6039 Example matches a (matcher = binaryOperator(hasLHS()))
6044 <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>
6045 <tr><td colspan="4" class="doc
" id="hasOperands0
"><pre>Matches if both matchers match with opposite sides of the binary operator.
6047 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(1),
6048 integerLiteral(equals(2)))
6056 <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>
6057 <tr><td colspan="4" class="doc
" id="hasRHS0
"><pre>Matches the right hand side of binary operator expressions.
6059 Example matches b (matcher = binaryOperator(hasRHS()))
6064 <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>
6065 <tr><td colspan="4" class="doc
" id="forDecomposition0
"><pre>Matches the DecompositionDecl the binding belongs to.
6071 auto &[f, s, t] = arr;
6076 bindingDecl(hasName("f
"),
6077 forDecomposition(decompositionDecl())
6078 matches 'f' in 'auto &[f, s, t]'.
6082 <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>
6083 <tr><td colspan="4" class="doc
" id="hasAnyParameter2
"><pre>Matches any parameter of a function or an ObjC method declaration or a
6086 Does not match the 'this' parameter of a method.
6089 class X { void f(int x, int y, int z) {} };
6090 cxxMethodDecl(hasAnyParameter(hasName("y
")))
6091 matches f(int x, int y, int z) {}
6092 with hasAnyParameter(...)
6095 For ObjectiveC, given
6096 @interface I - (void) f:(int) y; @end
6098 the matcher objcMethodDecl(hasAnyParameter(hasName("y
")))
6099 matches the declaration of method f with hasParameter
6103 b = ^(int y) { printf("%d
", y) };
6105 the matcher blockDecl(hasAnyParameter(hasName("y
")))
6106 matches the declaration of the block b with hasParameter
6111 <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>
6112 <tr><td colspan="4" class="doc
" id="hasParameter2
"><pre>Matches the n'th parameter of a function or an ObjC method
6113 declaration or a block.
6116 class X { void f(int x) {} };
6117 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
6119 with hasParameter(...)
6122 For ObjectiveC, given
6123 @interface I - (void) f:(int) y; @end
6125 the matcher objcMethodDecl(hasParameter(0, hasName("y
")))
6126 matches the declaration of method f with hasParameter
6131 <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>
6132 <tr><td colspan="4" class="doc
" id="pointee0
"><pre>Narrows PointerType (and similar) matchers to those where the
6133 pointee matches a given matcher.
6139 pointerType(pointee(isConstQualified(), isInteger()))
6140 matches "int const *b
"
6142 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>>,
6143 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>>
6147 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</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>
6148 <tr><td colspan="4" class="doc
" id="hasType7
"><pre>Overloaded to match the declaration of the expression's or value
6151 In case of a value declaration (for example a variable declaration),
6152 this resolves one layer of indirection. For example, in the value
6153 declaration "X x;
", cxxRecordDecl(hasName("X
")) matches the declaration of
6154 X, while varDecl(hasType(cxxRecordDecl(hasName("X
")))) matches the
6157 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
6158 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
6159 and friend class X (matcher = friendDecl(hasType("X
"))
6161 void y(X &x) { x; X z; }
6162 class Y { friend class X; };
6164 Example matches class Derived
6165 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base
"))))))
6167 class Derived : Base {};
6169 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>>,
6170 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>
6174 <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>
6175 <tr><td colspan="4" class="doc
" id="forEachArgumentWithParam1
"><pre>Matches all arguments and their respective ParmVarDecl.
6182 forEachArgumentWithParam(
6183 declRefExpr(to(varDecl(hasName("y
")))),
6184 parmVarDecl(hasType(isInteger()))
6187 with declRefExpr(...)
6189 and parmVarDecl(...)
6194 <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>
6195 <tr><td colspan="4" class="doc
" id="forEachArgumentWithParamType1
"><pre>Matches all arguments and their respective types for a CallExpr or
6196 CXXConstructExpr. It is very similar to forEachArgumentWithParam but
6197 it works on calls through function pointers as well.
6199 The difference is, that function pointers do not provide access to a
6200 ParmVarDecl, but only the QualType for each argument.
6206 void (*f_ptr)(int) = f;
6209 forEachArgumentWithParamType(
6210 declRefExpr(to(varDecl(hasName("y
")))),
6211 qualType(isInteger()).bind("type)
6213 matches f(y) and f_ptr(y)
6214 with declRefExpr(...)
6221 <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>
6222 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call
6223 expression, or an ObjC-message-send expression.
6226 void x(int, int, int) { int y; x(
1, y,
42); }
6227 callExpr(hasAnyArgument(declRefExpr()))
6229 with hasAnyArgument(...)
6232 For ObjectiveC, given
6233 @interface I - (void) f:(int) y; @end
6234 void foo(I *i) { [i f:
12]; }
6235 objcMessageExpr(hasAnyArgument(integerLiteral(equals(
12))))
6240 <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>
6241 <tr><td colspan=
"4" class=
"doc" id=
"hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor
6244 Example matches y in x(y)
6245 (matcher = callExpr(hasArgument(
0, declRefExpr())))
6246 void x(int) { int y; x(y); }
6250 <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>
6251 <tr><td colspan=
"4" class=
"doc" id=
"hasDeclaration13"><pre>Matches a node if the declaration associated with that node
6252 matches the given matcher.
6254 The associated declaration is:
6255 - for type nodes, the declaration of the underlying type
6256 - for CallExpr, the declaration of the callee
6257 - for MemberExpr, the declaration of the referenced member
6258 - for CXXConstructExpr, the declaration of the constructor
6259 - for CXXNewExpr, the declaration of the operator new
6260 - for ObjCIvarExpr, the declaration of the ivar
6262 For type nodes, hasDeclaration will generally match the declaration of the
6267 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6268 typedefDecl. A common use case is to match the underlying, desugared type.
6269 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6270 varDecl(hasType(hasUnqualifiedDesugaredType(
6271 recordType(hasDeclaration(decl())))))
6272 In this matcher, the decl will match the CXXRecordDecl of class X.
6274 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>>,
6275 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>>,
6276 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>>,
6277 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>>,
6278 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>>,
6279 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>>,
6280 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType
</a>>
6284 <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>
6285 <tr><td colspan=
"4" class=
"doc" id=
"forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition.
6288 class A { A() : i(
42), j(
42) {} int i; int j; };
6289 cxxConstructorDecl(forEachConstructorInitializer(
6290 forField(decl().bind(
"x"))
6292 will trigger two matches, binding for 'i' and 'j' respectively.
6296 <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>
6297 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyConstructorInitializer0"><pre>Matches a constructor initializer.
6304 cxxRecordDecl(has(cxxConstructorDecl(
6305 hasAnyConstructorInitializer(anything())
6307 record matches Foo, hasAnyConstructorInitializer matches foo_(
1)
6311 <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>
6312 <tr><td colspan=
"4" class=
"doc" id=
"forField0"><pre>Matches the field declaration of a constructor initializer.
6319 cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
6320 forField(hasName(
"foo_"))))))
6322 with forField matching foo_
6326 <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>
6327 <tr><td colspan=
"4" class=
"doc" id=
"withInitializer0"><pre>Matches the initializer expression of a constructor initializer.
6334 cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer(
6335 withInitializer(integerLiteral(equals(
1)))))))
6337 with withInitializer matching (
1)
6341 <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>
6342 <tr><td colspan=
"4" class=
"doc" id=
"hasObjectExpression2"><pre>Matches a member expression where the object expression is matched by a
6343 given matcher. Implicit object expressions are included; that is, it matches
6344 use of implicit `this`.
6349 int f(X x) { x.m; return m; }
6351 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName(
"X")))))
6352 matches `x.m`, but not `m`; however,
6353 memberExpr(hasObjectExpression(hasType(pointsTo(
6354 cxxRecordDecl(hasName(
"X"))))))
6355 matches `m` (aka. `this-
>m`), but not `x.m`.
6359 <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>
6360 <tr><td colspan=
"4" class=
"doc" id=
"hasBody3"><pre></pre></td></tr>
6363 <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>
6364 <tr><td colspan=
"4" class=
"doc" id=
"hasInitStatement2"><pre>Matches selection statements with initializer.
6368 if (int i = foobar(); i
> 0) {}
6369 switch (int i = foobar(); i) {}
6370 for (auto
& a = get_range(); auto
& x : a) {}
6373 if (foobar()
> 0) {}
6374 switch (foobar()) {}
6375 for (auto
& x : get_range()) {}
6377 ifStmt(hasInitStatement(anything()))
6378 matches the if statement in foo but not in bar.
6379 switchStmt(hasInitStatement(anything()))
6380 matches the switch statement in foo but not in bar.
6381 cxxForRangeStmt(hasInitStatement(anything()))
6382 matches the range for statement in foo but not in bar.
6386 <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>
6387 <tr><td colspan=
"4" class=
"doc" id=
"hasLoopVariable0"><pre>Matches the initialization statement of a for loop.
6390 forStmt(hasLoopVariable(anything()))
6396 <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>
6397 <tr><td colspan=
"4" class=
"doc" id=
"hasRangeInit0"><pre>Matches the range initialization statement of a for loop.
6400 forStmt(hasRangeInit(anything()))
6406 <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>
6407 <tr><td colspan=
"4" class=
"doc" id=
"onImplicitObjectArgument0"><pre>Matches on the implicit object argument of a member call expression. Unlike
6408 `on`, matches the argument directly without stripping away anything.
6411 class Y { public: void m(); };
6413 class X : public Y { void g(); };
6414 void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); }
6415 cxxMemberCallExpr(onImplicitObjectArgument(hasType(
6416 cxxRecordDecl(hasName(
"Y")))))
6417 matches `y.m()`, `x.m()` and (g()).m(), but not `x.g()`.
6418 cxxMemberCallExpr(on(callExpr()))
6419 does not match `(g()).m()`, because the parens are not ignored.
6421 FIXME: Overload to allow directly matching types?
6425 <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>
6426 <tr><td colspan=
"4" class=
"doc" id=
"on0"><pre>Matches on the implicit object argument of a member call expression, after
6427 stripping off any parentheses or implicit casts.
6430 class Y { public: void m(); };
6432 class X : public Y {};
6433 void z(Y y, X x) { y.m(); (g()).m(); x.m(); }
6434 cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName(
"Y")))))
6435 matches `y.m()` and `(g()).m()`.
6436 cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName(
"X")))))
6438 cxxMemberCallExpr(on(callExpr()))
6439 matches `(g()).m()`.
6441 FIXME: Overload to allow directly matching types?
6445 <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>
6446 <tr><td colspan=
"4" class=
"doc" id=
"thisPointerType1"><pre>Overloaded to match the type's declaration.
6450 <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>
6451 <tr><td colspan=
"4" class=
"doc" id=
"thisPointerType0"><pre>Matches if the type of the expression's implicit object argument either
6452 matches the InnerMatcher, or is a pointer to a type that matches the
6456 class Y { public: void m(); };
6457 class X : public Y { void g(); };
6458 void z() { Y y; y.m(); Y *p; p-
>m(); X x; x.m(); x.g(); }
6459 cxxMemberCallExpr(thisPointerType(hasDeclaration(
6460 cxxRecordDecl(hasName(
"Y")))))
6461 matches `y.m()`, `p-
>m()` and `x.m()`.
6462 cxxMemberCallExpr(thisPointerType(hasDeclaration(
6463 cxxRecordDecl(hasName(
"X")))))
6468 <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>
6469 <tr><td colspan=
"4" class=
"doc" id=
"forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may
6470 produce multiple matches.
6473 class A { virtual void f(); };
6474 class B : public A { void f(); };
6475 class C : public B { void f(); };
6476 cxxMethodDecl(ofClass(hasName(
"C")),
6477 forEachOverridden(cxxMethodDecl().bind(
"b"))).bind(
"d")
6478 matches once, with
"b" binding
"A::f" and
"d" binding
"C::f" (Note
6479 that B::f is not overridden by C::f).
6481 The check can produce multiple matches in case of multiple inheritance, e.g.
6482 class A1 { virtual void f(); };
6483 class A2 { virtual void f(); };
6484 class C : public A1, public A2 { void f(); };
6485 cxxMethodDecl(ofClass(hasName(
"C")),
6486 forEachOverridden(cxxMethodDecl().bind(
"b"))).bind(
"d")
6487 matches twice, once with
"b" binding
"A1::f" and
"d" binding
"C::f", and
6488 once with
"b" binding
"A2::f" and
"d" binding
"C::f".
6492 <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>
6493 <tr><td colspan=
"4" class=
"doc" id=
"ofClass0"><pre>Matches the class declaration that the given method declaration
6496 FIXME: Generalize this for other kinds of declarations.
6497 FIXME: What other kind of declarations would we need to generalize
6500 Example matches A() in the last line
6501 (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl(
6502 ofClass(hasName(
"A"))))))
6511 <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>
6512 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyPlacementArg0"><pre>Matches any placement new expression arguments.
6515 MyClass *p1 = new (Storage) MyClass();
6516 cxxNewExpr(hasAnyPlacementArg(anything()))
6517 matches the expression 'new (Storage,
16) MyClass()'.
6521 <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>
6522 <tr><td colspan=
"4" class=
"doc" id=
"hasArraySize0"><pre>Matches array new expressions with a given array size.
6525 MyClass *p1 = new MyClass[
10];
6526 cxxNewExpr(hasArraySize(integerLiteral(equals(
10))))
6527 matches the expression 'new MyClass[
10]'.
6531 <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>
6532 <tr><td colspan=
"4" class=
"doc" id=
"hasDeclaration12"><pre>Matches a node if the declaration associated with that node
6533 matches the given matcher.
6535 The associated declaration is:
6536 - for type nodes, the declaration of the underlying type
6537 - for CallExpr, the declaration of the callee
6538 - for MemberExpr, the declaration of the referenced member
6539 - for CXXConstructExpr, the declaration of the constructor
6540 - for CXXNewExpr, the declaration of the operator new
6541 - for ObjCIvarExpr, the declaration of the ivar
6543 For type nodes, hasDeclaration will generally match the declaration of the
6548 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6549 typedefDecl. A common use case is to match the underlying, desugared type.
6550 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6551 varDecl(hasType(hasUnqualifiedDesugaredType(
6552 recordType(hasDeclaration(decl())))))
6553 In this matcher, the decl will match the CXXRecordDecl of class X.
6555 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>>,
6556 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>>,
6557 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>>,
6558 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>>,
6559 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>>,
6560 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>>,
6561 Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType
</a>>
6565 <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>
6566 <tr><td colspan=
"4" class=
"doc" id=
"hasPlacementArg0"><pre>Matches placement new expression arguments.
6569 MyClass *p1 = new (Storage,
16) MyClass();
6570 cxxNewExpr(hasPlacementArg(
1, integerLiteral(equals(
16))))
6571 matches the expression 'new (Storage,
16) MyClass()'.
6575 <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>
6576 <tr><td colspan=
"4" class=
"doc" id=
"hasEitherOperand1"><pre>Matches if either the left hand side or the right hand side of a
6577 binary operator matches.
6581 <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>
6582 <tr><td colspan=
"4" class=
"doc" id=
"hasLHS1"><pre>Matches the left hand side of binary operator expressions.
6584 Example matches a (matcher = binaryOperator(hasLHS()))
6589 <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>
6590 <tr><td colspan=
"4" class=
"doc" id=
"hasOperands1"><pre>Matches if both matchers match with opposite sides of the binary operator.
6592 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(
1),
6593 integerLiteral(equals(
2)))
6601 <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>
6602 <tr><td colspan=
"4" class=
"doc" id=
"hasRHS1"><pre>Matches the right hand side of binary operator expressions.
6604 Example matches b (matcher = binaryOperator(hasRHS()))
6609 <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>
6610 <tr><td colspan=
"4" class=
"doc" id=
"hasUnaryOperand1"><pre>Matches if the operand of a unary operator matches.
6612 Example matches true (matcher = hasUnaryOperand(
6613 cxxBoolLiteral(equals(true))))
6618 <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>
6619 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyBase0"><pre>Matches C++ classes that have a direct or indirect base matching BaseSpecMatcher.
6622 matcher hasAnyBase(hasType(cxxRecordDecl(hasName(
"SpecialBase"))))
6627 class Proxy : SpecialBase {}; // matches Proxy
6628 class IndirectlyDerived : Proxy {}; //matches IndirectlyDerived
6630 FIXME: Refactor this and isDerivedFrom to reuse implementation.
6634 <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>
6635 <tr><td colspan=
"4" class=
"doc" id=
"hasDirectBase0"><pre>Matches C++ classes that have a direct base matching BaseSpecMatcher.
6638 matcher hasDirectBase(hasType(cxxRecordDecl(hasName(
"SpecialBase"))))
6643 class Proxy : SpecialBase {}; // matches Proxy
6644 class IndirectlyDerived : Proxy {}; // doesn't match
6648 <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>
6649 <tr><td colspan=
"4" class=
"doc" id=
"hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher.
6652 class A { void func(); };
6653 class B { void member(); };
6655 cxxRecordDecl(hasMethod(hasName(
"func"))) matches the declaration of
6660 <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>
6661 <tr><td colspan=
"4" class=
"doc" id=
"isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from a class
6662 matching Base, or Objective-C classes that directly or indirectly
6663 subclass a class matching Base.
6665 Note that a class is not considered to be derived from itself.
6667 Example matches Y, Z, C (Base == hasName(
"X"))
6669 class Y : public X {}; // directly derived
6670 class Z : public Y {}; // indirectly derived
6673 class C : public B {}; // derived from a typedef of X
6675 In the following example, Bar matches isDerivedFrom(hasName(
"X")):
6678 class Bar : public Foo {}; // derived from a type that X is a typedef of
6680 In the following example, Bar matches isDerivedFrom(hasName(
"NSObject"))
6681 @interface NSObject @end
6682 @interface Bar : NSObject @end
6684 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>>
6688 <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>
6689 <tr><td colspan=
"4" class=
"doc" id=
"isDirectlyDerivedFrom0"><pre>Matches C++ or Objective-C classes that are directly derived from a class
6692 Note that a class is not considered to be derived from itself.
6694 Example matches Y, C (Base == hasName(
"X"))
6696 class Y : public X {}; // directly derived
6697 class Z : public Y {}; // indirectly derived
6700 class C : public B {}; // derived from a typedef of X
6702 In the following example, Bar matches isDerivedFrom(hasName(
"X")):
6705 class Bar : public Foo {}; // derived from a type that X is a typedef of
6709 <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>
6710 <tr><td colspan=
"4" class=
"doc" id=
"isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly
6715 <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>
6716 <tr><td colspan=
"4" class=
"doc" id=
"hasEitherOperand2"><pre>Matches if either the left hand side or the right hand side of a
6717 binary operator matches.
6721 <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>
6722 <tr><td colspan=
"4" class=
"doc" id=
"hasLHS2"><pre>Matches the left hand side of binary operator expressions.
6724 Example matches a (matcher = binaryOperator(hasLHS()))
6729 <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>
6730 <tr><td colspan=
"4" class=
"doc" id=
"hasOperands2"><pre>Matches if both matchers match with opposite sides of the binary operator.
6732 Example matcher = binaryOperator(hasOperands(integerLiteral(equals(
1),
6733 integerLiteral(equals(
2)))
6741 <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>
6742 <tr><td colspan=
"4" class=
"doc" id=
"hasRHS2"><pre>Matches the right hand side of binary operator expressions.
6744 Example matches b (matcher = binaryOperator(hasRHS()))
6749 <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>
6750 <tr><td colspan=
"4" class=
"doc" id=
"hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call
6751 expression, or an ObjC-message-send expression.
6754 void x(int, int, int) { int y; x(
1, y,
42); }
6755 callExpr(hasAnyArgument(declRefExpr()))
6757 with hasAnyArgument(...)
6760 For ObjectiveC, given
6761 @interface I - (void) f:(int) y; @end
6762 void foo(I *i) { [i f:
12]; }
6763 objcMessageExpr(hasAnyArgument(integerLiteral(equals(
12))))
6768 <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>
6769 <tr><td colspan=
"4" class=
"doc" id=
"hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor
6772 Example matches y in x(y)
6773 (matcher = callExpr(hasArgument(
0, declRefExpr())))
6774 void x(int) { int y; x(y); }
6778 <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>
6779 <tr><td colspan=
"4" class=
"doc" id=
"callee1"><pre>Matches if the call expression's callee's declaration matches the
6782 Example matches y.x() (matcher = callExpr(callee(
6783 cxxMethodDecl(hasName(
"x")))))
6784 class Y { public: void x(); };
6785 void z() { Y y; y.x(); }
6789 <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>
6790 <tr><td colspan=
"4" class=
"doc" id=
"callee0"><pre>Matches if the call expression's callee expression matches.
6793 class Y { void x() { this-
>x(); x(); Y y; y.x(); } };
6795 callExpr(callee(expr()))
6796 matches this-
>x(), x(), y.x(), f()
6798 matching this-
>x, x, y.x, f respectively
6800 Note: Callee cannot take the more general internal::Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr
</a>>
6801 because this introduces ambiguous overloads with calls to Callee taking a
6802 internal::Matcher
<<a href=
"https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl
</a>>, as the matcher hierarchy is purely
6803 implemented in terms of implicit casts.
6807 <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>
6808 <tr><td colspan=
"4" class=
"doc" id=
"forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl.
6815 forEachArgumentWithParam(
6816 declRefExpr(to(varDecl(hasName(
"y")))),
6817 parmVarDecl(hasType(isInteger()))
6820 with declRefExpr(...)
6822 and parmVarDecl(...)
6827 <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>
6828 <tr><td colspan=
"4" class=
"doc" id=
"forEachArgumentWithParamType0"><pre>Matches all arguments and their respective types for a CallExpr or
6829 CXXConstructExpr. It is very similar to forEachArgumentWithParam but
6830 it works on calls through function pointers as well.
6832 The difference is, that function pointers do not provide access to a
6833 ParmVarDecl, but only the QualType for each argument.
6839 void (*f_ptr)(int) = f;
6842 forEachArgumentWithParamType(
6843 declRefExpr(to(varDecl(hasName(
"y")))),
6844 qualType(isInteger()).bind(
"type)
6846 matches f(y) and f_ptr(y)
6847 with declRefExpr(...)
6854 <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>
6855 <tr><td colspan="4" class="doc
" id="hasAnyArgument0
"><pre>Matches any argument of a call expression or a constructor call
6856 expression, or an ObjC-message-send expression.
6859 void x(int, int, int) { int y; x(1, y, 42); }
6860 callExpr(hasAnyArgument(declRefExpr()))
6862 with hasAnyArgument(...)
6865 For ObjectiveC, given
6866 @interface I - (void) f:(int) y; @end
6867 void foo(I *i) { [i f:12]; }
6868 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
6873 <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>
6874 <tr><td colspan="4" class="doc
" id="hasArgument0
"><pre>Matches the n'th argument of a call expression or a constructor
6877 Example matches y in x(y)
6878 (matcher = callExpr(hasArgument(0, declRefExpr())))
6879 void x(int) { int y; x(y); }
6883 <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>
6884 <tr><td colspan="4" class="doc
" id="hasDeclaration14
"><pre>Matches a node if the declaration associated with that node
6885 matches the given matcher.
6887 The associated declaration is:
6888 - for type nodes, the declaration of the underlying type
6889 - for CallExpr, the declaration of the callee
6890 - for MemberExpr, the declaration of the referenced member
6891 - for CXXConstructExpr, the declaration of the constructor
6892 - for CXXNewExpr, the declaration of the operator new
6893 - for ObjCIvarExpr, the declaration of the ivar
6895 For type nodes, hasDeclaration will generally match the declaration of the
6900 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
6901 typedefDecl. A common use case is to match the underlying, desugared type.
6902 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
6903 varDecl(hasType(hasUnqualifiedDesugaredType(
6904 recordType(hasDeclaration(decl())))))
6905 In this matcher, the decl will match the CXXRecordDecl of class X.
6907 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>>,
6908 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>>,
6909 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>>,
6910 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>>,
6911 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>>,
6912 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>>,
6913 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
6917 <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>
6918 <tr><td colspan="4" class="doc
" id="hasCaseConstant0
"><pre>If the given case statement does not use the GNU case range
6919 extension, matches the constant given in the statement.
6922 switch (1) { case 1: case 1+1: case 3 ... 4: ; }
6923 caseStmt(hasCaseConstant(integerLiteral()))
6928 <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>
6929 <tr><td colspan="4" class="doc
" id="hasSourceExpression0
"><pre>Matches if the cast's source expression
6930 or opaque value's source expression matches the given matcher.
6932 Example 1: matches "a string
"
6933 (matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
6934 class URL { URL(string); };
6935 URL url = "a string
";
6937 Example 2: matches 'b' (matcher =
6938 opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
6943 <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>
6944 <tr><td colspan="4" class="doc
" id="hasAnyTemplateArgument0
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
6945 functionDecl that have at least one TemplateArgument matching the given
6949 template<typename T> class A {};
6950 template<> class A<double> {};
6953 template<typename T> f() {};
6954 void func() { f<int>(); };
6956 classTemplateSpecializationDecl(hasAnyTemplateArgument(
6957 refersToType(asString("int
"))))
6958 matches the specialization A<int>
6960 functionDecl(hasAnyTemplateArgument(refersToType(asString("int
"))))
6961 matches the specialization f<int>
6965 <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>
6966 <tr><td colspan="4" class="doc
" id="hasSpecializedTemplate0
"><pre>Matches the specialized template of a specialization declaration.
6969 template<typename T> class A {}; #1
6970 template<> class A<int> {}; #2
6971 classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl()))
6972 matches '#2' with classTemplateDecl() matching the class template
6973 declaration of 'A' at #1.
6977 <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>
6978 <tr><td colspan="4" class="doc
" id="hasTemplateArgument0
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
6979 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
6982 template<typename T, typename U> class A {};
6983 A<bool, int> b;
6984 A<int, bool> c;
6986 template<typename T> void f() {}
6987 void func() { f<int>(); };
6988 classTemplateSpecializationDecl(hasTemplateArgument(
6989 1, refersToType(asString("int
"))))
6990 matches the specialization A<bool, int>
6992 functionDecl(hasTemplateArgument(0, refersToType(asString("int
"))))
6993 matches the specialization f<int>
6997 <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>
6998 <tr><td colspan="4" class="doc
" id="hasElementType1
"><pre>Matches arrays and C99 complex types that have a specific element
7005 arrayType(hasElementType(builtinType()))
7008 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>>
7012 <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>
7013 <tr><td colspan="4" class="doc
" id="hasAnySubstatement0
"><pre>Matches compound statements where at least one substatement matches
7014 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
7018 hasAnySubstatement(compoundStmt())
7019 matches '{ {}; 1+2; }'
7025 <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>
7026 <tr><td colspan="4" class="doc
" id="hasDecayedType0
"><pre>Matches the decayed type, whoes decayed type matches InnerMatcher
7030 <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>
7031 <tr><td colspan="4" class="doc
" id="hasDeclaration11
"><pre>Matches a node if the declaration associated with that node
7032 matches the given matcher.
7034 The associated declaration is:
7035 - for type nodes, the declaration of the underlying type
7036 - for CallExpr, the declaration of the callee
7037 - for MemberExpr, the declaration of the referenced member
7038 - for CXXConstructExpr, the declaration of the constructor
7039 - for CXXNewExpr, the declaration of the operator new
7040 - for ObjCIvarExpr, the declaration of the ivar
7042 For type nodes, hasDeclaration will generally match the declaration of the
7047 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7048 typedefDecl. A common use case is to match the underlying, desugared type.
7049 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7050 varDecl(hasType(hasUnqualifiedDesugaredType(
7051 recordType(hasDeclaration(decl())))))
7052 In this matcher, the decl will match the CXXRecordDecl of class X.
7054 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>>,
7055 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>>,
7056 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>>,
7057 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>>,
7058 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>>,
7059 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>>,
7060 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
7064 <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>> InnerMatcher</td></tr>
7065 <tr><td colspan="4" class="doc
" id="throughUsingDecl0
"><pre>Matches a DeclRefExpr that refers to a declaration through a
7066 specific using shadow declaration.
7069 namespace a { void f() {} }
7072 f(); // Matches this ..
7073 a::f(); // .. but not this.
7075 declRefExpr(throughUsingDecl(anything()))
7080 <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>
7081 <tr><td colspan="4" class="doc
" id="to0
"><pre>Matches a DeclRefExpr that refers to a declaration that matches the
7084 Example matches x in if(x)
7085 (matcher = declRefExpr(to(varDecl(hasName("x
")))))
7091 <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>
7092 <tr><td colspan="4" class="doc
" id="containsDeclaration0
"><pre>Matches the n'th declaration of a declaration statement.
7094 Note that this does not work for global declarations because the AST
7095 breaks up multiple-declaration DeclStmt's into multiple single-declaration
7097 Example: Given non-global declarations
7101 declStmt(containsDeclaration(
7102 0, varDecl(hasInitializer(anything()))))
7103 matches only 'int d = 2, e;', and
7104 declStmt(containsDeclaration(1, varDecl()))
7105 matches 'int a, b = 0' as well as 'int d = 2, e;'
7106 but 'int c;' is not matched.
7110 <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>
7111 <tr><td colspan="4" class="doc
" id="hasSingleDecl0
"><pre>Matches the Decl of a DeclStmt which has a single declaration.
7116 declStmt(hasSingleDecl(anything()))
7117 matches 'int c;' but not 'int a, b;'.
7121 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html
">DeclaratorDecl</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>
7122 <tr><td colspan="4" class="doc
" id="hasTypeLoc0
"><pre>Matches if the type location of the declarator decl's type matches
7127 declaratorDecl(hasTypeLoc(loc(asString("int
"))))
7132 <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>
7133 <tr><td colspan="4" class="doc
" id="hasDeclContext0
"><pre>Matches declarations whose declaration context, interpreted as a
7134 Decl, matches InnerMatcher.
7143 cxxRcordDecl(hasDeclContext(namedDecl(hasName("M
")))) matches the
7144 declaration of class D.
7148 <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>
7149 <tr><td colspan="4" class="doc
" id="hasUnderlyingType0
"><pre>Matches DecltypeType nodes to find out the underlying type.
7153 decltype(2.0) b = 2.0;
7154 decltypeType(hasUnderlyingType(isInteger()))
7155 matches the type of "a
"
7157 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html
">DecltypeType</a>>
7161 <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>
7162 <tr><td colspan="4" class="doc
" id="hasAnyBinding0
"><pre>Matches any binding of a DecompositionDecl.
7168 auto &[f, s, t] = arr;
7173 decompositionDecl(hasAnyBinding(bindingDecl(hasName("f
").bind("fBinding
"))))
7174 matches the decomposition decl with 'f' bound to "fBinding
".
7178 <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>
7179 <tr><td colspan="4" class="doc
" id="hasBinding0
"><pre>Matches the Nth binding of a DecompositionDecl.
7185 auto &[f, s, t] = arr;
7190 decompositionDecl(hasBinding(0,
7191 bindingDecl(hasName("f
").bind("fBinding
"))))
7192 matches the decomposition decl with 'f' bound to "fBinding
".
7196 <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>
7197 <tr><td colspan="4" class="doc
" id="hasBody0
"><pre></pre></td></tr>
7200 <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>
7201 <tr><td colspan="4" class="doc
" id="hasCondition3
"><pre>Matches the condition expression of an if statement, for loop,
7202 switch statement or conditional operator.
7204 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
7209 <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>
7210 <tr><td colspan="4" class="doc
" id="hasQualifier0
"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier,
7211 matches InnerMatcher if the qualifier exists.
7221 elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N
"))))
7222 matches the type of the variable declaration of d.
7226 <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>
7227 <tr><td colspan="4" class="doc
" id="namesType0
"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher.
7237 elaboratedType(namesType(recordType(
7238 hasDeclaration(namedDecl(hasName("D
")))))) matches the type of the variable
7243 <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>
7244 <tr><td colspan="4" class="doc
" id="hasDeclaration10
"><pre>Matches a node if the declaration associated with that node
7245 matches the given matcher.
7247 The associated declaration is:
7248 - for type nodes, the declaration of the underlying type
7249 - for CallExpr, the declaration of the callee
7250 - for MemberExpr, the declaration of the referenced member
7251 - for CXXConstructExpr, the declaration of the constructor
7252 - for CXXNewExpr, the declaration of the operator new
7253 - for ObjCIvarExpr, the declaration of the ivar
7255 For type nodes, hasDeclaration will generally match the declaration of the
7260 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7261 typedefDecl. A common use case is to match the underlying, desugared type.
7262 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7263 varDecl(hasType(hasUnqualifiedDesugaredType(
7264 recordType(hasDeclaration(decl())))))
7265 In this matcher, the decl will match the CXXRecordDecl of class X.
7267 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>>,
7268 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>>,
7269 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>>,
7270 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>>,
7271 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>>,
7272 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>>,
7273 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
7277 <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>
7278 <tr><td colspan="4" class="doc
" id="hasDestinationType0
"><pre>Matches casts whose destination type matches a given matcher.
7280 (Note: Clang's AST refers to other conversions as "casts
" too, and calls
7281 actual casts "explicit
" casts.)
7285 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html
">Expr</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_1Decl.html
">Decl</a>> InnerMatcher</td></tr>
7286 <tr><td colspan="4" class="doc
" id="hasType4
"><pre>Overloaded to match the declaration of the expression's or value
7289 In case of a value declaration (for example a variable declaration),
7290 this resolves one layer of indirection. For example, in the value
7291 declaration "X x;
", cxxRecordDecl(hasName("X
")) matches the declaration of
7292 X, while varDecl(hasType(cxxRecordDecl(hasName("X
")))) matches the
7295 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
7296 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
7297 and friend class X (matcher = friendDecl(hasType("X
"))
7299 void y(X &x) { x; X z; }
7300 class Y { friend class X; };
7302 Example matches class Derived
7303 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base
"))))))
7305 class Derived : Base {};
7307 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>>,
7308 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>
7312 <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>
7313 <tr><td colspan="4" class="doc
" id="hasType0
"><pre>Matches if the expression's or declaration's type matches a type
7316 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
7317 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
7318 and U (matcher = typedefDecl(hasType(asString("int
")))
7319 and friend class X (matcher = friendDecl(hasType("X
"))
7321 void y(X &x) { x; X z; }
7323 class Y { friend class X; };
7327 <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>
7328 <tr><td colspan="4" class="doc
" id="ignoringElidableConstructorCall0
"><pre>Matches expressions that match InnerMatcher that are possibly wrapped in an
7329 elidable constructor and other corresponding bookkeeping nodes.
7331 In C++17, elidable copy constructors are no longer being generated in the
7332 AST as it is not permitted by the standard. They are, however, part of the
7333 AST in C++14 and earlier. So, a matcher must abstract over these differences
7334 to work in all language modes. This matcher skips elidable constructor-call
7335 AST nodes, `ExprWithCleanups` nodes wrapping elidable constructor-calls and
7336 various implicit nodes inside the constructor calls, all of which will not
7337 appear in the C++17 AST.
7347 ``varDecl(hasInitializer(ignoringElidableConstructorCall(callExpr())))``
7348 matches ``H D = G()`` in C++11 through C++17 (and beyond).
7352 <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>
7353 <tr><td colspan="4" class="doc
" id="ignoringImpCasts0
"><pre>Matches expressions that match InnerMatcher after any implicit casts
7356 Parentheses and explicit casts are not discarded.
7365 varDecl(hasInitializer(ignoringImpCasts(integerLiteral())))
7366 varDecl(hasInitializer(ignoringImpCasts(declRefExpr())))
7367 would match the declarations for a, b, c, and d, but not e.
7369 varDecl(hasInitializer(integerLiteral()))
7370 varDecl(hasInitializer(declRefExpr()))
7371 only match the declarations for b, c, and d.
7375 <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>
7376 <tr><td colspan="4" class="doc
" id="ignoringImplicit0
"><pre>Matches expressions that match InnerMatcher after any implicit AST
7377 nodes are stripped off.
7379 Parentheses and explicit casts are not discarded.
7386 varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr())))
7387 would match the declarations for a, b, and c.
7389 varDecl(hasInitializer(cxxConstructExpr()))
7390 only match the declarations for b and c.
7394 <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>
7395 <tr><td colspan="4" class="doc
" id="ignoringParenCasts0
"><pre>Matches expressions that match InnerMatcher after parentheses and
7396 casts are stripped off.
7398 Implicit and non-C Style casts are also discarded.
7402 void* c = reinterpret_cast<char*>(0);
7405 varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
7406 would match the declarations for a, b, c, and d.
7408 varDecl(hasInitializer(integerLiteral()))
7409 only match the declaration for a.
7413 <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>
7414 <tr><td colspan="4" class="doc
" id="ignoringParenImpCasts0
"><pre>Matches expressions that match InnerMatcher after implicit casts and
7415 parentheses are stripped off.
7417 Explicit casts are not discarded.
7424 long e = ((long) 0l);
7426 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral())))
7427 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr())))
7428 would match the declarations for a, b, c, and d, but not e.
7430 varDecl(hasInitializer(integerLiteral()))
7431 varDecl(hasInitializer(declRefExpr()))
7432 would only match the declaration for a.
7436 <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>
7437 <tr><td colspan="4" class="doc
" id="ignoringParens1
"><pre>Overload ignoringParens for Expr.
7440 const char* str = ("my-string
");
7442 implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral())))
7443 would match the implicit cast resulting from the assignment.
7447 <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>
7448 <tr><td colspan="4" class="doc
" id="hasInClassInitializer0
"><pre>Matches non-static data members that have an in-class initializer.
7456 fieldDecl(hasInClassInitializer(integerLiteral(equals(2))))
7457 matches 'int a;' but not 'int b;'.
7458 fieldDecl(hasInClassInitializer(anything()))
7459 matches 'int a;' and 'int b;' but not 'int c;'.
7463 <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>
7464 <tr><td colspan="4" class="doc
" id="hasBody1
"><pre></pre></td></tr>
7467 <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>
7468 <tr><td colspan="4" class="doc
" id="hasCondition1
"><pre>Matches the condition expression of an if statement, for loop,
7469 switch statement or conditional operator.
7471 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
7476 <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>
7477 <tr><td colspan="4" class="doc
" id="hasIncrement0
"><pre>Matches the increment statement of a for loop.
7480 forStmt(hasIncrement(unaryOperator(hasOperatorName("++
"))))
7482 for (x; x < N; ++x) { }
7486 <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>
7487 <tr><td colspan="4" class="doc
" id="hasLoopInit0
"><pre>Matches the initialization statement of a for loop.
7490 forStmt(hasLoopInit(declStmt()))
7491 matches 'int x = 0' in
7492 for (int x = 0; x < N; ++x) { }
7496 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html
">FriendDecl</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>
7497 <tr><td colspan="4" class="doc
" id="hasType5
"><pre>Overloaded to match the declaration of the expression's or value
7500 In case of a value declaration (for example a variable declaration),
7501 this resolves one layer of indirection. For example, in the value
7502 declaration "X x;
", cxxRecordDecl(hasName("X
")) matches the declaration of
7503 X, while varDecl(hasType(cxxRecordDecl(hasName("X
")))) matches the
7506 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
7507 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
7508 and friend class X (matcher = friendDecl(hasType("X
"))
7510 void y(X &x) { x; X z; }
7511 class Y { friend class X; };
7513 Example matches class Derived
7514 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base
"))))))
7516 class Derived : Base {};
7518 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>>,
7519 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>
7523 <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>
7524 <tr><td colspan="4" class="doc
" id="hasType1
"><pre>Matches if the expression's or declaration's type matches a type
7527 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
7528 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
7529 and U (matcher = typedefDecl(hasType(asString("int
")))
7530 and friend class X (matcher = friendDecl(hasType("X
"))
7532 void y(X &x) { x; X z; }
7534 class Y { friend class X; };
7538 <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>
7539 <tr><td colspan="4" class="doc
" id="hasAnyBody0
"><pre>Matches a function declaration that has a given body present in the AST.
7540 Note that this matcher matches all the declarations of a function whose
7541 body is present in the AST.
7547 functionDecl(hasAnyBody(compoundStmt()))
7548 matches both 'void f();'
7552 but does not match 'void g();'
7556 <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>
7557 <tr><td colspan="4" class="doc
" id="hasAnyParameter0
"><pre>Matches any parameter of a function or an ObjC method declaration or a
7560 Does not match the 'this' parameter of a method.
7563 class X { void f(int x, int y, int z) {} };
7564 cxxMethodDecl(hasAnyParameter(hasName("y
")))
7565 matches f(int x, int y, int z) {}
7566 with hasAnyParameter(...)
7569 For ObjectiveC, given
7570 @interface I - (void) f:(int) y; @end
7572 the matcher objcMethodDecl(hasAnyParameter(hasName("y
")))
7573 matches the declaration of method f with hasParameter
7577 b = ^(int y) { printf("%d
", y) };
7579 the matcher blockDecl(hasAnyParameter(hasName("y
")))
7580 matches the declaration of the block b with hasParameter
7585 <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>
7586 <tr><td colspan="4" class="doc
" id="hasAnyTemplateArgument2
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
7587 functionDecl that have at least one TemplateArgument matching the given
7591 template<typename T> class A {};
7592 template<> class A<double> {};
7595 template<typename T> f() {};
7596 void func() { f<int>(); };
7598 classTemplateSpecializationDecl(hasAnyTemplateArgument(
7599 refersToType(asString("int
"))))
7600 matches the specialization A<int>
7602 functionDecl(hasAnyTemplateArgument(refersToType(asString("int
"))))
7603 matches the specialization f<int>
7607 <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>
7608 <tr><td colspan="4" class="doc
" id="hasBody4
"><pre></pre></td></tr>
7611 <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>
7612 <tr><td colspan="4" class="doc
" id="hasExplicitSpecifier0
"><pre>Matches the expression in an explicit specifier if present in the given
7616 template<bool b>
7619 explicit S(double); // #2
7620 operator int(); // #3
7621 explicit operator bool(); // #4
7622 explicit(false) S(bool) // # 7
7623 explicit(true) S(char) // # 8
7624 explicit(b) S(S) // # 9
7626 S(int) -> S<true> // #5
7627 explicit S(double) -> S<false> // #6
7628 cxxConstructorDecl(hasExplicitSpecifier(constantExpr())) will match #7, #8 and #9, but not #1 or #2.
7629 cxxConversionDecl(hasExplicitSpecifier(constantExpr())) will not match #3 or #4.
7630 cxxDeductionGuideDecl(hasExplicitSpecifier(constantExpr())) will not match #5 or #6.
7634 <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>
7635 <tr><td colspan="4" class="doc
" id="hasParameter0
"><pre>Matches the n'th parameter of a function or an ObjC method
7636 declaration or a block.
7639 class X { void f(int x) {} };
7640 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
7642 with hasParameter(...)
7645 For ObjectiveC, given
7646 @interface I - (void) f:(int) y; @end
7648 the matcher objcMethodDecl(hasParameter(0, hasName("y
")))
7649 matches the declaration of method f with hasParameter
7654 <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>
7655 <tr><td colspan="4" class="doc
" id="hasTemplateArgument2
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
7656 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
7659 template<typename T, typename U> class A {};
7660 A<bool, int> b;
7661 A<int, bool> c;
7663 template<typename T> void f() {}
7664 void func() { f<int>(); };
7665 classTemplateSpecializationDecl(hasTemplateArgument(
7666 1, refersToType(asString("int
"))))
7667 matches the specialization A<bool, int>
7669 functionDecl(hasTemplateArgument(0, refersToType(asString("int
"))))
7670 matches the specialization f<int>
7674 <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>
7675 <tr><td colspan="4" class="doc
" id="returns0
"><pre>Matches the return type of a function declaration.
7678 class X { int f() { return 1; } };
7679 cxxMethodDecl(returns(asString("int
")))
7680 matches int f() { return 1; }
7684 <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>
7685 <tr><td colspan="4" class="doc
" id="hasCondition0
"><pre>Matches the condition expression of an if statement, for loop,
7686 switch statement or conditional operator.
7688 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
7693 <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>
7694 <tr><td colspan="4" class="doc
" id="hasConditionVariableStatement0
"><pre>Matches the condition variable statement in an if statement.
7697 if (A* a = GetAPointer()) {}
7698 hasConditionVariableStatement(...)
7699 matches 'A* a = GetAPointer()'.
7703 <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>
7704 <tr><td colspan="4" class="doc
" id="hasElse0
"><pre>Matches the else-statement of an if statement.
7706 Examples matches the if statement
7707 (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true)))))
7708 if (false) false; else true;
7712 <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>
7713 <tr><td colspan="4" class="doc
" id="hasInitStatement0
"><pre>Matches selection statements with initializer.
7717 if (int i = foobar(); i > 0) {}
7718 switch (int i = foobar(); i) {}
7719 for (auto& a = get_range(); auto& x : a) {}
7722 if (foobar() > 0) {}
7723 switch (foobar()) {}
7724 for (auto& x : get_range()) {}
7726 ifStmt(hasInitStatement(anything()))
7727 matches the if statement in foo but not in bar.
7728 switchStmt(hasInitStatement(anything()))
7729 matches the switch statement in foo but not in bar.
7730 cxxForRangeStmt(hasInitStatement(anything()))
7731 matches the range for statement in foo but not in bar.
7735 <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>
7736 <tr><td colspan="4" class="doc
" id="hasThen0
"><pre>Matches the then-statement of an if statement.
7738 Examples matches the if statement
7739 (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true)))))
7740 if (false) true; else false;
7744 <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>
7745 <tr><td colspan="4" class="doc
" id="hasImplicitDestinationType0
"><pre>Matches implicit casts whose destination type matches a given
7748 FIXME: Unit test this matcher
7752 <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>
7753 <tr><td colspan="4" class="doc
" id="hasInit0
"><pre>Matches the n'th item of an initializer list expression.
7756 (matcher = initListExpr(hasInit(0, expr())))
7761 <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>
7762 <tr><td colspan="4" class="doc
" id="hasSyntacticForm0
"><pre>Matches the syntactic form of init list expressions
7763 (if expression have it).
7767 <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>
7768 <tr><td colspan="4" class="doc
" id="hasDeclaration9
"><pre>Matches a node if the declaration associated with that node
7769 matches the given matcher.
7771 The associated declaration is:
7772 - for type nodes, the declaration of the underlying type
7773 - for CallExpr, the declaration of the callee
7774 - for MemberExpr, the declaration of the referenced member
7775 - for CXXConstructExpr, the declaration of the constructor
7776 - for CXXNewExpr, the declaration of the operator new
7777 - for ObjCIvarExpr, the declaration of the ivar
7779 For type nodes, hasDeclaration will generally match the declaration of the
7784 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7785 typedefDecl. A common use case is to match the underlying, desugared type.
7786 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7787 varDecl(hasType(hasUnqualifiedDesugaredType(
7788 recordType(hasDeclaration(decl())))))
7789 In this matcher, the decl will match the CXXRecordDecl of class X.
7791 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>>,
7792 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>>,
7793 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>>,
7794 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>>,
7795 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>>,
7796 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>>,
7797 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
7801 <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>
7802 <tr><td colspan="4" class="doc
" id="hasDeclaration8
"><pre>Matches a node if the declaration associated with that node
7803 matches the given matcher.
7805 The associated declaration is:
7806 - for type nodes, the declaration of the underlying type
7807 - for CallExpr, the declaration of the callee
7808 - for MemberExpr, the declaration of the referenced member
7809 - for CXXConstructExpr, the declaration of the constructor
7810 - for CXXNewExpr, the declaration of the operator new
7811 - for ObjCIvarExpr, the declaration of the ivar
7813 For type nodes, hasDeclaration will generally match the declaration of the
7818 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7819 typedefDecl. A common use case is to match the underlying, desugared type.
7820 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7821 varDecl(hasType(hasUnqualifiedDesugaredType(
7822 recordType(hasDeclaration(decl())))))
7823 In this matcher, the decl will match the CXXRecordDecl of class X.
7825 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>>,
7826 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>>,
7827 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>>,
7828 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>>,
7829 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>>,
7830 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>>,
7831 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
7835 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html
">LambdaExpr</a>></td><td class="name
" onclick="toggle('hasAnyCapture1')
"><a name="hasAnyCapture1Anchor
">hasAnyCapture</a></td><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html
">CXXThisExpr</a>> InnerMatcher</td></tr>
7836 <tr><td colspan="4" class="doc
" id="hasAnyCapture1
"><pre>Matches any capture of 'this' in a lambda expression.
7841 auto f = [this](){};
7844 lambdaExpr(hasAnyCapture(cxxThisExpr()))
7849 <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_1VarDecl.html
">VarDecl</a>> InnerMatcher</td></tr>
7850 <tr><td colspan="4" class="doc
" id="hasAnyCapture0
"><pre>Matches any capture of a lambda expression.
7857 lambdaExpr(hasAnyCapture(anything()))
7862 <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>
7863 <tr><td colspan="4" class="doc
" id="hasDeclaration7
"><pre>Matches a node if the declaration associated with that node
7864 matches the given matcher.
7866 The associated declaration is:
7867 - for type nodes, the declaration of the underlying type
7868 - for CallExpr, the declaration of the callee
7869 - for MemberExpr, the declaration of the referenced member
7870 - for CXXConstructExpr, the declaration of the constructor
7871 - for CXXNewExpr, the declaration of the operator new
7872 - for ObjCIvarExpr, the declaration of the ivar
7874 For type nodes, hasDeclaration will generally match the declaration of the
7879 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
7880 typedefDecl. A common use case is to match the underlying, desugared type.
7881 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
7882 varDecl(hasType(hasUnqualifiedDesugaredType(
7883 recordType(hasDeclaration(decl())))))
7884 In this matcher, the decl will match the CXXRecordDecl of class X.
7886 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>>,
7887 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>>,
7888 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>>,
7889 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>>,
7890 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>>,
7891 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>>,
7892 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
7896 <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>
7897 <tr><td colspan="4" class="doc
" id="hasObjectExpression0
"><pre>Matches a member expression where the object expression is matched by a
7898 given matcher. Implicit object expressions are included; that is, it matches
7899 use of implicit `this`.
7904 int f(X x) { x.m; return m; }
7906 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X
")))))
7907 matches `x.m`, but not `m`; however,
7908 memberExpr(hasObjectExpression(hasType(pointsTo(
7909 cxxRecordDecl(hasName("X
"))))))
7910 matches `m` (aka. `this->m`), but not `x.m`.
7914 <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>
7915 <tr><td colspan="4" class="doc
" id="member0
"><pre>Matches a member expression where the member is matched by a
7919 struct { int first, second; } first, second;
7920 int i(second.first);
7921 int j(first.second);
7922 memberExpr(member(hasName("first
")))
7923 matches second.first
7924 but not first.second (because the member name there is "second
").
7928 <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>
7929 <tr><td colspan="4" class="doc
" id="pointee1
"><pre>Narrows PointerType (and similar) matchers to those where the
7930 pointee matches a given matcher.
7936 pointerType(pointee(isConstQualified(), isInteger()))
7937 matches "int const *b
"
7939 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>>,
7940 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>>
7944 <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>
7945 <tr><td colspan="4" class="doc
" id="hasUnderlyingDecl0
"><pre>Matches a NamedDecl whose underlying declaration matches the given
7949 namespace N { template<class T> void f(T t); }
7950 template <class T> void g() { using N::f; f(T()); }
7951 unresolvedLookupExpr(hasAnyDeclaration(
7952 namedDecl(hasUnderlyingDecl(hasName("::N::f
")))))
7953 matches the use of f in g() .
7957 <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>
7958 <tr><td colspan="4" class="doc
" id="hasPrefix1
"><pre>Matches on the prefix of a NestedNameSpecifierLoc.
7961 struct A { struct B { struct C {}; }; };
7963 nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A
")))))
7968 <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>
7969 <tr><td colspan="4" class="doc
" id="loc1
"><pre>Matches NestedNameSpecifierLocs for which the given inner
7970 NestedNameSpecifier-matcher matches.
7974 <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>
7975 <tr><td colspan="4" class="doc
" id="specifiesTypeLoc0
"><pre>Matches nested name specifier locs that specify a type matching the
7979 struct A { struct B { struct C {}; }; };
7981 nestedNameSpecifierLoc(specifiesTypeLoc(loc(type(
7982 hasDeclaration(cxxRecordDecl(hasName("A
")))))))
7987 <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>
7988 <tr><td colspan="4" class="doc
" id="hasPrefix0
"><pre>Matches on the prefix of a NestedNameSpecifier.
7991 struct A { struct B { struct C {}; }; };
7993 nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A
")))) and
7998 <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>
7999 <tr><td colspan="4" class="doc
" id="specifiesNamespace0
"><pre>Matches nested name specifiers that specify a namespace matching the
8000 given namespace matcher.
8003 namespace ns { struct A {}; }
8005 nestedNameSpecifier(specifiesNamespace(hasName("ns
")))
8010 <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>
8011 <tr><td colspan="4" class="doc
" id="specifiesType0
"><pre>Matches nested name specifiers that specify a type matching the
8012 given QualType matcher without qualifiers.
8015 struct A { struct B { struct C {}; }; };
8017 nestedNameSpecifier(specifiesType(
8018 hasDeclaration(cxxRecordDecl(hasName("A
")))
8024 <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>
8025 <tr><td colspan="4" class="doc
" id="hasAnyClause0
"><pre>Matches any clause in an OpenMP directive.
8029 #pragma omp parallel
8030 #pragma omp parallel default(none)
8032 ``ompExecutableDirective(hasAnyClause(anything()))`` matches
8033 ``omp parallel default(none)``.
8037 <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>
8038 <tr><td colspan="4" class="doc
" id="hasStructuredBlock0
"><pre>Matches the structured-block of the OpenMP executable directive
8040 Prerequisite: the executable directive must not be standalone directive.
8041 If it is, it will never match.
8045 #pragma omp parallel
8047 #pragma omp parallel
8050 ``ompExecutableDirective(hasStructuredBlock(nullStmt()))`` will match ``;``
8054 <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>
8055 <tr><td colspan="4" class="doc
" id="isDerivedFrom1
"><pre>Matches C++ classes that are directly or indirectly derived from a class
8056 matching Base, or Objective-C classes that directly or indirectly
8057 subclass a class matching Base.
8059 Note that a class is not considered to be derived from itself.
8061 Example matches Y, Z, C (Base == hasName("X
"))
8063 class Y : public X {}; // directly derived
8064 class Z : public Y {}; // indirectly derived
8067 class C : public B {}; // derived from a typedef of X
8069 In the following example, Bar matches isDerivedFrom(hasName("X
")):
8072 class Bar : public Foo {}; // derived from a type that X is a typedef of
8074 In the following example, Bar matches isDerivedFrom(hasName("NSObject
"))
8075 @interface NSObject @end
8076 @interface Bar : NSObject @end
8078 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>>
8082 <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>
8083 <tr><td colspan="4" class="doc
" id="isDirectlyDerivedFrom1
"><pre>Matches C++ or Objective-C classes that are directly derived from a class
8086 Note that a class is not considered to be derived from itself.
8088 Example matches Y, C (Base == hasName("X
"))
8090 class Y : public X {}; // directly derived
8091 class Z : public Y {}; // indirectly derived
8094 class C : public B {}; // derived from a typedef of X
8096 In the following example, Bar matches isDerivedFrom(hasName("X
")):
8099 class Bar : public Foo {}; // derived from a type that X is a typedef of
8103 <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>
8104 <tr><td colspan="4" class="doc
" id="isSameOrDerivedFrom1
"><pre>Similar to isDerivedFrom(), but also matches classes that directly
8109 <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>
8110 <tr><td colspan="4" class="doc
" id="hasAnyArgument3
"><pre>Matches any argument of a call expression or a constructor call
8111 expression, or an ObjC-message-send expression.
8114 void x(int, int, int) { int y; x(1, y, 42); }
8115 callExpr(hasAnyArgument(declRefExpr()))
8117 with hasAnyArgument(...)
8120 For ObjectiveC, given
8121 @interface I - (void) f:(int) y; @end
8122 void foo(I *i) { [i f:12]; }
8123 objcMessageExpr(hasAnyArgument(integerLiteral(equals(12))))
8128 <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>
8129 <tr><td colspan="4" class="doc
" id="hasArgument3
"><pre>Matches the n'th argument of a call expression or a constructor
8132 Example matches y in x(y)
8133 (matcher = callExpr(hasArgument(0, declRefExpr())))
8134 void x(int) { int y; x(y); }
8138 <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>
8139 <tr><td colspan="4" class="doc
" id="hasReceiver0
"><pre>Matches if the Objective-C message is sent to an instance,
8140 and the inner matcher matches on that instance.
8142 For example the method call in
8143 NSString *x = @"hello
";
8144 [x containsString:@"h
"];
8146 objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x
"))))))
8150 <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>
8151 <tr><td colspan="4" class="doc
" id="hasReceiverType0
"><pre>Matches on the receiver of an ObjectiveC Message expression.
8154 matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *
")));
8155 matches the [webView ...] message invocation.
8156 NSString *webViewJavaScript = ...
8157 UIWebView *webView = ...
8158 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript];
8162 <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>
8163 <tr><td colspan="4" class="doc
" id="hasAnyParameter1
"><pre>Matches any parameter of a function or an ObjC method declaration or a
8166 Does not match the 'this' parameter of a method.
8169 class X { void f(int x, int y, int z) {} };
8170 cxxMethodDecl(hasAnyParameter(hasName("y
")))
8171 matches f(int x, int y, int z) {}
8172 with hasAnyParameter(...)
8175 For ObjectiveC, given
8176 @interface I - (void) f:(int) y; @end
8178 the matcher objcMethodDecl(hasAnyParameter(hasName("y
")))
8179 matches the declaration of method f with hasParameter
8183 b = ^(int y) { printf("%d
", y) };
8185 the matcher blockDecl(hasAnyParameter(hasName("y
")))
8186 matches the declaration of the block b with hasParameter
8191 <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>
8192 <tr><td colspan="4" class="doc
" id="hasParameter1
"><pre>Matches the n'th parameter of a function or an ObjC method
8193 declaration or a block.
8196 class X { void f(int x) {} };
8197 cxxMethodDecl(hasParameter(0, hasType(varDecl())))
8199 with hasParameter(...)
8202 For ObjectiveC, given
8203 @interface I - (void) f:(int) y; @end
8205 the matcher objcMethodDecl(hasParameter(0, hasName("y
")))
8206 matches the declaration of method f with hasParameter
8211 <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>
8212 <tr><td colspan="4" class="doc
" id="hasSourceExpression1
"><pre>Matches if the cast's source expression
8213 or opaque value's source expression matches the given matcher.
8215 Example 1: matches "a string
"
8216 (matcher = castExpr(hasSourceExpression(cxxConstructExpr())))
8217 class URL { URL(string); };
8218 URL url = "a string
";
8220 Example 2: matches 'b' (matcher =
8221 opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr())))
8226 <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>
8227 <tr><td colspan="4" class="doc
" id="hasAnyDeclaration0
"><pre>Matches an OverloadExpr if any of the declarations in the set of
8228 overloads matches the given matcher.
8231 template <typename T> void foo(T);
8232 template <typename T> void bar(T);
8233 template <typename T> void baz(T t) {
8237 unresolvedLookupExpr(hasAnyDeclaration(
8238 functionTemplateDecl(hasName("foo
"))))
8239 matches foo in foo(t); but not bar in bar(t);
8243 <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>
8244 <tr><td colspan="4" class="doc
" id="innerType0
"><pre>Matches ParenType nodes where the inner type is a specific type.
8247 int (*ptr_to_array)[4];
8248 int (*ptr_to_func)(int);
8250 varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches
8251 ptr_to_func but not ptr_to_array.
8253 Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html
">ParenType</a>>
8257 <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>
8258 <tr><td colspan="4" class="doc
" id="pointee2
"><pre>Narrows PointerType (and similar) matchers to those where the
8259 pointee matches a given matcher.
8265 pointerType(pointee(isConstQualified(), isInteger()))
8266 matches "int const *b
"
8268 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>>,
8269 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>>
8273 <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>
8274 <tr><td colspan="4" class="doc
" id="hasCanonicalType0
"><pre>Matches QualTypes whose canonical type matches InnerMatcher.
8277 typedef int &int_ref;
8281 varDecl(hasType(qualType(referenceType()))))) will not match the
8282 declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does.
8286 <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>
8287 <tr><td colspan="4" class="doc
" id="hasDeclaration6
"><pre>Matches a node if the declaration associated with that node
8288 matches the given matcher.
8290 The associated declaration is:
8291 - for type nodes, the declaration of the underlying type
8292 - for CallExpr, the declaration of the callee
8293 - for MemberExpr, the declaration of the referenced member
8294 - for CXXConstructExpr, the declaration of the constructor
8295 - for CXXNewExpr, the declaration of the operator new
8296 - for ObjCIvarExpr, the declaration of the ivar
8298 For type nodes, hasDeclaration will generally match the declaration of the
8303 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8304 typedefDecl. A common use case is to match the underlying, desugared type.
8305 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8306 varDecl(hasType(hasUnqualifiedDesugaredType(
8307 recordType(hasDeclaration(decl())))))
8308 In this matcher, the decl will match the CXXRecordDecl of class X.
8310 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>>,
8311 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>>,
8312 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>>,
8313 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>>,
8314 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>>,
8315 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>>,
8316 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
8320 <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>
8321 <tr><td colspan="4" class="doc
" id="ignoringParens0
"><pre>Matches types that match InnerMatcher after any parens are stripped.
8326 varDecl(hasType(pointerType(pointee(ignoringParens(functionType())))))
8327 would match the declaration for fp.
8331 <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>
8332 <tr><td colspan="4" class="doc
" id="pointsTo1
"><pre>Overloaded to match the pointee type's declaration.
8336 <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>
8337 <tr><td colspan="4" class="doc
" id="pointsTo0
"><pre>Matches if the matched type is a pointer type and the pointee type
8338 matches the specified matcher.
8340 Example matches y->x()
8341 (matcher = cxxMemberCallExpr(on(hasType(pointsTo
8342 cxxRecordDecl(hasName("Y
")))))))
8343 class Y { public: void x(); };
8344 void z() { Y *y; y->x(); }
8348 <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>
8349 <tr><td colspan="4" class="doc
" id="references1
"><pre>Overloaded to match the referenced type's declaration.
8353 <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>
8354 <tr><td colspan="4" class="doc
" id="references0
"><pre>Matches if the matched type is a reference type and the referenced
8355 type matches the specified matcher.
8357 Example matches X &x and const X &y
8358 (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X
"))))))
8368 <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>
8369 <tr><td colspan="4" class="doc
" id="hasDeclaration5
"><pre>Matches a node if the declaration associated with that node
8370 matches the given matcher.
8372 The associated declaration is:
8373 - for type nodes, the declaration of the underlying type
8374 - for CallExpr, the declaration of the callee
8375 - for MemberExpr, the declaration of the referenced member
8376 - for CXXConstructExpr, the declaration of the constructor
8377 - for CXXNewExpr, the declaration of the operator new
8378 - for ObjCIvarExpr, the declaration of the ivar
8380 For type nodes, hasDeclaration will generally match the declaration of the
8385 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8386 typedefDecl. A common use case is to match the underlying, desugared type.
8387 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8388 varDecl(hasType(hasUnqualifiedDesugaredType(
8389 recordType(hasDeclaration(decl())))))
8390 In this matcher, the decl will match the CXXRecordDecl of class X.
8392 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>>,
8393 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>>,
8394 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>>,
8395 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>>,
8396 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>>,
8397 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>>,
8398 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
8402 <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>
8403 <tr><td colspan="4" class="doc
" id="pointee3
"><pre>Narrows PointerType (and similar) matchers to those where the
8404 pointee matches a given matcher.
8410 pointerType(pointee(isConstQualified(), isInteger()))
8411 matches "int const *b
"
8413 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>>,
8414 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>>
8418 <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>
8419 <tr><td colspan="4" class="doc
" id="hasReturnValue0
"><pre>Matches the return value expression of a return statement
8423 hasReturnValue(binaryOperator())
8424 matches 'return a + b'
8425 with binaryOperator()
8430 <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>
8431 <tr><td colspan="4" class="doc
" id="hasAnySubstatement1
"><pre>Matches compound statements where at least one substatement matches
8432 a given matcher. Also matches StmtExprs that have CompoundStmt as children.
8436 hasAnySubstatement(compoundStmt())
8437 matches '{ {}; 1+2; }'
8443 <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>
8444 <tr><td colspan="4" class="doc
" id="alignOfExpr0
"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
8449 <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>
8450 <tr><td colspan="4" class="doc
" id="forFunction0
"><pre>Matches declaration of the function the statement belongs to
8453 F& operator=(const F& o) {
8454 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; });
8457 returnStmt(forFunction(hasName("operator=
")))
8458 matches 'return *this'
8459 but does not match 'return v > 0'
8463 <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>
8464 <tr><td colspan="4" class="doc
" id="sizeOfExpr0
"><pre>Same as unaryExprOrTypeTraitExpr, but only matching
8469 <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>
8470 <tr><td colspan="4" class="doc
" id="hasReplacementType0
"><pre>Matches template type parameter substitutions that have a replacement
8471 type that matches the provided matcher.
8474 template <typename T>
8479 substTemplateTypeParmType(hasReplacementType(type())) matches int
8483 <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>
8484 <tr><td colspan="4" class="doc
" id="forEachSwitchCase0
"><pre>Matches each case or default statement belonging to the given switch
8485 statement. This matcher may produce multiple matches.
8488 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } }
8489 switchStmt(forEachSwitchCase(caseStmt().bind("c
"))).bind("s
")
8490 matches four times, with "c
" binding each of "case
1:
", "case
2:
",
8491 "case
3:
" and "case
4:
", and "s
" respectively binding "switch (
1)
",
8492 "switch (
1)
", "switch (
2)
" and "switch (
2)
".
8496 <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>
8497 <tr><td colspan="4" class="doc
" id="hasCondition4
"><pre>Matches the condition expression of an if statement, for loop,
8498 switch statement or conditional operator.
8500 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8505 <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>
8506 <tr><td colspan="4" class="doc
" id="hasInitStatement1
"><pre>Matches selection statements with initializer.
8510 if (int i = foobar(); i > 0) {}
8511 switch (int i = foobar(); i) {}
8512 for (auto& a = get_range(); auto& x : a) {}
8515 if (foobar() > 0) {}
8516 switch (foobar()) {}
8517 for (auto& x : get_range()) {}
8519 ifStmt(hasInitStatement(anything()))
8520 matches the if statement in foo but not in bar.
8521 switchStmt(hasInitStatement(anything()))
8522 matches the switch statement in foo but not in bar.
8523 cxxForRangeStmt(hasInitStatement(anything()))
8524 matches the range for statement in foo but not in bar.
8528 <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>
8529 <tr><td colspan="4" class="doc
" id="hasDeclaration4
"><pre>Matches a node if the declaration associated with that node
8530 matches the given matcher.
8532 The associated declaration is:
8533 - for type nodes, the declaration of the underlying type
8534 - for CallExpr, the declaration of the callee
8535 - for MemberExpr, the declaration of the referenced member
8536 - for CXXConstructExpr, the declaration of the constructor
8537 - for CXXNewExpr, the declaration of the operator new
8538 - for ObjCIvarExpr, the declaration of the ivar
8540 For type nodes, hasDeclaration will generally match the declaration of the
8545 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8546 typedefDecl. A common use case is to match the underlying, desugared type.
8547 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8548 varDecl(hasType(hasUnqualifiedDesugaredType(
8549 recordType(hasDeclaration(decl())))))
8550 In this matcher, the decl will match the CXXRecordDecl of class X.
8552 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>>,
8553 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>>,
8554 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>>,
8555 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>>,
8556 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>>,
8557 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>>,
8558 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
8562 <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>
8563 <tr><td colspan="4" class="doc
" id="isExpr0
"><pre>Matches a sugar TemplateArgument that refers to a certain expression.
8566 struct B { int next; };
8567 template<int(B::*next_ptr)> struct A {};
8568 A<&B::next> a;
8569 templateSpecializationType(hasAnyTemplateArgument(
8570 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next
"))))))))
8571 matches the specialization A<&B::next> with fieldDecl(...) matching
8576 <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>
8577 <tr><td colspan="4" class="doc
" id="refersToDeclaration0
"><pre>Matches a canonical TemplateArgument that refers to a certain
8581 struct B { int next; };
8582 template<int(B::*next_ptr)> struct A {};
8583 A<&B::next> a;
8584 classTemplateSpecializationDecl(hasAnyTemplateArgument(
8585 refersToDeclaration(fieldDecl(hasName("next
")))))
8586 matches the specialization A<&B::next> with fieldDecl(...) matching
8591 <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>
8592 <tr><td colspan="4" class="doc
" id="refersToIntegralType0
"><pre>Matches a TemplateArgument that refers to an integral type.
8595 template<int T> struct C {};
8597 classTemplateSpecializationDecl(
8598 hasAnyTemplateArgument(refersToIntegralType(asString("int
"))))
8599 matches the implicit instantiation of C in C<42>.
8603 <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>
8604 <tr><td colspan="4" class="doc
" id="refersToTemplate0
"><pre>Matches a TemplateArgument that refers to a certain template.
8607 template<template <typename> class S> class X {};
8608 template<typename T> class Y {};
8610 classTemplateSpecializationDecl(hasAnyTemplateArgument(
8611 refersToTemplate(templateName())))
8612 matches the specialization X<Y>
8616 <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>
8617 <tr><td colspan="4" class="doc
" id="refersToType0
"><pre>Matches a TemplateArgument that refers to a certain type.
8621 template<typename T> struct A {};
8623 classTemplateSpecializationDecl(hasAnyTemplateArgument(
8624 refersToType(class(hasName("X
")))))
8625 matches the specialization A<X>
8629 <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>
8630 <tr><td colspan="4" class="doc
" id="hasAnyTemplateArgument1
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
8631 functionDecl that have at least one TemplateArgument matching the given
8635 template<typename T> class A {};
8636 template<> class A<double> {};
8639 template<typename T> f() {};
8640 void func() { f<int>(); };
8642 classTemplateSpecializationDecl(hasAnyTemplateArgument(
8643 refersToType(asString("int
"))))
8644 matches the specialization A<int>
8646 functionDecl(hasAnyTemplateArgument(refersToType(asString("int
"))))
8647 matches the specialization f<int>
8651 <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>
8652 <tr><td colspan="4" class="doc
" id="hasDeclaration3
"><pre>Matches a node if the declaration associated with that node
8653 matches the given matcher.
8655 The associated declaration is:
8656 - for type nodes, the declaration of the underlying type
8657 - for CallExpr, the declaration of the callee
8658 - for MemberExpr, the declaration of the referenced member
8659 - for CXXConstructExpr, the declaration of the constructor
8660 - for CXXNewExpr, the declaration of the operator new
8661 - for ObjCIvarExpr, the declaration of the ivar
8663 For type nodes, hasDeclaration will generally match the declaration of the
8668 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8669 typedefDecl. A common use case is to match the underlying, desugared type.
8670 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8671 varDecl(hasType(hasUnqualifiedDesugaredType(
8672 recordType(hasDeclaration(decl())))))
8673 In this matcher, the decl will match the CXXRecordDecl of class X.
8675 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>>,
8676 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>>,
8677 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>>,
8678 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>>,
8679 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>>,
8680 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>>,
8681 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
8685 <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>
8686 <tr><td colspan="4" class="doc
" id="hasTemplateArgument1
"><pre>Matches classTemplateSpecializations, templateSpecializationType and
8687 functionDecl where the n'th TemplateArgument matches the given InnerMatcher.
8690 template<typename T, typename U> class A {};
8691 A<bool, int> b;
8692 A<int, bool> c;
8694 template<typename T> void f() {}
8695 void func() { f<int>(); };
8696 classTemplateSpecializationDecl(hasTemplateArgument(
8697 1, refersToType(asString("int
"))))
8698 matches the specialization A<bool, int>
8700 functionDecl(hasTemplateArgument(0, refersToType(asString("int
"))))
8701 matches the specialization f<int>
8705 <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>
8706 <tr><td colspan="4" class="doc
" id="hasDeclaration2
"><pre>Matches a node if the declaration associated with that node
8707 matches the given matcher.
8709 The associated declaration is:
8710 - for type nodes, the declaration of the underlying type
8711 - for CallExpr, the declaration of the callee
8712 - for MemberExpr, the declaration of the referenced member
8713 - for CXXConstructExpr, the declaration of the constructor
8714 - for CXXNewExpr, the declaration of the operator new
8715 - for ObjCIvarExpr, the declaration of the ivar
8717 For type nodes, hasDeclaration will generally match the declaration of the
8722 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8723 typedefDecl. A common use case is to match the underlying, desugared type.
8724 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8725 varDecl(hasType(hasUnqualifiedDesugaredType(
8726 recordType(hasDeclaration(decl())))))
8727 In this matcher, the decl will match the CXXRecordDecl of class X.
8729 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>>,
8730 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>>,
8731 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>>,
8732 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>>,
8733 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>>,
8734 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>>,
8735 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
8739 <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>
8740 <tr><td colspan="4" class="doc
" id="loc0
"><pre>Matches TypeLocs for which the given inner
8741 QualType-matcher matches.
8745 <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>
8746 <tr><td colspan="4" class="doc
" id="hasType2
"><pre>Matches if the expression's or declaration's type matches a type
8749 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
8750 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
8751 and U (matcher = typedefDecl(hasType(asString("int
")))
8752 and friend class X (matcher = friendDecl(hasType("X
"))
8754 void y(X &x) { x; X z; }
8756 class Y { friend class X; };
8760 <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>
8761 <tr><td colspan="4" class="doc
" id="hasDeclaration1
"><pre>Matches a node if the declaration associated with that node
8762 matches the given matcher.
8764 The associated declaration is:
8765 - for type nodes, the declaration of the underlying type
8766 - for CallExpr, the declaration of the callee
8767 - for MemberExpr, the declaration of the referenced member
8768 - for CXXConstructExpr, the declaration of the constructor
8769 - for CXXNewExpr, the declaration of the operator new
8770 - for ObjCIvarExpr, the declaration of the ivar
8772 For type nodes, hasDeclaration will generally match the declaration of the
8777 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8778 typedefDecl. A common use case is to match the underlying, desugared type.
8779 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8780 varDecl(hasType(hasUnqualifiedDesugaredType(
8781 recordType(hasDeclaration(decl())))))
8782 In this matcher, the decl will match the CXXRecordDecl of class X.
8784 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>>,
8785 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>>,
8786 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>>,
8787 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>>,
8788 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>>,
8789 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>>,
8790 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
8794 <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>
8795 <tr><td colspan="4" class="doc
" id="hasUnqualifiedDesugaredType0
"><pre>Matches if the matched type matches the unqualified desugared
8796 type of the matched node.
8801 The matcher type(hasUnqualifiedDesugaredType(recordType())) matches
8806 <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>
8807 <tr><td colspan="4" class="doc
" id="hasArgumentOfType0
"><pre>Matches unary expressions that have a specific type of argument.
8810 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c);
8811 unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int
"))
8812 matches sizeof(a) and alignof(c)
8816 <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>
8817 <tr><td colspan="4" class="doc
" id="hasUnaryOperand0
"><pre>Matches if the operand of a unary operator matches.
8819 Example matches true (matcher = hasUnaryOperand(
8820 cxxBoolLiteral(equals(true))))
8825 <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>
8826 <tr><td colspan="4" class="doc
" id="hasObjectExpression1
"><pre>Matches a member expression where the object expression is matched by a
8827 given matcher. Implicit object expressions are included; that is, it matches
8828 use of implicit `this`.
8833 int f(X x) { x.m; return m; }
8835 memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X
")))))
8836 matches `x.m`, but not `m`; however,
8837 memberExpr(hasObjectExpression(hasType(pointsTo(
8838 cxxRecordDecl(hasName("X
"))))))
8839 matches `m` (aka. `this->m`), but not `x.m`.
8843 <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>
8844 <tr><td colspan="4" class="doc
" id="hasDeclaration0
"><pre>Matches a node if the declaration associated with that node
8845 matches the given matcher.
8847 The associated declaration is:
8848 - for type nodes, the declaration of the underlying type
8849 - for CallExpr, the declaration of the callee
8850 - for MemberExpr, the declaration of the referenced member
8851 - for CXXConstructExpr, the declaration of the constructor
8852 - for CXXNewExpr, the declaration of the operator new
8853 - for ObjCIvarExpr, the declaration of the ivar
8855 For type nodes, hasDeclaration will generally match the declaration of the
8860 in varDecl(hasType(hasDeclaration(decl()))) the decl will match the
8861 typedefDecl. A common use case is to match the underlying, desugared type.
8862 This can be achieved by using the hasUnqualifiedDesugaredType matcher:
8863 varDecl(hasType(hasUnqualifiedDesugaredType(
8864 recordType(hasDeclaration(decl())))))
8865 In this matcher, the decl will match the CXXRecordDecl of class X.
8867 Usable as: Matcher<<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>>,
8868 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>>,
8869 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>>,
8870 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>>,
8871 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>>,
8872 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>>,
8873 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html
">UnresolvedUsingType</a>>
8877 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html
">UsingDecl</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>
8878 <tr><td colspan="4" class="doc
" id="hasAnyUsingShadowDecl0
"><pre>Matches any using shadow declaration.
8881 namespace X { void b(); }
8883 usingDecl(hasAnyUsingShadowDecl(hasName("b
"))))
8884 matches using X::b </pre></td></tr>
8887 <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>
8888 <tr><td colspan="4" class="doc
" id="hasTargetDecl0
"><pre>Matches a using shadow declaration where the target declaration is
8889 matched by the given matcher.
8892 namespace X { int a; void b(); }
8895 usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl())))
8896 matches using X::b but not using X::a </pre></td></tr>
8899 <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html
">ValueDecl</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>
8900 <tr><td colspan="4" class="doc
" id="hasType6
"><pre>Overloaded to match the declaration of the expression's or value
8903 In case of a value declaration (for example a variable declaration),
8904 this resolves one layer of indirection. For example, in the value
8905 declaration "X x;
", cxxRecordDecl(hasName("X
")) matches the declaration of
8906 X, while varDecl(hasType(cxxRecordDecl(hasName("X
")))) matches the
8909 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
8910 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
8911 and friend class X (matcher = friendDecl(hasType("X
"))
8913 void y(X &x) { x; X z; }
8914 class Y { friend class X; };
8916 Example matches class Derived
8917 (matcher = cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base
"))))))
8919 class Derived : Base {};
8921 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>>,
8922 Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html
">CXXBaseSpecifier</a>>
8926 <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>
8927 <tr><td colspan="4" class="doc
" id="hasType3
"><pre>Matches if the expression's or declaration's type matches a type
8930 Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X
")))))
8931 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X
")))))
8932 and U (matcher = typedefDecl(hasType(asString("int
")))
8933 and friend class X (matcher = friendDecl(hasType("X
"))
8935 void y(X &x) { x; X z; }
8937 class Y { friend class X; };
8941 <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>
8942 <tr><td colspan="4" class="doc
" id="hasInitializer0
"><pre>Matches a variable declaration that has an initializer expression
8943 that matches the given matcher.
8945 Example matches x (matcher = varDecl(hasInitializer(callExpr())))
8946 bool y() { return true; }
8951 <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>
8952 <tr><td colspan="4" class="doc
" id="hasSizeExpr0
"><pre>Matches VariableArrayType nodes that have a specific size
8959 variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to(
8960 varDecl(hasName("b
")))))))
8965 <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>
8966 <tr><td colspan="4" class="doc
" id="hasBody2
"><pre></pre></td></tr>
8969 <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>
8970 <tr><td colspan="4" class="doc
" id="hasCondition2
"><pre>Matches the condition expression of an if statement, for loop,
8971 switch statement or conditional operator.
8973 Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
8977 <!--END_TRAVERSAL_MATCHERS -->