Benjamin Kramer | 7d0cc23 | 2015-11-20 07:57:46 +0000 | [diff] [blame] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
| 3 | <html> |
| 4 | <head> |
| 5 | <title>AST Matcher Reference</title> |
| 6 | <link type="text/css" rel="stylesheet" href="../menu.css" /> |
| 7 | <link type="text/css" rel="stylesheet" href="../content.css" /> |
| 8 | <style type="text/css"> |
| 9 | td { |
| 10 | padding: .33em; |
| 11 | } |
| 12 | td.doc { |
| 13 | display: none; |
| 14 | border-bottom: 1px solid black; |
| 15 | } |
| 16 | td.name:hover { |
| 17 | color: blue; |
| 18 | cursor: pointer; |
| 19 | } |
| 20 | </style> |
| 21 | <script type="text/javascript"> |
| 22 | function toggle(id) { |
| 23 | if (!id) return; |
| 24 | row = document.getElementById(id); |
| 25 | if (row.style.display != 'table-cell') |
| 26 | row.style.display = 'table-cell'; |
| 27 | else |
| 28 | row.style.display = 'none'; |
| 29 | } |
| 30 | </script> |
| 31 | </head> |
| 32 | <body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))"> |
| 33 | |
| 34 | <!--#include virtual="../menu.html.incl"--> |
| 35 | |
| 36 | <div id="content"> |
| 37 | |
| 38 | <h1>AST Matcher Reference</h1> |
| 39 | |
| 40 | <p>This document shows all currently implemented matchers. The matchers are grouped |
| 41 | by category and node type they match. You can click on matcher names to show the |
| 42 | matcher's source documentation.</p> |
| 43 | |
| 44 | <p>There are three different basic categories of matchers: |
| 45 | <ul> |
| 46 | <li><a href="#decl-matchers">Node Matchers:</a> Matchers that match a specific type of AST node.</li> |
| 47 | <li><a href="#narrowing-matchers">Narrowing Matchers:</a> Matchers that match attributes on AST nodes.</li> |
| 48 | <li><a href="#traversal-matchers">Traversal Matchers:</a> Matchers that allow traversal between AST nodes.</li> |
| 49 | </ul> |
| 50 | </p> |
| 51 | |
| 52 | <p>Within each category the matchers are ordered by node type they match on. |
| 53 | Note that if a matcher can match multiple node types, it will it will appear |
| 54 | multiple times. This means that by searching for Matcher<Stmt> you can |
| 55 | find all matchers that can be used to match on Stmt nodes.</p> |
| 56 | |
| 57 | <p>The exception to that rule are matchers that can match on any node. Those |
| 58 | are marked with a * and are listed in the beginning of each category.</p> |
| 59 | |
| 60 | <p>Note that the categorization of matchers is a great help when you combine |
| 61 | them into matcher expressions. You will usually want to form matcher expressions |
| 62 | that read like english sentences by alternating between node matchers and |
| 63 | narrowing or traversal matchers, like this: |
| 64 | <pre> |
| 65 | recordDecl(hasDescendant( |
| 66 | ifStmt(hasTrueExpression( |
| 67 | expr(hasDescendant( |
| 68 | ifStmt())))))) |
| 69 | </pre> |
| 70 | </p> |
| 71 | |
| 72 | <!-- ======================================================================= --> |
| 73 | <h2 id="decl-matchers">Node Matchers</h2> |
| 74 | <!-- ======================================================================= --> |
| 75 | |
| 76 | <p>Node matchers are at the core of matcher expressions - they specify the type |
| 77 | of node that is expected. Every match expression starts with a node matcher, |
| 78 | which can then be further refined with a narrowing or traversal matcher. All |
| 79 | traversal matchers take node matchers as their arguments.</p> |
| 80 | |
| 81 | <p>For convenience, all node matchers take an arbitrary number of arguments |
| 82 | and implicitly act as allOf matchers.</p> |
| 83 | |
| 84 | <p>Node matchers are the only matchers that support the bind("id") call to |
| 85 | bind the matched node to the given string, to be later retrieved from the |
| 86 | match callback.</p> |
| 87 | |
| 88 | <p>It is important to remember that the arguments to node matchers are |
| 89 | predicates on the same node, just with additional information about the type. |
| 90 | This is often useful to make matcher expression more readable by inlining bind |
| 91 | calls into redundant node matchers inside another node matcher: |
| 92 | <pre> |
| 93 | // This binds the CXXRecordDecl to "id", as the decl() matcher will stay on |
| 94 | // the same node. |
| 95 | recordDecl(decl().bind("id"), hasName("::MyClass")) |
| 96 | </pre> |
| 97 | </p> |
| 98 | |
| 99 | <table> |
| 100 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 101 | <!-- START_DECL_MATCHERS --> |
| 102 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 103 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 104 | <tr><td colspan="4" class="doc" id="cxxCtorInitializer0"><pre>Matches constructor initializers. |
| 105 | |
| 106 | Examples matches i(42). |
| 107 | class C { |
| 108 | C() : i(42) {} |
| 109 | int i; |
| 110 | }; |
| 111 | </pre></td></tr> |
| 112 | |
| 113 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 114 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 115 | <tr><td colspan="4" class="doc" id="accessSpecDecl0"><pre>Matches C++ access specifier declarations. |
| 116 | |
| 117 | Given |
| 118 | class C { |
| 119 | public: |
| 120 | int a; |
| 121 | }; |
| 122 | accessSpecDecl() |
| 123 | matches 'public:' |
| 124 | </pre></td></tr> |
| 125 | |
| 126 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 127 | <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> |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 128 | <tr><td colspan="4" class="doc" id="blockDecl0"><pre>Matches block declarations. |
| 129 | |
| 130 | Example matches the declaration of the nameless block printing an input |
| 131 | integer. |
| 132 | |
| 133 | myFunc(^(int p) { |
| 134 | printf("%d", p); |
| 135 | }) |
| 136 | </pre></td></tr> |
| 137 | |
| 138 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 139 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 140 | <tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations. |
| 141 | |
| 142 | Example matches Z |
| 143 | template<class T> class Z {}; |
| 144 | </pre></td></tr> |
| 145 | |
| 146 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 147 | <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> |
Stephen Kelly | 9b8fa52 | 2018-10-09 08:24:11 +0000 | [diff] [blame] | 148 | <tr><td colspan="4" class="doc" id="classTemplatePartialSpecializationDecl0"><pre>Matches C++ class template partial specializations. |
| 149 | |
| 150 | Given |
| 151 | template<class T1, class T2, int I> |
| 152 | class A {}; |
| 153 | |
| 154 | template<class T, int I> |
| 155 | class A<T, T*, I> {}; |
| 156 | |
| 157 | template<> |
| 158 | class A<int, int, 1> {}; |
| 159 | classTemplatePartialSpecializationDecl() |
| 160 | matches the specialization A<T,T*,I> but not A<int,int,1> |
| 161 | </pre></td></tr> |
| 162 | |
| 163 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 164 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 165 | <tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations. |
| 166 | |
| 167 | Given |
| 168 | template<typename T> class A {}; |
| 169 | template<> class A<double> {}; |
| 170 | A<int> a; |
| 171 | classTemplateSpecializationDecl() |
| 172 | matches the specializations A<int> and A<double> |
| 173 | </pre></td></tr> |
| 174 | |
| 175 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 176 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 177 | <tr><td colspan="4" class="doc" id="cxxConstructorDecl0"><pre>Matches C++ constructor declarations. |
| 178 | |
| 179 | Example matches Foo::Foo() and Foo::Foo(int) |
| 180 | class Foo { |
| 181 | public: |
| 182 | Foo(); |
| 183 | Foo(int); |
| 184 | int DoSomething(); |
| 185 | }; |
| 186 | </pre></td></tr> |
| 187 | |
| 188 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 189 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 190 | <tr><td colspan="4" class="doc" id="cxxConversionDecl0"><pre>Matches conversion operator declarations. |
| 191 | |
| 192 | Example matches the operator. |
| 193 | class X { operator int() const; }; |
| 194 | </pre></td></tr> |
| 195 | |
| 196 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 197 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 198 | <tr><td colspan="4" class="doc" id="cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations. |
| 199 | |
| 200 | Example matches Foo::~Foo() |
| 201 | class Foo { |
| 202 | public: |
| 203 | virtual ~Foo(); |
| 204 | }; |
| 205 | </pre></td></tr> |
| 206 | |
| 207 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 208 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 209 | <tr><td colspan="4" class="doc" id="cxxMethodDecl0"><pre>Matches method declarations. |
| 210 | |
| 211 | Example matches y |
| 212 | class X { void y(); }; |
| 213 | </pre></td></tr> |
| 214 | |
| 215 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 216 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 217 | <tr><td colspan="4" class="doc" id="cxxRecordDecl0"><pre>Matches C++ class declarations. |
| 218 | |
| 219 | Example matches X, Z |
| 220 | class X; |
| 221 | template<class T> class Z {}; |
| 222 | </pre></td></tr> |
| 223 | |
| 224 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 225 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 226 | <tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations. |
| 227 | |
| 228 | Examples matches X, C, and the friend declaration inside C; |
| 229 | void X(); |
| 230 | class C { |
| 231 | friend X; |
| 232 | }; |
| 233 | </pre></td></tr> |
| 234 | |
| 235 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 236 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 237 | <tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function |
| 238 | and non-type template parameter declarations). |
| 239 | |
| 240 | Given |
| 241 | class X { int y; }; |
| 242 | declaratorDecl() |
| 243 | matches int y. |
| 244 | </pre></td></tr> |
| 245 | |
| 246 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 247 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 248 | <tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants. |
| 249 | |
| 250 | Example matches A, B, C |
| 251 | enum X { |
| 252 | A, B, C |
| 253 | }; |
| 254 | </pre></td></tr> |
| 255 | |
| 256 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 257 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 258 | <tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations. |
| 259 | |
| 260 | Example matches X |
| 261 | enum X { |
| 262 | A, B, C |
| 263 | }; |
| 264 | </pre></td></tr> |
| 265 | |
| 266 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 267 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 268 | <tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations. |
| 269 | |
| 270 | Given |
| 271 | class X { int m; }; |
| 272 | fieldDecl() |
| 273 | matches 'm'. |
| 274 | </pre></td></tr> |
| 275 | |
| 276 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 277 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 278 | <tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations. |
| 279 | |
| 280 | Given |
| 281 | class X { friend void foo(); }; |
| 282 | friendDecl() |
| 283 | matches 'friend void foo()'. |
| 284 | </pre></td></tr> |
| 285 | |
| 286 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 287 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 288 | <tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations. |
| 289 | |
| 290 | Example matches f |
| 291 | void f(); |
| 292 | </pre></td></tr> |
| 293 | |
| 294 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 295 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 296 | <tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations. |
| 297 | |
| 298 | Example matches f |
| 299 | template<class T> void f(T t) {} |
| 300 | </pre></td></tr> |
| 301 | |
| 302 | |
Gabor Marton | 7df342a | 2018-12-17 12:42:12 +0000 | [diff] [blame] | 303 | <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> |
| 304 | <tr><td colspan="4" class="doc" id="indirectFieldDecl0"><pre>Matches indirect field declarations. |
| 305 | |
| 306 | Given |
| 307 | struct X { struct { int a; }; }; |
| 308 | indirectFieldDecl() |
| 309 | matches 'a'. |
| 310 | </pre></td></tr> |
| 311 | |
| 312 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 313 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 314 | <tr><td colspan="4" class="doc" id="labelDecl0"><pre>Matches a declaration of label. |
| 315 | |
| 316 | Given |
| 317 | goto FOO; |
| 318 | FOO: bar(); |
| 319 | labelDecl() |
| 320 | matches 'FOO:' |
| 321 | </pre></td></tr> |
| 322 | |
| 323 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 324 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 325 | <tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification. |
| 326 | |
| 327 | Given |
| 328 | extern "C" {} |
| 329 | linkageSpecDecl() |
| 330 | matches "extern "C" {}" |
| 331 | </pre></td></tr> |
| 332 | |
| 333 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 334 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 335 | <tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name. |
| 336 | |
| 337 | Example matches X, S, the anonymous union type, i, and U; |
| 338 | typedef int X; |
| 339 | struct S { |
| 340 | union { |
| 341 | int i; |
| 342 | } U; |
| 343 | }; |
| 344 | </pre></td></tr> |
| 345 | |
| 346 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 347 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 348 | <tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias. |
| 349 | |
| 350 | Given |
| 351 | namespace test {} |
| 352 | namespace alias = ::test; |
| 353 | namespaceAliasDecl() |
| 354 | matches "namespace alias" but not "namespace test" |
| 355 | </pre></td></tr> |
| 356 | |
| 357 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 358 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 359 | <tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace. |
| 360 | |
| 361 | Given |
| 362 | namespace {} |
| 363 | namespace test {} |
| 364 | namespaceDecl() |
| 365 | matches "namespace {}" and "namespace test {}" |
| 366 | </pre></td></tr> |
| 367 | |
| 368 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 369 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 370 | <tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations. |
| 371 | |
| 372 | Given |
| 373 | template <typename T, int N> struct C {}; |
| 374 | nonTypeTemplateParmDecl() |
| 375 | matches 'N', but not 'T'. |
| 376 | </pre></td></tr> |
| 377 | |
| 378 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 379 | <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> |
Aaron Ballman | 9fd6ee6 | 2017-03-15 20:14:25 +0000 | [diff] [blame] | 380 | <tr><td colspan="4" class="doc" id="objcCategoryDecl0"><pre>Matches Objective-C category declarations. |
| 381 | |
| 382 | Example matches Foo (Additions) |
| 383 | @interface Foo (Additions) |
| 384 | @end |
| 385 | </pre></td></tr> |
| 386 | |
| 387 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 388 | <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> |
Dave Lee | 55540a0 | 2017-10-26 15:53:37 +0000 | [diff] [blame] | 389 | <tr><td colspan="4" class="doc" id="objcCategoryImplDecl0"><pre>Matches Objective-C category definitions. |
| 390 | |
| 391 | Example matches Foo (Additions) |
| 392 | @implementation Foo (Additions) |
| 393 | @end |
| 394 | </pre></td></tr> |
| 395 | |
| 396 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 397 | <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> |
Dave Lee | e6d362c | 2017-09-10 21:00:15 +0000 | [diff] [blame] | 398 | <tr><td colspan="4" class="doc" id="objcImplementationDecl0"><pre>Matches Objective-C implementation declarations. |
| 399 | |
| 400 | Example matches Foo |
| 401 | @implementation Foo |
| 402 | @end |
| 403 | </pre></td></tr> |
| 404 | |
| 405 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 406 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 407 | <tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations. |
| 408 | |
| 409 | Example matches Foo |
| 410 | @interface Foo |
| 411 | @end |
| 412 | </pre></td></tr> |
| 413 | |
| 414 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 415 | <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> |
Aaron Ballman | 9fd6ee6 | 2017-03-15 20:14:25 +0000 | [diff] [blame] | 416 | <tr><td colspan="4" class="doc" id="objcIvarDecl0"><pre>Matches Objective-C instance variable declarations. |
| 417 | |
| 418 | Example matches _enabled |
| 419 | @implementation Foo { |
| 420 | BOOL _enabled; |
| 421 | } |
| 422 | @end |
| 423 | </pre></td></tr> |
| 424 | |
| 425 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 426 | <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> |
Aaron Ballman | 9fd6ee6 | 2017-03-15 20:14:25 +0000 | [diff] [blame] | 427 | <tr><td colspan="4" class="doc" id="objcMethodDecl0"><pre>Matches Objective-C method declarations. |
| 428 | |
| 429 | Example matches both declaration and definition of -[Foo method] |
| 430 | @interface Foo |
| 431 | - (void)method; |
| 432 | @end |
| 433 | |
| 434 | @implementation Foo |
| 435 | - (void)method {} |
| 436 | @end |
| 437 | </pre></td></tr> |
| 438 | |
| 439 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 440 | <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> |
Aaron Ballman | 9fd6ee6 | 2017-03-15 20:14:25 +0000 | [diff] [blame] | 441 | <tr><td colspan="4" class="doc" id="objcPropertyDecl0"><pre>Matches Objective-C property declarations. |
| 442 | |
| 443 | Example matches enabled |
| 444 | @interface Foo |
| 445 | @property BOOL enabled; |
| 446 | @end |
| 447 | </pre></td></tr> |
| 448 | |
| 449 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 450 | <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> |
Aaron Ballman | 9fd6ee6 | 2017-03-15 20:14:25 +0000 | [diff] [blame] | 451 | <tr><td colspan="4" class="doc" id="objcProtocolDecl0"><pre>Matches Objective-C protocol declarations. |
| 452 | |
| 453 | Example matches FooDelegate |
| 454 | @protocol FooDelegate |
| 455 | @end |
| 456 | </pre></td></tr> |
| 457 | |
| 458 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 459 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 460 | <tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations. |
| 461 | |
| 462 | Given |
| 463 | void f(int x); |
| 464 | parmVarDecl() |
| 465 | matches int x. |
| 466 | </pre></td></tr> |
| 467 | |
| 468 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 469 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 470 | <tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations. |
| 471 | |
| 472 | Example matches X, Z, U, and S |
| 473 | class X; |
| 474 | template<class T> class Z {}; |
| 475 | struct S {}; |
| 476 | union U {}; |
| 477 | </pre></td></tr> |
| 478 | |
| 479 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 480 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 481 | <tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration. |
| 482 | |
| 483 | Example: |
| 484 | staticAssertExpr() |
| 485 | matches |
| 486 | static_assert(sizeof(S) == sizeof(int)) |
| 487 | in |
| 488 | struct S { |
| 489 | int x; |
| 490 | }; |
| 491 | static_assert(sizeof(S) == sizeof(int)); |
| 492 | </pre></td></tr> |
| 493 | |
| 494 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 495 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 496 | <tr><td colspan="4" class="doc" id="templateTypeParmDecl0"><pre>Matches template type parameter declarations. |
| 497 | |
| 498 | Given |
| 499 | template <typename T, int N> struct C {}; |
| 500 | templateTypeParmDecl() |
| 501 | matches 'T', but not 'N'. |
| 502 | </pre></td></tr> |
| 503 | |
| 504 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 505 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 506 | <tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context. |
| 507 | |
| 508 | Given |
| 509 | int X; |
| 510 | namespace NS { |
| 511 | int Y; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 512 | } // namespace NS |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 513 | decl(hasDeclContext(translationUnitDecl())) |
| 514 | matches "int X", but not "int Y". |
| 515 | </pre></td></tr> |
| 516 | |
| 517 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 518 | <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> |
Aaron Ballman | 66eb58a | 2016-04-14 16:05:45 +0000 | [diff] [blame] | 519 | <tr><td colspan="4" class="doc" id="typeAliasDecl0"><pre>Matches type alias declarations. |
| 520 | |
| 521 | Given |
| 522 | typedef int X; |
Samuel Benzaquen | a4076ea | 2016-05-04 20:45:00 +0000 | [diff] [blame] | 523 | using Y = int; |
Aaron Ballman | 66eb58a | 2016-04-14 16:05:45 +0000 | [diff] [blame] | 524 | typeAliasDecl() |
| 525 | matches "using Y = int", but not "typedef int X" |
| 526 | </pre></td></tr> |
| 527 | |
| 528 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 529 | <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> |
Eric Liu | 285f804 | 2017-03-28 12:56:47 +0000 | [diff] [blame] | 530 | <tr><td colspan="4" class="doc" id="typeAliasTemplateDecl0"><pre>Matches type alias template declarations. |
| 531 | |
| 532 | typeAliasTemplateDecl() matches |
| 533 | template <typename T> |
| 534 | using Y = X<T>; |
| 535 | </pre></td></tr> |
| 536 | |
| 537 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 538 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 539 | <tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations. |
| 540 | |
| 541 | Given |
| 542 | typedef int X; |
Samuel Benzaquen | a4076ea | 2016-05-04 20:45:00 +0000 | [diff] [blame] | 543 | using Y = int; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 544 | typedefDecl() |
Aaron Ballman | 66eb58a | 2016-04-14 16:05:45 +0000 | [diff] [blame] | 545 | matches "typedef int X", but not "using Y = int" |
| 546 | </pre></td></tr> |
| 547 | |
| 548 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 549 | <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> |
Aaron Ballman | 66eb58a | 2016-04-14 16:05:45 +0000 | [diff] [blame] | 550 | <tr><td colspan="4" class="doc" id="typedefNameDecl0"><pre>Matches typedef name declarations. |
| 551 | |
| 552 | Given |
| 553 | typedef int X; |
Samuel Benzaquen | a4076ea | 2016-05-04 20:45:00 +0000 | [diff] [blame] | 554 | using Y = int; |
Aaron Ballman | 66eb58a | 2016-04-14 16:05:45 +0000 | [diff] [blame] | 555 | typedefNameDecl() |
| 556 | matches "typedef int X" and "using Y = int" |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 557 | </pre></td></tr> |
| 558 | |
| 559 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 560 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 561 | <tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the |
| 562 | typename. |
| 563 | |
| 564 | Given |
| 565 | template <typename T> |
| 566 | struct Base { typedef T Foo; }; |
| 567 | |
| 568 | template<typename T> |
| 569 | struct S : private Base<T> { |
| 570 | using typename Base<T>::Foo; |
| 571 | }; |
| 572 | unresolvedUsingTypenameDecl() |
| 573 | matches using Base<T>::Foo </pre></td></tr> |
| 574 | |
| 575 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 576 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 577 | <tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations. |
| 578 | |
| 579 | Given |
| 580 | template<typename X> |
| 581 | class C : private X { |
| 582 | using X::x; |
| 583 | }; |
| 584 | unresolvedUsingValueDecl() |
| 585 | matches using X::x </pre></td></tr> |
| 586 | |
| 587 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 588 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 589 | <tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations. |
| 590 | |
| 591 | Given |
| 592 | namespace X { int x; } |
| 593 | using X::x; |
| 594 | usingDecl() |
| 595 | matches using X::x </pre></td></tr> |
| 596 | |
| 597 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 598 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 599 | <tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations. |
| 600 | |
| 601 | Given |
| 602 | namespace X { int x; } |
| 603 | using namespace X; |
| 604 | usingDirectiveDecl() |
| 605 | matches using namespace X </pre></td></tr> |
| 606 | |
| 607 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 608 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 609 | <tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration. |
| 610 | |
| 611 | Example matches A, B, C and F |
| 612 | enum X { A, B, C }; |
| 613 | void F(); |
| 614 | </pre></td></tr> |
| 615 | |
| 616 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 617 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 618 | <tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations. |
| 619 | |
| 620 | Note: this does not match declarations of member variables, which are |
| 621 | "field" declarations in Clang parlance. |
| 622 | |
| 623 | Example matches a |
| 624 | int a; |
| 625 | </pre></td></tr> |
| 626 | |
| 627 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 628 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 629 | <tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. |
| 630 | </pre></td></tr> |
| 631 | |
| 632 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 633 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 634 | <tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers. |
| 635 | |
| 636 | Given |
| 637 | namespace ns { |
| 638 | struct A { static void f(); }; |
| 639 | void A::f() {} |
| 640 | void g() { A::f(); } |
| 641 | } |
| 642 | ns::A a; |
| 643 | nestedNameSpecifier() |
| 644 | matches "ns::" and both "A::" |
| 645 | </pre></td></tr> |
| 646 | |
| 647 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 648 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 649 | <tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST. |
| 650 | </pre></td></tr> |
| 651 | |
| 652 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 653 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 654 | <tr><td colspan="4" class="doc" id="addrLabelExpr0"><pre>Matches address of label statements (GNU extension). |
| 655 | |
| 656 | Given |
| 657 | FOO: bar(); |
| 658 | void *ptr = &&FOO; |
| 659 | goto *bar; |
| 660 | addrLabelExpr() |
| 661 | matches '&&FOO' |
| 662 | </pre></td></tr> |
| 663 | |
| 664 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 665 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 666 | <tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. |
| 667 | |
| 668 | Given |
| 669 | int i = a[1]; |
| 670 | arraySubscriptExpr() |
| 671 | matches "a[1]" |
| 672 | </pre></td></tr> |
| 673 | |
| 674 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 675 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 676 | <tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements. |
| 677 | |
| 678 | int i = 100; |
| 679 | __asm("mov al, 2"); |
| 680 | asmStmt() |
| 681 | matches '__asm("mov al, 2")' |
| 682 | </pre></td></tr> |
| 683 | |
| 684 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 685 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 686 | <tr><td colspan="4" class="doc" id="atomicExpr0"><pre>Matches atomic builtins. |
| 687 | Example matches __atomic_load_n(ptr, 1) |
| 688 | void foo() { int *ptr; __atomic_load_n(ptr, 1); } |
| 689 | </pre></td></tr> |
| 690 | |
| 691 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 692 | <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> |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 693 | <tr><td colspan="4" class="doc" id="autoreleasePoolStmt0"><pre>Matches an Objective-C autorelease pool statement. |
| 694 | |
| 695 | Given |
| 696 | @autoreleasepool { |
| 697 | int x = 0; |
| 698 | } |
| 699 | autoreleasePoolStmt(stmt()) matches the declaration of "x" |
| 700 | inside the autorelease pool. |
| 701 | </pre></td></tr> |
| 702 | |
| 703 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 704 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 705 | <tr><td colspan="4" class="doc" id="binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension). |
| 706 | |
| 707 | Example matches a ?: b |
| 708 | (a ?: b) + 42; |
| 709 | </pre></td></tr> |
| 710 | |
| 711 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 712 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 713 | <tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. |
| 714 | |
| 715 | Example matches a || b |
| 716 | !(a || b) |
| 717 | </pre></td></tr> |
| 718 | |
| 719 | |
Stephane Moore | 3897b2d | 2018-12-13 03:35:10 +0000 | [diff] [blame] | 720 | <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> |
Hyrum Wright | 2cd40c0 | 2019-01-07 14:14:36 +0000 | [diff] [blame] | 721 | <tr><td colspan="4" class="doc" id="blockExpr0"><pre>Matches a reference to a block. |
Stephane Moore | 3897b2d | 2018-12-13 03:35:10 +0000 | [diff] [blame] | 722 | |
| 723 | Example: matches "^{}": |
| 724 | void f() { ^{}(); } |
| 725 | </pre></td></tr> |
| 726 | |
| 727 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 728 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 729 | <tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. |
| 730 | |
| 731 | Given |
| 732 | while (true) { break; } |
| 733 | breakStmt() |
| 734 | matches 'break' |
| 735 | </pre></td></tr> |
| 736 | |
| 737 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 738 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 739 | <tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. |
| 740 | |
Artem Dergachev | ded92a9 | 2016-11-11 22:34:53 +0000 | [diff] [blame] | 741 | Example: Matches (int) 2.2f in |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 742 | int i = (int) 2.2f; |
| 743 | </pre></td></tr> |
| 744 | |
| 745 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 746 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 747 | <tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. |
| 748 | |
| 749 | Example matches x.y() and y() |
| 750 | X x; |
| 751 | x.y(); |
| 752 | y(); |
| 753 | </pre></td></tr> |
| 754 | |
| 755 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 756 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 757 | <tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements. |
| 758 | |
| 759 | Given |
| 760 | switch(a) { case 42: break; default: break; } |
| 761 | caseStmt() |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 762 | matches 'case 42:'. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 763 | </pre></td></tr> |
| 764 | |
| 765 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 766 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 767 | <tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. |
| 768 | |
| 769 | Example: castExpr() matches each of the following: |
| 770 | (int) 3; |
| 771 | const_cast<Expr *>(SubExpr); |
| 772 | char c = 0; |
| 773 | but does not match |
| 774 | int i = (0); |
| 775 | int k = 0; |
| 776 | </pre></td></tr> |
| 777 | |
| 778 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 779 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 780 | <tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). |
| 781 | |
| 782 | Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), |
| 783 | though. |
| 784 | |
| 785 | Example matches 'a', L'a' |
Etienne Bergeron | 3588be7 | 2016-05-12 04:20:04 +0000 | [diff] [blame] | 786 | char ch = 'a'; |
| 787 | wchar_t chw = L'a'; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 788 | </pre></td></tr> |
| 789 | |
| 790 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 791 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 792 | <tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals |
| 793 | |
| 794 | Example match: {1}, (1, 2) |
Etienne Bergeron | 3588be7 | 2016-05-12 04:20:04 +0000 | [diff] [blame] | 795 | int array[4] = {1}; |
| 796 | vector int myvec = (vector int)(1, 2); |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 797 | </pre></td></tr> |
| 798 | |
| 799 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 800 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 801 | <tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. |
| 802 | |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 803 | Example matches '{}' and '{{}}' in 'for (;;) {{}}' |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 804 | for (;;) {{}} |
| 805 | </pre></td></tr> |
| 806 | |
| 807 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 808 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 809 | <tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. |
| 810 | |
| 811 | Example matches a ? b : c |
| 812 | (a ? b : c) + 42 |
| 813 | </pre></td></tr> |
| 814 | |
| 815 | |
Clement Courbet | 314cfb5 | 2018-11-22 10:44:36 +0000 | [diff] [blame] | 816 | <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> |
| 817 | <tr><td colspan="4" class="doc" id="constantExpr0"><pre>Matches a constant expression wrapper. |
| 818 | |
| 819 | Example matches the constant in the case statement: |
| 820 | (matcher = constantExpr()) |
| 821 | switch (a) { |
| 822 | case 37: break; |
| 823 | } |
| 824 | </pre></td></tr> |
| 825 | |
| 826 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 827 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 828 | <tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. |
| 829 | |
| 830 | Given |
| 831 | while (true) { continue; } |
| 832 | continueStmt() |
| 833 | matches 'continue' |
| 834 | </pre></td></tr> |
| 835 | |
| 836 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 837 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 838 | <tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression. |
| 839 | |
| 840 | Example matches, |
| 841 | kernel<<<i,j>>>(); |
| 842 | </pre></td></tr> |
| 843 | |
| 844 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 845 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 846 | <tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created. |
| 847 | |
| 848 | Example matches FunctionTakesString(GetStringByValue()) |
| 849 | (matcher = cxxBindTemporaryExpr()) |
| 850 | FunctionTakesString(GetStringByValue()); |
| 851 | FunctionTakesStringByPointer(GetStringPointer()); |
| 852 | </pre></td></tr> |
| 853 | |
| 854 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 855 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 856 | <tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals. |
| 857 | |
| 858 | Example matches true |
| 859 | true |
| 860 | </pre></td></tr> |
| 861 | |
| 862 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 863 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 864 | <tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements. |
| 865 | |
| 866 | try {} catch(int i) {} |
| 867 | cxxCatchStmt() |
| 868 | matches 'catch(int i)' |
| 869 | </pre></td></tr> |
| 870 | |
| 871 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 872 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 873 | <tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression. |
| 874 | |
| 875 | Example: Matches const_cast<int*>(&r) in |
| 876 | int n = 42; |
| 877 | const int &r(n); |
| 878 | int* p = const_cast<int*>(&r); |
| 879 | </pre></td></tr> |
| 880 | |
| 881 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 882 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 883 | <tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones). |
| 884 | |
| 885 | Example matches string(ptr, n) and ptr within arguments of f |
| 886 | (matcher = cxxConstructExpr()) |
| 887 | void f(const string &a, const string &b); |
| 888 | char *ptr; |
| 889 | int n; |
| 890 | f(string(ptr, n), ptr); |
| 891 | </pre></td></tr> |
| 892 | |
| 893 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 894 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 895 | <tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site. |
| 896 | |
| 897 | Example matches the CXXDefaultArgExpr placeholder inserted for the |
| 898 | default value of the second parameter in the call expression f(42) |
| 899 | (matcher = cxxDefaultArgExpr()) |
| 900 | void f(int x, int y = 0); |
| 901 | f(42); |
| 902 | </pre></td></tr> |
| 903 | |
| 904 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 905 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 906 | <tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions. |
| 907 | |
| 908 | Given |
| 909 | delete X; |
| 910 | cxxDeleteExpr() |
| 911 | matches 'delete X'. |
| 912 | </pre></td></tr> |
| 913 | |
| 914 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 915 | <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> |
Shuai Wang | 72b56ed | 2018-08-12 17:34:36 +0000 | [diff] [blame] | 916 | <tr><td colspan="4" class="doc" id="cxxDependentScopeMemberExpr0"><pre>Matches member expressions where the actual member referenced could not be |
| 917 | resolved because the base expression or the member name was dependent. |
| 918 | |
| 919 | Given |
| 920 | template <class T> void f() { T t; t.g(); } |
| 921 | cxxDependentScopeMemberExpr() |
| 922 | matches t.g |
| 923 | </pre></td></tr> |
| 924 | |
| 925 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 926 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 927 | <tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression. |
| 928 | |
| 929 | Example: |
| 930 | cxxDynamicCastExpr() |
| 931 | matches |
| 932 | dynamic_cast<D*>(&b); |
| 933 | in |
| 934 | struct B { virtual ~B() {} }; struct D : B {}; |
| 935 | B b; |
| 936 | D* p = dynamic_cast<D*>(&b); |
| 937 | </pre></td></tr> |
| 938 | |
| 939 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 940 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 941 | <tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements. |
| 942 | |
| 943 | cxxForRangeStmt() matches 'for (auto a : i)' |
| 944 | int i[] = {1, 2, 3}; for (auto a : i); |
| 945 | for(int j = 0; j < 5; ++j); |
| 946 | </pre></td></tr> |
| 947 | |
| 948 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 949 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 950 | <tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions |
| 951 | |
| 952 | Example: Matches Foo(bar); |
| 953 | Foo f = bar; |
| 954 | Foo g = (Foo) bar; |
| 955 | Foo h = Foo(bar); |
| 956 | </pre></td></tr> |
| 957 | |
| 958 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 959 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 960 | <tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions. |
| 961 | |
| 962 | Example matches x.y() |
| 963 | X x; |
| 964 | x.y(); |
| 965 | </pre></td></tr> |
| 966 | |
| 967 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 968 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 969 | <tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions. |
| 970 | |
| 971 | Given |
| 972 | new X; |
| 973 | cxxNewExpr() |
| 974 | matches 'new X'. |
| 975 | </pre></td></tr> |
| 976 | |
| 977 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 978 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 979 | <tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal. |
| 980 | </pre></td></tr> |
| 981 | |
| 982 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 983 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 984 | <tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls. |
| 985 | |
| 986 | Note that if an operator isn't overloaded, it won't match. Instead, use |
| 987 | binaryOperator matcher. |
| 988 | Currently it does not match operators such as new delete. |
| 989 | FIXME: figure out why these do not match? |
| 990 | |
| 991 | Example matches both operator<<((o << b), c) and operator<<(o, b) |
| 992 | (matcher = cxxOperatorCallExpr()) |
| 993 | ostream &operator<< (ostream &out, int i) { }; |
| 994 | ostream &o; int b = 1, c = 1; |
| 995 | o << b << c; |
| 996 | </pre></td></tr> |
| 997 | |
| 998 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 999 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1000 | <tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. |
| 1001 | |
| 1002 | Either the source expression or the destination type can be matched |
| 1003 | using has(), but hasDestinationType() is more specific and can be |
| 1004 | more readable. |
| 1005 | |
| 1006 | Example matches reinterpret_cast<char*>(&p) in |
| 1007 | void* p = reinterpret_cast<char*>(&p); |
| 1008 | </pre></td></tr> |
| 1009 | |
| 1010 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1011 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1012 | <tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression. |
| 1013 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1014 | See also: hasDestinationType |
| 1015 | See also: reinterpretCast |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1016 | |
| 1017 | Example: |
| 1018 | cxxStaticCastExpr() |
| 1019 | matches |
| 1020 | static_cast<long>(8) |
| 1021 | in |
| 1022 | long eight(static_cast<long>(8)); |
| 1023 | </pre></td></tr> |
| 1024 | |
| 1025 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1026 | <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> |
Jakub Kuderski | 64b6c78 | 2017-05-05 21:01:12 +0000 | [diff] [blame] | 1027 | <tr><td colspan="4" class="doc" id="cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions. |
| 1028 | |
| 1029 | Given |
| 1030 | std::vector<int> a({ 1, 2, 3 }); |
| 1031 | std::vector<int> b = { 4, 5 }; |
| 1032 | int c[] = { 6, 7 }; |
| 1033 | std::pair<int, int> d = { 8, 9 }; |
| 1034 | cxxStdInitializerListExpr() |
| 1035 | matches "{ 1, 2, 3 }" and "{ 4, 5 }" |
| 1036 | </pre></td></tr> |
| 1037 | |
| 1038 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1039 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1040 | <tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments |
| 1041 | |
| 1042 | Example: Matches Foo(bar, bar) |
| 1043 | Foo h = Foo(bar, bar); |
| 1044 | </pre></td></tr> |
| 1045 | |
| 1046 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1047 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1048 | <tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions. |
| 1049 | |
| 1050 | Example matches the implicit this expression in "return i". |
| 1051 | (matcher = cxxThisExpr()) |
| 1052 | struct foo { |
| 1053 | int i; |
| 1054 | int f() { return i; } |
| 1055 | }; |
| 1056 | </pre></td></tr> |
| 1057 | |
| 1058 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1059 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1060 | <tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions. |
| 1061 | |
| 1062 | try { throw 5; } catch(int i) {} |
| 1063 | cxxThrowExpr() |
| 1064 | matches 'throw 5' |
| 1065 | </pre></td></tr> |
| 1066 | |
| 1067 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1068 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1069 | <tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements. |
| 1070 | |
| 1071 | try {} catch(int i) {} |
| 1072 | cxxTryStmt() |
| 1073 | matches 'try {}' |
| 1074 | </pre></td></tr> |
| 1075 | |
| 1076 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1077 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1078 | <tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions. |
| 1079 | |
| 1080 | Example matches T(t) in return statement of f |
| 1081 | (matcher = cxxUnresolvedConstructExpr()) |
| 1082 | template <typename T> |
| 1083 | void f(const T& t) { return T(t); } |
| 1084 | </pre></td></tr> |
| 1085 | |
| 1086 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1087 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1088 | <tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. |
| 1089 | |
| 1090 | Example matches x in if (x) |
| 1091 | bool x; |
| 1092 | if (x) {} |
| 1093 | </pre></td></tr> |
| 1094 | |
| 1095 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1096 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1097 | <tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. |
| 1098 | |
| 1099 | Given |
| 1100 | int a; |
| 1101 | declStmt() |
| 1102 | matches 'int a'. |
| 1103 | </pre></td></tr> |
| 1104 | |
| 1105 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1106 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1107 | <tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements. |
| 1108 | |
| 1109 | Given |
| 1110 | switch(a) { case 42: break; default: break; } |
| 1111 | defaultStmt() |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 1112 | matches 'default:'. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1113 | </pre></td></tr> |
| 1114 | |
| 1115 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1116 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1117 | <tr><td colspan="4" class="doc" id="designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99 6.7.8]. |
| 1118 | |
| 1119 | Example: Matches { [2].y = 1.0, [0].x = 1.0 } |
| 1120 | point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; |
| 1121 | </pre></td></tr> |
| 1122 | |
| 1123 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1124 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1125 | <tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. |
| 1126 | |
| 1127 | Given |
| 1128 | do {} while (true); |
| 1129 | doStmt() |
| 1130 | matches 'do {} while(true)' |
| 1131 | </pre></td></tr> |
| 1132 | |
| 1133 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1134 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1135 | <tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. |
| 1136 | |
| 1137 | Matches any cast expression written in user code, whether it be a |
| 1138 | C-style cast, a functional-style cast, or a keyword cast. |
| 1139 | |
| 1140 | Does not match implicit conversions. |
| 1141 | |
| 1142 | Note: the name "explicitCast" is chosen to match Clang's terminology, as |
| 1143 | Clang uses the term "cast" to apply to implicit conversions as well as to |
| 1144 | actual cast expressions. |
| 1145 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1146 | See also: hasDestinationType. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1147 | |
| 1148 | Example: matches all five of the casts in |
| 1149 | int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) |
| 1150 | but does not match the implicit conversion in |
| 1151 | long ell = 42; |
| 1152 | </pre></td></tr> |
| 1153 | |
| 1154 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1155 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1156 | <tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. |
| 1157 | |
| 1158 | Example matches x() |
| 1159 | void f() { x(); } |
| 1160 | </pre></td></tr> |
| 1161 | |
| 1162 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1163 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1164 | <tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end |
| 1165 | of the sub-expression's evaluation. |
| 1166 | |
| 1167 | Example matches std::string() |
| 1168 | const std::string str = std::string(); |
| 1169 | </pre></td></tr> |
| 1170 | |
| 1171 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1172 | <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> |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 1173 | <tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes / encodings, e.g. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1174 | 1.0, 1.0f, 1.0L and 1e10. |
| 1175 | |
| 1176 | Does not match implicit conversions such as |
| 1177 | float a = 10; |
| 1178 | </pre></td></tr> |
| 1179 | |
| 1180 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1181 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1182 | <tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. |
| 1183 | |
| 1184 | Example matches 'for (;;) {}' |
| 1185 | for (;;) {} |
| 1186 | int i[] = {1, 2, 3}; for (auto a : i); |
| 1187 | </pre></td></tr> |
| 1188 | |
| 1189 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1190 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1191 | <tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression. |
| 1192 | </pre></td></tr> |
| 1193 | |
| 1194 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1195 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1196 | <tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. |
| 1197 | |
| 1198 | Given |
| 1199 | goto FOO; |
| 1200 | FOO: bar(); |
| 1201 | gotoStmt() |
| 1202 | matches 'goto FOO' |
| 1203 | </pre></td></tr> |
| 1204 | |
| 1205 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1206 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1207 | <tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. |
| 1208 | |
| 1209 | Example matches 'if (x) {}' |
| 1210 | if (x) {} |
| 1211 | </pre></td></tr> |
| 1212 | |
| 1213 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1214 | <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> |
Stephen Kelly | 9b8fa52 | 2018-10-09 08:24:11 +0000 | [diff] [blame] | 1215 | <tr><td colspan="4" class="doc" id="imaginaryLiteral0"><pre>Matches imaginary literals, which are based on integer and floating |
| 1216 | point literals e.g.: 1i, 1.0i |
| 1217 | </pre></td></tr> |
| 1218 | |
| 1219 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1220 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1221 | <tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. |
| 1222 | |
| 1223 | This matches many different places, including function call return value |
| 1224 | eliding, as well as any type conversions. |
| 1225 | </pre></td></tr> |
| 1226 | |
| 1227 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1228 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1229 | <tr><td colspan="4" class="doc" id="implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions. |
| 1230 | |
| 1231 | Given |
| 1232 | point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 }; |
| 1233 | implicitValueInitExpr() |
| 1234 | matches "[0].y" (implicitly) |
| 1235 | </pre></td></tr> |
| 1236 | |
| 1237 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1238 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1239 | <tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. |
| 1240 | |
| 1241 | Given |
| 1242 | int a[] = { 1, 2 }; |
| 1243 | struct B { int x, y; }; |
| 1244 | B b = { 5, 6 }; |
| 1245 | initListExpr() |
| 1246 | matches "{ 1, 2 }" and "{ 5, 6 }" |
| 1247 | </pre></td></tr> |
| 1248 | |
| 1249 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1250 | <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> |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 1251 | <tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes / encodings, e.g. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1252 | 1, 1L, 0x1 and 1U. |
| 1253 | |
| 1254 | Does not match character-encoded integers such as L'a'. |
| 1255 | </pre></td></tr> |
| 1256 | |
| 1257 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1258 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1259 | <tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. |
| 1260 | |
| 1261 | Given |
| 1262 | goto FOO; |
| 1263 | FOO: bar(); |
| 1264 | labelStmt() |
| 1265 | matches 'FOO:' |
| 1266 | </pre></td></tr> |
| 1267 | |
| 1268 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1269 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1270 | <tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. |
| 1271 | |
| 1272 | Example matches [&](){return 5;} |
| 1273 | [&](){return 5;} |
| 1274 | </pre></td></tr> |
| 1275 | |
| 1276 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1277 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1278 | <tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. |
| 1279 | |
| 1280 | Example: Given |
Jakub Kuderski | 64b6c78 | 2017-05-05 21:01:12 +0000 | [diff] [blame] | 1281 | struct T {void func();}; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1282 | T f(); |
| 1283 | void g(T); |
| 1284 | materializeTemporaryExpr() matches 'f()' in these statements |
| 1285 | T u(f()); |
| 1286 | g(f()); |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 1287 | f().func(); |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1288 | but does not match |
| 1289 | f(); |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1290 | </pre></td></tr> |
| 1291 | |
| 1292 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1293 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1294 | <tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. |
| 1295 | |
| 1296 | Given |
| 1297 | class Y { |
| 1298 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 1299 | int a; static int b; |
| 1300 | }; |
| 1301 | memberExpr() |
| 1302 | matches this->x, x, y.x, a, this->b |
| 1303 | </pre></td></tr> |
| 1304 | |
| 1305 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1306 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1307 | <tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. |
| 1308 | |
| 1309 | foo();; |
| 1310 | nullStmt() |
| 1311 | matches the second ';' |
| 1312 | </pre></td></tr> |
| 1313 | |
| 1314 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1315 | <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> |
Dave Lee | 0934fdc | 2017-11-11 22:46:15 +0000 | [diff] [blame] | 1316 | <tr><td colspan="4" class="doc" id="objcCatchStmt0"><pre>Matches Objective-C @catch statements. |
| 1317 | |
| 1318 | Example matches @catch |
| 1319 | @try {} |
| 1320 | @catch (...) {} |
| 1321 | </pre></td></tr> |
| 1322 | |
| 1323 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1324 | <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> |
Dave Lee | 0934fdc | 2017-11-11 22:46:15 +0000 | [diff] [blame] | 1325 | <tr><td colspan="4" class="doc" id="objcFinallyStmt0"><pre>Matches Objective-C @finally statements. |
| 1326 | |
| 1327 | Example matches @finally |
| 1328 | @try {} |
| 1329 | @finally {} |
| 1330 | </pre></td></tr> |
| 1331 | |
| 1332 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1333 | <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> |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 1334 | <tr><td colspan="4" class="doc" id="objcIvarRefExpr0"><pre>Matches a reference to an ObjCIvar. |
| 1335 | |
| 1336 | Example: matches "a" in "init" method: |
| 1337 | @implementation A { |
| 1338 | NSString *a; |
| 1339 | } |
| 1340 | - (void) init { |
| 1341 | a = @"hello"; |
| 1342 | } |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 1343 | </pre></td></tr> |
| 1344 | |
| 1345 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1346 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1347 | <tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions. |
| 1348 | |
| 1349 | The innermost message send invokes the "alloc" class method on the |
| 1350 | NSString class, while the outermost message send invokes the |
| 1351 | "initWithString" instance method on the object returned from |
| 1352 | NSString's "alloc". This matcher should match both message sends. |
| 1353 | [[NSString alloc] initWithString:@"Hello"] |
| 1354 | </pre></td></tr> |
| 1355 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1356 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1357 | <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> |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 1358 | <tr><td colspan="4" class="doc" id="objcThrowStmt0"><pre>Matches Objective-C statements. |
Dave Lee | 0934fdc | 2017-11-11 22:46:15 +0000 | [diff] [blame] | 1359 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 1360 | Example matches @throw obj; |
Dave Lee | 0934fdc | 2017-11-11 22:46:15 +0000 | [diff] [blame] | 1361 | </pre></td></tr> |
| 1362 | |
| 1363 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1364 | <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> |
Dave Lee | 0934fdc | 2017-11-11 22:46:15 +0000 | [diff] [blame] | 1365 | <tr><td colspan="4" class="doc" id="objcTryStmt0"><pre>Matches Objective-C @try statements. |
| 1366 | |
| 1367 | Example matches @try |
| 1368 | @try {} |
| 1369 | @catch (...) {} |
| 1370 | </pre></td></tr> |
| 1371 | |
| 1372 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1373 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1374 | <tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers |
| 1375 | to reference another expressions and can be met |
| 1376 | in BinaryConditionalOperators, for example. |
| 1377 | |
| 1378 | Example matches 'a' |
| 1379 | (a ?: c) + 42; |
| 1380 | </pre></td></tr> |
| 1381 | |
| 1382 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1383 | <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> |
Aaron Ballman | e8295d7 | 2016-01-20 16:17:39 +0000 | [diff] [blame] | 1384 | <tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions. |
| 1385 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1386 | Example matches (foo() + 1) |
Aaron Ballman | e8295d7 | 2016-01-20 16:17:39 +0000 | [diff] [blame] | 1387 | int foo() { return 1; } |
| 1388 | int a = (foo() + 1); |
Aaron Ballman | e8295d7 | 2016-01-20 16:17:39 +0000 | [diff] [blame] | 1389 | </pre></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1390 | |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 1391 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1392 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1393 | <tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions. |
| 1394 | ParenListExprs don't have a predefined type and are used for late parsing. |
| 1395 | In the final AST, they can be met in template declarations. |
| 1396 | |
| 1397 | Given |
| 1398 | template<typename T> class X { |
| 1399 | void f() { |
| 1400 | X x(*this); |
| 1401 | int a = 0, b = 1; int i = (a, b); |
| 1402 | } |
| 1403 | }; |
| 1404 | parenListExpr() matches "*this" but NOT matches (a, b) because (a, b) |
| 1405 | has a predefined type and is a ParenExpr, not a ParenListExpr. |
| 1406 | </pre></td></tr> |
| 1407 | |
| 1408 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1409 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1410 | <tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2]. |
| 1411 | |
| 1412 | Example: Matches __func__ |
| 1413 | printf("%s", __func__); |
| 1414 | </pre></td></tr> |
| 1415 | |
| 1416 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1417 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1418 | <tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. |
| 1419 | |
| 1420 | Given |
| 1421 | return 1; |
| 1422 | returnStmt() |
| 1423 | matches 'return 1' |
| 1424 | </pre></td></tr> |
| 1425 | |
| 1426 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1427 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1428 | <tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. |
| 1429 | |
| 1430 | Given |
| 1431 | { ++a; } |
| 1432 | stmt() |
| 1433 | matches both the compound statement '{ ++a; }' and '++a'. |
| 1434 | </pre></td></tr> |
| 1435 | |
| 1436 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1437 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 1438 | <tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension). |
| 1439 | |
| 1440 | Example match: ({ int X = 4; X; }) |
| 1441 | int C = ({ int X = 4; X; }); |
| 1442 | </pre></td></tr> |
| 1443 | |
| 1444 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1445 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1446 | <tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). |
| 1447 | |
| 1448 | Example matches "abcd", L"abcd" |
Etienne Bergeron | 3588be7 | 2016-05-12 04:20:04 +0000 | [diff] [blame] | 1449 | char *s = "abcd"; |
| 1450 | wchar_t *ws = L"abcd"; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1451 | </pre></td></tr> |
| 1452 | |
| 1453 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1454 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1455 | <tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters. |
| 1456 | |
| 1457 | Given |
| 1458 | template <int N> |
| 1459 | struct A { static const int n = N; }; |
| 1460 | struct B : public A<42> {}; |
| 1461 | substNonTypeTemplateParmExpr() |
| 1462 | matches "N" in the right-hand side of "static const int n = N;" |
| 1463 | </pre></td></tr> |
| 1464 | |
| 1465 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1466 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1467 | <tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. |
| 1468 | |
| 1469 | Given |
| 1470 | switch(a) { case 42: break; default: break; } |
| 1471 | switchCase() |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 1472 | matches 'case 42:' and 'default:'. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1473 | </pre></td></tr> |
| 1474 | |
| 1475 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1476 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1477 | <tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. |
| 1478 | |
| 1479 | Given |
| 1480 | switch(a) { case 42: break; default: break; } |
| 1481 | switchStmt() |
| 1482 | matches 'switch(a)'. |
| 1483 | </pre></td></tr> |
| 1484 | |
| 1485 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1486 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1487 | <tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) |
| 1488 | |
| 1489 | Given |
| 1490 | Foo x = bar; |
| 1491 | int y = sizeof(x) + alignof(x); |
| 1492 | unaryExprOrTypeTraitExpr() |
| 1493 | matches sizeof(x) and alignof(x) |
| 1494 | </pre></td></tr> |
| 1495 | |
| 1496 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1497 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1498 | <tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. |
| 1499 | |
| 1500 | Example matches !a |
| 1501 | !a || b |
| 1502 | </pre></td></tr> |
| 1503 | |
| 1504 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1505 | <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> |
Haojian Wu | 7751c92 | 2016-05-18 12:53:59 +0000 | [diff] [blame] | 1506 | <tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing |
| 1507 | but could not be resolved to a specific declaration. |
| 1508 | |
| 1509 | Given |
| 1510 | template<typename T> |
| 1511 | T foo() { T a; return a; } |
| 1512 | template<typename T> |
| 1513 | void bar() { |
| 1514 | foo<T>(); |
| 1515 | } |
| 1516 | unresolvedLookupExpr() |
| 1517 | matches foo<T>() </pre></td></tr> |
| 1518 | |
| 1519 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1520 | <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> |
Shuai Wang | 72b56ed | 2018-08-12 17:34:36 +0000 | [diff] [blame] | 1521 | <tr><td colspan="4" class="doc" id="unresolvedMemberExpr0"><pre>Matches unresolved member expressions. |
| 1522 | |
| 1523 | Given |
| 1524 | struct X { |
| 1525 | template <class T> void f(); |
| 1526 | void g(); |
| 1527 | }; |
| 1528 | template <class T> void h() { X x; x.f<T>(); x.g(); } |
| 1529 | unresolvedMemberExpr() |
| 1530 | matches x.f<T> |
| 1531 | </pre></td></tr> |
| 1532 | |
| 1533 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1534 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1535 | <tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. |
| 1536 | |
| 1537 | Example match: "foo"_suffix |
| 1538 | </pre></td></tr> |
| 1539 | |
| 1540 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1541 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1542 | <tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. |
| 1543 | |
| 1544 | Given |
| 1545 | while (true) {} |
| 1546 | whileStmt() |
| 1547 | matches 'while (true) {}'. |
| 1548 | </pre></td></tr> |
| 1549 | |
| 1550 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1551 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1552 | <tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments. |
| 1553 | |
| 1554 | Given |
| 1555 | template <typename T> struct C {}; |
| 1556 | C<int> c; |
| 1557 | templateArgument() |
| 1558 | matches 'int' in C<int>. |
| 1559 | </pre></td></tr> |
| 1560 | |
| 1561 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1562 | <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> |
Haojian Wu | b33b02e | 2016-07-29 15:45:11 +0000 | [diff] [blame] | 1563 | <tr><td colspan="4" class="doc" id="templateName0"><pre>Matches template name. |
| 1564 | |
| 1565 | Given |
| 1566 | template <typename T> class X { }; |
| 1567 | X<int> xi; |
| 1568 | templateName() |
| 1569 | matches 'X' in X<int>. |
| 1570 | </pre></td></tr> |
| 1571 | |
| 1572 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1573 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1574 | <tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. |
| 1575 | </pre></td></tr> |
| 1576 | |
| 1577 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1578 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1579 | <tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. |
| 1580 | |
| 1581 | Given |
| 1582 | int a[] = { 2, 3 }; |
| 1583 | int b[4]; |
| 1584 | void f() { int c[a[0]]; } |
| 1585 | arrayType() |
| 1586 | matches "int a[]", "int b[4]" and "int c[a[0]]"; |
| 1587 | </pre></td></tr> |
| 1588 | |
| 1589 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1590 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1591 | <tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. |
| 1592 | |
| 1593 | Given |
| 1594 | _Atomic(int) i; |
| 1595 | atomicType() |
| 1596 | matches "_Atomic(int) i" |
| 1597 | </pre></td></tr> |
| 1598 | |
| 1599 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1600 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1601 | <tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. |
| 1602 | |
| 1603 | Given: |
| 1604 | auto n = 4; |
| 1605 | int v[] = { 2, 3 } |
| 1606 | for (auto i : v) { } |
| 1607 | autoType() |
| 1608 | matches "auto n" and "auto i" |
| 1609 | </pre></td></tr> |
| 1610 | |
| 1611 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1612 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1613 | <tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as |
| 1614 | "void (^)(int)". |
| 1615 | |
| 1616 | The pointee is always required to be a FunctionType. |
| 1617 | </pre></td></tr> |
| 1618 | |
| 1619 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1620 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1621 | <tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. |
| 1622 | |
| 1623 | Given |
| 1624 | struct A {}; |
| 1625 | A a; |
| 1626 | int b; |
| 1627 | float c; |
| 1628 | bool d; |
| 1629 | builtinType() |
| 1630 | matches "int b", "float c" and "bool d" |
| 1631 | </pre></td></tr> |
| 1632 | |
| 1633 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1634 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1635 | <tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. |
| 1636 | |
| 1637 | Given |
| 1638 | _Complex float f; |
| 1639 | complexType() |
| 1640 | matches "_Complex float f" |
| 1641 | </pre></td></tr> |
| 1642 | |
| 1643 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1644 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1645 | <tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. |
| 1646 | |
| 1647 | Given |
| 1648 | void() { |
| 1649 | int a[2]; |
| 1650 | int b[] = { 2, 3 }; |
| 1651 | int c[b[0]]; |
| 1652 | } |
| 1653 | constantArrayType() |
| 1654 | matches "int a[2]" |
| 1655 | </pre></td></tr> |
| 1656 | |
| 1657 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1658 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1659 | <tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type |
| 1660 | Example matches i[] in declaration of f. |
| 1661 | (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))) |
| 1662 | Example matches i[1]. |
| 1663 | (matcher = expr(hasType(decayedType(hasDecayedType(pointerType()))))) |
| 1664 | void f(int i[]) { |
| 1665 | i[1] = 0; |
| 1666 | } |
| 1667 | </pre></td></tr> |
| 1668 | |
| 1669 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1670 | <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> |
Jonas Toth | acf8367 | 2018-07-26 13:02:05 +0000 | [diff] [blame] | 1671 | <tr><td colspan="4" class="doc" id="decltypeType0"><pre>Matches types nodes representing C++11 decltype(<expr>) types. |
| 1672 | |
| 1673 | Given: |
| 1674 | short i = 1; |
| 1675 | int j = 42; |
| 1676 | decltype(i + j) result = i + j; |
Shuai Wang | 72b56ed | 2018-08-12 17:34:36 +0000 | [diff] [blame] | 1677 | decltypeType() |
Jonas Toth | acf8367 | 2018-07-26 13:02:05 +0000 | [diff] [blame] | 1678 | matches "decltype(i + j)" |
| 1679 | </pre></td></tr> |
| 1680 | |
| 1681 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1682 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1683 | <tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. |
| 1684 | |
| 1685 | Given |
| 1686 | template<typename T, int Size> |
| 1687 | class array { |
| 1688 | T data[Size]; |
| 1689 | }; |
| 1690 | dependentSizedArrayType |
| 1691 | matches "T data[Size]" |
| 1692 | </pre></td></tr> |
| 1693 | |
| 1694 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1695 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1696 | <tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a |
| 1697 | qualified name. |
| 1698 | |
| 1699 | Given |
| 1700 | namespace N { |
| 1701 | namespace M { |
| 1702 | class D {}; |
| 1703 | } |
| 1704 | } |
| 1705 | class C {}; |
| 1706 | |
| 1707 | class C c; |
| 1708 | N::M::D d; |
| 1709 | |
| 1710 | elaboratedType() matches the type of the variable declarations of both |
| 1711 | c and d. |
| 1712 | </pre></td></tr> |
| 1713 | |
| 1714 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1715 | <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> |
Haojian Wu | e775de8 | 2016-06-30 07:50:01 +0000 | [diff] [blame] | 1716 | <tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types. |
| 1717 | |
| 1718 | Given |
| 1719 | enum C { Green }; |
Aaron Ballman | 5c57434 | 2016-07-06 18:25:16 +0000 | [diff] [blame] | 1720 | enum class S { Red }; |
Haojian Wu | e775de8 | 2016-06-30 07:50:01 +0000 | [diff] [blame] | 1721 | |
| 1722 | C c; |
| 1723 | S s; |
| 1724 | |
| 1725 | enumType() matches the type of the variable declarations of both c and |
| 1726 | s. |
| 1727 | </pre></td></tr> |
| 1728 | |
| 1729 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1730 | <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> |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 1731 | <tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes. |
| 1732 | |
| 1733 | Given |
| 1734 | int (*f)(int); |
| 1735 | void g(); |
| 1736 | functionProtoType() |
| 1737 | matches "int (*f)(int)" and the type of "g" in C++ mode. |
| 1738 | In C mode, "g" is not matched because it does not contain a prototype. |
| 1739 | </pre></td></tr> |
| 1740 | |
| 1741 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1742 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1743 | <tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. |
| 1744 | |
| 1745 | Given |
| 1746 | int (*f)(int); |
| 1747 | void g(); |
| 1748 | functionType() |
| 1749 | matches "int (*f)(int)" and the type of "g". |
| 1750 | </pre></td></tr> |
| 1751 | |
| 1752 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1753 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1754 | <tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. |
| 1755 | |
| 1756 | Given |
| 1757 | int a[] = { 2, 3 }; |
| 1758 | int b[42]; |
| 1759 | void f(int c[]) { int d[a[0]]; }; |
| 1760 | incompleteArrayType() |
| 1761 | matches "int a[]" and "int c[]" |
| 1762 | </pre></td></tr> |
| 1763 | |
| 1764 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1765 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1766 | <tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types. |
| 1767 | |
| 1768 | Example matches S s, but not S<T> s. |
| 1769 | (matcher = parmVarDecl(hasType(injectedClassNameType()))) |
| 1770 | template <typename T> struct S { |
| 1771 | void f(S s); |
| 1772 | void g(S<T> s); |
| 1773 | }; |
| 1774 | </pre></td></tr> |
| 1775 | |
| 1776 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1777 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1778 | <tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. |
| 1779 | |
| 1780 | Given: |
| 1781 | int *a; |
| 1782 | int &b = *a; |
| 1783 | int &&c = 1; |
| 1784 | auto &d = b; |
| 1785 | auto &&e = c; |
| 1786 | auto &&f = 2; |
| 1787 | int g = 5; |
| 1788 | |
| 1789 | lValueReferenceType() matches the types of b, d, and e. e is |
| 1790 | matched since the type is deduced as int& by reference collapsing rules. |
| 1791 | </pre></td></tr> |
| 1792 | |
| 1793 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1794 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1795 | <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. |
| 1796 | Given |
| 1797 | struct A { int i; } |
| 1798 | A::* ptr = A::i; |
| 1799 | memberPointerType() |
| 1800 | matches "A::* ptr" |
| 1801 | </pre></td></tr> |
| 1802 | |
| 1803 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1804 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1805 | <tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from |
| 1806 | a pointer type, despite being syntactically similar. |
| 1807 | |
| 1808 | Given |
| 1809 | int *a; |
| 1810 | |
| 1811 | @interface Foo |
| 1812 | @end |
| 1813 | Foo *f; |
| 1814 | pointerType() |
| 1815 | matches "Foo *f", but does not match "int *a". |
| 1816 | </pre></td></tr> |
| 1817 | |
| 1818 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1819 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1820 | <tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. |
| 1821 | |
| 1822 | Given |
| 1823 | int (*ptr_to_array)[4]; |
| 1824 | int *array_of_ptrs[4]; |
| 1825 | |
| 1826 | varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not |
| 1827 | array_of_ptrs. |
| 1828 | </pre></td></tr> |
| 1829 | |
| 1830 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1831 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1832 | <tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer |
| 1833 | types. |
| 1834 | |
| 1835 | Given |
| 1836 | int *a; |
| 1837 | int &b = *a; |
| 1838 | int c = 5; |
| 1839 | |
| 1840 | @interface Foo |
| 1841 | @end |
| 1842 | Foo *f; |
| 1843 | pointerType() |
| 1844 | matches "int *a", but does not match "Foo *f". |
| 1845 | </pre></td></tr> |
| 1846 | |
| 1847 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1848 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1849 | <tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. |
| 1850 | |
| 1851 | Given: |
| 1852 | int *a; |
| 1853 | int &b = *a; |
| 1854 | int &&c = 1; |
| 1855 | auto &d = b; |
| 1856 | auto &&e = c; |
| 1857 | auto &&f = 2; |
| 1858 | int g = 5; |
| 1859 | |
| 1860 | rValueReferenceType() matches the types of c and f. e is not |
| 1861 | matched as it is deduced to int& by reference collapsing rules. |
| 1862 | </pre></td></tr> |
| 1863 | |
| 1864 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1865 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1866 | <tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). |
| 1867 | |
| 1868 | Given |
| 1869 | class C {}; |
| 1870 | struct S {}; |
| 1871 | |
| 1872 | C c; |
| 1873 | S s; |
| 1874 | |
| 1875 | recordType() matches the type of the variable declarations of both c |
| 1876 | and s. |
| 1877 | </pre></td></tr> |
| 1878 | |
| 1879 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1880 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1881 | <tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. |
| 1882 | |
| 1883 | Given |
| 1884 | int *a; |
| 1885 | int &b = *a; |
| 1886 | int &&c = 1; |
| 1887 | auto &d = b; |
| 1888 | auto &&e = c; |
| 1889 | auto &&f = 2; |
| 1890 | int g = 5; |
| 1891 | |
| 1892 | referenceType() matches the types of b, c, d, e, and f. |
| 1893 | </pre></td></tr> |
| 1894 | |
| 1895 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1896 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1897 | <tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a |
| 1898 | template type parameter. |
| 1899 | |
| 1900 | Given |
| 1901 | template <typename T> |
| 1902 | void F(T t) { |
| 1903 | int i = 1 + t; |
| 1904 | } |
| 1905 | |
| 1906 | substTemplateTypeParmType() matches the type of 't' but not '1' |
| 1907 | </pre></td></tr> |
| 1908 | |
| 1909 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1910 | <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> |
Manuel Klimek | 696e505 | 2017-08-02 13:04:44 +0000 | [diff] [blame] | 1911 | <tr><td colspan="4" class="doc" id="tagType0"><pre>Matches tag types (record and enum types). |
| 1912 | |
| 1913 | Given |
| 1914 | enum E {}; |
| 1915 | class C {}; |
| 1916 | |
| 1917 | E e; |
| 1918 | C c; |
| 1919 | |
| 1920 | tagType() matches the type of the variable declarations of both e |
| 1921 | and c. |
| 1922 | </pre></td></tr> |
| 1923 | |
| 1924 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1925 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1926 | <tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. |
| 1927 | |
| 1928 | Given |
| 1929 | template <typename T> |
| 1930 | class C { }; |
| 1931 | |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 1932 | template class C<int>; // A |
| 1933 | C<char> var; // B |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1934 | |
| 1935 | templateSpecializationType() matches the type of the explicit |
| 1936 | instantiation in A and the type of the variable declaration in B. |
| 1937 | </pre></td></tr> |
| 1938 | |
| 1939 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1940 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1941 | <tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types. |
| 1942 | |
| 1943 | Example matches T, but not int. |
| 1944 | (matcher = templateTypeParmType()) |
| 1945 | template <typename T> void f(int i); |
| 1946 | </pre></td></tr> |
| 1947 | |
| 1948 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1949 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1950 | <tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. |
| 1951 | </pre></td></tr> |
| 1952 | |
| 1953 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1954 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1955 | <tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. |
| 1956 | |
| 1957 | Given |
| 1958 | typedef int X; |
| 1959 | typedefType() |
| 1960 | matches "typedef int X" |
| 1961 | </pre></td></tr> |
| 1962 | |
| 1963 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1964 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1965 | <tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. |
| 1966 | |
| 1967 | Given: |
| 1968 | typedef __underlying_type(T) type; |
| 1969 | unaryTransformType() |
| 1970 | matches "__underlying_type(T)" |
| 1971 | </pre></td></tr> |
| 1972 | |
| 1973 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 1974 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 1975 | <tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an |
| 1976 | integer-constant-expression. |
| 1977 | |
| 1978 | Given |
| 1979 | void f() { |
| 1980 | int a[] = { 2, 3 } |
| 1981 | int b[42]; |
| 1982 | int c[a[0]]; |
| 1983 | } |
| 1984 | variableArrayType() |
| 1985 | matches "int c[a[0]]" |
| 1986 | </pre></td></tr> |
| 1987 | |
Benjamin Kramer | 7d0cc23 | 2015-11-20 07:57:46 +0000 | [diff] [blame] | 1988 | <!--END_DECL_MATCHERS --> |
| 1989 | </table> |
| 1990 | |
| 1991 | <!-- ======================================================================= --> |
| 1992 | <h2 id="narrowing-matchers">Narrowing Matchers</h2> |
| 1993 | <!-- ======================================================================= --> |
| 1994 | |
| 1995 | <p>Narrowing matchers match certain attributes on the current node, thus |
| 1996 | narrowing down the set of nodes of the current type to match on.</p> |
| 1997 | |
| 1998 | <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) |
| 1999 | which allow users to create more powerful match expressions.</p> |
| 2000 | |
| 2001 | <table> |
| 2002 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2003 | <!-- START_NARROWING_MATCHERS --> |
| 2004 | |
| 2005 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 2006 | <tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. |
| 2007 | |
| 2008 | Usable as: Any Matcher |
| 2009 | </pre></td></tr> |
| 2010 | |
| 2011 | |
| 2012 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 2013 | <tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. |
| 2014 | |
| 2015 | Usable as: Any Matcher |
| 2016 | </pre></td></tr> |
| 2017 | |
| 2018 | |
| 2019 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> |
| 2020 | <tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. |
| 2021 | |
| 2022 | Useful when another matcher requires a child matcher, but there's no |
| 2023 | additional constraint. This will often be used with an explicit conversion |
| 2024 | to an internal::Matcher<> type such as TypeMatcher. |
| 2025 | |
| 2026 | Example: DeclarationMatcher(anything()) matches all declarations, e.g., |
| 2027 | "int* p" and "void f()" in |
| 2028 | int* p; |
| 2029 | void f(); |
| 2030 | |
| 2031 | Usable as: Any Matcher |
| 2032 | </pre></td></tr> |
| 2033 | |
| 2034 | |
| 2035 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> |
| 2036 | <tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. |
| 2037 | |
| 2038 | Example matches Y (matcher = cxxRecordDecl(unless(hasName("X")))) |
| 2039 | class X {}; |
| 2040 | class Y {}; |
| 2041 | |
| 2042 | Usable as: Any Matcher |
| 2043 | </pre></td></tr> |
| 2044 | |
| 2045 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2046 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2047 | <tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or |
| 2048 | unary). |
| 2049 | |
| 2050 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 2051 | !(a || b) |
| 2052 | </pre></td></tr> |
| 2053 | |
| 2054 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2055 | <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> |
Peter Szecsi | fff11db | 2018-03-27 12:11:46 +0000 | [diff] [blame] | 2056 | <tr><td colspan="4" class="doc" id="isAssignmentOperator0"><pre>Matches all kinds of assignment operators. |
| 2057 | |
| 2058 | Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) |
| 2059 | if (a == b) |
| 2060 | a += b; |
| 2061 | |
Alexander Kornienko | 395ab2e | 2018-04-30 18:12:15 +0000 | [diff] [blame] | 2062 | Example 2: matches s1 = s2 |
| 2063 | (matcher = cxxOperatorCallExpr(isAssignmentOperator())) |
| 2064 | struct S { S& operator=(const S&); }; |
Peter Szecsi | fff11db | 2018-03-27 12:11:46 +0000 | [diff] [blame] | 2065 | void x() { S s1, s2; s1 = s2; }) |
| 2066 | </pre></td></tr> |
| 2067 | |
| 2068 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2069 | <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> |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 2070 | <tr><td colspan="4" class="doc" id="equals5"><pre></pre></td></tr> |
| 2071 | |
| 2072 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2073 | <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> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2074 | <tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value of type ValueT. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2075 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2076 | Given |
| 2077 | f('false, 3.14, 42); |
| 2078 | characterLiteral(equals(0)) |
| 2079 | matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) |
| 2080 | match false |
| 2081 | floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) |
| 2082 | match 3.14 |
| 2083 | integerLiteral(equals(42)) |
| 2084 | matches 42 |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2085 | |
Clement Courbet | 43bdba4 | 2017-07-11 15:45:22 +0000 | [diff] [blame] | 2086 | Note that you cannot directly match a negative numeric literal because the |
| 2087 | minus sign is not part of the literal: It is a unary operator whose operand |
| 2088 | is the positive numeric literal. Instead, you must use a unaryOperator() |
| 2089 | matcher to match the minus sign: |
| 2090 | |
| 2091 | unaryOperator(hasOperatorName("-"), |
| 2092 | hasUnaryOperand(integerLiteral(equals(13)))) |
| 2093 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2094 | 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>>, |
| 2095 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2096 | </pre></td></tr> |
| 2097 | |
| 2098 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2099 | <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> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2100 | <tr><td colspan="4" class="doc" id="equals11"><pre></pre></td></tr> |
| 2101 | |
| 2102 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2103 | <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> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2104 | <tr><td colspan="4" class="doc" id="equals8"><pre></pre></td></tr> |
| 2105 | |
| 2106 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2107 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2108 | <tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler. |
| 2109 | |
| 2110 | Given |
| 2111 | try { |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 2112 | // ... |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2113 | } catch (int) { |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 2114 | // ... |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2115 | } catch (...) { |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 2116 | // ... |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2117 | } |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2118 | cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int). |
| 2119 | </pre></td></tr> |
| 2120 | |
| 2121 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2122 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2123 | <tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has |
| 2124 | a specific number of arguments (including absent default arguments). |
| 2125 | |
| 2126 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 2127 | void f(int x, int y); |
| 2128 | f(0, 0); |
| 2129 | </pre></td></tr> |
| 2130 | |
| 2131 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2132 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2133 | <tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. |
| 2134 | </pre></td></tr> |
| 2135 | |
| 2136 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2137 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 2138 | <tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires |
| 2139 | zero initialization. |
| 2140 | |
| 2141 | Given |
| 2142 | void foo() { |
| 2143 | struct point { double x; double y; }; |
| 2144 | point pt[2] = { { 1.0, 2.0 } }; |
| 2145 | } |
| 2146 | initListExpr(has(cxxConstructExpr(requiresZeroInitialization())) |
| 2147 | will match the implicit array filler for pt[1]. |
| 2148 | </pre></td></tr> |
| 2149 | |
| 2150 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2151 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2152 | <tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors. |
| 2153 | |
| 2154 | Given |
| 2155 | struct S { |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 2156 | S(); // #1 |
| 2157 | S(const S &); // #2 |
| 2158 | S(S &&); // #3 |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2159 | }; |
| 2160 | cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3. |
| 2161 | </pre></td></tr> |
| 2162 | |
| 2163 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2164 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2165 | <tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors. |
| 2166 | |
| 2167 | Given |
| 2168 | struct S { |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 2169 | S(); // #1 |
| 2170 | S(const S &); // #2 |
| 2171 | S(S &&); // #3 |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2172 | }; |
| 2173 | cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3. |
| 2174 | </pre></td></tr> |
| 2175 | |
| 2176 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2177 | <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> |
Alexander Kornienko | 7d20a5a | 2016-04-13 11:13:08 +0000 | [diff] [blame] | 2178 | <tr><td colspan="4" class="doc" id="isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor. |
| 2179 | |
| 2180 | Given |
| 2181 | struct S { |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 2182 | S(); // #1 |
| 2183 | S(int) {} // #2 |
| 2184 | S(S &&) : S() {} // #3 |
Alexander Kornienko | 7d20a5a | 2016-04-13 11:13:08 +0000 | [diff] [blame] | 2185 | }; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 2186 | S::S() : S(0) {} // #4 |
Alexander Kornienko | 7d20a5a | 2016-04-13 11:13:08 +0000 | [diff] [blame] | 2187 | cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not |
| 2188 | #1 or #2. |
| 2189 | </pre></td></tr> |
| 2190 | |
| 2191 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2192 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2193 | <tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor and conversion declarations that are marked with |
| 2194 | the explicit keyword. |
| 2195 | |
| 2196 | Given |
| 2197 | struct S { |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 2198 | S(int); // #1 |
| 2199 | explicit S(double); // #2 |
| 2200 | operator int(); // #3 |
| 2201 | explicit operator bool(); // #4 |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2202 | }; |
| 2203 | cxxConstructorDecl(isExplicit()) will match #2, but not #1. |
| 2204 | cxxConversionDecl(isExplicit()) will match #4, but not #3. |
| 2205 | </pre></td></tr> |
| 2206 | |
| 2207 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2208 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2209 | <tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors. |
| 2210 | |
| 2211 | Given |
| 2212 | struct S { |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 2213 | S(); // #1 |
| 2214 | S(const S &); // #2 |
| 2215 | S(S &&); // #3 |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2216 | }; |
| 2217 | cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. |
| 2218 | </pre></td></tr> |
| 2219 | |
| 2220 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2221 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2222 | <tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor and conversion declarations that are marked with |
| 2223 | the explicit keyword. |
| 2224 | |
| 2225 | Given |
| 2226 | struct S { |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 2227 | S(int); // #1 |
| 2228 | explicit S(double); // #2 |
| 2229 | operator int(); // #3 |
| 2230 | explicit operator bool(); // #4 |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2231 | }; |
| 2232 | cxxConstructorDecl(isExplicit()) will match #2, but not #1. |
| 2233 | cxxConversionDecl(isExplicit()) will match #4, but not #3. |
| 2234 | </pre></td></tr> |
| 2235 | |
| 2236 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2237 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2238 | <tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as |
| 2239 | opposed to a member. |
| 2240 | |
| 2241 | Given |
| 2242 | struct B {}; |
| 2243 | struct D : B { |
| 2244 | int I; |
| 2245 | D(int i) : I(i) {} |
| 2246 | }; |
| 2247 | struct E : B { |
| 2248 | E() : B() {} |
| 2249 | }; |
| 2250 | cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) |
| 2251 | will match E(), but not match D(int). |
| 2252 | </pre></td></tr> |
| 2253 | |
| 2254 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2255 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2256 | <tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as |
| 2257 | opposed to a base. |
| 2258 | |
| 2259 | Given |
| 2260 | struct B {}; |
| 2261 | struct D : B { |
| 2262 | int I; |
| 2263 | D(int i) : I(i) {} |
| 2264 | }; |
| 2265 | struct E : B { |
| 2266 | E() : B() {} |
| 2267 | }; |
| 2268 | cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) |
| 2269 | will match D(int), but not match E(). |
| 2270 | </pre></td></tr> |
| 2271 | |
| 2272 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2273 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2274 | <tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in |
| 2275 | code (as opposed to implicitly added by the compiler). |
| 2276 | |
| 2277 | Given |
| 2278 | struct Foo { |
| 2279 | Foo() { } |
| 2280 | Foo(int) : foo_("A") { } |
| 2281 | string foo_; |
| 2282 | }; |
| 2283 | cxxConstructorDecl(hasAnyConstructorInitializer(isWritten())) |
| 2284 | will match Foo(int), but not Foo() |
| 2285 | </pre></td></tr> |
| 2286 | |
| 2287 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2288 | <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> |
Shuai Wang | e0248ae | 2018-09-17 18:48:43 +0000 | [diff] [blame] | 2289 | <tr><td colspan="4" class="doc" id="isArrow2"><pre>Matches member expressions that are called with '->' as opposed |
| 2290 | to '.'. |
| 2291 | |
| 2292 | Member calls on the implicit this pointer match as called with '->'. |
| 2293 | |
| 2294 | Given |
| 2295 | class Y { |
| 2296 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 2297 | template <class T> void f() { this->f<T>(); f<T>(); } |
| 2298 | int a; |
| 2299 | static int b; |
| 2300 | }; |
| 2301 | template <class T> |
| 2302 | class Z { |
| 2303 | void x() { this->m; } |
| 2304 | }; |
| 2305 | memberExpr(isArrow()) |
| 2306 | matches this->x, x, y.x, a, this->b |
| 2307 | cxxDependentScopeMemberExpr(isArrow()) |
| 2308 | matches this->m |
| 2309 | unresolvedMemberExpr(isArrow()) |
| 2310 | matches this->f<T>, f<T> |
| 2311 | </pre></td></tr> |
| 2312 | |
| 2313 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2314 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2315 | <tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. |
| 2316 | |
| 2317 | Given |
| 2318 | struct A { |
| 2319 | void foo() const; |
| 2320 | void bar(); |
| 2321 | }; |
| 2322 | |
| 2323 | cxxMethodDecl(isConst()) matches A::foo() but not A::bar() |
| 2324 | </pre></td></tr> |
| 2325 | |
| 2326 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2327 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2328 | <tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment |
| 2329 | operator. |
| 2330 | |
| 2331 | Given |
| 2332 | struct A { |
| 2333 | A &operator=(const A &); |
| 2334 | A &operator=(A &&); |
| 2335 | }; |
| 2336 | |
| 2337 | cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not |
| 2338 | the second one. |
| 2339 | </pre></td></tr> |
| 2340 | |
| 2341 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2342 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2343 | <tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final. |
| 2344 | |
| 2345 | Given: |
| 2346 | class A final {}; |
| 2347 | |
| 2348 | struct B { |
| 2349 | virtual void f(); |
| 2350 | }; |
| 2351 | |
| 2352 | struct C : B { |
| 2353 | void f() final; |
| 2354 | }; |
| 2355 | matches A and C::f, but not B, C, or B::f |
| 2356 | </pre></td></tr> |
| 2357 | |
| 2358 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2359 | <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> |
Aaron Ballman | 31bde87 | 2016-01-22 22:37:09 +0000 | [diff] [blame] | 2360 | <tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment |
| 2361 | operator. |
| 2362 | |
| 2363 | Given |
Aaron Ballman | a681151 | 2016-01-23 17:49:18 +0000 | [diff] [blame] | 2364 | struct A { |
| 2365 | A &operator=(const A &); |
| 2366 | A &operator=(A &&); |
| 2367 | }; |
| 2368 | |
| 2369 | cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not |
| 2370 | the first one. |
Aaron Ballman | 31bde87 | 2016-01-22 22:37:09 +0000 | [diff] [blame] | 2371 | </pre></td></tr> |
| 2372 | |
| 2373 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2374 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2375 | <tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. |
| 2376 | |
| 2377 | Given |
| 2378 | class A { |
| 2379 | public: |
| 2380 | virtual void x(); |
| 2381 | }; |
| 2382 | class B : public A { |
| 2383 | public: |
| 2384 | virtual void x(); |
| 2385 | }; |
| 2386 | matches B::x |
| 2387 | </pre></td></tr> |
| 2388 | |
| 2389 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2390 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2391 | <tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. |
| 2392 | |
| 2393 | Given |
| 2394 | class A { |
| 2395 | public: |
| 2396 | virtual void x() = 0; |
| 2397 | }; |
| 2398 | matches A::x |
| 2399 | </pre></td></tr> |
| 2400 | |
| 2401 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2402 | <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> |
Alexander Kornienko | 7d20a5a | 2016-04-13 11:13:08 +0000 | [diff] [blame] | 2403 | <tr><td colspan="4" class="doc" id="isUserProvided0"><pre>Matches method declarations that are user-provided. |
| 2404 | |
| 2405 | Given |
| 2406 | struct S { |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 2407 | S(); // #1 |
| 2408 | S(const S &) = default; // #2 |
| 2409 | S(S &&) = delete; // #3 |
Alexander Kornienko | 7d20a5a | 2016-04-13 11:13:08 +0000 | [diff] [blame] | 2410 | }; |
| 2411 | cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3. |
| 2412 | </pre></td></tr> |
| 2413 | |
| 2414 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2415 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2416 | <tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual. |
| 2417 | |
| 2418 | Given |
| 2419 | class A { |
| 2420 | public: |
| 2421 | virtual void x(); |
| 2422 | }; |
| 2423 | matches A::x |
| 2424 | </pre></td></tr> |
| 2425 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2426 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2427 | <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> |
Nico Weber | a415a1d | 2016-01-21 17:56:24 +0000 | [diff] [blame] | 2428 | <tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual". |
| 2429 | |
| 2430 | Given |
| 2431 | class A { |
| 2432 | public: |
| 2433 | virtual void x(); |
| 2434 | }; |
| 2435 | class B : public A { |
| 2436 | public: |
| 2437 | void x(); |
| 2438 | }; |
| 2439 | matches A::x but not B::x |
| 2440 | </pre></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2441 | |
Aaron Ballman | 672dde2 | 2016-01-22 23:15:00 +0000 | [diff] [blame] | 2442 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2443 | <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> |
Adam Balogh | da488a6 | 2017-11-23 12:43:20 +0000 | [diff] [blame] | 2444 | <tr><td colspan="4" class="doc" id="isArray0"><pre>Matches array new expressions. |
| 2445 | |
| 2446 | Given: |
| 2447 | MyClass *p1 = new MyClass[10]; |
| 2448 | cxxNewExpr(isArray()) |
| 2449 | matches the expression 'new MyClass[10]'. |
| 2450 | </pre></td></tr> |
| 2451 | |
| 2452 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2453 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2454 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. |
| 2455 | |
| 2456 | Matches overloaded operator names specified in strings without the |
| 2457 | "operator" prefix: e.g. "<<". |
| 2458 | |
| 2459 | Given: |
| 2460 | class A { int operator*(); }; |
| 2461 | const A &operator<<(const A &a, const A &b); |
| 2462 | A a; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 2463 | a << a; // <-- This matches |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2464 | |
| 2465 | cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the |
| 2466 | specified line and |
| 2467 | cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) |
| 2468 | matches the declaration of A. |
| 2469 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2470 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2471 | </pre></td></tr> |
| 2472 | |
| 2473 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2474 | <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> |
Peter Szecsi | fff11db | 2018-03-27 12:11:46 +0000 | [diff] [blame] | 2475 | <tr><td colspan="4" class="doc" id="isAssignmentOperator1"><pre>Matches all kinds of assignment operators. |
| 2476 | |
| 2477 | Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) |
| 2478 | if (a == b) |
| 2479 | a += b; |
| 2480 | |
Alexander Kornienko | 395ab2e | 2018-04-30 18:12:15 +0000 | [diff] [blame] | 2481 | Example 2: matches s1 = s2 |
| 2482 | (matcher = cxxOperatorCallExpr(isAssignmentOperator())) |
| 2483 | struct S { S& operator=(const S&); }; |
Peter Szecsi | fff11db | 2018-03-27 12:11:46 +0000 | [diff] [blame] | 2484 | void x() { S s1, s2; s1 = s2; }) |
| 2485 | </pre></td></tr> |
| 2486 | |
| 2487 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2488 | <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> |
Aaron Ballman | 813e36c | 2017-11-29 21:21:51 +0000 | [diff] [blame] | 2489 | <tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined. |
| 2490 | |
| 2491 | Example matches x (matcher = cxxRecordDecl(hasDefinition())) |
| 2492 | class x {}; |
| 2493 | class y; |
| 2494 | </pre></td></tr> |
| 2495 | |
| 2496 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2497 | <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isDerivedFrom1')"><a name="isDerivedFrom1Anchor">isDerivedFrom</a></td><td>std::string BaseName</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2498 | <tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). |
| 2499 | </pre></td></tr> |
| 2500 | |
| 2501 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2502 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2503 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or |
| 2504 | static member variable template instantiations. |
| 2505 | |
| 2506 | Given |
| 2507 | template<typename T> void A(T t) { } |
| 2508 | template<> void A(int N) { } |
| 2509 | functionDecl(isExplicitTemplateSpecialization()) |
| 2510 | matches the specialization A<int>(). |
| 2511 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2512 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2513 | </pre></td></tr> |
| 2514 | |
| 2515 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2516 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2517 | <tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final. |
| 2518 | |
| 2519 | Given: |
| 2520 | class A final {}; |
| 2521 | |
| 2522 | struct B { |
| 2523 | virtual void f(); |
| 2524 | }; |
| 2525 | |
| 2526 | struct C : B { |
| 2527 | void f() final; |
| 2528 | }; |
| 2529 | matches A and C::f, but not B, C, or B::f |
| 2530 | </pre></td></tr> |
| 2531 | |
| 2532 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2533 | <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> |
Samuel Benzaquen | 49385c7 | 2016-06-28 14:08:56 +0000 | [diff] [blame] | 2534 | <tr><td colspan="4" class="doc" id="isLambda0"><pre>Matches the generated class of lambda expressions. |
| 2535 | |
| 2536 | Given: |
| 2537 | auto x = []{}; |
| 2538 | |
| 2539 | cxxRecordDecl(isLambda()) matches the implicit class declaration of |
| 2540 | decltype(x) |
| 2541 | </pre></td></tr> |
| 2542 | |
| 2543 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2544 | <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isSameOrDerivedFrom1')"><a name="isSameOrDerivedFrom1Anchor">isSameOrDerivedFrom</a></td><td>std::string BaseName</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2545 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for |
| 2546 | isSameOrDerivedFrom(hasName(...)). |
| 2547 | </pre></td></tr> |
| 2548 | |
| 2549 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2550 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2551 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static |
| 2552 | member variable template instantiations. |
| 2553 | |
| 2554 | Given |
| 2555 | template <typename T> class X {}; class A {}; X<A> x; |
| 2556 | or |
| 2557 | template <typename T> class X {}; class A {}; template class X<A>; |
Eric Liu | 09ee48e | 2018-02-21 14:22:42 +0000 | [diff] [blame] | 2558 | or |
| 2559 | template <typename T> class X {}; class A {}; extern template class X<A>; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2560 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 2561 | matches the template instantiation of X<A>. |
| 2562 | |
| 2563 | But given |
| 2564 | template <typename T> class X {}; class A {}; |
| 2565 | template <> class X<A> {}; X<A> x; |
| 2566 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 2567 | does not match, as X<A> is an explicit template specialization. |
| 2568 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2569 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2570 | </pre></td></tr> |
| 2571 | |
| 2572 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2573 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2574 | <tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has |
| 2575 | a specific number of arguments (including absent default arguments). |
| 2576 | |
| 2577 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 2578 | void f(int x, int y); |
| 2579 | f(0, 0); |
| 2580 | </pre></td></tr> |
| 2581 | |
| 2582 | |
Eric Fiselier | 5cdc2cd | 2018-12-12 21:50:55 +0000 | [diff] [blame] | 2583 | <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> |
| 2584 | <tr><td colspan="4" class="doc" id="usesADL0"><pre>Matches call expressions which were resolved using ADL. |
| 2585 | |
| 2586 | Example matches y(x) but not y(42) or NS::y(x). |
| 2587 | namespace NS { |
| 2588 | struct X {}; |
| 2589 | void y(X); |
| 2590 | } |
| 2591 | |
| 2592 | void y(...); |
| 2593 | |
| 2594 | void test() { |
| 2595 | NS::X x; |
| 2596 | y(x); // Matches |
| 2597 | NS::y(x); // Doesn't match |
| 2598 | y(42); // Doesn't match |
| 2599 | using NS::y; |
| 2600 | y(x); // Found by both unqualified lookup and ADL, doesn't match |
| 2601 | } |
| 2602 | </pre></td></tr> |
| 2603 | |
| 2604 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2605 | <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> |
Etienne Bergeron | 75e5272 | 2016-05-13 19:36:55 +0000 | [diff] [blame] | 2606 | <tr><td colspan="4" class="doc" id="hasCastKind0"><pre>Matches casts that has a given cast kind. |
| 2607 | |
| 2608 | Example: matches the implicit cast around 0 |
| 2609 | (matcher = castExpr(hasCastKind(CK_NullToPointer))) |
| 2610 | int *p = 0; |
| 2611 | </pre></td></tr> |
| 2612 | |
| 2613 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2614 | <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> |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 2615 | <tr><td colspan="4" class="doc" id="equals4"><pre></pre></td></tr> |
| 2616 | |
| 2617 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2618 | <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> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2619 | <tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value of type ValueT. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2620 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2621 | Given |
| 2622 | f('false, 3.14, 42); |
| 2623 | characterLiteral(equals(0)) |
| 2624 | matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) |
| 2625 | match false |
| 2626 | floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) |
| 2627 | match 3.14 |
| 2628 | integerLiteral(equals(42)) |
| 2629 | matches 42 |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2630 | |
Clement Courbet | 43bdba4 | 2017-07-11 15:45:22 +0000 | [diff] [blame] | 2631 | Note that you cannot directly match a negative numeric literal because the |
| 2632 | minus sign is not part of the literal: It is a unary operator whose operand |
| 2633 | is the positive numeric literal. Instead, you must use a unaryOperator() |
| 2634 | matcher to match the minus sign: |
| 2635 | |
| 2636 | unaryOperator(hasOperatorName("-"), |
| 2637 | hasUnaryOperand(integerLiteral(equals(13)))) |
| 2638 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2639 | 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>>, |
| 2640 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2641 | </pre></td></tr> |
| 2642 | |
| 2643 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2644 | <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> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2645 | <tr><td colspan="4" class="doc" id="equals10"><pre></pre></td></tr> |
| 2646 | |
| 2647 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2648 | <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> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2649 | <tr><td colspan="4" class="doc" id="equals7"><pre></pre></td></tr> |
| 2650 | |
| 2651 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2652 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2653 | <tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N. |
| 2654 | |
| 2655 | Given |
| 2656 | template<typename T> struct C {}; |
| 2657 | C<int> c; |
| 2658 | classTemplateSpecializationDecl(templateArgumentCountIs(1)) |
| 2659 | matches C<int>. |
| 2660 | </pre></td></tr> |
| 2661 | |
| 2662 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2663 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2664 | <tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of |
| 2665 | child statements. |
| 2666 | |
| 2667 | Example: Given |
| 2668 | { for (;;) {} } |
| 2669 | compoundStmt(statementCountIs(0))) |
| 2670 | matches '{}' |
| 2671 | but does not match the outer compound statement. |
| 2672 | </pre></td></tr> |
| 2673 | |
| 2674 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2675 | <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> |
Etienne Bergeron | 3588be7 | 2016-05-12 04:20:04 +0000 | [diff] [blame] | 2676 | <tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches nodes that have the specified size. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2677 | |
| 2678 | Given |
| 2679 | int a[42]; |
| 2680 | int b[2 * 21]; |
| 2681 | int c[41], d[43]; |
Etienne Bergeron | 3588be7 | 2016-05-12 04:20:04 +0000 | [diff] [blame] | 2682 | char *s = "abcd"; |
| 2683 | wchar_t *ws = L"abcd"; |
| 2684 | char *w = "a"; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2685 | constantArrayType(hasSize(42)) |
| 2686 | matches "int a[42]" and "int b[2 * 21]" |
Etienne Bergeron | 3588be7 | 2016-05-12 04:20:04 +0000 | [diff] [blame] | 2687 | stringLiteral(hasSize(4)) |
| 2688 | matches "abcd", L"abcd" |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2689 | </pre></td></tr> |
| 2690 | |
| 2691 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2692 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2693 | <tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of |
| 2694 | declarations. |
| 2695 | |
| 2696 | Example: Given |
| 2697 | int a, b; |
| 2698 | int c; |
| 2699 | int d = 2, e; |
| 2700 | declCountIs(2) |
| 2701 | matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. |
| 2702 | </pre></td></tr> |
| 2703 | |
| 2704 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2705 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2706 | <tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. |
| 2707 | |
| 2708 | Matches a node if it equals the node previously bound to ID. |
| 2709 | |
| 2710 | Given |
| 2711 | class X { int a; int b; }; |
| 2712 | cxxRecordDecl( |
| 2713 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 2714 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 2715 | matches the class X, as a and b have the same type. |
| 2716 | |
| 2717 | Note that when multiple matches are involved via forEach* matchers, |
| 2718 | equalsBoundNodes acts as a filter. |
| 2719 | For example: |
| 2720 | compoundStmt( |
| 2721 | forEachDescendant(varDecl().bind("d")), |
| 2722 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 2723 | will trigger a match for each combination of variable declaration |
| 2724 | and reference to that variable declaration within a compound statement. |
| 2725 | </pre></td></tr> |
| 2726 | |
| 2727 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2728 | <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> |
Samuel Benzaquen | a4076ea | 2016-05-04 20:45:00 +0000 | [diff] [blame] | 2729 | <tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node. |
| 2730 | |
| 2731 | Decl has pointer identity in the AST. |
| 2732 | </pre></td></tr> |
| 2733 | |
| 2734 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2735 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2736 | <tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute. |
| 2737 | |
| 2738 | Given |
| 2739 | __attribute__((device)) void f() { ... } |
| 2740 | decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of |
| 2741 | f. If the matcher is use from clang-query, attr::Kind parameter should be |
| 2742 | passed as a quoted string. e.g., hasAttr("attr::CUDADevice"). |
| 2743 | </pre></td></tr> |
| 2744 | |
| 2745 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2746 | <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>std::string RegExp</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2747 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is |
| 2748 | partially matching a given regex. |
| 2749 | |
| 2750 | Example matches Y but not X |
| 2751 | (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 2752 | #include "ASTMatcher.h" |
| 2753 | class X {}; |
| 2754 | ASTMatcher.h: |
| 2755 | class Y {}; |
| 2756 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2757 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2758 | </pre></td></tr> |
| 2759 | |
| 2760 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2761 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2762 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file. |
| 2763 | |
| 2764 | Example matches X but not Y |
| 2765 | (matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 2766 | #include <Y.h> |
| 2767 | class X {}; |
| 2768 | Y.h: |
| 2769 | class Y {}; |
| 2770 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2771 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2772 | </pre></td></tr> |
| 2773 | |
| 2774 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2775 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2776 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files. |
| 2777 | |
| 2778 | Example matches Y but not X |
| 2779 | (matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 2780 | #include <SystemHeader.h> |
| 2781 | class X {}; |
| 2782 | SystemHeader.h: |
| 2783 | class Y {}; |
| 2784 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2785 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2786 | </pre></td></tr> |
| 2787 | |
| 2788 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2789 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2790 | <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 2791 | by the compiler (eg. implicit default/copy constructors). |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2792 | </pre></td></tr> |
| 2793 | |
| 2794 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2795 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2796 | <tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. |
| 2797 | |
| 2798 | Given |
| 2799 | class C { |
| 2800 | public: int a; |
| 2801 | protected: int b; |
| 2802 | private: int c; |
| 2803 | }; |
| 2804 | fieldDecl(isPrivate()) |
Cong Liu | 8a02efb | 2016-06-24 09:38:03 +0000 | [diff] [blame] | 2805 | matches 'int c;' |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2806 | </pre></td></tr> |
| 2807 | |
| 2808 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2809 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2810 | <tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. |
| 2811 | |
| 2812 | Given |
| 2813 | class C { |
| 2814 | public: int a; |
| 2815 | protected: int b; |
| 2816 | private: int c; |
| 2817 | }; |
| 2818 | fieldDecl(isProtected()) |
Cong Liu | 8a02efb | 2016-06-24 09:38:03 +0000 | [diff] [blame] | 2819 | matches 'int b;' |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2820 | </pre></td></tr> |
| 2821 | |
| 2822 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2823 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2824 | <tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. |
| 2825 | |
| 2826 | Given |
| 2827 | class C { |
| 2828 | public: int a; |
| 2829 | protected: int b; |
| 2830 | private: int c; |
| 2831 | }; |
| 2832 | fieldDecl(isPublic()) |
Cong Liu | 8a02efb | 2016-06-24 09:38:03 +0000 | [diff] [blame] | 2833 | matches 'int a;' |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2834 | </pre></td></tr> |
| 2835 | |
| 2836 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2837 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 2838 | <tr><td colspan="4" class="doc" id="designatorCountIs0"><pre>Matches designated initializer expressions that contain |
| 2839 | a specific number of designators. |
| 2840 | |
| 2841 | Example: Given |
| 2842 | point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; |
| 2843 | point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }; |
| 2844 | designatorCountIs(2) |
| 2845 | matches '{ [2].y = 1.0, [0].x = 1.0 }', |
| 2846 | but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'. |
| 2847 | </pre></td></tr> |
| 2848 | |
| 2849 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2850 | <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> |
Haojian Wu | 9c3be3a | 2018-01-18 09:47:57 +0000 | [diff] [blame] | 2851 | <tr><td colspan="4" class="doc" id="isScoped0"><pre>Matches C++11 scoped enum declaration. |
| 2852 | |
| 2853 | Example matches Y (matcher = enumDecl(isScoped())) |
| 2854 | enum X {}; |
| 2855 | enum class Y {}; |
| 2856 | </pre></td></tr> |
| 2857 | |
| 2858 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2859 | <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> |
Jonas Toth | 2253878 | 2018-09-11 16:09:19 +0000 | [diff] [blame] | 2860 | <tr><td colspan="4" class="doc" id="isInstantiationDependent0"><pre>Matches expressions that are instantiation-dependent even if it is |
| 2861 | neither type- nor value-dependent. |
| 2862 | |
| 2863 | In the following example, the expression sizeof(sizeof(T() + T())) |
| 2864 | is instantiation-dependent (since it involves a template parameter T), |
| 2865 | but is neither type- nor value-dependent, since the type of the inner |
| 2866 | sizeof is known (std::size_t) and therefore the size of the outer |
| 2867 | sizeof is known. |
| 2868 | template<typename T> |
| 2869 | void f(T x, T y) { sizeof(sizeof(T() + T()); } |
| 2870 | expr(isInstantiationDependent()) matches sizeof(sizeof(T() + T()) |
| 2871 | </pre></td></tr> |
| 2872 | |
| 2873 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2874 | <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> |
Jonas Toth | 2253878 | 2018-09-11 16:09:19 +0000 | [diff] [blame] | 2875 | <tr><td colspan="4" class="doc" id="isTypeDependent0"><pre>Matches expressions that are type-dependent because the template type |
| 2876 | is not yet instantiated. |
| 2877 | |
| 2878 | For example, the expressions "x" and "x + y" are type-dependent in |
| 2879 | the following code, but "y" is not type-dependent: |
| 2880 | template<typename T> |
| 2881 | void add(T x, int y) { |
| 2882 | x + y; |
| 2883 | } |
| 2884 | expr(isTypeDependent()) matches x + y |
| 2885 | </pre></td></tr> |
| 2886 | |
| 2887 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2888 | <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> |
Jonas Toth | 2253878 | 2018-09-11 16:09:19 +0000 | [diff] [blame] | 2889 | <tr><td colspan="4" class="doc" id="isValueDependent0"><pre>Matches expression that are value-dependent because they contain a |
| 2890 | non-type template parameter. |
| 2891 | |
| 2892 | For example, the array bound of "Chars" in the following example is |
| 2893 | value-dependent. |
| 2894 | template<int Size> int f() { return Size; } |
| 2895 | expr(isValueDependent()) matches return Size |
| 2896 | </pre></td></tr> |
| 2897 | |
| 2898 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2899 | <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> |
Malcolm Parsons | 81e48b2 | 2016-12-24 13:22:26 +0000 | [diff] [blame] | 2900 | <tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified |
| 2901 | bit width. |
Aaron Ballman | 5c57434 | 2016-07-06 18:25:16 +0000 | [diff] [blame] | 2902 | |
| 2903 | Given |
| 2904 | class C { |
| 2905 | int a : 2; |
| 2906 | int b : 4; |
| 2907 | int c : 2; |
| 2908 | }; |
Malcolm Parsons | 81e48b2 | 2016-12-24 13:22:26 +0000 | [diff] [blame] | 2909 | fieldDecl(hasBitWidth(2)) |
Aaron Ballman | 5c57434 | 2016-07-06 18:25:16 +0000 | [diff] [blame] | 2910 | matches 'int a;' and 'int c;' but not 'int b;'. |
| 2911 | </pre></td></tr> |
| 2912 | |
| 2913 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2914 | <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> |
Aaron Ballman | 5c57434 | 2016-07-06 18:25:16 +0000 | [diff] [blame] | 2915 | <tr><td colspan="4" class="doc" id="isBitField0"><pre>Matches non-static data members that are bit-fields. |
| 2916 | |
| 2917 | Given |
| 2918 | class C { |
| 2919 | int a : 2; |
| 2920 | int b; |
| 2921 | }; |
| 2922 | fieldDecl(isBitField()) |
| 2923 | matches 'int a;' but not 'int b;'. |
| 2924 | </pre></td></tr> |
| 2925 | |
| 2926 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2927 | <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> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2928 | <tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value of type ValueT. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2929 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2930 | Given |
| 2931 | f('false, 3.14, 42); |
| 2932 | characterLiteral(equals(0)) |
| 2933 | matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) |
| 2934 | match false |
| 2935 | floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) |
| 2936 | match 3.14 |
| 2937 | integerLiteral(equals(42)) |
| 2938 | matches 42 |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2939 | |
Clement Courbet | 43bdba4 | 2017-07-11 15:45:22 +0000 | [diff] [blame] | 2940 | Note that you cannot directly match a negative numeric literal because the |
| 2941 | minus sign is not part of the literal: It is a unary operator whose operand |
| 2942 | is the positive numeric literal. Instead, you must use a unaryOperator() |
| 2943 | matcher to match the minus sign: |
| 2944 | |
| 2945 | unaryOperator(hasOperatorName("-"), |
| 2946 | hasUnaryOperand(integerLiteral(equals(13)))) |
| 2947 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2948 | 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>>, |
| 2949 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2950 | </pre></td></tr> |
| 2951 | |
| 2952 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2953 | <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> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 2954 | <tr><td colspan="4" class="doc" id="equals12"><pre></pre></td></tr> |
| 2955 | |
| 2956 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2957 | <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> |
Aaron Ballman | abdbbbc | 2016-05-16 16:49:01 +0000 | [diff] [blame] | 2958 | <tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification. |
| 2959 | |
| 2960 | Given: |
| 2961 | void f(); |
| 2962 | void g() noexcept; |
| 2963 | void h() noexcept(true); |
| 2964 | void i() noexcept(false); |
| 2965 | void j() throw(); |
| 2966 | void k() throw(int); |
| 2967 | void l() throw(...); |
Aaron Ballman | 230ad97 | 2016-06-07 17:34:45 +0000 | [diff] [blame] | 2968 | functionDecl(hasDynamicExceptionSpec()) and |
| 2969 | functionProtoType(hasDynamicExceptionSpec()) |
| 2970 | match the declarations of j, k, and l, but not f, g, h, or i. |
Aaron Ballman | abdbbbc | 2016-05-16 16:49:01 +0000 | [diff] [blame] | 2971 | </pre></td></tr> |
| 2972 | |
| 2973 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2974 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2975 | <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. |
| 2976 | |
| 2977 | Matches overloaded operator names specified in strings without the |
| 2978 | "operator" prefix: e.g. "<<". |
| 2979 | |
| 2980 | Given: |
| 2981 | class A { int operator*(); }; |
| 2982 | const A &operator<<(const A &a, const A &b); |
| 2983 | A a; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 2984 | a << a; // <-- This matches |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2985 | |
| 2986 | cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the |
| 2987 | specified line and |
| 2988 | cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) |
| 2989 | matches the declaration of A. |
| 2990 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2991 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 2992 | </pre></td></tr> |
| 2993 | |
| 2994 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 2995 | <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> |
Julie Hockett | 239d25a | 2018-01-22 22:45:23 +0000 | [diff] [blame] | 2996 | <tr><td colspan="4" class="doc" id="hasTrailingReturn0"><pre>Matches a function declared with a trailing return type. |
| 2997 | |
| 2998 | Example matches Y (matcher = functionDecl(hasTrailingReturn())) |
| 2999 | int X() {} |
| 3000 | auto Y() -> int {} |
| 3001 | </pre></td></tr> |
| 3002 | |
| 3003 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3004 | <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> |
Gabor Horvath | 3cd0aa3 | 2018-05-08 11:53:32 +0000 | [diff] [blame] | 3005 | <tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations, |
| 3006 | and if constexpr. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3007 | |
| 3008 | Given: |
| 3009 | constexpr int foo = 42; |
| 3010 | constexpr int bar(); |
Gabor Horvath | 3cd0aa3 | 2018-05-08 11:53:32 +0000 | [diff] [blame] | 3011 | void baz() { if constexpr(1 > 0) {} } |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3012 | varDecl(isConstexpr()) |
| 3013 | matches the declaration of foo. |
| 3014 | functionDecl(isConstexpr()) |
| 3015 | matches the declaration of bar. |
Gabor Horvath | 3cd0aa3 | 2018-05-08 11:53:32 +0000 | [diff] [blame] | 3016 | ifStmt(isConstexpr()) |
| 3017 | matches the if statement in baz. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3018 | </pre></td></tr> |
| 3019 | |
| 3020 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3021 | <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> |
Aaron Ballman | c35724c | 2016-01-21 15:18:25 +0000 | [diff] [blame] | 3022 | <tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations. |
| 3023 | |
| 3024 | Given: |
| 3025 | class A { ~A(); }; |
| 3026 | class B { ~B() = default; }; |
| 3027 | functionDecl(isDefaulted()) |
| 3028 | matches the declaration of ~B, but not ~A. |
| 3029 | </pre></td></tr> |
| 3030 | |
| 3031 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3032 | <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> |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 3033 | <tr><td colspan="4" class="doc" id="isDefinition3"><pre>Matches if a declaration has a body attached. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3034 | |
| 3035 | Example matches A, va, fa |
| 3036 | class A {}; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3037 | class B; // Doesn't match, as it has no body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3038 | int va; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3039 | extern int vb; // Doesn't match, as it doesn't define the variable. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3040 | void fa() {} |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3041 | void fb(); // Doesn't match, as it has no body. |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 3042 | @interface X |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3043 | - (void)ma; // Doesn't match, interface is declaration. |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 3044 | @end |
| 3045 | @implementation X |
| 3046 | - (void)ma {} |
| 3047 | @end |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3048 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3049 | 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>>, |
| 3050 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3051 | </pre></td></tr> |
| 3052 | |
| 3053 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3054 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3055 | <tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. |
| 3056 | |
| 3057 | Given: |
| 3058 | void Func(); |
| 3059 | void DeletedFunc() = delete; |
| 3060 | functionDecl(isDeleted()) |
| 3061 | matches the declaration of DeletedFunc, but not Func. |
| 3062 | </pre></td></tr> |
| 3063 | |
| 3064 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3065 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3066 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or |
| 3067 | static member variable template instantiations. |
| 3068 | |
| 3069 | Given |
| 3070 | template<typename T> void A(T t) { } |
| 3071 | template<> void A(int N) { } |
| 3072 | functionDecl(isExplicitTemplateSpecialization()) |
| 3073 | matches the specialization A<int>(). |
| 3074 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3075 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3076 | </pre></td></tr> |
| 3077 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 3078 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3079 | <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> |
Alexander Shaposhnikov | f681c4e | 2017-09-22 19:29:38 +0000 | [diff] [blame] | 3080 | <tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function or variable declarations. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3081 | |
| 3082 | Given: |
| 3083 | extern "C" void f() {} |
| 3084 | extern "C" { void g() {} } |
| 3085 | void h() {} |
Alexander Shaposhnikov | f681c4e | 2017-09-22 19:29:38 +0000 | [diff] [blame] | 3086 | extern "C" int x = 1; |
| 3087 | extern "C" int y = 2; |
| 3088 | int z = 3; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3089 | functionDecl(isExternC()) |
Alexander Shaposhnikov | f681c4e | 2017-09-22 19:29:38 +0000 | [diff] [blame] | 3090 | matches the declaration of f and g, but not the declaration of h. |
| 3091 | varDecl(isExternC()) |
| 3092 | matches the declaration of x and y, but not the declaration of z. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3093 | </pre></td></tr> |
| 3094 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 3095 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3096 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3097 | <tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with |
| 3098 | the inline keyword. |
| 3099 | |
| 3100 | Given |
| 3101 | inline void f(); |
| 3102 | void g(); |
| 3103 | namespace n { |
| 3104 | inline namespace m {} |
| 3105 | } |
| 3106 | functionDecl(isInline()) will match ::f(). |
| 3107 | namespaceDecl(isInline()) will match n::m. |
| 3108 | </pre></td></tr> |
| 3109 | |
| 3110 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3111 | <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> |
George Karpenkov | fc3d72e | 2018-07-23 22:29:35 +0000 | [diff] [blame] | 3112 | <tr><td colspan="4" class="doc" id="isMain0"><pre>Determines whether the function is "main", which is the entry point |
| 3113 | into an executable program. |
| 3114 | </pre></td></tr> |
| 3115 | |
| 3116 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3117 | <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> |
Roman Lebedev | 6c3871b | 2018-01-17 19:40:55 +0000 | [diff] [blame] | 3118 | <tr><td colspan="4" class="doc" id="isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute. |
| 3119 | |
| 3120 | Given |
| 3121 | void nope(); |
| 3122 | [[noreturn]] void a(); |
| 3123 | __attribute__((noreturn)) void b(); |
| 3124 | struct c { [[noreturn]] c(); }; |
| 3125 | functionDecl(isNoReturn()) |
| 3126 | matches all of those except |
| 3127 | void nope(); |
| 3128 | </pre></td></tr> |
| 3129 | |
| 3130 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3131 | <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> |
Aaron Ballman | a60bcda | 2015-12-02 15:23:59 +0000 | [diff] [blame] | 3132 | <tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification. |
| 3133 | |
| 3134 | Given: |
| 3135 | void f(); |
| 3136 | void g() noexcept; |
| 3137 | void h() throw(); |
| 3138 | void i() throw(int); |
| 3139 | void j() noexcept(false); |
Aaron Ballman | 230ad97 | 2016-06-07 17:34:45 +0000 | [diff] [blame] | 3140 | functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) |
| 3141 | match the declarations of g, and h, but not f, i or j. |
Aaron Ballman | a60bcda | 2015-12-02 15:23:59 +0000 | [diff] [blame] | 3142 | </pre></td></tr> |
| 3143 | |
| 3144 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3145 | <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> |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3146 | <tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variable/function declarations that have "static" storage |
Haojian Wu | 398a8ea | 2016-09-27 07:53:20 +0000 | [diff] [blame] | 3147 | class specifier ("static" keyword) written in the source. |
Haojian Wu | b3d2546 | 2016-09-26 16:01:52 +0000 | [diff] [blame] | 3148 | |
| 3149 | Given: |
| 3150 | static void f() {} |
| 3151 | static int i = 0; |
Haojian Wu | 398a8ea | 2016-09-27 07:53:20 +0000 | [diff] [blame] | 3152 | extern int j; |
| 3153 | int k; |
Haojian Wu | b3d2546 | 2016-09-26 16:01:52 +0000 | [diff] [blame] | 3154 | functionDecl(isStaticStorageClass()) |
| 3155 | matches the function declaration f. |
| 3156 | varDecl(isStaticStorageClass()) |
| 3157 | matches the variable declaration i. |
| 3158 | </pre></td></tr> |
| 3159 | |
| 3160 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3161 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3162 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static |
| 3163 | member variable template instantiations. |
| 3164 | |
| 3165 | Given |
| 3166 | template <typename T> class X {}; class A {}; X<A> x; |
| 3167 | or |
| 3168 | template <typename T> class X {}; class A {}; template class X<A>; |
Eric Liu | 09ee48e | 2018-02-21 14:22:42 +0000 | [diff] [blame] | 3169 | or |
| 3170 | template <typename T> class X {}; class A {}; extern template class X<A>; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3171 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 3172 | matches the template instantiation of X<A>. |
| 3173 | |
| 3174 | But given |
| 3175 | template <typename T> class X {}; class A {}; |
| 3176 | template <> class X<A> {}; X<A> x; |
| 3177 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 3178 | does not match, as X<A> is an explicit template specialization. |
| 3179 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3180 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3181 | </pre></td></tr> |
| 3182 | |
| 3183 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3184 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3185 | <tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic. |
| 3186 | |
| 3187 | Example matches f, but not g or h. The function i will not match, even when |
| 3188 | compiled in C mode. |
| 3189 | void f(...); |
| 3190 | void g(int); |
| 3191 | template <typename... Ts> void h(Ts...); |
| 3192 | void i(); |
| 3193 | </pre></td></tr> |
| 3194 | |
| 3195 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3196 | <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> |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3197 | <tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a |
| 3198 | specific parameter count. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3199 | |
| 3200 | Given |
| 3201 | void f(int i) {} |
| 3202 | void g(int i, int j) {} |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3203 | void h(int i, int j); |
| 3204 | void j(int i); |
| 3205 | void k(int x, int y, int z, ...); |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3206 | functionDecl(parameterCountIs(2)) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3207 | matches g and h |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3208 | functionProtoType(parameterCountIs(2)) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3209 | matches g and h |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3210 | functionProtoType(parameterCountIs(3)) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3211 | matches k |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3212 | </pre></td></tr> |
| 3213 | |
| 3214 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3215 | <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> |
Aaron Ballman | 230ad97 | 2016-06-07 17:34:45 +0000 | [diff] [blame] | 3216 | <tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification. |
| 3217 | |
| 3218 | Given: |
| 3219 | void f(); |
| 3220 | void g() noexcept; |
| 3221 | void h() noexcept(true); |
| 3222 | void i() noexcept(false); |
| 3223 | void j() throw(); |
| 3224 | void k() throw(int); |
| 3225 | void l() throw(...); |
| 3226 | functionDecl(hasDynamicExceptionSpec()) and |
| 3227 | functionProtoType(hasDynamicExceptionSpec()) |
| 3228 | match the declarations of j, k, and l, but not f, g, h, or i. |
| 3229 | </pre></td></tr> |
| 3230 | |
| 3231 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3232 | <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> |
Aaron Ballman | 230ad97 | 2016-06-07 17:34:45 +0000 | [diff] [blame] | 3233 | <tr><td colspan="4" class="doc" id="isNoThrow1"><pre>Matches functions that have a non-throwing exception specification. |
| 3234 | |
| 3235 | Given: |
| 3236 | void f(); |
| 3237 | void g() noexcept; |
| 3238 | void h() throw(); |
| 3239 | void i() throw(int); |
| 3240 | void j() noexcept(false); |
| 3241 | functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) |
| 3242 | match the declarations of g, and h, but not f, i or j. |
| 3243 | </pre></td></tr> |
| 3244 | |
| 3245 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3246 | <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> |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3247 | <tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a |
| 3248 | specific parameter count. |
| 3249 | |
| 3250 | Given |
| 3251 | void f(int i) {} |
| 3252 | void g(int i, int j) {} |
| 3253 | void h(int i, int j); |
| 3254 | void j(int i); |
| 3255 | void k(int x, int y, int z, ...); |
| 3256 | functionDecl(parameterCountIs(2)) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3257 | matches g and h |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3258 | functionProtoType(parameterCountIs(2)) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3259 | matches g and h |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 3260 | functionProtoType(parameterCountIs(3)) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3261 | matches k |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3262 | </pre></td></tr> |
| 3263 | |
| 3264 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3265 | <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> |
Gabor Horvath | 3cd0aa3 | 2018-05-08 11:53:32 +0000 | [diff] [blame] | 3266 | <tr><td colspan="4" class="doc" id="isConstexpr2"><pre>Matches constexpr variable and function declarations, |
| 3267 | and if constexpr. |
| 3268 | |
| 3269 | Given: |
| 3270 | constexpr int foo = 42; |
| 3271 | constexpr int bar(); |
| 3272 | void baz() { if constexpr(1 > 0) {} } |
| 3273 | varDecl(isConstexpr()) |
| 3274 | matches the declaration of foo. |
| 3275 | functionDecl(isConstexpr()) |
| 3276 | matches the declaration of bar. |
| 3277 | ifStmt(isConstexpr()) |
| 3278 | matches the if statement in baz. |
| 3279 | </pre></td></tr> |
| 3280 | |
| 3281 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3282 | <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> |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 3283 | <tr><td colspan="4" class="doc" id="equals6"><pre></pre></td></tr> |
| 3284 | |
| 3285 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3286 | <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> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 3287 | <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value of type ValueT. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3288 | |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 3289 | Given |
| 3290 | f('false, 3.14, 42); |
| 3291 | characterLiteral(equals(0)) |
| 3292 | matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) |
| 3293 | match false |
| 3294 | floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) |
| 3295 | match 3.14 |
| 3296 | integerLiteral(equals(42)) |
| 3297 | matches 42 |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3298 | |
Clement Courbet | 43bdba4 | 2017-07-11 15:45:22 +0000 | [diff] [blame] | 3299 | Note that you cannot directly match a negative numeric literal because the |
| 3300 | minus sign is not part of the literal: It is a unary operator whose operand |
| 3301 | is the positive numeric literal. Instead, you must use a unaryOperator() |
| 3302 | matcher to match the minus sign: |
| 3303 | |
| 3304 | unaryOperator(hasOperatorName("-"), |
| 3305 | hasUnaryOperand(integerLiteral(equals(13)))) |
| 3306 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3307 | 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>>, |
| 3308 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3309 | </pre></td></tr> |
| 3310 | |
| 3311 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3312 | <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> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 3313 | <tr><td colspan="4" class="doc" id="equals13"><pre></pre></td></tr> |
| 3314 | |
| 3315 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3316 | <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> |
Peter Wu | a9244b5 | 2017-06-08 22:00:58 +0000 | [diff] [blame] | 3317 | <tr><td colspan="4" class="doc" id="equals9"><pre></pre></td></tr> |
| 3318 | |
| 3319 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3320 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3321 | <tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed |
| 3322 | to '.'. |
| 3323 | |
| 3324 | Member calls on the implicit this pointer match as called with '->'. |
| 3325 | |
| 3326 | Given |
| 3327 | class Y { |
| 3328 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
Shuai Wang | e0248ae | 2018-09-17 18:48:43 +0000 | [diff] [blame] | 3329 | template <class T> void f() { this->f<T>(); f<T>(); } |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3330 | int a; |
| 3331 | static int b; |
| 3332 | }; |
Shuai Wang | e0248ae | 2018-09-17 18:48:43 +0000 | [diff] [blame] | 3333 | template <class T> |
| 3334 | class Z { |
| 3335 | void x() { this->m; } |
| 3336 | }; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3337 | memberExpr(isArrow()) |
| 3338 | matches this->x, x, y.x, a, this->b |
Shuai Wang | e0248ae | 2018-09-17 18:48:43 +0000 | [diff] [blame] | 3339 | cxxDependentScopeMemberExpr(isArrow()) |
| 3340 | matches this->m |
| 3341 | unresolvedMemberExpr(isArrow()) |
| 3342 | matches this->f<T>, f<T> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3343 | </pre></td></tr> |
| 3344 | |
| 3345 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3346 | <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> |
Aaron Ballman | a086b9f | 2016-08-17 13:10:42 +0000 | [diff] [blame] | 3347 | <tr><td colspan="4" class="doc" id="hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage. |
| 3348 | |
| 3349 | Example matches only z (matcher = varDecl(hasExternalFormalLinkage())) |
| 3350 | void f() { |
| 3351 | int x; |
| 3352 | static int y; |
| 3353 | } |
| 3354 | int z; |
| 3355 | |
| 3356 | Example matches f() because it has external formal linkage despite being |
| 3357 | unique to the translation unit as though it has internal likage |
| 3358 | (matcher = functionDecl(hasExternalFormalLinkage())) |
| 3359 | |
| 3360 | namespace { |
| 3361 | void f() {} |
| 3362 | } |
| 3363 | </pre></td></tr> |
| 3364 | |
| 3365 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3366 | <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>const std::string Name</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3367 | <tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. |
| 3368 | |
| 3369 | Supports specifying enclosing namespaces or classes by prefixing the name |
| 3370 | with '<enclosing>::'. |
| 3371 | Does not match typedefs of an underlying type with the given name. |
| 3372 | |
| 3373 | Example matches X (Name == "X") |
| 3374 | class X; |
| 3375 | |
| 3376 | Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") |
| 3377 | namespace a { namespace b { class X; } } |
| 3378 | </pre></td></tr> |
| 3379 | |
| 3380 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3381 | <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>std::string RegExp</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3382 | <tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain |
| 3383 | a substring matched by the given RegExp. |
| 3384 | |
| 3385 | Supports specifying enclosing namespaces or classes by |
| 3386 | prefixing the name with '<enclosing>::'. Does not match typedefs |
| 3387 | of an underlying type with the given name. |
| 3388 | |
| 3389 | Example matches X (regexp == "::X") |
| 3390 | class X; |
| 3391 | |
| 3392 | Example matches X (regexp is one of "::X", "^foo::.*X", among others) |
| 3393 | namespace foo { namespace bar { class X; } } |
| 3394 | </pre></td></tr> |
| 3395 | |
| 3396 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3397 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3398 | <tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. |
| 3399 | |
| 3400 | Given |
| 3401 | namespace n { |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3402 | namespace {} // #1 |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3403 | } |
| 3404 | namespaceDecl(isAnonymous()) will match #1 but not ::n. |
| 3405 | </pre></td></tr> |
| 3406 | |
| 3407 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3408 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3409 | <tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with |
| 3410 | the inline keyword. |
| 3411 | |
| 3412 | Given |
| 3413 | inline void f(); |
| 3414 | void g(); |
| 3415 | namespace n { |
| 3416 | inline namespace m {} |
| 3417 | } |
| 3418 | functionDecl(isInline()) will match ::f(). |
| 3419 | namespaceDecl(isInline()) will match n::m. |
| 3420 | </pre></td></tr> |
| 3421 | |
| 3422 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3423 | <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('argumentCountIs2')"><a name="argumentCountIs2Anchor">argumentCountIs</a></td><td>unsigned N</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3424 | <tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has |
| 3425 | a specific number of arguments (including absent default arguments). |
| 3426 | |
| 3427 | Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) |
| 3428 | void f(int x, int y); |
| 3429 | f(0, 0); |
| 3430 | </pre></td></tr> |
| 3431 | |
| 3432 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3433 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3434 | <tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector |
| 3435 | |
| 3436 | objCMessageExpr(hasKeywordSelector()) matches the generated setFrame |
| 3437 | message expression in |
| 3438 | |
| 3439 | UIWebView *webView = ...; |
| 3440 | CGRect bodyFrame = webView.frame; |
| 3441 | bodyFrame.size.height = self.bodyContentHeight; |
| 3442 | webView.frame = bodyFrame; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3443 | // ^---- matches here |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3444 | </pre></td></tr> |
| 3445 | |
| 3446 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3447 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3448 | <tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector |
| 3449 | |
| 3450 | Matches only when the selector of the objCMessageExpr is NULL. This may |
| 3451 | represent an error condition in the tree! |
| 3452 | </pre></td></tr> |
| 3453 | |
| 3454 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3455 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3456 | <tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() |
| 3457 | |
| 3458 | matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); |
| 3459 | matches the outer message expr in the code below, but NOT the message |
| 3460 | invocation for self.bodyView. |
| 3461 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 3462 | </pre></td></tr> |
| 3463 | |
| 3464 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3465 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3466 | <tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector |
| 3467 | |
| 3468 | matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); |
| 3469 | matches self.bodyView in the code below, but NOT the outer message |
| 3470 | invocation of "loadHTMLString:baseURL:". |
| 3471 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 3472 | </pre></td></tr> |
| 3473 | |
| 3474 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3475 | <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> |
George Karpenkov | b5ea4df | 2018-07-16 20:22:12 +0000 | [diff] [blame] | 3476 | <tr><td colspan="4" class="doc" id="isInstanceMessage0"><pre>Returns true when the Objective-C message is sent to an instance. |
| 3477 | |
| 3478 | Example |
| 3479 | matcher = objcMessagaeExpr(isInstanceMessage()) |
| 3480 | matches |
| 3481 | NSString *x = @"hello"; |
George Karpenkov | daac52c | 2018-07-23 22:29:10 +0000 | [diff] [blame] | 3482 | [x containsString:@"h"]; |
George Karpenkov | b5ea4df | 2018-07-16 20:22:12 +0000 | [diff] [blame] | 3483 | but not |
George Karpenkov | daac52c | 2018-07-23 22:29:10 +0000 | [diff] [blame] | 3484 | [NSString stringWithFormat:@"format"]; |
George Karpenkov | b5ea4df | 2018-07-16 20:22:12 +0000 | [diff] [blame] | 3485 | </pre></td></tr> |
| 3486 | |
| 3487 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3488 | <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>std::string RegExp</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3489 | <tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains |
| 3490 | a substring matched by the given RegExp. |
| 3491 | matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message |
| 3492 | invocation for self.bodyView. |
| 3493 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 3494 | </pre></td></tr> |
| 3495 | |
| 3496 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3497 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3498 | <tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments |
| 3499 | |
| 3500 | matcher = objCMessageExpr(numSelectorArgs(0)); |
| 3501 | matches self.bodyView in the code below |
| 3502 | |
| 3503 | matcher = objCMessageExpr(numSelectorArgs(2)); |
| 3504 | matches the invocation of "loadHTMLString:baseURL:" but not that |
| 3505 | of self.bodyView |
| 3506 | [self.bodyView loadHTMLString:html baseURL:NULL]; |
| 3507 | </pre></td></tr> |
| 3508 | |
| 3509 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3510 | <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> |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 3511 | <tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. |
| 3512 | |
| 3513 | Example matches A, va, fa |
| 3514 | class A {}; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3515 | class B; // Doesn't match, as it has no body. |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 3516 | int va; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3517 | extern int vb; // Doesn't match, as it doesn't define the variable. |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 3518 | void fa() {} |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3519 | void fb(); // Doesn't match, as it has no body. |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 3520 | @interface X |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3521 | - (void)ma; // Doesn't match, interface is declaration. |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 3522 | @end |
| 3523 | @implementation X |
| 3524 | - (void)ma {} |
| 3525 | @end |
| 3526 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3527 | 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>>, |
| 3528 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 3529 | </pre></td></tr> |
| 3530 | |
| 3531 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3532 | <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> |
Aaron Ballman | 5f8980a | 2017-11-21 19:22:34 +0000 | [diff] [blame] | 3533 | <tr><td colspan="4" class="doc" id="hasDefaultArgument0"><pre>Matches a declaration that has default arguments. |
| 3534 | |
| 3535 | Example matches y (matcher = parmVarDecl(hasDefaultArgument())) |
| 3536 | void x(int val) {} |
| 3537 | void y(int val = 0) {} |
| 3538 | </pre></td></tr> |
| 3539 | |
| 3540 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3541 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3542 | <tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. |
| 3543 | |
| 3544 | Given |
| 3545 | class Y { public: void x(); }; |
| 3546 | void z() { Y* y; y->x(); } |
| 3547 | cxxMemberCallExpr(on(hasType(asString("class Y *")))) |
| 3548 | matches y->x() |
| 3549 | </pre></td></tr> |
| 3550 | |
| 3551 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3552 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3553 | <tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. |
| 3554 | |
| 3555 | Matches a node if it equals the node previously bound to ID. |
| 3556 | |
| 3557 | Given |
| 3558 | class X { int a; int b; }; |
| 3559 | cxxRecordDecl( |
| 3560 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 3561 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 3562 | matches the class X, as a and b have the same type. |
| 3563 | |
| 3564 | Note that when multiple matches are involved via forEach* matchers, |
| 3565 | equalsBoundNodes acts as a filter. |
| 3566 | For example: |
| 3567 | compoundStmt( |
| 3568 | forEachDescendant(varDecl().bind("d")), |
| 3569 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 3570 | will trigger a match for each combination of variable declaration |
| 3571 | and reference to that variable declaration within a compound statement. |
| 3572 | </pre></td></tr> |
| 3573 | |
| 3574 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3575 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3576 | <tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to |
| 3577 | the node, not hidden within a typedef. |
| 3578 | |
| 3579 | Given |
| 3580 | typedef const int const_int; |
| 3581 | const_int i; |
| 3582 | int *const j; |
| 3583 | int *volatile k; |
| 3584 | int m; |
| 3585 | varDecl(hasType(hasLocalQualifiers())) matches only j and k. |
| 3586 | i is const-qualified but the qualifier is not local. |
| 3587 | </pre></td></tr> |
| 3588 | |
| 3589 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3590 | <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> |
Samuel Benzaquen | 30747f7 | 2015-12-22 21:06:36 +0000 | [diff] [blame] | 3591 | <tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type. |
| 3592 | |
| 3593 | Given |
| 3594 | void a(char); |
| 3595 | void b(wchar_t); |
| 3596 | void c(double); |
| 3597 | functionDecl(hasAnyParameter(hasType(isAnyCharacter()))) |
| 3598 | matches "a(char)", "b(wchar_t)", but not "c(double)". |
| 3599 | </pre></td></tr> |
| 3600 | |
| 3601 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3602 | <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> |
Alexander Kornienko | 7d20a5a | 2016-04-13 11:13:08 +0000 | [diff] [blame] | 3603 | <tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type; this includes |
| 3604 | the Objective-C object pointer type, which is different despite being |
| 3605 | syntactically similar. |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 3606 | |
| 3607 | Given |
| 3608 | int *i = nullptr; |
Alexander Kornienko | 7d20a5a | 2016-04-13 11:13:08 +0000 | [diff] [blame] | 3609 | |
| 3610 | @interface Foo |
| 3611 | @end |
| 3612 | Foo *f; |
| 3613 | |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 3614 | int j; |
| 3615 | varDecl(hasType(isAnyPointer())) |
Alexander Kornienko | 7d20a5a | 2016-04-13 11:13:08 +0000 | [diff] [blame] | 3616 | matches "int *i" and "Foo *f", but not "int j". |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 3617 | </pre></td></tr> |
| 3618 | |
| 3619 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3620 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3621 | <tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that |
| 3622 | include "top-level" const. |
| 3623 | |
| 3624 | Given |
| 3625 | void a(int); |
| 3626 | void b(int const); |
| 3627 | void c(const int); |
| 3628 | void d(const int*); |
| 3629 | void e(int const) {}; |
| 3630 | functionDecl(hasAnyParameter(hasType(isConstQualified()))) |
| 3631 | matches "void b(int const)", "void c(const int)" and |
| 3632 | "void e(int const) {}". It does not match d as there |
| 3633 | is no top-level const on the parameter type "const int *". |
| 3634 | </pre></td></tr> |
| 3635 | |
| 3636 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3637 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3638 | <tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. |
| 3639 | |
| 3640 | Given |
| 3641 | void a(int); |
| 3642 | void b(long); |
| 3643 | void c(double); |
| 3644 | functionDecl(hasAnyParameter(hasType(isInteger()))) |
| 3645 | matches "a(int)", "b(long)", but not "c(double)". |
| 3646 | </pre></td></tr> |
| 3647 | |
| 3648 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3649 | <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> |
Clement Courbet | 4251759 | 2016-07-12 06:36:00 +0000 | [diff] [blame] | 3650 | <tr><td colspan="4" class="doc" id="isSignedInteger0"><pre>Matches QualType nodes that are of signed integer type. |
| 3651 | |
| 3652 | Given |
| 3653 | void a(int); |
| 3654 | void b(unsigned long); |
| 3655 | void c(double); |
Aaron Ballman | 75de707 | 2016-08-18 12:26:17 +0000 | [diff] [blame] | 3656 | functionDecl(hasAnyParameter(hasType(isSignedInteger()))) |
Clement Courbet | 4251759 | 2016-07-12 06:36:00 +0000 | [diff] [blame] | 3657 | matches "a(int)", but not "b(unsigned long)" and "c(double)". |
| 3658 | </pre></td></tr> |
| 3659 | |
| 3660 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3661 | <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> |
Clement Courbet | 4251759 | 2016-07-12 06:36:00 +0000 | [diff] [blame] | 3662 | <tr><td colspan="4" class="doc" id="isUnsignedInteger0"><pre>Matches QualType nodes that are of unsigned integer type. |
| 3663 | |
| 3664 | Given |
| 3665 | void a(int); |
| 3666 | void b(unsigned long); |
| 3667 | void c(double); |
Aaron Ballman | 75de707 | 2016-08-18 12:26:17 +0000 | [diff] [blame] | 3668 | functionDecl(hasAnyParameter(hasType(isUnsignedInteger()))) |
Clement Courbet | 4251759 | 2016-07-12 06:36:00 +0000 | [diff] [blame] | 3669 | matches "b(unsigned long)", but not "a(int)" and "c(double)". |
| 3670 | </pre></td></tr> |
| 3671 | |
| 3672 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3673 | <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> |
Aaron Ballman | 6290fc9 | 2015-11-23 17:09:24 +0000 | [diff] [blame] | 3674 | <tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that |
| 3675 | include "top-level" volatile. |
| 3676 | |
| 3677 | Given |
| 3678 | void a(int); |
| 3679 | void b(int volatile); |
| 3680 | void c(volatile int); |
| 3681 | void d(volatile int*); |
| 3682 | void e(int volatile) {}; |
| 3683 | functionDecl(hasAnyParameter(hasType(isVolatileQualified()))) |
| 3684 | matches "void b(int volatile)", "void c(volatile int)" and |
| 3685 | "void e(int volatile) {}". It does not match d as there |
| 3686 | is no top-level volatile on the parameter type "volatile int *". |
| 3687 | </pre></td></tr> |
| 3688 | |
| 3689 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3690 | <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>></td><td class="name" onclick="toggle('isClass0')"><a name="isClass0Anchor">isClass</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3691 | <tr><td colspan="4" class="doc" id="isClass0"><pre>Matches RecordDecl object that are spelled with "class." |
| 3692 | |
| 3693 | Example matches C, but not S or U. |
| 3694 | struct S {}; |
| 3695 | class C {}; |
| 3696 | union U {}; |
| 3697 | </pre></td></tr> |
| 3698 | |
| 3699 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3700 | <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>></td><td class="name" onclick="toggle('isStruct0')"><a name="isStruct0Anchor">isStruct</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3701 | <tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches RecordDecl object that are spelled with "struct." |
| 3702 | |
| 3703 | Example matches S, but not C or U. |
| 3704 | struct S {}; |
| 3705 | class C {}; |
| 3706 | union U {}; |
| 3707 | </pre></td></tr> |
| 3708 | |
| 3709 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3710 | <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>></td><td class="name" onclick="toggle('isUnion0')"><a name="isUnion0Anchor">isUnion</a></td><td></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3711 | <tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches RecordDecl object that are spelled with "union." |
| 3712 | |
| 3713 | Example matches U, but not C or S. |
| 3714 | struct S {}; |
| 3715 | class C {}; |
| 3716 | union U {}; |
| 3717 | </pre></td></tr> |
| 3718 | |
| 3719 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3720 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3721 | <tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. |
| 3722 | |
| 3723 | Matches a node if it equals the node previously bound to ID. |
| 3724 | |
| 3725 | Given |
| 3726 | class X { int a; int b; }; |
| 3727 | cxxRecordDecl( |
| 3728 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 3729 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 3730 | matches the class X, as a and b have the same type. |
| 3731 | |
| 3732 | Note that when multiple matches are involved via forEach* matchers, |
| 3733 | equalsBoundNodes acts as a filter. |
| 3734 | For example: |
| 3735 | compoundStmt( |
| 3736 | forEachDescendant(varDecl().bind("d")), |
| 3737 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 3738 | will trigger a match for each combination of variable declaration |
| 3739 | and reference to that variable declaration within a compound statement. |
| 3740 | </pre></td></tr> |
| 3741 | |
| 3742 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3743 | <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> |
Samuel Benzaquen | a4076ea | 2016-05-04 20:45:00 +0000 | [diff] [blame] | 3744 | <tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node. |
| 3745 | |
| 3746 | Stmt has pointer identity in the AST. |
| 3747 | </pre></td></tr> |
| 3748 | |
| 3749 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3750 | <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>std::string RegExp</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3751 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is |
| 3752 | partially matching a given regex. |
| 3753 | |
| 3754 | Example matches Y but not X |
| 3755 | (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 3756 | #include "ASTMatcher.h" |
| 3757 | class X {}; |
| 3758 | ASTMatcher.h: |
| 3759 | class Y {}; |
| 3760 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3761 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3762 | </pre></td></tr> |
| 3763 | |
| 3764 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3765 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3766 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. |
| 3767 | |
| 3768 | Example matches X but not Y |
| 3769 | (matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 3770 | #include <Y.h> |
| 3771 | class X {}; |
| 3772 | Y.h: |
| 3773 | class Y {}; |
| 3774 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3775 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3776 | </pre></td></tr> |
| 3777 | |
| 3778 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3779 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3780 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. |
| 3781 | |
| 3782 | Example matches Y but not X |
| 3783 | (matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 3784 | #include <SystemHeader.h> |
| 3785 | class X {}; |
| 3786 | SystemHeader.h: |
| 3787 | class Y {}; |
| 3788 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3789 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3790 | </pre></td></tr> |
| 3791 | |
| 3792 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3793 | <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> |
Etienne Bergeron | 3588be7 | 2016-05-12 04:20:04 +0000 | [diff] [blame] | 3794 | <tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size. |
| 3795 | |
| 3796 | Given |
| 3797 | int a[42]; |
| 3798 | int b[2 * 21]; |
| 3799 | int c[41], d[43]; |
| 3800 | char *s = "abcd"; |
| 3801 | wchar_t *ws = L"abcd"; |
| 3802 | char *w = "a"; |
| 3803 | constantArrayType(hasSize(42)) |
| 3804 | matches "int a[42]" and "int b[2 * 21]" |
| 3805 | stringLiteral(hasSize(4)) |
| 3806 | matches "abcd", L"abcd" |
| 3807 | </pre></td></tr> |
| 3808 | |
| 3809 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3810 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3811 | <tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. |
| 3812 | |
| 3813 | Example matches A, va, fa |
| 3814 | class A {}; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3815 | class B; // Doesn't match, as it has no body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3816 | int va; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3817 | extern int vb; // Doesn't match, as it doesn't define the variable. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3818 | void fa() {} |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3819 | void fb(); // Doesn't match, as it has no body. |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 3820 | @interface X |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 3821 | - (void)ma; // Doesn't match, interface is declaration. |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 3822 | @end |
| 3823 | @implementation X |
| 3824 | - (void)ma {} |
| 3825 | @end |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3826 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3827 | 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>>, |
| 3828 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3829 | </pre></td></tr> |
| 3830 | |
| 3831 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3832 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3833 | <tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. |
| 3834 | |
| 3835 | Note that 'Value' is a string as the template argument's value is |
| 3836 | an arbitrary precision integer. 'Value' must be euqal to the canonical |
| 3837 | representation of that integral value in base 10. |
| 3838 | |
| 3839 | Given |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3840 | template<int T> struct C {}; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3841 | C<42> c; |
| 3842 | classTemplateSpecializationDecl( |
| 3843 | hasAnyTemplateArgument(equalsIntegralValue("42"))) |
| 3844 | matches the implicit instantiation of C in C<42>. |
| 3845 | </pre></td></tr> |
| 3846 | |
| 3847 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3848 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3849 | <tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. |
| 3850 | |
| 3851 | Given |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 3852 | template<int T> struct C {}; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3853 | C<42> c; |
| 3854 | classTemplateSpecializationDecl( |
| 3855 | hasAnyTemplateArgument(isIntegral())) |
| 3856 | matches the implicit instantiation of C in C<42> |
| 3857 | with isIntegral() matching 42. |
| 3858 | </pre></td></tr> |
| 3859 | |
| 3860 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3861 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3862 | <tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. |
| 3863 | |
| 3864 | Given |
| 3865 | template<typename T> struct C {}; |
| 3866 | C<int> c; |
| 3867 | classTemplateSpecializationDecl(templateArgumentCountIs(1)) |
| 3868 | matches C<int>. |
| 3869 | </pre></td></tr> |
| 3870 | |
| 3871 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3872 | <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>std::string RegExp</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3873 | <tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is |
| 3874 | partially matching a given regex. |
| 3875 | |
| 3876 | Example matches Y but not X |
| 3877 | (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) |
| 3878 | #include "ASTMatcher.h" |
| 3879 | class X {}; |
| 3880 | ASTMatcher.h: |
| 3881 | class Y {}; |
| 3882 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3883 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3884 | </pre></td></tr> |
| 3885 | |
| 3886 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3887 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3888 | <tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. |
| 3889 | |
| 3890 | Example matches X but not Y |
| 3891 | (matcher = cxxRecordDecl(isExpansionInMainFile()) |
| 3892 | #include <Y.h> |
| 3893 | class X {}; |
| 3894 | Y.h: |
| 3895 | class Y {}; |
| 3896 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3897 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3898 | </pre></td></tr> |
| 3899 | |
| 3900 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3901 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3902 | <tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. |
| 3903 | |
| 3904 | Example matches Y but not X |
| 3905 | (matcher = cxxRecordDecl(isExpansionInSystemHeader()) |
| 3906 | #include <SystemHeader.h> |
| 3907 | class X {}; |
| 3908 | SystemHeader.h: |
| 3909 | class Y {}; |
| 3910 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3911 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3912 | </pre></td></tr> |
| 3913 | |
| 3914 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3915 | <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> |
Samuel Benzaquen | 30747f7 | 2015-12-22 21:06:36 +0000 | [diff] [blame] | 3916 | <tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool. |
| 3917 | |
| 3918 | Given |
| 3919 | struct S { bool func(); }; |
| 3920 | functionDecl(returns(booleanType())) |
| 3921 | matches "bool func();" |
| 3922 | </pre></td></tr> |
| 3923 | |
| 3924 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3925 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3926 | <tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. |
| 3927 | |
| 3928 | Matches a node if it equals the node previously bound to ID. |
| 3929 | |
| 3930 | Given |
| 3931 | class X { int a; int b; }; |
| 3932 | cxxRecordDecl( |
| 3933 | has(fieldDecl(hasName("a"), hasType(type().bind("t")))), |
| 3934 | has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) |
| 3935 | matches the class X, as a and b have the same type. |
| 3936 | |
| 3937 | Note that when multiple matches are involved via forEach* matchers, |
| 3938 | equalsBoundNodes acts as a filter. |
| 3939 | For example: |
| 3940 | compoundStmt( |
| 3941 | forEachDescendant(varDecl().bind("d")), |
| 3942 | forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) |
| 3943 | will trigger a match for each combination of variable declaration |
| 3944 | and reference to that variable declaration within a compound statement. |
| 3945 | </pre></td></tr> |
| 3946 | |
| 3947 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3948 | <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> |
Samuel Benzaquen | a4076ea | 2016-05-04 20:45:00 +0000 | [diff] [blame] | 3949 | <tr><td colspan="4" class="doc" id="equalsNode2"><pre>Matches if a node equals another node. |
| 3950 | |
| 3951 | Type has pointer identity in the AST. |
| 3952 | </pre></td></tr> |
| 3953 | |
| 3954 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3955 | <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> |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 3956 | <tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double). |
| 3957 | |
| 3958 | Given |
| 3959 | int i; |
| 3960 | float f; |
| 3961 | realFloatingPointType() |
| 3962 | matches "float f" but not "int i" |
| 3963 | </pre></td></tr> |
| 3964 | |
| 3965 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3966 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3967 | <tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. |
| 3968 | |
| 3969 | Given |
| 3970 | struct S { void func(); }; |
| 3971 | functionDecl(returns(voidType())) |
| 3972 | matches "void func();" |
| 3973 | </pre></td></tr> |
| 3974 | |
| 3975 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3976 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3977 | <tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. |
| 3978 | |
| 3979 | Given |
| 3980 | int x; |
| 3981 | int s = sizeof(x) + alignof(x) |
| 3982 | unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) |
| 3983 | matches sizeof(x) |
| 3984 | </pre></td></tr> |
| 3985 | |
| 3986 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3987 | <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>></td><td class="name" onclick="toggle('hasOperatorName1')"><a name="hasOperatorName1Anchor">hasOperatorName</a></td><td>std::string Name</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 3988 | <tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or |
| 3989 | unary). |
| 3990 | |
| 3991 | Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) |
| 3992 | !(a || b) |
| 3993 | </pre></td></tr> |
| 3994 | |
| 3995 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 3996 | <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> |
Shuai Wang | e0248ae | 2018-09-17 18:48:43 +0000 | [diff] [blame] | 3997 | <tr><td colspan="4" class="doc" id="isArrow1"><pre>Matches member expressions that are called with '->' as opposed |
| 3998 | to '.'. |
| 3999 | |
| 4000 | Member calls on the implicit this pointer match as called with '->'. |
| 4001 | |
| 4002 | Given |
| 4003 | class Y { |
| 4004 | void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } |
| 4005 | template <class T> void f() { this->f<T>(); f<T>(); } |
| 4006 | int a; |
| 4007 | static int b; |
| 4008 | }; |
| 4009 | template <class T> |
| 4010 | class Z { |
| 4011 | void x() { this->m; } |
| 4012 | }; |
| 4013 | memberExpr(isArrow()) |
| 4014 | matches this->x, x, y.x, a, this->b |
| 4015 | cxxDependentScopeMemberExpr(isArrow()) |
| 4016 | matches this->m |
| 4017 | unresolvedMemberExpr(isArrow()) |
| 4018 | matches this->f<T>, f<T> |
| 4019 | </pre></td></tr> |
| 4020 | |
| 4021 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4022 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4023 | <tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration. |
| 4024 | |
| 4025 | Example matches x, but not y, z, or a. |
| 4026 | (matcher = varDecl(hasAutomaticStorageDuration()) |
| 4027 | void f() { |
| 4028 | int x; |
| 4029 | static int y; |
| 4030 | thread_local int z; |
| 4031 | } |
| 4032 | int a; |
| 4033 | </pre></td></tr> |
| 4034 | |
| 4035 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4036 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4037 | <tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. |
| 4038 | |
| 4039 | Example matches y and z (matcher = varDecl(hasGlobalStorage()) |
| 4040 | void f() { |
| 4041 | int x; |
| 4042 | static int y; |
| 4043 | } |
| 4044 | int z; |
| 4045 | </pre></td></tr> |
| 4046 | |
| 4047 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4048 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4049 | <tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a |
| 4050 | non-static local variable. |
| 4051 | |
| 4052 | Example matches x (matcher = varDecl(hasLocalStorage()) |
| 4053 | void f() { |
| 4054 | int x; |
| 4055 | static int y; |
| 4056 | } |
| 4057 | int z; |
| 4058 | </pre></td></tr> |
| 4059 | |
| 4060 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4061 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4062 | <tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration. |
Haojian Wu | 398a8ea | 2016-09-27 07:53:20 +0000 | [diff] [blame] | 4063 | It includes the variable declared at namespace scope and those declared |
| 4064 | with "static" and "extern" storage class specifiers. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4065 | |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4066 | void f() { |
| 4067 | int x; |
| 4068 | static int y; |
| 4069 | thread_local int z; |
| 4070 | } |
| 4071 | int a; |
Haojian Wu | 398a8ea | 2016-09-27 07:53:20 +0000 | [diff] [blame] | 4072 | static int b; |
| 4073 | extern int c; |
| 4074 | varDecl(hasStaticStorageDuration()) |
| 4075 | matches the function declaration y, a, b and c. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4076 | </pre></td></tr> |
| 4077 | |
| 4078 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4079 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4080 | <tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration. |
| 4081 | |
| 4082 | Example matches z, but not x, z, or a. |
| 4083 | (matcher = varDecl(hasThreadStorageDuration()) |
| 4084 | void f() { |
| 4085 | int x; |
| 4086 | static int y; |
| 4087 | thread_local int z; |
| 4088 | } |
| 4089 | int a; |
| 4090 | </pre></td></tr> |
| 4091 | |
| 4092 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4093 | <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> |
Gabor Horvath | 3cd0aa3 | 2018-05-08 11:53:32 +0000 | [diff] [blame] | 4094 | <tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations, |
| 4095 | and if constexpr. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4096 | |
| 4097 | Given: |
| 4098 | constexpr int foo = 42; |
| 4099 | constexpr int bar(); |
Gabor Horvath | 3cd0aa3 | 2018-05-08 11:53:32 +0000 | [diff] [blame] | 4100 | void baz() { if constexpr(1 > 0) {} } |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4101 | varDecl(isConstexpr()) |
| 4102 | matches the declaration of foo. |
| 4103 | functionDecl(isConstexpr()) |
| 4104 | matches the declaration of bar. |
Gabor Horvath | 3cd0aa3 | 2018-05-08 11:53:32 +0000 | [diff] [blame] | 4105 | ifStmt(isConstexpr()) |
| 4106 | matches the if statement in baz. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4107 | </pre></td></tr> |
| 4108 | |
| 4109 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4110 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4111 | <tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. |
| 4112 | |
| 4113 | Example matches A, va, fa |
| 4114 | class A {}; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 4115 | class B; // Doesn't match, as it has no body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4116 | int va; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 4117 | extern int vb; // Doesn't match, as it doesn't define the variable. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4118 | void fa() {} |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 4119 | void fb(); // Doesn't match, as it has no body. |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 4120 | @interface X |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 4121 | - (void)ma; // Doesn't match, interface is declaration. |
Dave Lee | be39868 | 2017-11-14 14:17:26 +0000 | [diff] [blame] | 4122 | @end |
| 4123 | @implementation X |
| 4124 | - (void)ma {} |
| 4125 | @end |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4126 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4127 | 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>>, |
| 4128 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4129 | </pre></td></tr> |
| 4130 | |
| 4131 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4132 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4133 | <tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from |
| 4134 | a C++ catch block, or an Objective-C statement. |
| 4135 | |
| 4136 | Example matches x (matcher = varDecl(isExceptionVariable()) |
| 4137 | void f(int y) { |
| 4138 | try { |
| 4139 | } catch (int x) { |
| 4140 | } |
| 4141 | } |
| 4142 | </pre></td></tr> |
| 4143 | |
| 4144 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4145 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4146 | <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or |
| 4147 | static member variable template instantiations. |
| 4148 | |
| 4149 | Given |
| 4150 | template<typename T> void A(T t) { } |
| 4151 | template<> void A(int N) { } |
| 4152 | functionDecl(isExplicitTemplateSpecialization()) |
| 4153 | matches the specialization A<int>(). |
| 4154 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4155 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4156 | </pre></td></tr> |
| 4157 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 4158 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4159 | <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> |
Alexander Shaposhnikov | f681c4e | 2017-09-22 19:29:38 +0000 | [diff] [blame] | 4160 | <tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function or variable declarations. |
Benjamin Kramer | 87e6d99 | 2016-08-04 10:02:03 +0000 | [diff] [blame] | 4161 | |
| 4162 | Given: |
| 4163 | extern "C" void f() {} |
| 4164 | extern "C" { void g() {} } |
| 4165 | void h() {} |
Alexander Shaposhnikov | f681c4e | 2017-09-22 19:29:38 +0000 | [diff] [blame] | 4166 | extern "C" int x = 1; |
| 4167 | extern "C" int y = 2; |
| 4168 | int z = 3; |
Benjamin Kramer | 87e6d99 | 2016-08-04 10:02:03 +0000 | [diff] [blame] | 4169 | functionDecl(isExternC()) |
Alexander Shaposhnikov | f681c4e | 2017-09-22 19:29:38 +0000 | [diff] [blame] | 4170 | matches the declaration of f and g, but not the declaration of h. |
| 4171 | varDecl(isExternC()) |
| 4172 | matches the declaration of x and y, but not the declaration of z. |
Benjamin Kramer | 87e6d99 | 2016-08-04 10:02:03 +0000 | [diff] [blame] | 4173 | </pre></td></tr> |
| 4174 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 4175 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4176 | <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> |
Aaron Ballman | 31f48c5 | 2018-10-29 13:47:56 +0000 | [diff] [blame] | 4177 | <tr><td colspan="4" class="doc" id="isStaticLocal0"><pre>Matches a static variable with local scope. |
| 4178 | |
| 4179 | Example matches y (matcher = varDecl(isStaticLocal())) |
| 4180 | void f() { |
| 4181 | int x; |
| 4182 | static int y; |
| 4183 | } |
| 4184 | static int z; |
| 4185 | </pre></td></tr> |
| 4186 | |
| 4187 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4188 | <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> |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 4189 | <tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variable/function declarations that have "static" storage |
Haojian Wu | 398a8ea | 2016-09-27 07:53:20 +0000 | [diff] [blame] | 4190 | class specifier ("static" keyword) written in the source. |
Haojian Wu | b3d2546 | 2016-09-26 16:01:52 +0000 | [diff] [blame] | 4191 | |
| 4192 | Given: |
| 4193 | static void f() {} |
| 4194 | static int i = 0; |
Haojian Wu | 398a8ea | 2016-09-27 07:53:20 +0000 | [diff] [blame] | 4195 | extern int j; |
| 4196 | int k; |
Haojian Wu | b3d2546 | 2016-09-26 16:01:52 +0000 | [diff] [blame] | 4197 | functionDecl(isStaticStorageClass()) |
| 4198 | matches the function declaration f. |
| 4199 | varDecl(isStaticStorageClass()) |
| 4200 | matches the variable declaration i. |
| 4201 | </pre></td></tr> |
| 4202 | |
| 4203 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4204 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4205 | <tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static |
| 4206 | member variable template instantiations. |
| 4207 | |
| 4208 | Given |
| 4209 | template <typename T> class X {}; class A {}; X<A> x; |
| 4210 | or |
| 4211 | template <typename T> class X {}; class A {}; template class X<A>; |
Eric Liu | 09ee48e | 2018-02-21 14:22:42 +0000 | [diff] [blame] | 4212 | or |
| 4213 | template <typename T> class X {}; class A {}; extern template class X<A>; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4214 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 4215 | matches the template instantiation of X<A>. |
| 4216 | |
| 4217 | But given |
| 4218 | template <typename T> class X {}; class A {}; |
| 4219 | template <> class X<A> {}; X<A> x; |
| 4220 | cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) |
| 4221 | does not match, as X<A> is an explicit template specialization. |
| 4222 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4223 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4224 | </pre></td></tr> |
| 4225 | |
| 4226 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4227 | <tr><td>Matcher<internal::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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4228 | <tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside |
| 4229 | template instantiations. |
| 4230 | |
| 4231 | Given |
| 4232 | template<typename T> void A(T t) { T i; } |
| 4233 | A(0); |
| 4234 | A(0U); |
| 4235 | functionDecl(isInstantiated()) |
| 4236 | matches 'A(int) {...};' and 'A(unsigned) {...}'. |
| 4237 | </pre></td></tr> |
| 4238 | |
| 4239 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4240 | <tr><td>Matcher<internal::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> |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 4241 | <tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as |
| 4242 | GNU's __null, C++11's nullptr, or C's NULL macro. |
| 4243 | |
| 4244 | Given: |
| 4245 | void *v1 = NULL; |
| 4246 | void *v2 = nullptr; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 4247 | void *v3 = __null; // GNU extension |
Aaron Ballman | eb7e5d9 | 2016-02-18 16:36:01 +0000 | [diff] [blame] | 4248 | char *cp = (char *)0; |
| 4249 | int *ip = 0; |
| 4250 | int i = 0; |
| 4251 | expr(nullPointerConstant()) |
| 4252 | matches the initializer for v1, v2, v3, cp, and ip. Does not match the |
| 4253 | initializer for i. |
| 4254 | </pre></td></tr> |
| 4255 | |
| 4256 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4257 | <tr><td>Matcher<internal::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> |
Samuel Benzaquen | a4076ea | 2016-05-04 20:45:00 +0000 | [diff] [blame] | 4258 | <tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names. |
| 4259 | |
| 4260 | This matcher is only provided as a performance optimization of hasName. |
| 4261 | hasAnyName(a, b, c) |
| 4262 | is equivalent to, but faster than |
| 4263 | anyOf(hasName(a), hasName(b), hasName(c)) |
| 4264 | </pre></td></tr> |
| 4265 | |
| 4266 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4267 | <tr><td>Matcher<internal::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> |
George Karpenkov | 88a16a0 | 2018-03-29 00:51:12 +0000 | [diff] [blame] | 4268 | <tr><td colspan="4" class="doc" id="hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the |
| 4269 | Selector.getAsString() |
| 4270 | |
| 4271 | matcher = objCMessageExpr(hasSelector("methodA:", "methodB:")); |
| 4272 | matches both of the expressions below: |
| 4273 | [myObj methodA:argA]; |
| 4274 | [myObj methodB:argB]; |
| 4275 | </pre></td></tr> |
| 4276 | |
| 4277 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4278 | <tr><td>Matcher<internal::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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4279 | <tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. |
| 4280 | |
| 4281 | Given |
| 4282 | int j; |
| 4283 | template<typename T> void A(T t) { T i; j += 42;} |
| 4284 | A(0); |
| 4285 | A(0U); |
| 4286 | declStmt(isInTemplateInstantiation()) |
| 4287 | matches 'int i;' and 'unsigned i'. |
| 4288 | unless(stmt(isInTemplateInstantiation())) |
| 4289 | will NOT match j += 42; as it's shared between the template definition and |
| 4290 | instantiation. |
| 4291 | </pre></td></tr> |
| 4292 | |
Benjamin Kramer | 7d0cc23 | 2015-11-20 07:57:46 +0000 | [diff] [blame] | 4293 | <!--END_NARROWING_MATCHERS --> |
| 4294 | </table> |
| 4295 | |
| 4296 | <!-- ======================================================================= --> |
| 4297 | <h2 id="traversal-matchers">AST Traversal Matchers</h2> |
| 4298 | <!-- ======================================================================= --> |
| 4299 | |
| 4300 | <p>Traversal matchers specify the relationship to other nodes that are |
| 4301 | reachable from the current node.</p> |
| 4302 | |
| 4303 | <p>Note that there are special traversal matchers (has, hasDescendant, forEach and |
| 4304 | forEachDescendant) which work on all nodes and allow users to write more generic |
| 4305 | match expressions.</p> |
| 4306 | |
| 4307 | <table> |
| 4308 | <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4309 | <!-- START_TRAVERSAL_MATCHERS --> |
| 4310 | |
| 4311 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> |
| 4312 | <tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. |
| 4313 | |
| 4314 | Unlike anyOf, eachOf will generate a match result for each |
| 4315 | matching submatcher. |
| 4316 | |
| 4317 | For example, in: |
| 4318 | class A { int a; int b; }; |
| 4319 | The matcher: |
| 4320 | cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), |
| 4321 | has(fieldDecl(hasName("b")).bind("v")))) |
| 4322 | will generate two results binding "v", the first of which binds |
| 4323 | the field declaration of a, the second the field declaration of |
| 4324 | b. |
| 4325 | |
| 4326 | Usable as: Any Matcher |
| 4327 | </pre></td></tr> |
| 4328 | |
| 4329 | |
| 4330 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> |
| 4331 | <tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 4332 | provided matcher. |
| 4333 | |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 4334 | Example matches X, A, A::X, B, B::C, B::C::X |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4335 | (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X"))))) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 4336 | class X {}; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 4337 | class A { class X {}; }; // Matches A, because A::X is a class of name |
| 4338 | // X inside A. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4339 | class B { class C { class X {}; }; }; |
| 4340 | |
| 4341 | DescendantT must be an AST base type. |
| 4342 | |
| 4343 | As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for |
| 4344 | each result that matches instead of only on the first one. |
| 4345 | |
| 4346 | Note: Recursively combined ForEachDescendant can cause many matches: |
| 4347 | cxxRecordDecl(forEachDescendant(cxxRecordDecl( |
| 4348 | forEachDescendant(cxxRecordDecl()) |
| 4349 | ))) |
| 4350 | will match 10 times (plus injected class name matches) on: |
| 4351 | class A { class B { class C { class D { class E {}; }; }; }; }; |
| 4352 | |
| 4353 | Usable as: Any Matcher |
| 4354 | </pre></td></tr> |
| 4355 | |
| 4356 | |
| 4357 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> |
| 4358 | <tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the |
| 4359 | provided matcher. |
| 4360 | |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 4361 | Example matches X, Y, Y::X, Z::Y, Z::Y::X |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4362 | (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X"))) |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 4363 | class X {}; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 4364 | class Y { class X {}; }; // Matches Y, because Y::X is a class of name X |
| 4365 | // inside Y. |
| 4366 | class Z { class Y { class X {}; }; }; // Does not match Z. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4367 | |
| 4368 | ChildT must be an AST base type. |
| 4369 | |
| 4370 | As opposed to 'has', 'forEach' will cause a match for each result that |
| 4371 | matches instead of only on the first one. |
| 4372 | |
| 4373 | Usable as: Any Matcher |
| 4374 | </pre></td></tr> |
| 4375 | |
| 4376 | |
| 4377 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> |
| 4378 | <tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided |
| 4379 | matcher. |
| 4380 | |
| 4381 | Given |
| 4382 | void f() { if (true) { int x = 42; } } |
| 4383 | void g() { for (;;) { int x = 43; } } |
| 4384 | expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. |
| 4385 | |
| 4386 | Usable as: Any Matcher |
| 4387 | </pre></td></tr> |
| 4388 | |
| 4389 | |
| 4390 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> |
| 4391 | <tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the |
| 4392 | provided matcher. |
| 4393 | |
| 4394 | Example matches X, Y, Z |
| 4395 | (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X"))))) |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 4396 | class X {}; // Matches X, because X::X is a class of name X inside X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4397 | class Y { class X {}; }; |
| 4398 | class Z { class Y { class X {}; }; }; |
| 4399 | |
| 4400 | DescendantT must be an AST base type. |
| 4401 | |
| 4402 | Usable as: Any Matcher |
| 4403 | </pre></td></tr> |
| 4404 | |
| 4405 | |
| 4406 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> |
| 4407 | <tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the |
| 4408 | provided matcher. |
| 4409 | |
| 4410 | Example matches X, Y |
| 4411 | (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X"))) |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 4412 | class X {}; // Matches X, because X::X is a class of name X inside X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4413 | class Y { class X {}; }; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 4414 | class Z { class Y { class X {}; }; }; // Does not match Z. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4415 | |
| 4416 | ChildT must be an AST base type. |
| 4417 | |
| 4418 | Usable as: Any Matcher |
Aaron Ballman | ba8dbbe | 2016-06-06 18:52:17 +0000 | [diff] [blame] | 4419 | Note that has is direct matcher, so it also matches things like implicit |
| 4420 | casts and paren casts. If you are matching with expr then you should |
| 4421 | probably consider using ignoringParenImpCasts like: |
| 4422 | has(ignoringParenImpCasts(expr())). |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4423 | </pre></td></tr> |
| 4424 | |
| 4425 | |
| 4426 | <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> |
| 4427 | <tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided |
| 4428 | matcher. |
| 4429 | |
| 4430 | Given |
| 4431 | void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } |
| 4432 | compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". |
| 4433 | |
| 4434 | Usable as: Any Matcher |
| 4435 | </pre></td></tr> |
| 4436 | |
| 4437 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4438 | <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> |
Etienne Bergeron | 5500f95 | 2016-05-30 15:25:25 +0000 | [diff] [blame] | 4439 | <tr><td colspan="4" class="doc" id="hasCondition5"><pre>Matches the condition expression of an if statement, for loop, |
| 4440 | switch statement or conditional operator. |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4441 | |
| 4442 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 4443 | if (true) {} |
| 4444 | </pre></td></tr> |
| 4445 | |
| 4446 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4447 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4448 | <tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator |
| 4449 | (binary or ternary). |
| 4450 | |
| 4451 | Example matches b |
| 4452 | condition ? a : b |
| 4453 | condition ?: b |
| 4454 | </pre></td></tr> |
| 4455 | |
| 4456 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4457 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4458 | <tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. |
| 4459 | |
| 4460 | Example 1 (conditional ternary operator): matches a |
| 4461 | condition ? a : b |
| 4462 | |
| 4463 | Example 2 (conditional binary operator): matches opaqueValueExpr(condition) |
| 4464 | condition ?: b |
| 4465 | </pre></td></tr> |
| 4466 | |
| 4467 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4468 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 4469 | <tr><td colspan="4" class="doc" id="hasDeclaration15"><pre>Matches a node if the declaration associated with that node |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4470 | matches the given matcher. |
| 4471 | |
| 4472 | The associated declaration is: |
| 4473 | - for type nodes, the declaration of the underlying type |
| 4474 | - for CallExpr, the declaration of the callee |
| 4475 | - for MemberExpr, the declaration of the referenced member |
| 4476 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 4477 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 4478 | - for ObjCIvarExpr, the declaration of the ivar |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4479 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 4480 | For type nodes, hasDeclaration will generally match the declaration of the |
| 4481 | sugared type. Given |
| 4482 | class X {}; |
| 4483 | typedef X Y; |
| 4484 | Y y; |
| 4485 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 4486 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 4487 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 4488 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 4489 | recordType(hasDeclaration(decl()))))) |
| 4490 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4491 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4492 | 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>>, |
| 4493 | 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>>, |
| 4494 | 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>>, |
| 4495 | 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>>, |
| 4496 | 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>>, |
| 4497 | 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>>, |
| 4498 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4499 | </pre></td></tr> |
| 4500 | |
| 4501 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4502 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4503 | <tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. |
| 4504 | |
| 4505 | Given |
| 4506 | int i[5]; |
| 4507 | void f() { i[1] = 42; } |
| 4508 | arraySubscriptExpression(hasBase(implicitCastExpr( |
| 4509 | hasSourceExpression(declRefExpr())))) |
| 4510 | matches i[1] with the declRefExpr() matching i |
| 4511 | </pre></td></tr> |
| 4512 | |
| 4513 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4514 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4515 | <tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. |
| 4516 | |
| 4517 | Given |
| 4518 | int i[5]; |
| 4519 | void f() { i[1] = 42; } |
| 4520 | arraySubscriptExpression(hasIndex(integerLiteral())) |
| 4521 | matches i[1] with the integerLiteral() matching 1 |
| 4522 | </pre></td></tr> |
| 4523 | |
| 4524 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4525 | <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4526 | <tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions. |
| 4527 | |
| 4528 | Example matches a (matcher = binaryOperator(hasLHS())) |
| 4529 | a || b |
| 4530 | </pre></td></tr> |
| 4531 | |
| 4532 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4533 | <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4534 | <tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions. |
| 4535 | |
| 4536 | Example matches b (matcher = binaryOperator(hasRHS())) |
| 4537 | a || b |
| 4538 | </pre></td></tr> |
| 4539 | |
| 4540 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4541 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4542 | <tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element |
| 4543 | type. |
| 4544 | |
| 4545 | Given |
| 4546 | struct A {}; |
| 4547 | A a[7]; |
| 4548 | int b[7]; |
| 4549 | arrayType(hasElementType(builtinType())) |
| 4550 | matches "int b[7]" |
| 4551 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4552 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4553 | </pre></td></tr> |
| 4554 | |
| 4555 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4556 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4557 | <tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. |
| 4558 | |
| 4559 | Given |
| 4560 | _Atomic(int) i; |
| 4561 | _Atomic(float) f; |
| 4562 | atomicType(hasValueType(isInteger())) |
| 4563 | matches "_Atomic(int) i" |
| 4564 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4565 | Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4566 | </pre></td></tr> |
| 4567 | |
| 4568 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4569 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4570 | <tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. |
| 4571 | |
| 4572 | Note: There is no TypeLoc for the deduced type and thus no |
| 4573 | getDeducedLoc() matcher. |
| 4574 | |
| 4575 | Given |
| 4576 | auto a = 1; |
| 4577 | auto b = 2.0; |
| 4578 | autoType(hasDeducedType(isInteger())) |
| 4579 | matches "auto a" |
| 4580 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4581 | Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4582 | </pre></td></tr> |
| 4583 | |
| 4584 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4585 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4586 | <tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a |
| 4587 | binary operator matches. |
| 4588 | </pre></td></tr> |
| 4589 | |
| 4590 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4591 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4592 | <tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. |
| 4593 | |
| 4594 | Example matches a (matcher = binaryOperator(hasLHS())) |
| 4595 | a || b |
| 4596 | </pre></td></tr> |
| 4597 | |
| 4598 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4599 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4600 | <tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. |
| 4601 | |
| 4602 | Example matches b (matcher = binaryOperator(hasRHS())) |
| 4603 | a || b |
| 4604 | </pre></td></tr> |
| 4605 | |
| 4606 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4607 | <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> |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 4608 | <tr><td colspan="4" class="doc" id="hasAnyParameter2"><pre>Matches any parameter of a function or an ObjC method declaration or a |
| 4609 | block. |
| 4610 | |
| 4611 | Does not match the 'this' parameter of a method. |
| 4612 | |
| 4613 | Given |
| 4614 | class X { void f(int x, int y, int z) {} }; |
| 4615 | cxxMethodDecl(hasAnyParameter(hasName("y"))) |
| 4616 | matches f(int x, int y, int z) {} |
| 4617 | with hasAnyParameter(...) |
| 4618 | matching int y |
| 4619 | |
| 4620 | For ObjectiveC, given |
| 4621 | @interface I - (void) f:(int) y; @end |
| 4622 | |
| 4623 | the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) |
| 4624 | matches the declaration of method f with hasParameter |
| 4625 | matching y. |
| 4626 | |
| 4627 | For blocks, given |
| 4628 | b = ^(int y) { printf("%d", y) }; |
| 4629 | |
| 4630 | the matcher blockDecl(hasAnyParameter(hasName("y"))) |
| 4631 | matches the declaration of the block b with hasParameter |
| 4632 | matching y. |
| 4633 | </pre></td></tr> |
| 4634 | |
| 4635 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4636 | <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> |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 4637 | <tr><td colspan="4" class="doc" id="hasParameter2"><pre>Matches the n'th parameter of a function or an ObjC method |
| 4638 | declaration or a block. |
| 4639 | |
| 4640 | Given |
| 4641 | class X { void f(int x) {} }; |
| 4642 | cxxMethodDecl(hasParameter(0, hasType(varDecl()))) |
| 4643 | matches f(int x) {} |
| 4644 | with hasParameter(...) |
| 4645 | matching int x |
| 4646 | |
| 4647 | For ObjectiveC, given |
| 4648 | @interface I - (void) f:(int) y; @end |
| 4649 | |
| 4650 | the matcher objcMethodDecl(hasParameter(0, hasName("y"))) |
| 4651 | matches the declaration of method f with hasParameter |
| 4652 | matching y. |
| 4653 | </pre></td></tr> |
| 4654 | |
| 4655 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4656 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4657 | <tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the |
| 4658 | pointee matches a given matcher. |
| 4659 | |
| 4660 | Given |
| 4661 | int *a; |
| 4662 | int const *b; |
| 4663 | float const *f; |
| 4664 | pointerType(pointee(isConstQualified(), isInteger())) |
| 4665 | matches "int const *b" |
| 4666 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4667 | 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>>, |
| 4668 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4669 | </pre></td></tr> |
| 4670 | |
| 4671 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4672 | <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> |
Aaron Ballman | d7b18b9 | 2016-01-18 20:28:57 +0000 | [diff] [blame] | 4673 | <tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl. |
| 4674 | |
| 4675 | Given |
| 4676 | void f(int i); |
| 4677 | int y; |
| 4678 | f(y); |
Clement Courbet | 4251759 | 2016-07-12 06:36:00 +0000 | [diff] [blame] | 4679 | callExpr( |
| 4680 | forEachArgumentWithParam( |
| 4681 | declRefExpr(to(varDecl(hasName("y")))), |
| 4682 | parmVarDecl(hasType(isInteger())) |
| 4683 | )) |
Aaron Ballman | d7b18b9 | 2016-01-18 20:28:57 +0000 | [diff] [blame] | 4684 | matches f(y); |
| 4685 | with declRefExpr(...) |
| 4686 | matching int y |
| 4687 | and parmVarDecl(...) |
| 4688 | matching int i |
| 4689 | </pre></td></tr> |
| 4690 | |
| 4691 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4692 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4693 | <tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 4694 | expression, or an ObjC-message-send expression. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4695 | |
| 4696 | Given |
| 4697 | void x(int, int, int) { int y; x(1, y, 42); } |
| 4698 | callExpr(hasAnyArgument(declRefExpr())) |
| 4699 | matches x(1, y, 42) |
| 4700 | with hasAnyArgument(...) |
| 4701 | matching y |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 4702 | |
| 4703 | For ObjectiveC, given |
| 4704 | @interface I - (void) f:(int) y; @end |
Clement Courbet | 2513aa0 | 2018-03-21 10:48:00 +0000 | [diff] [blame] | 4705 | void foo(I *i) { [i f:12]; } |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 4706 | objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) |
| 4707 | matches [i f:12] |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4708 | </pre></td></tr> |
| 4709 | |
| 4710 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4711 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4712 | <tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor |
| 4713 | call expression. |
| 4714 | |
| 4715 | Example matches y in x(y) |
| 4716 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 4717 | void x(int) { int y; x(y); } |
| 4718 | </pre></td></tr> |
| 4719 | |
| 4720 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4721 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 4722 | <tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4723 | matches the given matcher. |
| 4724 | |
| 4725 | The associated declaration is: |
| 4726 | - for type nodes, the declaration of the underlying type |
| 4727 | - for CallExpr, the declaration of the callee |
| 4728 | - for MemberExpr, the declaration of the referenced member |
| 4729 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 4730 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 4731 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4732 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 4733 | For type nodes, hasDeclaration will generally match the declaration of the |
| 4734 | sugared type. Given |
| 4735 | class X {}; |
| 4736 | typedef X Y; |
| 4737 | Y y; |
| 4738 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 4739 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 4740 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 4741 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 4742 | recordType(hasDeclaration(decl()))))) |
| 4743 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4744 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4745 | 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>>, |
| 4746 | 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>>, |
| 4747 | 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>>, |
| 4748 | 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>>, |
| 4749 | 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>>, |
| 4750 | 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>>, |
| 4751 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4752 | </pre></td></tr> |
| 4753 | |
| 4754 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4755 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4756 | <tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. |
| 4757 | |
| 4758 | Given |
| 4759 | class A { A() : i(42), j(42) {} int i; int j; }; |
| 4760 | cxxConstructorDecl(forEachConstructorInitializer( |
| 4761 | forField(decl().bind("x")) |
| 4762 | )) |
| 4763 | will trigger two matches, binding for 'i' and 'j' respectively. |
| 4764 | </pre></td></tr> |
| 4765 | |
| 4766 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4767 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4768 | <tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. |
| 4769 | |
| 4770 | Given |
| 4771 | struct Foo { |
| 4772 | Foo() : foo_(1) { } |
| 4773 | int foo_; |
| 4774 | }; |
| 4775 | cxxRecordDecl(has(cxxConstructorDecl( |
| 4776 | hasAnyConstructorInitializer(anything()) |
| 4777 | ))) |
| 4778 | record matches Foo, hasAnyConstructorInitializer matches foo_(1) |
| 4779 | </pre></td></tr> |
| 4780 | |
| 4781 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4782 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4783 | <tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. |
| 4784 | |
| 4785 | Given |
| 4786 | struct Foo { |
| 4787 | Foo() : foo_(1) { } |
| 4788 | int foo_; |
| 4789 | }; |
| 4790 | cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( |
| 4791 | forField(hasName("foo_")))))) |
| 4792 | matches Foo |
| 4793 | with forField matching foo_ |
| 4794 | </pre></td></tr> |
| 4795 | |
| 4796 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4797 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4798 | <tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. |
| 4799 | |
| 4800 | Given |
| 4801 | struct Foo { |
| 4802 | Foo() : foo_(1) { } |
| 4803 | int foo_; |
| 4804 | }; |
| 4805 | cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( |
| 4806 | withInitializer(integerLiteral(equals(1))))))) |
| 4807 | matches Foo |
| 4808 | with withInitializer matching (1) |
| 4809 | </pre></td></tr> |
| 4810 | |
| 4811 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4812 | <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> |
Yitzhak Mandelbaum | 8a43680 | 2019-02-08 16:00:44 +0000 | [diff] [blame^] | 4813 | <tr><td colspan="4" class="doc" id="hasObjectExpression2"><pre>Matches a member expression where the object expression is matched by a |
| 4814 | given matcher. Implicit object expressions are included; that is, it matches |
| 4815 | use of implicit `this`. |
Shuai Wang | 92f9d1b | 2018-08-23 17:16:06 +0000 | [diff] [blame] | 4816 | |
| 4817 | Given |
Yitzhak Mandelbaum | 8a43680 | 2019-02-08 16:00:44 +0000 | [diff] [blame^] | 4818 | struct X { |
| 4819 | int m; |
| 4820 | int f(X x) { x.m; return m; } |
| 4821 | }; |
| 4822 | memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))) |
| 4823 | matches `x.m`, but not `m`; however, |
| 4824 | memberExpr(hasObjectExpression(hasType(pointsTo( |
| 4825 | cxxRecordDecl(hasName("X")))))) |
| 4826 | matches `m` (aka. `this->m`), but not `x.m`. |
Shuai Wang | 92f9d1b | 2018-08-23 17:16:06 +0000 | [diff] [blame] | 4827 | </pre></td></tr> |
| 4828 | |
| 4829 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4830 | <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> |
Aaron Ballman | 2b6963f | 2016-01-20 16:26:48 +0000 | [diff] [blame] | 4831 | <tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 4832 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4833 | |
| 4834 | Given |
| 4835 | for (;;) {} |
| 4836 | hasBody(compoundStmt()) |
| 4837 | matches 'for (;;) {}' |
| 4838 | with compoundStmt() |
| 4839 | matching '{}' |
| 4840 | </pre></td></tr> |
| 4841 | |
| 4842 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4843 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4844 | <tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. |
| 4845 | |
| 4846 | Example: |
| 4847 | forStmt(hasLoopVariable(anything())) |
| 4848 | matches 'int x' in |
| 4849 | for (int x : a) { } |
| 4850 | </pre></td></tr> |
| 4851 | |
| 4852 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4853 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4854 | <tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. |
| 4855 | |
| 4856 | Example: |
| 4857 | forStmt(hasRangeInit(anything())) |
| 4858 | matches 'a' in |
| 4859 | for (int x : a) { } |
| 4860 | </pre></td></tr> |
| 4861 | |
| 4862 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4863 | <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> |
Yitzhak Mandelbaum | 8a43680 | 2019-02-08 16:00:44 +0000 | [diff] [blame^] | 4864 | <tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre>Matches on the implicit object argument of a member call expression. Unlike |
| 4865 | `on`, matches the argument directly without stripping away anything. |
| 4866 | |
| 4867 | Given |
| 4868 | class Y { public: void m(); }; |
| 4869 | Y g(); |
| 4870 | class X : public Y { void g(); }; |
| 4871 | void z(Y y, X x) { y.m(); x.m(); x.g(); (g()).m(); } |
| 4872 | cxxMemberCallExpr(onImplicitObjectArgument(hasType( |
| 4873 | cxxRecordDecl(hasName("Y"))))) |
| 4874 | matches `y.m()`, `x.m()` and (g()).m(), but not `x.g()`. |
| 4875 | cxxMemberCallExpr(on(callExpr())) |
| 4876 | does not match `(g()).m()`, because the parens are not ignored. |
| 4877 | |
| 4878 | FIXME: Overload to allow directly matching types? |
| 4879 | </pre></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4880 | |
| 4881 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4882 | <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> |
Yitzhak Mandelbaum | 8a43680 | 2019-02-08 16:00:44 +0000 | [diff] [blame^] | 4883 | <tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression, after |
| 4884 | stripping off any parentheses or implicit casts. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4885 | |
Yitzhak Mandelbaum | 8a43680 | 2019-02-08 16:00:44 +0000 | [diff] [blame^] | 4886 | Given |
| 4887 | class Y { public: void m(); }; |
| 4888 | Y g(); |
| 4889 | class X : public Y {}; |
| 4890 | void z(Y y, X x) { y.m(); (g()).m(); x.m(); } |
| 4891 | cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y"))))) |
| 4892 | matches `y.m()` and `(g()).m()`. |
| 4893 | cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X"))))) |
| 4894 | matches `x.m()`. |
| 4895 | cxxMemberCallExpr(on(callExpr())) |
| 4896 | matches `(g()).m()`. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4897 | |
| 4898 | FIXME: Overload to allow directly matching types? |
| 4899 | </pre></td></tr> |
| 4900 | |
| 4901 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4902 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4903 | <tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. |
| 4904 | </pre></td></tr> |
| 4905 | |
| 4906 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4907 | <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> |
Yitzhak Mandelbaum | 8a43680 | 2019-02-08 16:00:44 +0000 | [diff] [blame^] | 4908 | <tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the type of the expression's implicit object argument either |
| 4909 | matches the InnerMatcher, or is a pointer to a type that matches the |
| 4910 | InnerMatcher. |
| 4911 | |
| 4912 | Given |
| 4913 | class Y { public: void m(); }; |
| 4914 | class X : public Y { void g(); }; |
| 4915 | void z() { Y y; y.m(); Y *p; p->m(); X x; x.m(); x.g(); } |
| 4916 | cxxMemberCallExpr(thisPointerType(hasDeclaration( |
| 4917 | cxxRecordDecl(hasName("Y"))))) |
| 4918 | matches `y.m()`, `p->m()` and `x.m()`. |
| 4919 | cxxMemberCallExpr(thisPointerType(hasDeclaration( |
| 4920 | cxxRecordDecl(hasName("X"))))) |
| 4921 | matches `x.g()`. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4922 | </pre></td></tr> |
| 4923 | |
| 4924 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4925 | <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> |
Alexander Kornienko | 2a8c18d | 2018-04-06 15:14:32 +0000 | [diff] [blame] | 4926 | <tr><td colspan="4" class="doc" id="forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may |
Clement Courbet | 6ecaec8 | 2016-07-05 07:49:31 +0000 | [diff] [blame] | 4927 | produce multiple matches. |
| 4928 | |
| 4929 | Given |
| 4930 | class A { virtual void f(); }; |
| 4931 | class B : public A { void f(); }; |
| 4932 | class C : public B { void f(); }; |
| 4933 | cxxMethodDecl(ofClass(hasName("C")), |
| 4934 | forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") |
| 4935 | matches once, with "b" binding "A::f" and "d" binding "C::f" (Note |
| 4936 | that B::f is not overridden by C::f). |
| 4937 | |
| 4938 | The check can produce multiple matches in case of multiple inheritance, e.g. |
| 4939 | class A1 { virtual void f(); }; |
| 4940 | class A2 { virtual void f(); }; |
| 4941 | class C : public A1, public A2 { void f(); }; |
| 4942 | cxxMethodDecl(ofClass(hasName("C")), |
| 4943 | forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") |
| 4944 | matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and |
| 4945 | once with "b" binding "A2::f" and "d" binding "C::f". |
| 4946 | </pre></td></tr> |
| 4947 | |
| 4948 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4949 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 4950 | <tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration |
| 4951 | belongs to. |
| 4952 | |
| 4953 | FIXME: Generalize this for other kinds of declarations. |
| 4954 | FIXME: What other kind of declarations would we need to generalize |
| 4955 | this to? |
| 4956 | |
| 4957 | Example matches A() in the last line |
| 4958 | (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl( |
| 4959 | ofClass(hasName("A")))))) |
| 4960 | class A { |
| 4961 | public: |
| 4962 | A(); |
| 4963 | }; |
| 4964 | A a = A(); |
| 4965 | </pre></td></tr> |
| 4966 | |
| 4967 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4968 | <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> |
Adam Balogh | da488a6 | 2017-11-23 12:43:20 +0000 | [diff] [blame] | 4969 | <tr><td colspan="4" class="doc" id="hasArraySize0"><pre>Matches array new expressions with a given array size. |
| 4970 | |
| 4971 | Given: |
| 4972 | MyClass *p1 = new MyClass[10]; |
| 4973 | cxxNewExpr(hasArraySize(intgerLiteral(equals(10)))) |
| 4974 | matches the expression 'new MyClass[10]'. |
| 4975 | </pre></td></tr> |
| 4976 | |
| 4977 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 4978 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 4979 | <tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 4980 | matches the given matcher. |
| 4981 | |
| 4982 | The associated declaration is: |
| 4983 | - for type nodes, the declaration of the underlying type |
| 4984 | - for CallExpr, the declaration of the callee |
| 4985 | - for MemberExpr, the declaration of the referenced member |
| 4986 | - for CXXConstructExpr, the declaration of the constructor |
| 4987 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 4988 | - for ObjCIvarExpr, the declaration of the ivar |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 4989 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 4990 | For type nodes, hasDeclaration will generally match the declaration of the |
| 4991 | sugared type. Given |
| 4992 | class X {}; |
| 4993 | typedef X Y; |
| 4994 | Y y; |
| 4995 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 4996 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 4997 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 4998 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 4999 | recordType(hasDeclaration(decl()))))) |
| 5000 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 5001 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5002 | 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>>, |
| 5003 | 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>>, |
| 5004 | 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>>, |
| 5005 | 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>>, |
| 5006 | 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>>, |
| 5007 | 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>>, |
| 5008 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 5009 | </pre></td></tr> |
| 5010 | |
| 5011 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5012 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5013 | <tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. |
| 5014 | |
| 5015 | Given: |
| 5016 | class A { void func(); }; |
| 5017 | class B { void member(); }; |
| 5018 | |
| 5019 | cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of |
| 5020 | A but not B. |
| 5021 | </pre></td></tr> |
| 5022 | |
| 5023 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5024 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5025 | <tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from |
| 5026 | a class matching Base. |
| 5027 | |
| 5028 | Note that a class is not considered to be derived from itself. |
| 5029 | |
| 5030 | Example matches Y, Z, C (Base == hasName("X")) |
| 5031 | class X; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 5032 | class Y : public X {}; // directly derived |
| 5033 | class Z : public Y {}; // indirectly derived |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5034 | typedef X A; |
| 5035 | typedef A B; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 5036 | class C : public B {}; // derived from a typedef of X |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5037 | |
| 5038 | In the following example, Bar matches isDerivedFrom(hasName("X")): |
| 5039 | class Foo; |
| 5040 | typedef Foo X; |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 5041 | class Bar : public Foo {}; // derived from a type that X is a typedef of |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5042 | </pre></td></tr> |
| 5043 | |
| 5044 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5045 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5046 | <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly |
| 5047 | match Base. |
| 5048 | </pre></td></tr> |
| 5049 | |
| 5050 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5051 | <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> |
Shuai Wang | 3b2a17b | 2018-08-12 23:30:05 +0000 | [diff] [blame] | 5052 | <tr><td colspan="4" class="doc" id="hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call |
| 5053 | expression, or an ObjC-message-send expression. |
| 5054 | |
| 5055 | Given |
| 5056 | void x(int, int, int) { int y; x(1, y, 42); } |
| 5057 | callExpr(hasAnyArgument(declRefExpr())) |
| 5058 | matches x(1, y, 42) |
| 5059 | with hasAnyArgument(...) |
| 5060 | matching y |
| 5061 | |
| 5062 | For ObjectiveC, given |
| 5063 | @interface I - (void) f:(int) y; @end |
| 5064 | void foo(I *i) { [i f:12]; } |
| 5065 | objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) |
| 5066 | matches [i f:12] |
| 5067 | </pre></td></tr> |
| 5068 | |
| 5069 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5070 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5071 | <tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the |
| 5072 | given matcher. |
| 5073 | |
| 5074 | Example matches y.x() (matcher = callExpr(callee( |
| 5075 | cxxMethodDecl(hasName("x"))))) |
| 5076 | class Y { public: void x(); }; |
| 5077 | void z() { Y y; y.x(); } |
| 5078 | </pre></td></tr> |
| 5079 | |
| 5080 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5081 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5082 | <tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. |
| 5083 | |
| 5084 | Given |
| 5085 | class Y { void x() { this->x(); x(); Y y; y.x(); } }; |
| 5086 | void f() { f(); } |
| 5087 | callExpr(callee(expr())) |
| 5088 | matches this->x(), x(), y.x(), f() |
| 5089 | with callee(...) |
| 5090 | matching this->x, x, y.x, f respectively |
| 5091 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5092 | Note: Callee cannot take the more general internal::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5093 | because this introduces ambiguous overloads with calls to Callee taking a |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5094 | internal::Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5095 | implemented in terms of implicit casts. |
| 5096 | </pre></td></tr> |
| 5097 | |
| 5098 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5099 | <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> |
Aaron Ballman | d7b18b9 | 2016-01-18 20:28:57 +0000 | [diff] [blame] | 5100 | <tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl. |
| 5101 | |
| 5102 | Given |
| 5103 | void f(int i); |
| 5104 | int y; |
| 5105 | f(y); |
Clement Courbet | 4251759 | 2016-07-12 06:36:00 +0000 | [diff] [blame] | 5106 | callExpr( |
| 5107 | forEachArgumentWithParam( |
| 5108 | declRefExpr(to(varDecl(hasName("y")))), |
| 5109 | parmVarDecl(hasType(isInteger())) |
| 5110 | )) |
Aaron Ballman | d7b18b9 | 2016-01-18 20:28:57 +0000 | [diff] [blame] | 5111 | matches f(y); |
| 5112 | with declRefExpr(...) |
| 5113 | matching int y |
| 5114 | and parmVarDecl(...) |
| 5115 | matching int i |
| 5116 | </pre></td></tr> |
| 5117 | |
| 5118 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5119 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5120 | <tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 5121 | expression, or an ObjC-message-send expression. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5122 | |
| 5123 | Given |
| 5124 | void x(int, int, int) { int y; x(1, y, 42); } |
| 5125 | callExpr(hasAnyArgument(declRefExpr())) |
| 5126 | matches x(1, y, 42) |
| 5127 | with hasAnyArgument(...) |
| 5128 | matching y |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 5129 | |
| 5130 | For ObjectiveC, given |
| 5131 | @interface I - (void) f:(int) y; @end |
Clement Courbet | 2513aa0 | 2018-03-21 10:48:00 +0000 | [diff] [blame] | 5132 | void foo(I *i) { [i f:12]; } |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 5133 | objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) |
| 5134 | matches [i f:12] |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5135 | </pre></td></tr> |
| 5136 | |
| 5137 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5138 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5139 | <tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor |
| 5140 | call expression. |
| 5141 | |
| 5142 | Example matches y in x(y) |
| 5143 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 5144 | void x(int) { int y; x(y); } |
| 5145 | </pre></td></tr> |
| 5146 | |
| 5147 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5148 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 5149 | <tr><td colspan="4" class="doc" id="hasDeclaration14"><pre>Matches a node if the declaration associated with that node |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5150 | matches the given matcher. |
| 5151 | |
| 5152 | The associated declaration is: |
| 5153 | - for type nodes, the declaration of the underlying type |
| 5154 | - for CallExpr, the declaration of the callee |
| 5155 | - for MemberExpr, the declaration of the referenced member |
| 5156 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 5157 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 5158 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5159 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5160 | For type nodes, hasDeclaration will generally match the declaration of the |
| 5161 | sugared type. Given |
| 5162 | class X {}; |
| 5163 | typedef X Y; |
| 5164 | Y y; |
| 5165 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 5166 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 5167 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 5168 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 5169 | recordType(hasDeclaration(decl()))))) |
| 5170 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5171 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5172 | 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>>, |
| 5173 | 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>>, |
| 5174 | 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>>, |
| 5175 | 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>>, |
| 5176 | 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>>, |
| 5177 | 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>>, |
| 5178 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5179 | </pre></td></tr> |
| 5180 | |
| 5181 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5182 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5183 | <tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range |
| 5184 | extension, matches the constant given in the statement. |
| 5185 | |
| 5186 | Given |
| 5187 | switch (1) { case 1: case 1+1: case 3 ... 4: ; } |
| 5188 | caseStmt(hasCaseConstant(integerLiteral())) |
| 5189 | matches "case 1:" |
| 5190 | </pre></td></tr> |
| 5191 | |
| 5192 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5193 | <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> |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5194 | <tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression |
| 5195 | or opaque value's source expression matches the given matcher. |
| 5196 | |
| 5197 | Example 1: matches "a string" |
| 5198 | (matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) |
| 5199 | class URL { URL(string); }; |
| 5200 | URL url = "a string"; |
| 5201 | |
| 5202 | Example 2: matches 'b' (matcher = |
| 5203 | opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) |
| 5204 | int a = b ?: 1; |
| 5205 | </pre></td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5206 | |
| 5207 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5208 | <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> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5209 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and |
| 5210 | functionDecl that have at least one TemplateArgument matching the given |
| 5211 | InnerMatcher. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5212 | |
| 5213 | Given |
| 5214 | template<typename T> class A {}; |
| 5215 | template<> class A<double> {}; |
| 5216 | A<int> a; |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5217 | |
Haojian Wu | 99e39a7 | 2016-07-29 17:30:13 +0000 | [diff] [blame] | 5218 | template<typename T> f() {}; |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5219 | void func() { f<int>(); }; |
| 5220 | |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5221 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 5222 | refersToType(asString("int")))) |
| 5223 | matches the specialization A<int> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5224 | |
| 5225 | functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) |
| 5226 | matches the specialization f<int> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5227 | </pre></td></tr> |
| 5228 | |
| 5229 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5230 | <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> |
Manuel Klimek | 696e505 | 2017-08-02 13:04:44 +0000 | [diff] [blame] | 5231 | <tr><td colspan="4" class="doc" id="hasSpecializedTemplate0"><pre>Matches the specialized template of a specialization declaration. |
| 5232 | |
| 5233 | Given |
Stephen Kelly | 9b8fa52 | 2018-10-09 08:24:11 +0000 | [diff] [blame] | 5234 | template<typename T> class A {}; #1 |
| 5235 | template<> class A<int> {}; #2 |
Manuel Klimek | 696e505 | 2017-08-02 13:04:44 +0000 | [diff] [blame] | 5236 | classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl())) |
Stephen Kelly | 9b8fa52 | 2018-10-09 08:24:11 +0000 | [diff] [blame] | 5237 | matches '#2' with classTemplateDecl() matching the class template |
| 5238 | declaration of 'A' at #1. |
Manuel Klimek | 696e505 | 2017-08-02 13:04:44 +0000 | [diff] [blame] | 5239 | </pre></td></tr> |
| 5240 | |
| 5241 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5242 | <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> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5243 | <tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and |
| 5244 | functionDecl where the n'th TemplateArgument matches the given InnerMatcher. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5245 | |
| 5246 | Given |
| 5247 | template<typename T, typename U> class A {}; |
| 5248 | A<bool, int> b; |
| 5249 | A<int, bool> c; |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5250 | |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 5251 | template<typename T> void f() {} |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5252 | void func() { f<int>(); }; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5253 | classTemplateSpecializationDecl(hasTemplateArgument( |
| 5254 | 1, refersToType(asString("int")))) |
| 5255 | matches the specialization A<bool, int> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5256 | |
| 5257 | functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) |
| 5258 | matches the specialization f<int> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5259 | </pre></td></tr> |
| 5260 | |
| 5261 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5262 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5263 | <tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element |
| 5264 | type. |
| 5265 | |
| 5266 | Given |
| 5267 | struct A {}; |
| 5268 | A a[7]; |
| 5269 | int b[7]; |
| 5270 | arrayType(hasElementType(builtinType())) |
| 5271 | matches "int b[7]" |
| 5272 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5273 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5274 | </pre></td></tr> |
| 5275 | |
| 5276 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5277 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5278 | <tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 5279 | a given matcher. Also matches StmtExprs that have CompoundStmt as children. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5280 | |
| 5281 | Given |
| 5282 | { {}; 1+2; } |
| 5283 | hasAnySubstatement(compoundStmt()) |
| 5284 | matches '{ {}; 1+2; }' |
| 5285 | with compoundStmt() |
| 5286 | matching '{}' |
| 5287 | </pre></td></tr> |
| 5288 | |
| 5289 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5290 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5291 | <tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whos decayed type matches InnerMatcher |
| 5292 | </pre></td></tr> |
| 5293 | |
| 5294 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5295 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5296 | <tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5297 | matches the given matcher. |
| 5298 | |
| 5299 | The associated declaration is: |
| 5300 | - for type nodes, the declaration of the underlying type |
| 5301 | - for CallExpr, the declaration of the callee |
| 5302 | - for MemberExpr, the declaration of the referenced member |
| 5303 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 5304 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 5305 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5306 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5307 | For type nodes, hasDeclaration will generally match the declaration of the |
| 5308 | sugared type. Given |
| 5309 | class X {}; |
| 5310 | typedef X Y; |
| 5311 | Y y; |
| 5312 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 5313 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 5314 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 5315 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 5316 | recordType(hasDeclaration(decl()))))) |
| 5317 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5318 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5319 | 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>>, |
| 5320 | 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>>, |
| 5321 | 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>>, |
| 5322 | 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>>, |
| 5323 | 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>>, |
| 5324 | 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>>, |
| 5325 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5326 | </pre></td></tr> |
| 5327 | |
| 5328 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5329 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5330 | <tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a |
| 5331 | specific using shadow declaration. |
| 5332 | |
| 5333 | Given |
| 5334 | namespace a { void f() {} } |
| 5335 | using a::f; |
| 5336 | void g() { |
Aaron Ballman | 94f3e74 | 2018-12-11 19:30:49 +0000 | [diff] [blame] | 5337 | f(); // Matches this .. |
| 5338 | a::f(); // .. but not this. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5339 | } |
| 5340 | declRefExpr(throughUsingDecl(anything())) |
| 5341 | matches f() |
| 5342 | </pre></td></tr> |
| 5343 | |
| 5344 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5345 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5346 | <tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the |
| 5347 | specified matcher. |
| 5348 | |
| 5349 | Example matches x in if(x) |
| 5350 | (matcher = declRefExpr(to(varDecl(hasName("x"))))) |
| 5351 | bool x; |
| 5352 | if (x) {} |
| 5353 | </pre></td></tr> |
| 5354 | |
| 5355 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5356 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5357 | <tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. |
| 5358 | |
| 5359 | Note that this does not work for global declarations because the AST |
| 5360 | breaks up multiple-declaration DeclStmt's into multiple single-declaration |
| 5361 | DeclStmt's. |
| 5362 | Example: Given non-global declarations |
| 5363 | int a, b = 0; |
| 5364 | int c; |
| 5365 | int d = 2, e; |
| 5366 | declStmt(containsDeclaration( |
| 5367 | 0, varDecl(hasInitializer(anything())))) |
| 5368 | matches only 'int d = 2, e;', and |
| 5369 | declStmt(containsDeclaration(1, varDecl())) |
| 5370 | matches 'int a, b = 0' as well as 'int d = 2, e;' |
| 5371 | but 'int c;' is not matched. |
| 5372 | </pre></td></tr> |
| 5373 | |
| 5374 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5375 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5376 | <tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. |
| 5377 | |
| 5378 | Given |
| 5379 | int a, b; |
| 5380 | int c; |
| 5381 | declStmt(hasSingleDecl(anything())) |
| 5382 | matches 'int c;' but not 'int a, b;'. |
| 5383 | </pre></td></tr> |
| 5384 | |
| 5385 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5386 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5387 | <tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches |
| 5388 | the inner matcher. |
| 5389 | |
| 5390 | Given |
| 5391 | int x; |
| 5392 | declaratorDecl(hasTypeLoc(loc(asString("int")))) |
| 5393 | matches int x |
| 5394 | </pre></td></tr> |
| 5395 | |
| 5396 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5397 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5398 | <tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a |
| 5399 | Decl, matches InnerMatcher. |
| 5400 | |
| 5401 | Given |
| 5402 | namespace N { |
| 5403 | namespace M { |
| 5404 | class D {}; |
| 5405 | } |
| 5406 | } |
| 5407 | |
| 5408 | cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the |
| 5409 | declaration of class D. |
| 5410 | </pre></td></tr> |
| 5411 | |
| 5412 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5413 | <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> |
Jonas Toth | acf8367 | 2018-07-26 13:02:05 +0000 | [diff] [blame] | 5414 | <tr><td colspan="4" class="doc" id="hasUnderlyingType0"><pre>Matches DecltypeType nodes to find out the underlying type. |
| 5415 | |
| 5416 | Given |
| 5417 | decltype(1) a = 1; |
| 5418 | decltype(2.0) b = 2.0; |
| 5419 | decltypeType(hasUnderlyingType(isInteger())) |
Stephen Kelly | 9b8fa52 | 2018-10-09 08:24:11 +0000 | [diff] [blame] | 5420 | matches the type of "a" |
Jonas Toth | acf8367 | 2018-07-26 13:02:05 +0000 | [diff] [blame] | 5421 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5422 | Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1DecltypeType.html">DecltypeType</a>> |
Jonas Toth | acf8367 | 2018-07-26 13:02:05 +0000 | [diff] [blame] | 5423 | </pre></td></tr> |
| 5424 | |
| 5425 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5426 | <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> |
Aaron Ballman | 2b6963f | 2016-01-20 16:26:48 +0000 | [diff] [blame] | 5427 | <tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 5428 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5429 | |
| 5430 | Given |
| 5431 | for (;;) {} |
| 5432 | hasBody(compoundStmt()) |
| 5433 | matches 'for (;;) {}' |
| 5434 | with compoundStmt() |
| 5435 | matching '{}' |
| 5436 | </pre></td></tr> |
| 5437 | |
| 5438 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5439 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5440 | <tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, |
Etienne Bergeron | 5500f95 | 2016-05-30 15:25:25 +0000 | [diff] [blame] | 5441 | switch statement or conditional operator. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5442 | |
| 5443 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 5444 | if (true) {} |
| 5445 | </pre></td></tr> |
| 5446 | |
| 5447 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5448 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5449 | <tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, |
| 5450 | matches InnerMatcher if the qualifier exists. |
| 5451 | |
| 5452 | Given |
| 5453 | namespace N { |
| 5454 | namespace M { |
| 5455 | class D {}; |
| 5456 | } |
| 5457 | } |
| 5458 | N::M::D d; |
| 5459 | |
| 5460 | elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) |
| 5461 | matches the type of the variable declaration of d. |
| 5462 | </pre></td></tr> |
| 5463 | |
| 5464 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5465 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5466 | <tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. |
| 5467 | |
| 5468 | Given |
| 5469 | namespace N { |
| 5470 | namespace M { |
| 5471 | class D {}; |
| 5472 | } |
| 5473 | } |
| 5474 | N::M::D d; |
| 5475 | |
| 5476 | elaboratedType(namesType(recordType( |
| 5477 | hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable |
| 5478 | declaration of d. |
| 5479 | </pre></td></tr> |
| 5480 | |
| 5481 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5482 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5483 | <tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5484 | matches the given matcher. |
| 5485 | |
| 5486 | The associated declaration is: |
| 5487 | - for type nodes, the declaration of the underlying type |
| 5488 | - for CallExpr, the declaration of the callee |
| 5489 | - for MemberExpr, the declaration of the referenced member |
| 5490 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 5491 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 5492 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5493 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5494 | For type nodes, hasDeclaration will generally match the declaration of the |
| 5495 | sugared type. Given |
| 5496 | class X {}; |
| 5497 | typedef X Y; |
| 5498 | Y y; |
| 5499 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 5500 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 5501 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 5502 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 5503 | recordType(hasDeclaration(decl()))))) |
| 5504 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5505 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5506 | 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>>, |
| 5507 | 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>>, |
| 5508 | 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>>, |
| 5509 | 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>>, |
| 5510 | 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>>, |
| 5511 | 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>>, |
| 5512 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5513 | </pre></td></tr> |
| 5514 | |
| 5515 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5516 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5517 | <tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. |
| 5518 | |
| 5519 | (Note: Clang's AST refers to other conversions as "casts" too, and calls |
| 5520 | actual casts "explicit" casts.) |
| 5521 | </pre></td></tr> |
| 5522 | |
| 5523 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5524 | <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> |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 5525 | <tr><td colspan="4" class="doc" id="hasType4"><pre>Overloaded to match the declaration of the expression's or value |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5526 | declaration's type. |
| 5527 | |
| 5528 | In case of a value declaration (for example a variable declaration), |
| 5529 | this resolves one layer of indirection. For example, in the value |
| 5530 | declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 5531 | X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 5532 | declaration of x. |
| 5533 | |
| 5534 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 5535 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 5536 | and friend class X (matcher = friendDecl(hasType("X")) |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5537 | class X {}; |
| 5538 | void y(X &x) { x; X z; } |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 5539 | class Y { friend class X; }; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5540 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5541 | 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_1ValueDecl.html">ValueDecl</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5542 | </pre></td></tr> |
| 5543 | |
| 5544 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5545 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5546 | <tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type |
| 5547 | matcher. |
| 5548 | |
| 5549 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 5550 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 5551 | and U (matcher = typedefDecl(hasType(asString("int"))) |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 5552 | and friend class X (matcher = friendDecl(hasType("X")) |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5553 | class X {}; |
| 5554 | void y(X &x) { x; X z; } |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 5555 | typedef int U; |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 5556 | class Y { friend class X; }; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5557 | </pre></td></tr> |
| 5558 | |
| 5559 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5560 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5561 | <tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts |
| 5562 | are stripped off. |
| 5563 | |
| 5564 | Parentheses and explicit casts are not discarded. |
| 5565 | Given |
| 5566 | int arr[5]; |
| 5567 | int a = 0; |
| 5568 | char b = 0; |
| 5569 | const int c = a; |
| 5570 | int *d = arr; |
| 5571 | long e = (long) 0l; |
| 5572 | The matchers |
| 5573 | varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) |
| 5574 | varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) |
| 5575 | would match the declarations for a, b, c, and d, but not e. |
| 5576 | While |
| 5577 | varDecl(hasInitializer(integerLiteral())) |
| 5578 | varDecl(hasInitializer(declRefExpr())) |
| 5579 | only match the declarations for b, c, and d. |
| 5580 | </pre></td></tr> |
| 5581 | |
| 5582 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5583 | <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> |
Cong Liu | 8a02efb | 2016-06-24 09:38:03 +0000 | [diff] [blame] | 5584 | <tr><td colspan="4" class="doc" id="ignoringImplicit0"><pre>Matches expressions that match InnerMatcher after any implicit AST |
| 5585 | nodes are stripped off. |
| 5586 | |
| 5587 | Parentheses and explicit casts are not discarded. |
| 5588 | Given |
| 5589 | class C {}; |
| 5590 | C a = C(); |
| 5591 | C b; |
| 5592 | C c = b; |
| 5593 | The matchers |
| 5594 | varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr()))) |
| 5595 | would match the declarations for a, b, and c. |
| 5596 | While |
| 5597 | varDecl(hasInitializer(cxxConstructExpr())) |
| 5598 | only match the declarations for b and c. |
| 5599 | </pre></td></tr> |
| 5600 | |
| 5601 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5602 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5603 | <tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and |
| 5604 | casts are stripped off. |
| 5605 | |
| 5606 | Implicit and non-C Style casts are also discarded. |
| 5607 | Given |
| 5608 | int a = 0; |
| 5609 | char b = (0); |
| 5610 | void* c = reinterpret_cast<char*>(0); |
| 5611 | char d = char(0); |
| 5612 | The matcher |
| 5613 | varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) |
| 5614 | would match the declarations for a, b, c, and d. |
| 5615 | while |
| 5616 | varDecl(hasInitializer(integerLiteral())) |
| 5617 | only match the declaration for a. |
| 5618 | </pre></td></tr> |
| 5619 | |
| 5620 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5621 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5622 | <tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and |
| 5623 | parentheses are stripped off. |
| 5624 | |
| 5625 | Explicit casts are not discarded. |
| 5626 | Given |
| 5627 | int arr[5]; |
| 5628 | int a = 0; |
| 5629 | char b = (0); |
| 5630 | const int c = a; |
| 5631 | int *d = (arr); |
| 5632 | long e = ((long) 0l); |
| 5633 | The matchers |
| 5634 | varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) |
| 5635 | varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) |
| 5636 | would match the declarations for a, b, c, and d, but not e. |
| 5637 | while |
| 5638 | varDecl(hasInitializer(integerLiteral())) |
| 5639 | varDecl(hasInitializer(declRefExpr())) |
| 5640 | would only match the declaration for a. |
| 5641 | </pre></td></tr> |
| 5642 | |
| 5643 | |
Jonas Toth | 295aa09 | 2018-11-09 20:54:06 +0000 | [diff] [blame] | 5644 | <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> |
| 5645 | <tr><td colspan="4" class="doc" id="ignoringParens1"><pre>Overload ignoringParens for Expr. |
| 5646 | |
| 5647 | Given |
| 5648 | const char* str = ("my-string"); |
| 5649 | The matcher |
| 5650 | implicitCastExpr(hasSourceExpression(ignoringParens(stringLiteral()))) |
| 5651 | would match the implicit cast resulting from the assignment. |
| 5652 | </pre></td></tr> |
| 5653 | |
| 5654 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5655 | <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> |
Malcolm Parsons | 4ca3d18 | 2016-12-24 13:35:14 +0000 | [diff] [blame] | 5656 | <tr><td colspan="4" class="doc" id="hasInClassInitializer0"><pre>Matches non-static data members that have an in-class initializer. |
| 5657 | |
| 5658 | Given |
| 5659 | class C { |
| 5660 | int a = 2; |
| 5661 | int b = 3; |
| 5662 | int c; |
| 5663 | }; |
| 5664 | fieldDecl(hasInClassInitializer(integerLiteral(equals(2)))) |
| 5665 | matches 'int a;' but not 'int b;'. |
| 5666 | fieldDecl(hasInClassInitializer(anything())) |
| 5667 | matches 'int a;' and 'int b;' but not 'int c;'. |
| 5668 | </pre></td></tr> |
| 5669 | |
| 5670 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5671 | <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> |
Aaron Ballman | 2b6963f | 2016-01-20 16:26:48 +0000 | [diff] [blame] | 5672 | <tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 5673 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5674 | |
| 5675 | Given |
| 5676 | for (;;) {} |
| 5677 | hasBody(compoundStmt()) |
| 5678 | matches 'for (;;) {}' |
| 5679 | with compoundStmt() |
| 5680 | matching '{}' |
| 5681 | </pre></td></tr> |
| 5682 | |
| 5683 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5684 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5685 | <tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, |
Etienne Bergeron | 5500f95 | 2016-05-30 15:25:25 +0000 | [diff] [blame] | 5686 | switch statement or conditional operator. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5687 | |
| 5688 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 5689 | if (true) {} |
| 5690 | </pre></td></tr> |
| 5691 | |
| 5692 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5693 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5694 | <tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. |
| 5695 | |
| 5696 | Example: |
| 5697 | forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) |
| 5698 | matches '++x' in |
| 5699 | for (x; x < N; ++x) { } |
| 5700 | </pre></td></tr> |
| 5701 | |
| 5702 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5703 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5704 | <tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. |
| 5705 | |
| 5706 | Example: |
| 5707 | forStmt(hasLoopInit(declStmt())) |
| 5708 | matches 'int x = 0' in |
| 5709 | for (int x = 0; x < N; ++x) { } |
| 5710 | </pre></td></tr> |
| 5711 | |
| 5712 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5713 | <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> |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 5714 | <tr><td colspan="4" class="doc" id="hasType5"><pre>Overloaded to match the declaration of the expression's or value |
| 5715 | declaration's type. |
| 5716 | |
| 5717 | In case of a value declaration (for example a variable declaration), |
| 5718 | this resolves one layer of indirection. For example, in the value |
| 5719 | declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 5720 | X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 5721 | declaration of x. |
| 5722 | |
| 5723 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 5724 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 5725 | and friend class X (matcher = friendDecl(hasType("X")) |
| 5726 | class X {}; |
| 5727 | void y(X &x) { x; X z; } |
| 5728 | class Y { friend class X; }; |
| 5729 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5730 | 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_1ValueDecl.html">ValueDecl</a>> |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 5731 | </pre></td></tr> |
| 5732 | |
| 5733 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5734 | <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> |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 5735 | <tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type |
| 5736 | matcher. |
| 5737 | |
| 5738 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 5739 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 5740 | and U (matcher = typedefDecl(hasType(asString("int"))) |
| 5741 | and friend class X (matcher = friendDecl(hasType("X")) |
| 5742 | class X {}; |
| 5743 | void y(X &x) { x; X z; } |
| 5744 | typedef int U; |
| 5745 | class Y { friend class X; }; |
| 5746 | </pre></td></tr> |
| 5747 | |
| 5748 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5749 | <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> |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 5750 | <tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function or an ObjC method declaration or a |
| 5751 | block. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5752 | |
| 5753 | Does not match the 'this' parameter of a method. |
| 5754 | |
| 5755 | Given |
| 5756 | class X { void f(int x, int y, int z) {} }; |
| 5757 | cxxMethodDecl(hasAnyParameter(hasName("y"))) |
| 5758 | matches f(int x, int y, int z) {} |
| 5759 | with hasAnyParameter(...) |
| 5760 | matching int y |
George Karpenkov | 9d1d0c4 | 2018-03-29 00:51:11 +0000 | [diff] [blame] | 5761 | |
| 5762 | For ObjectiveC, given |
| 5763 | @interface I - (void) f:(int) y; @end |
| 5764 | |
| 5765 | the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) |
| 5766 | matches the declaration of method f with hasParameter |
| 5767 | matching y. |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 5768 | |
| 5769 | For blocks, given |
| 5770 | b = ^(int y) { printf("%d", y) }; |
| 5771 | |
| 5772 | the matcher blockDecl(hasAnyParameter(hasName("y"))) |
| 5773 | matches the declaration of the block b with hasParameter |
| 5774 | matching y. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5775 | </pre></td></tr> |
| 5776 | |
| 5777 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5778 | <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> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5779 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and |
| 5780 | functionDecl that have at least one TemplateArgument matching the given |
| 5781 | InnerMatcher. |
| 5782 | |
| 5783 | Given |
| 5784 | template<typename T> class A {}; |
| 5785 | template<> class A<double> {}; |
| 5786 | A<int> a; |
| 5787 | |
Haojian Wu | 99e39a7 | 2016-07-29 17:30:13 +0000 | [diff] [blame] | 5788 | template<typename T> f() {}; |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5789 | void func() { f<int>(); }; |
| 5790 | |
| 5791 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 5792 | refersToType(asString("int")))) |
| 5793 | matches the specialization A<int> |
| 5794 | |
| 5795 | functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) |
| 5796 | matches the specialization f<int> |
| 5797 | </pre></td></tr> |
| 5798 | |
| 5799 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5800 | <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> |
Aaron Ballman | 2b6963f | 2016-01-20 16:26:48 +0000 | [diff] [blame] | 5801 | <tr><td colspan="4" class="doc" id="hasBody4"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 5802 | definition that has a given body. |
| 5803 | |
| 5804 | Given |
| 5805 | for (;;) {} |
| 5806 | hasBody(compoundStmt()) |
| 5807 | matches 'for (;;) {}' |
| 5808 | with compoundStmt() |
| 5809 | matching '{}' |
| 5810 | </pre></td></tr> |
| 5811 | |
| 5812 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5813 | <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> |
George Karpenkov | 9d1d0c4 | 2018-03-29 00:51:11 +0000 | [diff] [blame] | 5814 | <tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function or an ObjC method |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 5815 | declaration or a block. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5816 | |
| 5817 | Given |
| 5818 | class X { void f(int x) {} }; |
| 5819 | cxxMethodDecl(hasParameter(0, hasType(varDecl()))) |
| 5820 | matches f(int x) {} |
| 5821 | with hasParameter(...) |
| 5822 | matching int x |
George Karpenkov | 9d1d0c4 | 2018-03-29 00:51:11 +0000 | [diff] [blame] | 5823 | |
| 5824 | For ObjectiveC, given |
| 5825 | @interface I - (void) f:(int) y; @end |
| 5826 | |
| 5827 | the matcher objcMethodDecl(hasParameter(0, hasName("y"))) |
| 5828 | matches the declaration of method f with hasParameter |
| 5829 | matching y. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5830 | </pre></td></tr> |
| 5831 | |
| 5832 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5833 | <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> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5834 | <tr><td colspan="4" class="doc" id="hasTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and |
| 5835 | functionDecl where the n'th TemplateArgument matches the given InnerMatcher. |
| 5836 | |
| 5837 | Given |
| 5838 | template<typename T, typename U> class A {}; |
| 5839 | A<bool, int> b; |
| 5840 | A<int, bool> c; |
| 5841 | |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 5842 | template<typename T> void f() {} |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 5843 | void func() { f<int>(); }; |
| 5844 | classTemplateSpecializationDecl(hasTemplateArgument( |
| 5845 | 1, refersToType(asString("int")))) |
| 5846 | matches the specialization A<bool, int> |
| 5847 | |
| 5848 | functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) |
| 5849 | matches the specialization f<int> |
| 5850 | </pre></td></tr> |
| 5851 | |
| 5852 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5853 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5854 | <tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. |
| 5855 | |
| 5856 | Given: |
| 5857 | class X { int f() { return 1; } }; |
| 5858 | cxxMethodDecl(returns(asString("int"))) |
| 5859 | matches int f() { return 1; } |
| 5860 | </pre></td></tr> |
| 5861 | |
| 5862 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5863 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5864 | <tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, |
Etienne Bergeron | 5500f95 | 2016-05-30 15:25:25 +0000 | [diff] [blame] | 5865 | switch statement or conditional operator. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5866 | |
| 5867 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 5868 | if (true) {} |
| 5869 | </pre></td></tr> |
| 5870 | |
| 5871 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5872 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5873 | <tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. |
| 5874 | |
| 5875 | Given |
| 5876 | if (A* a = GetAPointer()) {} |
| 5877 | hasConditionVariableStatement(...) |
| 5878 | matches 'A* a = GetAPointer()'. |
| 5879 | </pre></td></tr> |
| 5880 | |
| 5881 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5882 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5883 | <tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. |
| 5884 | |
| 5885 | Examples matches the if statement |
| 5886 | (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true))))) |
| 5887 | if (false) false; else true; |
| 5888 | </pre></td></tr> |
| 5889 | |
| 5890 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5891 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5892 | <tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. |
| 5893 | |
| 5894 | Examples matches the if statement |
| 5895 | (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true))))) |
| 5896 | if (false) true; else false; |
| 5897 | </pre></td></tr> |
| 5898 | |
| 5899 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5900 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5901 | <tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given |
| 5902 | matcher. |
| 5903 | |
| 5904 | FIXME: Unit test this matcher |
| 5905 | </pre></td></tr> |
| 5906 | |
| 5907 | |
Hyrum Wright | 2cd40c0 | 2019-01-07 14:14:36 +0000 | [diff] [blame] | 5908 | <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> |
| 5909 | <tr><td colspan="4" class="doc" id="hasInit0"><pre>Matches the n'th item of an initializer list expression. |
| 5910 | |
| 5911 | Example matches y. |
| 5912 | (matcher = initListExpr(hasInit(0, expr()))) |
| 5913 | int x{y}. |
| 5914 | </pre></td></tr> |
| 5915 | |
| 5916 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5917 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 5918 | <tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions |
| 5919 | (if expression have it). |
| 5920 | </pre></td></tr> |
| 5921 | |
| 5922 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5923 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5924 | <tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node |
| 5925 | matches the given matcher. |
| 5926 | |
| 5927 | The associated declaration is: |
| 5928 | - for type nodes, the declaration of the underlying type |
| 5929 | - for CallExpr, the declaration of the callee |
| 5930 | - for MemberExpr, the declaration of the referenced member |
| 5931 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 5932 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 5933 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5934 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5935 | For type nodes, hasDeclaration will generally match the declaration of the |
| 5936 | sugared type. Given |
| 5937 | class X {}; |
| 5938 | typedef X Y; |
| 5939 | Y y; |
| 5940 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 5941 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 5942 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 5943 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 5944 | recordType(hasDeclaration(decl()))))) |
| 5945 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5946 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5947 | 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>>, |
| 5948 | 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>>, |
| 5949 | 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>>, |
| 5950 | 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>>, |
| 5951 | 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>>, |
| 5952 | 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>>, |
| 5953 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5954 | </pre></td></tr> |
| 5955 | |
| 5956 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5957 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5958 | <tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node |
| 5959 | matches the given matcher. |
| 5960 | |
| 5961 | The associated declaration is: |
| 5962 | - for type nodes, the declaration of the underlying type |
| 5963 | - for CallExpr, the declaration of the callee |
| 5964 | - for MemberExpr, the declaration of the referenced member |
| 5965 | - for CXXConstructExpr, the declaration of the constructor |
| 5966 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 5967 | - for ObjCIvarExpr, the declaration of the ivar |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5968 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 5969 | For type nodes, hasDeclaration will generally match the declaration of the |
| 5970 | sugared type. Given |
| 5971 | class X {}; |
| 5972 | typedef X Y; |
| 5973 | Y y; |
| 5974 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 5975 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 5976 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 5977 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 5978 | recordType(hasDeclaration(decl()))))) |
| 5979 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 5980 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5981 | 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>>, |
| 5982 | 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>>, |
| 5983 | 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>>, |
| 5984 | 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>>, |
| 5985 | 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>>, |
| 5986 | 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>>, |
| 5987 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5988 | </pre></td></tr> |
| 5989 | |
| 5990 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 5991 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 5992 | <tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node |
| 5993 | matches the given matcher. |
| 5994 | |
| 5995 | The associated declaration is: |
| 5996 | - for type nodes, the declaration of the underlying type |
| 5997 | - for CallExpr, the declaration of the callee |
| 5998 | - for MemberExpr, the declaration of the referenced member |
| 5999 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6000 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6001 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6002 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6003 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6004 | sugared type. Given |
| 6005 | class X {}; |
| 6006 | typedef X Y; |
| 6007 | Y y; |
| 6008 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6009 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6010 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6011 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6012 | recordType(hasDeclaration(decl()))))) |
| 6013 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6014 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6015 | 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>>, |
| 6016 | 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>>, |
| 6017 | 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>>, |
| 6018 | 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>>, |
| 6019 | 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>>, |
| 6020 | 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>>, |
| 6021 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6022 | </pre></td></tr> |
| 6023 | |
| 6024 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6025 | <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> |
Yitzhak Mandelbaum | 8a43680 | 2019-02-08 16:00:44 +0000 | [diff] [blame^] | 6026 | <tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is matched by a |
| 6027 | given matcher. Implicit object expressions are included; that is, it matches |
| 6028 | use of implicit `this`. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6029 | |
| 6030 | Given |
Yitzhak Mandelbaum | 8a43680 | 2019-02-08 16:00:44 +0000 | [diff] [blame^] | 6031 | struct X { |
| 6032 | int m; |
| 6033 | int f(X x) { x.m; return m; } |
| 6034 | }; |
| 6035 | memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))) |
| 6036 | matches `x.m`, but not `m`; however, |
| 6037 | memberExpr(hasObjectExpression(hasType(pointsTo( |
| 6038 | cxxRecordDecl(hasName("X")))))) |
| 6039 | matches `m` (aka. `this->m`), but not `x.m`. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6040 | </pre></td></tr> |
| 6041 | |
| 6042 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6043 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6044 | <tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a |
| 6045 | given matcher. |
| 6046 | |
| 6047 | Given |
| 6048 | struct { int first, second; } first, second; |
| 6049 | int i(second.first); |
| 6050 | int j(first.second); |
| 6051 | memberExpr(member(hasName("first"))) |
| 6052 | matches second.first |
| 6053 | but not first.second (because the member name there is "second"). |
| 6054 | </pre></td></tr> |
| 6055 | |
| 6056 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6057 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6058 | <tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the |
| 6059 | pointee matches a given matcher. |
| 6060 | |
| 6061 | Given |
| 6062 | int *a; |
| 6063 | int const *b; |
| 6064 | float const *f; |
| 6065 | pointerType(pointee(isConstQualified(), isInteger())) |
| 6066 | matches "int const *b" |
| 6067 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6068 | 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>>, |
| 6069 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6070 | </pre></td></tr> |
| 6071 | |
| 6072 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6073 | <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> |
Martin Bohme | 8cef2c2 | 2016-08-09 15:07:52 +0000 | [diff] [blame] | 6074 | <tr><td colspan="4" class="doc" id="hasUnderlyingDecl0"><pre>Matches a NamedDecl whose underlying declaration matches the given |
| 6075 | matcher. |
| 6076 | |
| 6077 | Given |
| 6078 | namespace N { template<class T> void f(T t); } |
| 6079 | template <class T> void g() { using N::f; f(T()); } |
| 6080 | unresolvedLookupExpr(hasAnyDeclaration( |
| 6081 | namedDecl(hasUnderlyingDecl(hasName("::N::f"))))) |
| 6082 | matches the use of f in g() . |
| 6083 | </pre></td></tr> |
| 6084 | |
| 6085 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6086 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6087 | <tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. |
| 6088 | |
| 6089 | Given |
| 6090 | struct A { struct B { struct C {}; }; }; |
| 6091 | A::B::C c; |
| 6092 | nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) |
| 6093 | matches "A::" |
| 6094 | </pre></td></tr> |
| 6095 | |
| 6096 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6097 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6098 | <tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the |
| 6099 | given TypeLoc. |
| 6100 | |
| 6101 | Given |
| 6102 | struct A { struct B { struct C {}; }; }; |
| 6103 | A::B::C c; |
| 6104 | nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( |
| 6105 | hasDeclaration(cxxRecordDecl(hasName("A"))))))) |
| 6106 | matches "A::" |
| 6107 | </pre></td></tr> |
| 6108 | |
| 6109 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6110 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6111 | <tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. |
| 6112 | |
| 6113 | Given |
| 6114 | struct A { struct B { struct C {}; }; }; |
| 6115 | A::B::C c; |
| 6116 | nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and |
| 6117 | matches "A::" |
| 6118 | </pre></td></tr> |
| 6119 | |
| 6120 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6121 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6122 | <tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the |
| 6123 | given namespace matcher. |
| 6124 | |
| 6125 | Given |
| 6126 | namespace ns { struct A {}; } |
| 6127 | ns::A a; |
| 6128 | nestedNameSpecifier(specifiesNamespace(hasName("ns"))) |
| 6129 | matches "ns::" |
| 6130 | </pre></td></tr> |
| 6131 | |
| 6132 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6133 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6134 | <tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the |
| 6135 | given QualType matcher without qualifiers. |
| 6136 | |
| 6137 | Given |
| 6138 | struct A { struct B { struct C {}; }; }; |
| 6139 | A::B::C c; |
| 6140 | nestedNameSpecifier(specifiesType( |
| 6141 | hasDeclaration(cxxRecordDecl(hasName("A"))) |
| 6142 | )) |
| 6143 | matches "A::" |
| 6144 | </pre></td></tr> |
| 6145 | |
| 6146 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6147 | <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> |
Shuai Wang | 3b2a17b | 2018-08-12 23:30:05 +0000 | [diff] [blame] | 6148 | <tr><td colspan="4" class="doc" id="hasAnyArgument3"><pre>Matches any argument of a call expression or a constructor call |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 6149 | expression, or an ObjC-message-send expression. |
| 6150 | |
| 6151 | Given |
| 6152 | void x(int, int, int) { int y; x(1, y, 42); } |
| 6153 | callExpr(hasAnyArgument(declRefExpr())) |
| 6154 | matches x(1, y, 42) |
| 6155 | with hasAnyArgument(...) |
| 6156 | matching y |
| 6157 | |
| 6158 | For ObjectiveC, given |
| 6159 | @interface I - (void) f:(int) y; @end |
Clement Courbet | 2513aa0 | 2018-03-21 10:48:00 +0000 | [diff] [blame] | 6160 | void foo(I *i) { [i f:12]; } |
George Karpenkov | a763fdf | 2018-03-07 02:32:44 +0000 | [diff] [blame] | 6161 | objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) |
| 6162 | matches [i f:12] |
| 6163 | </pre></td></tr> |
| 6164 | |
| 6165 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6166 | <tr><td>Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6167 | <tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor |
| 6168 | call expression. |
| 6169 | |
| 6170 | Example matches y in x(y) |
| 6171 | (matcher = callExpr(hasArgument(0, declRefExpr()))) |
| 6172 | void x(int) { int y; x(y); } |
| 6173 | </pre></td></tr> |
| 6174 | |
| 6175 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6176 | <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> |
George Karpenkov | b5ea4df | 2018-07-16 20:22:12 +0000 | [diff] [blame] | 6177 | <tr><td colspan="4" class="doc" id="hasReceiver0"><pre>Matches if the Objective-C message is sent to an instance, |
| 6178 | and the inner matcher matches on that instance. |
| 6179 | |
| 6180 | For example the method call in |
| 6181 | NSString *x = @"hello"; |
George Karpenkov | daac52c | 2018-07-23 22:29:10 +0000 | [diff] [blame] | 6182 | [x containsString:@"h"]; |
George Karpenkov | b5ea4df | 2018-07-16 20:22:12 +0000 | [diff] [blame] | 6183 | is matched by |
| 6184 | objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x")))))) |
| 6185 | </pre></td></tr> |
| 6186 | |
| 6187 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6188 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6189 | <tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. |
| 6190 | |
| 6191 | Example |
Jakub Kuderski | 64b6c78 | 2017-05-05 21:01:12 +0000 | [diff] [blame] | 6192 | matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *"))); |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6193 | matches the [webView ...] message invocation. |
| 6194 | NSString *webViewJavaScript = ... |
| 6195 | UIWebView *webView = ... |
| 6196 | [webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; |
| 6197 | </pre></td></tr> |
| 6198 | |
| 6199 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6200 | <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> |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 6201 | <tr><td colspan="4" class="doc" id="hasAnyParameter1"><pre>Matches any parameter of a function or an ObjC method declaration or a |
| 6202 | block. |
George Karpenkov | 9d1d0c4 | 2018-03-29 00:51:11 +0000 | [diff] [blame] | 6203 | |
| 6204 | Does not match the 'this' parameter of a method. |
| 6205 | |
| 6206 | Given |
| 6207 | class X { void f(int x, int y, int z) {} }; |
| 6208 | cxxMethodDecl(hasAnyParameter(hasName("y"))) |
| 6209 | matches f(int x, int y, int z) {} |
| 6210 | with hasAnyParameter(...) |
| 6211 | matching int y |
| 6212 | |
| 6213 | For ObjectiveC, given |
| 6214 | @interface I - (void) f:(int) y; @end |
| 6215 | |
| 6216 | the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) |
| 6217 | matches the declaration of method f with hasParameter |
| 6218 | matching y. |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 6219 | |
| 6220 | For blocks, given |
| 6221 | b = ^(int y) { printf("%d", y) }; |
| 6222 | |
| 6223 | the matcher blockDecl(hasAnyParameter(hasName("y"))) |
| 6224 | matches the declaration of the block b with hasParameter |
| 6225 | matching y. |
George Karpenkov | 9d1d0c4 | 2018-03-29 00:51:11 +0000 | [diff] [blame] | 6226 | </pre></td></tr> |
| 6227 | |
| 6228 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6229 | <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> |
George Karpenkov | 9d1d0c4 | 2018-03-29 00:51:11 +0000 | [diff] [blame] | 6230 | <tr><td colspan="4" class="doc" id="hasParameter1"><pre>Matches the n'th parameter of a function or an ObjC method |
George Karpenkov | b4c0cbd | 2018-05-16 22:47:03 +0000 | [diff] [blame] | 6231 | declaration or a block. |
George Karpenkov | 9d1d0c4 | 2018-03-29 00:51:11 +0000 | [diff] [blame] | 6232 | |
| 6233 | Given |
| 6234 | class X { void f(int x) {} }; |
| 6235 | cxxMethodDecl(hasParameter(0, hasType(varDecl()))) |
| 6236 | matches f(int x) {} |
| 6237 | with hasParameter(...) |
| 6238 | matching int x |
| 6239 | |
| 6240 | For ObjectiveC, given |
| 6241 | @interface I - (void) f:(int) y; @end |
| 6242 | |
| 6243 | the matcher objcMethodDecl(hasParameter(0, hasName("y"))) |
| 6244 | matches the declaration of method f with hasParameter |
| 6245 | matching y. |
| 6246 | </pre></td></tr> |
| 6247 | |
| 6248 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6249 | <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> |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6250 | <tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre>Matches if the cast's source expression |
| 6251 | or opaque value's source expression matches the given matcher. |
| 6252 | |
| 6253 | Example 1: matches "a string" |
| 6254 | (matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) |
| 6255 | class URL { URL(string); }; |
| 6256 | URL url = "a string"; |
| 6257 | |
| 6258 | Example 2: matches 'b' (matcher = |
| 6259 | opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) |
| 6260 | int a = b ?: 1; |
| 6261 | </pre></td></tr> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 6262 | |
| 6263 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6264 | <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> |
Martin Bohme | 8cef2c2 | 2016-08-09 15:07:52 +0000 | [diff] [blame] | 6265 | <tr><td colspan="4" class="doc" id="hasAnyDeclaration0"><pre>Matches an OverloadExpr if any of the declarations in the set of |
| 6266 | overloads matches the given matcher. |
| 6267 | |
| 6268 | Given |
| 6269 | template <typename T> void foo(T); |
| 6270 | template <typename T> void bar(T); |
| 6271 | template <typename T> void baz(T t) { |
| 6272 | foo(t); |
| 6273 | bar(t); |
| 6274 | } |
| 6275 | unresolvedLookupExpr(hasAnyDeclaration( |
| 6276 | functionTemplateDecl(hasName("foo")))) |
| 6277 | matches foo in foo(t); but not bar in bar(t); |
| 6278 | </pre></td></tr> |
| 6279 | |
| 6280 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6281 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6282 | <tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. |
| 6283 | |
| 6284 | Given |
| 6285 | int (*ptr_to_array)[4]; |
| 6286 | int (*ptr_to_func)(int); |
| 6287 | |
| 6288 | varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches |
| 6289 | ptr_to_func but not ptr_to_array. |
| 6290 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6291 | Usable as: Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6292 | </pre></td></tr> |
| 6293 | |
| 6294 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6295 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6296 | <tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the |
| 6297 | pointee matches a given matcher. |
| 6298 | |
| 6299 | Given |
| 6300 | int *a; |
| 6301 | int const *b; |
| 6302 | float const *f; |
| 6303 | pointerType(pointee(isConstQualified(), isInteger())) |
| 6304 | matches "int const *b" |
| 6305 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6306 | 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>>, |
| 6307 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6308 | </pre></td></tr> |
| 6309 | |
| 6310 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6311 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6312 | <tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. |
| 6313 | |
| 6314 | Given: |
| 6315 | typedef int &int_ref; |
| 6316 | int a; |
| 6317 | int_ref b = a; |
| 6318 | |
| 6319 | varDecl(hasType(qualType(referenceType()))))) will not match the |
| 6320 | declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. |
| 6321 | </pre></td></tr> |
| 6322 | |
| 6323 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6324 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6325 | <tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node |
| 6326 | matches the given matcher. |
| 6327 | |
| 6328 | The associated declaration is: |
| 6329 | - for type nodes, the declaration of the underlying type |
| 6330 | - for CallExpr, the declaration of the callee |
| 6331 | - for MemberExpr, the declaration of the referenced member |
| 6332 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6333 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6334 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6335 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6336 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6337 | sugared type. Given |
| 6338 | class X {}; |
| 6339 | typedef X Y; |
| 6340 | Y y; |
| 6341 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6342 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6343 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6344 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6345 | recordType(hasDeclaration(decl()))))) |
| 6346 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6347 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6348 | 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>>, |
| 6349 | 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>>, |
| 6350 | 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>>, |
| 6351 | 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>>, |
| 6352 | 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>>, |
| 6353 | 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>>, |
| 6354 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6355 | </pre></td></tr> |
| 6356 | |
| 6357 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6358 | <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> |
Aaron Ballman | ba8dbbe | 2016-06-06 18:52:17 +0000 | [diff] [blame] | 6359 | <tr><td colspan="4" class="doc" id="ignoringParens0"><pre>Matches types that match InnerMatcher after any parens are stripped. |
| 6360 | |
| 6361 | Given |
| 6362 | void (*fp)(void); |
| 6363 | The matcher |
| 6364 | varDecl(hasType(pointerType(pointee(ignoringParens(functionType()))))) |
| 6365 | would match the declaration for fp. |
| 6366 | </pre></td></tr> |
| 6367 | |
| 6368 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6369 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6370 | <tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. |
| 6371 | </pre></td></tr> |
| 6372 | |
| 6373 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6374 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6375 | <tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type |
| 6376 | matches the specified matcher. |
| 6377 | |
| 6378 | Example matches y->x() |
| 6379 | (matcher = cxxMemberCallExpr(on(hasType(pointsTo |
| 6380 | cxxRecordDecl(hasName("Y"))))))) |
| 6381 | class Y { public: void x(); }; |
| 6382 | void z() { Y *y; y->x(); } |
| 6383 | </pre></td></tr> |
| 6384 | |
| 6385 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6386 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6387 | <tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. |
| 6388 | </pre></td></tr> |
| 6389 | |
| 6390 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6391 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6392 | <tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced |
| 6393 | type matches the specified matcher. |
| 6394 | |
| 6395 | Example matches X &x and const X &y |
| 6396 | (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X")))))) |
| 6397 | class X { |
| 6398 | void a(X b) { |
| 6399 | X &x = b; |
| 6400 | const X &y = b; |
| 6401 | } |
| 6402 | }; |
| 6403 | </pre></td></tr> |
| 6404 | |
| 6405 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6406 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6407 | <tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node |
| 6408 | matches the given matcher. |
| 6409 | |
| 6410 | The associated declaration is: |
| 6411 | - for type nodes, the declaration of the underlying type |
| 6412 | - for CallExpr, the declaration of the callee |
| 6413 | - for MemberExpr, the declaration of the referenced member |
| 6414 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6415 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6416 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6417 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6418 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6419 | sugared type. Given |
| 6420 | class X {}; |
| 6421 | typedef X Y; |
| 6422 | Y y; |
| 6423 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6424 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6425 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6426 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6427 | recordType(hasDeclaration(decl()))))) |
| 6428 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6429 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6430 | 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>>, |
| 6431 | 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>>, |
| 6432 | 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>>, |
| 6433 | 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>>, |
| 6434 | 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>>, |
| 6435 | 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>>, |
| 6436 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6437 | </pre></td></tr> |
| 6438 | |
| 6439 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6440 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6441 | <tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the |
| 6442 | pointee matches a given matcher. |
| 6443 | |
| 6444 | Given |
| 6445 | int *a; |
| 6446 | int const *b; |
| 6447 | float const *f; |
| 6448 | pointerType(pointee(isConstQualified(), isInteger())) |
| 6449 | matches "int const *b" |
| 6450 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6451 | 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>>, |
| 6452 | 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>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6453 | </pre></td></tr> |
| 6454 | |
| 6455 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6456 | <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> |
Alexander Kornienko | 976921d | 2016-03-22 11:03:03 +0000 | [diff] [blame] | 6457 | <tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement |
| 6458 | |
| 6459 | Given |
| 6460 | return a + b; |
| 6461 | hasReturnValue(binaryOperator()) |
| 6462 | matches 'return a + b' |
| 6463 | with binaryOperator() |
| 6464 | matching 'a + b' |
| 6465 | </pre></td></tr> |
| 6466 | |
| 6467 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6468 | <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> |
Aaron Ballman | a35b8fc | 2016-03-09 17:11:51 +0000 | [diff] [blame] | 6469 | <tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches |
| 6470 | a given matcher. Also matches StmtExprs that have CompoundStmt as children. |
| 6471 | |
| 6472 | Given |
| 6473 | { {}; 1+2; } |
| 6474 | hasAnySubstatement(compoundStmt()) |
| 6475 | matches '{ {}; 1+2; }' |
| 6476 | with compoundStmt() |
| 6477 | matching '{}' |
| 6478 | </pre></td></tr> |
| 6479 | |
| 6480 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6481 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6482 | <tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 6483 | alignof. |
| 6484 | </pre></td></tr> |
| 6485 | |
| 6486 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6487 | <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> |
Malcolm Parsons | def8f90 | 2017-01-20 09:54:26 +0000 | [diff] [blame] | 6488 | <tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statement belongs to |
Gabor Horvath | 1b3f8db | 2016-05-04 11:59:39 +0000 | [diff] [blame] | 6489 | |
| 6490 | Given: |
| 6491 | F& operator=(const F& o) { |
| 6492 | std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; }); |
| 6493 | return *this; |
| 6494 | } |
| 6495 | returnStmt(forFunction(hasName("operator="))) |
| 6496 | matches 'return *this' |
| 6497 | but does match 'return > 0' |
| 6498 | </pre></td></tr> |
| 6499 | |
| 6500 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6501 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6502 | <tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching |
| 6503 | sizeof. |
| 6504 | </pre></td></tr> |
| 6505 | |
| 6506 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6507 | <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> |
Malcolm Parsons | 77f039b | 2016-12-08 11:46:22 +0000 | [diff] [blame] | 6508 | <tr><td colspan="4" class="doc" id="hasReplacementType0"><pre>Matches template type parameter substitutions that have a replacement |
| 6509 | type that matches the provided matcher. |
| 6510 | |
| 6511 | Given |
| 6512 | template <typename T> |
| 6513 | double F(T t); |
| 6514 | int i; |
| 6515 | double j = F(i); |
| 6516 | |
| 6517 | substTemplateTypeParmType(hasReplacementType(type())) matches int |
| 6518 | </pre></td></tr> |
| 6519 | |
| 6520 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6521 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6522 | <tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch |
| 6523 | statement. This matcher may produce multiple matches. |
| 6524 | |
| 6525 | Given |
| 6526 | switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } |
| 6527 | switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") |
| 6528 | matches four times, with "c" binding each of "case 1:", "case 2:", |
| 6529 | "case 3:" and "case 4:", and "s" respectively binding "switch (1)", |
| 6530 | "switch (1)", "switch (2)" and "switch (2)". |
| 6531 | </pre></td></tr> |
| 6532 | |
| 6533 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6534 | <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> |
Etienne Bergeron | 5500f95 | 2016-05-30 15:25:25 +0000 | [diff] [blame] | 6535 | <tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, |
| 6536 | switch statement or conditional operator. |
| 6537 | |
| 6538 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 6539 | if (true) {} |
| 6540 | </pre></td></tr> |
| 6541 | |
| 6542 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6543 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6544 | <tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node |
| 6545 | matches the given matcher. |
| 6546 | |
| 6547 | The associated declaration is: |
| 6548 | - for type nodes, the declaration of the underlying type |
| 6549 | - for CallExpr, the declaration of the callee |
| 6550 | - for MemberExpr, the declaration of the referenced member |
| 6551 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6552 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6553 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6554 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6555 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6556 | sugared type. Given |
| 6557 | class X {}; |
| 6558 | typedef X Y; |
| 6559 | Y y; |
| 6560 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6561 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6562 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6563 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6564 | recordType(hasDeclaration(decl()))))) |
| 6565 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6566 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6567 | 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>>, |
| 6568 | 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>>, |
| 6569 | 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>>, |
| 6570 | 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>>, |
| 6571 | 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>>, |
| 6572 | 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>>, |
| 6573 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6574 | </pre></td></tr> |
| 6575 | |
| 6576 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6577 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6578 | <tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. |
| 6579 | |
| 6580 | Given |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 6581 | struct B { int next; }; |
| 6582 | template<int(B::*next_ptr)> struct A {}; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6583 | A<&B::next> a; |
| 6584 | templateSpecializationType(hasAnyTemplateArgument( |
| 6585 | isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) |
| 6586 | matches the specialization A<&B::next> with fieldDecl(...) matching |
| 6587 | B::next |
| 6588 | </pre></td></tr> |
| 6589 | |
| 6590 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6591 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6592 | <tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain |
| 6593 | declaration. |
| 6594 | |
| 6595 | Given |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 6596 | struct B { int next; }; |
| 6597 | template<int(B::*next_ptr)> struct A {}; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6598 | A<&B::next> a; |
| 6599 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 6600 | refersToDeclaration(fieldDecl(hasName("next"))))) |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6601 | matches the specialization A<&B::next> with fieldDecl(...) matching |
| 6602 | B::next |
| 6603 | </pre></td></tr> |
| 6604 | |
| 6605 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6606 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6607 | <tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type. |
| 6608 | |
| 6609 | Given |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 6610 | template<int T> struct C {}; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6611 | C<42> c; |
| 6612 | classTemplateSpecializationDecl( |
| 6613 | hasAnyTemplateArgument(refersToIntegralType(asString("int")))) |
| 6614 | matches the implicit instantiation of C in C<42>. |
| 6615 | </pre></td></tr> |
| 6616 | |
| 6617 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6618 | <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> |
Haojian Wu | b33b02e | 2016-07-29 15:45:11 +0000 | [diff] [blame] | 6619 | <tr><td colspan="4" class="doc" id="refersToTemplate0"><pre>Matches a TemplateArgument that refers to a certain template. |
| 6620 | |
| 6621 | Given |
| 6622 | template<template <typename> class S> class X {}; |
Stephen Kelly | 9b8fa52 | 2018-10-09 08:24:11 +0000 | [diff] [blame] | 6623 | template<typename T> class Y {}; |
Haojian Wu | b33b02e | 2016-07-29 15:45:11 +0000 | [diff] [blame] | 6624 | X<Y> xi; |
| 6625 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 6626 | refersToTemplate(templateName()))) |
| 6627 | matches the specialization X<Y> |
| 6628 | </pre></td></tr> |
| 6629 | |
| 6630 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6631 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6632 | <tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. |
| 6633 | |
| 6634 | Given |
| 6635 | struct X {}; |
| 6636 | template<typename T> struct A {}; |
| 6637 | A<X> a; |
| 6638 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 6639 | refersToType(class(hasName("X"))))) |
| 6640 | matches the specialization A<X> |
| 6641 | </pre></td></tr> |
| 6642 | |
| 6643 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6644 | <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> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6645 | <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and |
| 6646 | functionDecl that have at least one TemplateArgument matching the given |
| 6647 | InnerMatcher. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6648 | |
| 6649 | Given |
| 6650 | template<typename T> class A {}; |
| 6651 | template<> class A<double> {}; |
| 6652 | A<int> a; |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6653 | |
Haojian Wu | 99e39a7 | 2016-07-29 17:30:13 +0000 | [diff] [blame] | 6654 | template<typename T> f() {}; |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6655 | void func() { f<int>(); }; |
| 6656 | |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6657 | classTemplateSpecializationDecl(hasAnyTemplateArgument( |
| 6658 | refersToType(asString("int")))) |
| 6659 | matches the specialization A<int> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6660 | |
| 6661 | functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) |
| 6662 | matches the specialization f<int> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6663 | </pre></td></tr> |
| 6664 | |
| 6665 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6666 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6667 | <tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node |
| 6668 | matches the given matcher. |
| 6669 | |
| 6670 | The associated declaration is: |
| 6671 | - for type nodes, the declaration of the underlying type |
| 6672 | - for CallExpr, the declaration of the callee |
| 6673 | - for MemberExpr, the declaration of the referenced member |
| 6674 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6675 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6676 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6677 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6678 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6679 | sugared type. Given |
| 6680 | class X {}; |
| 6681 | typedef X Y; |
| 6682 | Y y; |
| 6683 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6684 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6685 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6686 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6687 | recordType(hasDeclaration(decl()))))) |
| 6688 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6689 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6690 | 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>>, |
| 6691 | 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>>, |
| 6692 | 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>>, |
| 6693 | 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>>, |
| 6694 | 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>>, |
| 6695 | 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>>, |
| 6696 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6697 | </pre></td></tr> |
| 6698 | |
| 6699 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6700 | <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> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6701 | <tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and |
| 6702 | functionDecl where the n'th TemplateArgument matches the given InnerMatcher. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6703 | |
| 6704 | Given |
| 6705 | template<typename T, typename U> class A {}; |
| 6706 | A<bool, int> b; |
| 6707 | A<int, bool> c; |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6708 | |
Fangrui Song | 55942ab | 2018-01-22 22:34:15 +0000 | [diff] [blame] | 6709 | template<typename T> void f() {} |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6710 | void func() { f<int>(); }; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6711 | classTemplateSpecializationDecl(hasTemplateArgument( |
| 6712 | 1, refersToType(asString("int")))) |
| 6713 | matches the specialization A<bool, int> |
Haojian Wu | d898b09 | 2016-07-29 13:57:27 +0000 | [diff] [blame] | 6714 | |
| 6715 | functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) |
| 6716 | matches the specialization f<int> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6717 | </pre></td></tr> |
| 6718 | |
| 6719 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6720 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6721 | <tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node |
| 6722 | matches the given matcher. |
| 6723 | |
| 6724 | The associated declaration is: |
| 6725 | - for type nodes, the declaration of the underlying type |
| 6726 | - for CallExpr, the declaration of the callee |
| 6727 | - for MemberExpr, the declaration of the referenced member |
| 6728 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6729 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6730 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6731 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6732 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6733 | sugared type. Given |
| 6734 | class X {}; |
| 6735 | typedef X Y; |
| 6736 | Y y; |
| 6737 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6738 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6739 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6740 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6741 | recordType(hasDeclaration(decl()))))) |
| 6742 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6743 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6744 | 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>>, |
| 6745 | 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>>, |
| 6746 | 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>>, |
| 6747 | 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>>, |
| 6748 | 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>>, |
| 6749 | 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>>, |
| 6750 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6751 | </pre></td></tr> |
| 6752 | |
| 6753 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6754 | <tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>const Matcher<T> Matcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6755 | <tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. |
| 6756 | |
| 6757 | Generates results for each match. |
| 6758 | |
| 6759 | For example, in: |
| 6760 | class A { class B {}; class C {}; }; |
| 6761 | The matcher: |
| 6762 | cxxRecordDecl(hasName("::A"), |
| 6763 | findAll(cxxRecordDecl(isDefinition()).bind("m"))) |
| 6764 | will generate results for A, B and C. |
| 6765 | |
| 6766 | Usable as: Any Matcher |
| 6767 | </pre></td></tr> |
| 6768 | |
| 6769 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6770 | <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> |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6771 | <tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 6772 | matcher. |
| 6773 | |
| 6774 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 6775 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
| 6776 | and U (matcher = typedefDecl(hasType(asString("int"))) |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6777 | and friend class X (matcher = friendDecl(hasType("X")) |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 6778 | class X {}; |
| 6779 | void y(X &x) { x; X z; } |
| 6780 | typedef int U; |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6781 | class Y { friend class X; }; |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 6782 | </pre></td></tr> |
| 6783 | |
| 6784 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6785 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6786 | <tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node |
| 6787 | matches the given matcher. |
| 6788 | |
| 6789 | The associated declaration is: |
| 6790 | - for type nodes, the declaration of the underlying type |
| 6791 | - for CallExpr, the declaration of the callee |
| 6792 | - for MemberExpr, the declaration of the referenced member |
| 6793 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6794 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6795 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6796 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6797 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6798 | sugared type. Given |
| 6799 | class X {}; |
| 6800 | typedef X Y; |
| 6801 | Y y; |
| 6802 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6803 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6804 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6805 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6806 | recordType(hasDeclaration(decl()))))) |
| 6807 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6808 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6809 | 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>>, |
| 6810 | 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>>, |
| 6811 | 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>>, |
| 6812 | 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>>, |
| 6813 | 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>>, |
| 6814 | 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>>, |
| 6815 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 6816 | </pre></td></tr> |
| 6817 | |
| 6818 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6819 | <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> |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 6820 | <tr><td colspan="4" class="doc" id="hasUnqualifiedDesugaredType0"><pre>Matches if the matched type matches the unqualified desugared |
| 6821 | type of the matched node. |
| 6822 | |
| 6823 | For example, in: |
| 6824 | class A {}; |
| 6825 | using B = A; |
George Karpenkov | daac52c | 2018-07-23 22:29:10 +0000 | [diff] [blame] | 6826 | The matcher type(hasUnqualifiedDesugaredType(recordType())) matches |
Manuel Klimek | a37e110 | 2016-12-01 15:45:06 +0000 | [diff] [blame] | 6827 | both B and A. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6828 | </pre></td></tr> |
| 6829 | |
| 6830 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6831 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6832 | <tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. |
| 6833 | |
| 6834 | Given |
| 6835 | int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); |
| 6836 | unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) |
| 6837 | matches sizeof(a) and alignof(c) |
| 6838 | </pre></td></tr> |
| 6839 | |
| 6840 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6841 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6842 | <tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. |
| 6843 | |
| 6844 | Example matches true (matcher = hasUnaryOperand( |
| 6845 | cxxBoolLiteral(equals(true)))) |
| 6846 | !true |
| 6847 | </pre></td></tr> |
| 6848 | |
| 6849 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6850 | <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> |
Yitzhak Mandelbaum | 8a43680 | 2019-02-08 16:00:44 +0000 | [diff] [blame^] | 6851 | <tr><td colspan="4" class="doc" id="hasObjectExpression1"><pre>Matches a member expression where the object expression is matched by a |
| 6852 | given matcher. Implicit object expressions are included; that is, it matches |
| 6853 | use of implicit `this`. |
Shuai Wang | 92f9d1b | 2018-08-23 17:16:06 +0000 | [diff] [blame] | 6854 | |
| 6855 | Given |
Yitzhak Mandelbaum | 8a43680 | 2019-02-08 16:00:44 +0000 | [diff] [blame^] | 6856 | struct X { |
| 6857 | int m; |
| 6858 | int f(X x) { x.m; return m; } |
| 6859 | }; |
| 6860 | memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))) |
| 6861 | matches `x.m`, but not `m`; however, |
| 6862 | memberExpr(hasObjectExpression(hasType(pointsTo( |
| 6863 | cxxRecordDecl(hasName("X")))))) |
| 6864 | matches `m` (aka. `this->m`), but not `x.m`. |
Shuai Wang | 92f9d1b | 2018-08-23 17:16:06 +0000 | [diff] [blame] | 6865 | </pre></td></tr> |
| 6866 | |
| 6867 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6868 | <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>const Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6869 | <tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node |
| 6870 | matches the given matcher. |
| 6871 | |
| 6872 | The associated declaration is: |
| 6873 | - for type nodes, the declaration of the underlying type |
| 6874 | - for CallExpr, the declaration of the callee |
| 6875 | - for MemberExpr, the declaration of the referenced member |
| 6876 | - for CXXConstructExpr, the declaration of the constructor |
Malcolm Parsons | 7d96c33 | 2016-10-31 22:04:07 +0000 | [diff] [blame] | 6877 | - for CXXNewExpr, the declaration of the operator new |
George Karpenkov | 079275b | 2018-07-27 17:26:11 +0000 | [diff] [blame] | 6878 | - for ObjCIvarExpr, the declaration of the ivar |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6879 | |
Benjamin Kramer | ae7ff38 | 2018-01-17 16:50:14 +0000 | [diff] [blame] | 6880 | For type nodes, hasDeclaration will generally match the declaration of the |
| 6881 | sugared type. Given |
| 6882 | class X {}; |
| 6883 | typedef X Y; |
| 6884 | Y y; |
| 6885 | in varDecl(hasType(hasDeclaration(decl()))) the decl will match the |
| 6886 | typedefDecl. A common use case is to match the underlying, desugared type. |
| 6887 | This can be achieved by using the hasUnqualifiedDesugaredType matcher: |
| 6888 | varDecl(hasType(hasUnqualifiedDesugaredType( |
| 6889 | recordType(hasDeclaration(decl()))))) |
| 6890 | In this matcher, the decl will match the CXXRecordDecl of class X. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6891 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6892 | 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>>, |
| 6893 | 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>>, |
| 6894 | 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>>, |
| 6895 | 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>>, |
| 6896 | 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>>, |
| 6897 | 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>>, |
| 6898 | Matcher<<a href="https://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6899 | </pre></td></tr> |
| 6900 | |
| 6901 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6902 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6903 | <tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. |
| 6904 | |
| 6905 | Given |
| 6906 | namespace X { void b(); } |
| 6907 | using X::b; |
| 6908 | usingDecl(hasAnyUsingShadowDecl(hasName("b")))) |
| 6909 | matches using X::b </pre></td></tr> |
| 6910 | |
| 6911 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6912 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6913 | <tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is |
| 6914 | matched by the given matcher. |
| 6915 | |
| 6916 | Given |
| 6917 | namespace X { int a; void b(); } |
| 6918 | using X::a; |
| 6919 | using X::b; |
| 6920 | usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) |
| 6921 | matches using X::b but not using X::a </pre></td></tr> |
| 6922 | |
| 6923 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6924 | <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> |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6925 | <tr><td colspan="4" class="doc" id="hasType6"><pre>Overloaded to match the declaration of the expression's or value |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6926 | declaration's type. |
| 6927 | |
| 6928 | In case of a value declaration (for example a variable declaration), |
| 6929 | this resolves one layer of indirection. For example, in the value |
| 6930 | declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of |
| 6931 | X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the |
| 6932 | declaration of x. |
| 6933 | |
| 6934 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 6935 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6936 | and friend class X (matcher = friendDecl(hasType("X")) |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6937 | class X {}; |
| 6938 | void y(X &x) { x; X z; } |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6939 | class Y { friend class X; }; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6940 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6941 | 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_1ValueDecl.html">ValueDecl</a>> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6942 | </pre></td></tr> |
| 6943 | |
| 6944 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6945 | <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> |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6946 | <tr><td colspan="4" class="doc" id="hasType3"><pre>Matches if the expression's or declaration's type matches a type |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6947 | matcher. |
| 6948 | |
| 6949 | Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) |
| 6950 | and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 6951 | and U (matcher = typedefDecl(hasType(asString("int"))) |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6952 | and friend class X (matcher = friendDecl(hasType("X")) |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6953 | class X {}; |
| 6954 | void y(X &x) { x; X z; } |
Aaron Ballman | 7e7b7b2 | 2016-02-01 14:11:47 +0000 | [diff] [blame] | 6955 | typedef int U; |
George Karpenkov | ba02bc5 | 2018-07-06 21:36:04 +0000 | [diff] [blame] | 6956 | class Y { friend class X; }; |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6957 | </pre></td></tr> |
| 6958 | |
| 6959 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6960 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6961 | <tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression |
| 6962 | that matches the given matcher. |
| 6963 | |
| 6964 | Example matches x (matcher = varDecl(hasInitializer(callExpr()))) |
| 6965 | bool y() { return true; } |
| 6966 | bool x = y(); |
| 6967 | </pre></td></tr> |
| 6968 | |
| 6969 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6970 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6971 | <tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size |
| 6972 | expression. |
| 6973 | |
| 6974 | Given |
| 6975 | void f(int b) { |
| 6976 | int a[b]; |
| 6977 | } |
| 6978 | variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( |
| 6979 | varDecl(hasName("b"))))))) |
| 6980 | matches "int a[b]" |
| 6981 | </pre></td></tr> |
| 6982 | |
| 6983 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6984 | <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> |
Aaron Ballman | 2b6963f | 2016-01-20 16:26:48 +0000 | [diff] [blame] | 6985 | <tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', 'do while' statement or a function |
| 6986 | definition that has a given body. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6987 | |
| 6988 | Given |
| 6989 | for (;;) {} |
| 6990 | hasBody(compoundStmt()) |
| 6991 | matches 'for (;;) {}' |
| 6992 | with compoundStmt() |
| 6993 | matching '{}' |
| 6994 | </pre></td></tr> |
| 6995 | |
| 6996 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 6997 | <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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 6998 | <tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, |
Etienne Bergeron | 5500f95 | 2016-05-30 15:25:25 +0000 | [diff] [blame] | 6999 | switch statement or conditional operator. |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 7000 | |
| 7001 | Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) |
| 7002 | if (true) {} |
| 7003 | </pre></td></tr> |
| 7004 | |
| 7005 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 7006 | <tr><td>Matcher<internal::BindableMatcher<<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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 7007 | <tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner |
| 7008 | NestedNameSpecifier-matcher matches. |
| 7009 | </pre></td></tr> |
| 7010 | |
| 7011 | |
Sylvestre Ledru | bc5c3f5 | 2018-11-04 17:02:00 +0000 | [diff] [blame] | 7012 | <tr><td>Matcher<internal::BindableMatcher<<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> |
Benjamin Kramer | 611d33a | 2015-11-20 07:46:19 +0000 | [diff] [blame] | 7013 | <tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner |
| 7014 | QualType-matcher matches. |
| 7015 | </pre></td></tr> |
| 7016 | |
Benjamin Kramer | 7d0cc23 | 2015-11-20 07:57:46 +0000 | [diff] [blame] | 7017 | <!--END_TRAVERSAL_MATCHERS --> |
| 7018 | </table> |
| 7019 | |
| 7020 | </div> |
| 7021 | </body> |
| 7022 | </html> |
| 7023 | |
| 7024 | |