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> 101 <!-- START_DECL_MATCHERS --> 102 103 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('ctorInitializer0')"><a name="ctorInitializer0Anchor">ctorInitializer</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>...</td></tr> 104 <tr><td colspan="4" class="doc" id="ctorInitializer0"><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 114 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1AccessSpecDecl.html">AccessSpecDecl</a>>...</td></tr> 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 127 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html">ClassTemplateDecl</a>>...</td></tr> 128 <tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations. 129 130 Example matches Z 131 template<class T> class Z {}; 132 </pre></td></tr> 133 134 135 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>...</td></tr> 136 <tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations. 137 138 Given 139 template<typename T> class A {}; 140 template<> class A<double> {}; 141 A<int> a; 142 classTemplateSpecializationDecl() 143 matches the specializations A<int> and A<double> 144 </pre></td></tr> 145 146 147 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('constructorDecl0')"><a name="constructorDecl0Anchor">constructorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>>...</td></tr> 148 <tr><td colspan="4" class="doc" id="constructorDecl0"><pre>Matches C++ constructor declarations. 149 150 Example matches Foo::Foo() and Foo::Foo(int) 151 class Foo { 152 public: 153 Foo(); 154 Foo(int); 155 int DoSomething(); 156 }; 157 </pre></td></tr> 158 159 160 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>...</td></tr> 161 <tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations. 162 163 Examples matches X, C, and the friend declaration inside C; 164 void X(); 165 class C { 166 friend X; 167 }; 168 </pre></td></tr> 169 170 171 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>...</td></tr> 172 <tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function 173 and non-type template parameter declarations). 174 175 Given 176 class X { int y; }; 177 declaratorDecl() 178 matches int y. 179 </pre></td></tr> 180 181 182 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('destructorDecl0')"><a name="destructorDecl0Anchor">destructorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>>...</td></tr> 183 <tr><td colspan="4" class="doc" id="destructorDecl0"><pre>Matches explicit C++ destructor declarations. 184 185 Example matches Foo::~Foo() 186 class Foo { 187 public: 188 virtual ~Foo(); 189 }; 190 </pre></td></tr> 191 192 193 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1EnumConstantDecl.html">EnumConstantDecl</a>>...</td></tr> 194 <tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants. 195 196 Example matches A, B, C 197 enum X { 198 A, B, C 199 }; 200 </pre></td></tr> 201 202 203 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl</a>>...</td></tr> 204 <tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations. 205 206 Example matches X 207 enum X { 208 A, B, C 209 }; 210 </pre></td></tr> 211 212 213 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>>...</td></tr> 214 <tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations. 215 216 Given 217 class X { int m; }; 218 fieldDecl() 219 matches 'm'. 220 </pre></td></tr> 221 222 223 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>>...</td></tr> 224 <tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations. 225 226 Given 227 class X { friend void foo(); }; 228 friendDecl() 229 matches 'friend void foo()'. 230 </pre></td></tr> 231 232 233 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>...</td></tr> 234 <tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations. 235 236 Example matches f 237 void f(); 238 </pre></td></tr> 239 240 241 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1FunctionTemplateDecl.html">FunctionTemplateDecl</a>>...</td></tr> 242 <tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations. 243 244 Example matches f 245 template<class T> void f(T t) {} 246 </pre></td></tr> 247 248 249 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('methodDecl0')"><a name="methodDecl0Anchor">methodDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>>...</td></tr> 250 <tr><td colspan="4" class="doc" id="methodDecl0"><pre>Matches method declarations. 251 252 Example matches y 253 class X { void y() }; 254 </pre></td></tr> 255 256 257 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>>...</td></tr> 258 <tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name. 259 260 Example matches X, S, the anonymous union type, i, and U; 261 typedef int X; 262 struct S { 263 union { 264 int i; 265 } U; 266 }; 267 </pre></td></tr> 268 269 270 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>>...</td></tr> 271 <tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace. 272 273 Given 274 namespace {} 275 namespace test {} 276 namespaceDecl() 277 matches "namespace {}" and "namespace test {}" 278 </pre></td></tr> 279 280 281 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>>...</td></tr> 282 <tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations. 283 284 Given 285 void f(int x); 286 parmVarDecl() 287 matches int x. 288 </pre></td></tr> 289 290 291 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>...</td></tr> 292 <tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches C++ class declarations. 293 294 Example matches X, Z 295 class X; 296 template<class T> class Z {}; 297 </pre></td></tr> 298 299 300 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingValueDecl.html">UnresolvedUsingValueDecl</a>>...</td></tr> 301 <tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations. 302 303 Given 304 template<typename X> 305 class C : private X { 306 using X::x; 307 }; 308 unresolvedUsingValueDecl() 309 matches using X::x </pre></td></tr> 310 311 312 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html">UsingDecl</a>>...</td></tr> 313 <tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations. 314 315 Given 316 namespace X { int x; } 317 using X::x; 318 usingDecl() 319 matches using X::x </pre></td></tr> 320 321 322 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>...</td></tr> 323 <tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations. 324 325 Note: this does not match declarations of member variables, which are 326 "field" declarations in Clang parlance. 327 328 Example matches a 329 int a; 330 </pre></td></tr> 331 332 333 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>>...</td></tr> 334 <tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. 335 </pre></td></tr> 336 337 338 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>>...</td></tr> 339 <tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers. 340 341 Given 342 namespace ns { 343 struct A { static void f(); }; 344 void A::f() {} 345 void g() { A::f(); } 346 } 347 ns::A a; 348 nestedNameSpecifier() 349 matches "ns::" and both "A::" 350 </pre></td></tr> 351 352 353 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>...</td></tr> 354 <tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST. 355 </pre></td></tr> 356 357 358 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>>...</td></tr> 359 <tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. 360 361 Given 362 int i = a[1]; 363 arraySubscriptExpr() 364 matches "a[1]" 365 </pre></td></tr> 366 367 368 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1AsmStmt.html">AsmStmt</a>>...</td></tr> 369 <tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements. 370 371 int i = 100; 372 __asm("mov al, 2"); 373 asmStmt() 374 matches '__asm("mov al, 2")' 375 </pre></td></tr> 376 377 378 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>>...</td></tr> 379 <tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. 380 381 Example matches a || b 382 !(a || b) 383 </pre></td></tr> 384 385 386 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('bindTemporaryExpr0')"><a name="bindTemporaryExpr0Anchor">bindTemporaryExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>>...</td></tr> 387 <tr><td colspan="4" class="doc" id="bindTemporaryExpr0"><pre>Matches nodes where temporaries are created. 388 389 Example matches FunctionTakesString(GetStringByValue()) 390 (matcher = bindTemporaryExpr()) 391 FunctionTakesString(GetStringByValue()); 392 FunctionTakesStringByPointer(GetStringPointer()); 393 </pre></td></tr> 394 395 396 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('boolLiteral0')"><a name="boolLiteral0Anchor">boolLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>...</td></tr> 397 <tr><td colspan="4" class="doc" id="boolLiteral0"><pre>Matches bool literals. 398 399 Example matches true 400 true 401 </pre></td></tr> 402 403 404 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1BreakStmt.html">BreakStmt</a>>...</td></tr> 405 <tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. 406 407 Given 408 while (true) { break; } 409 breakStmt() 410 matches 'break' 411 </pre></td></tr> 412 413 414 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1CStyleCastExpr.html">CStyleCastExpr</a>>...</td></tr> 415 <tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. 416 417 Example: Matches (int*) 2.2f in 418 int i = (int) 2.2f; 419 </pre></td></tr> 420 421 422 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>...</td></tr> 423 <tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. 424 425 Example matches x.y() and y() 426 X x; 427 x.y(); 428 y(); 429 </pre></td></tr> 430 431 432 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt</a>>...</td></tr> 433 <tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements. 434 435 Given 436 switch(a) { case 42: break; default: break; } 437 caseStmt() 438 matches 'case 42: break;'. 439 </pre></td></tr> 440 441 442 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>>...</td></tr> 443 <tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. 444 445 Example: castExpr() matches each of the following: 446 (int) 3; 447 const_cast<Expr *>(SubExpr); 448 char c = 0; 449 but does not match 450 int i = (0); 451 int k = 0; 452 </pre></td></tr> 453 454 455 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('catchStmt0')"><a name="catchStmt0Anchor">catchStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>>...</td></tr> 456 <tr><td colspan="4" class="doc" id="catchStmt0"><pre>Matches catch statements. 457 458 try {} catch(int i) {} 459 catchStmt() 460 matches 'catch(int i)' 461 </pre></td></tr> 462 463 464 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>...</td></tr> 465 <tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). 466 467 Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), 468 though. 469 470 Example matches 'a', L'a' 471 char ch = 'a'; wchar_t chw = L'a'; 472 </pre></td></tr> 473 474 475 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>...</td></tr> 476 <tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals 477 478 Example match: {1}, (1, 2) 479 int array[4] = {1}; vector int myvec = (vector int)(1, 2); 480 </pre></td></tr> 481 482 483 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>>...</td></tr> 484 <tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. 485 486 Example matches '{}' and '{{}}'in 'for (;;) {{}}' 487 for (;;) {{}} 488 </pre></td></tr> 489 490 491 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>>...</td></tr> 492 <tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. 493 494 Example matches a ? b : c 495 (a ? b : c) + 42 496 </pre></td></tr> 497 498 499 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('constCastExpr0')"><a name="constCastExpr0Anchor">constCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>>...</td></tr> 500 <tr><td colspan="4" class="doc" id="constCastExpr0"><pre>Matches a const_cast expression. 501 502 Example: Matches const_cast<int*>(&r) in 503 int n = 42; 504 const int &r(n); 505 int* p = const_cast<int*>(&r); 506 </pre></td></tr> 507 508 509 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('constructExpr0')"><a name="constructExpr0Anchor">constructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>...</td></tr> 510 <tr><td colspan="4" class="doc" id="constructExpr0"><pre>Matches constructor call expressions (including implicit ones). 511 512 Example matches string(ptr, n) and ptr within arguments of f 513 (matcher = constructExpr()) 514 void f(const string &a, const string &b); 515 char *ptr; 516 int n; 517 f(string(ptr, n), ptr); 518 </pre></td></tr> 519 520 521 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ContinueStmt.html">ContinueStmt</a>>...</td></tr> 522 <tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. 523 524 Given 525 while (true) { continue; } 526 continueStmt() 527 matches 'continue' 528 </pre></td></tr> 529 530 531 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>...</td></tr> 532 <tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. 533 534 Example matches x in if (x) 535 bool x; 536 if (x) {} 537 </pre></td></tr> 538 539 540 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>>...</td></tr> 541 <tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. 542 543 Given 544 int a; 545 declStmt() 546 matches 'int a'. 547 </pre></td></tr> 548 549 550 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('defaultArgExpr0')"><a name="defaultArgExpr0Anchor">defaultArgExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>>...</td></tr> 551 <tr><td colspan="4" class="doc" id="defaultArgExpr0"><pre>Matches the value of a default argument at the call site. 552 553 Example matches the CXXDefaultArgExpr placeholder inserted for the 554 default value of the second parameter in the call expression f(42) 555 (matcher = defaultArgExpr()) 556 void f(int x, int y = 0); 557 f(42); 558 </pre></td></tr> 559 560 561 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1DefaultStmt.html">DefaultStmt</a>>...</td></tr> 562 <tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements. 563 564 Given 565 switch(a) { case 42: break; default: break; } 566 defaultStmt() 567 matches 'default: break;'. 568 </pre></td></tr> 569 570 571 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('deleteExpr0')"><a name="deleteExpr0Anchor">deleteExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>>...</td></tr> 572 <tr><td colspan="4" class="doc" id="deleteExpr0"><pre>Matches delete expressions. 573 574 Given 575 delete X; 576 deleteExpr() 577 matches 'delete X'. 578 </pre></td></tr> 579 580 581 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1DoStmt.html">DoStmt</a>>...</td></tr> 582 <tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. 583 584 Given 585 do {} while (true); 586 doStmt() 587 matches 'do {} while(true)' 588 </pre></td></tr> 589 590 591 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('dynamicCastExpr0')"><a name="dynamicCastExpr0Anchor">dynamicCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>>...</td></tr> 592 <tr><td colspan="4" class="doc" id="dynamicCastExpr0"><pre>Matches a dynamic_cast expression. 593 594 Example: 595 dynamicCastExpr() 596 matches 597 dynamic_cast<D*>(&b); 598 in 599 struct B { virtual ~B() {} }; struct D : B {}; 600 B b; 601 D* p = dynamic_cast<D*>(&b); 602 </pre></td></tr> 603 604 605 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>...</td></tr> 606 <tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. 607 608 Matches any cast expression written in user code, whether it be a 609 C-style cast, a functional-style cast, or a keyword cast. 610 611 Does not match implicit conversions. 612 613 Note: the name "explicitCast" is chosen to match Clang's terminology, as 614 Clang uses the term "cast" to apply to implicit conversions as well as to 615 actual cast expressions. 616 617 hasDestinationType. 618 619 Example: matches all five of the casts in 620 int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) 621 but does not match the implicit conversion in 622 long ell = 42; 623 </pre></td></tr> 624 625 626 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>...</td></tr> 627 <tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. 628 629 Example matches x() 630 void f() { x(); } 631 </pre></td></tr> 632 633 634 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('forRangeStmt0')"><a name="forRangeStmt0Anchor">forRangeStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>>...</td></tr> 635 <tr><td colspan="4" class="doc" id="forRangeStmt0"><pre>Matches range-based for statements. 636 637 forRangeStmt() matches 'for (auto a : i)' 638 int i[] = {1, 2, 3}; for (auto a : i); 639 for(int j = 0; j < 5; ++j); 640 </pre></td></tr> 641 642 643 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ForStmt.html">ForStmt</a>>...</td></tr> 644 <tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. 645 646 Example matches 'for (;;) {}' 647 for (;;) {} 648 int i[] = {1, 2, 3}; for (auto a : i); 649 </pre></td></tr> 650 651 652 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('functionalCastExpr0')"><a name="functionalCastExpr0Anchor">functionalCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>...</td></tr> 653 <tr><td colspan="4" class="doc" id="functionalCastExpr0"><pre>Matches functional cast expressions 654 655 Example: Matches Foo(bar); 656 Foo f = bar; 657 Foo g = (Foo) bar; 658 Foo h = Foo(bar); 659 </pre></td></tr> 660 661 662 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1GotoStmt.html">GotoStmt</a>>...</td></tr> 663 <tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. 664 665 Given 666 goto FOO; 667 FOO: bar(); 668 gotoStmt() 669 matches 'goto FOO' 670 </pre></td></tr> 671 672 673 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>>...</td></tr> 674 <tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. 675 676 Example matches 'if (x) {}' 677 if (x) {} 678 </pre></td></tr> 679 680 681 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ImplicitCastExpr.html">ImplicitCastExpr</a>>...</td></tr> 682 <tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. 683 684 This matches many different places, including function call return value 685 eliding, as well as any type conversions. 686 </pre></td></tr> 687 688 689 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>>...</td></tr> 690 <tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. 691 692 Given 693 int a[] = { 1, 2 }; 694 struct B { int x, y; }; 695 B b = { 5, 6 }; 696 initList() 697 matches "{ 1, 2 }" and "{ 5, 6 }" 698 </pre></td></tr> 699 700 701 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>>...</td></tr> 702 <tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings. 703 704 Not matching character-encoded integers such as L'a'. 705 706 Example matches 1, 1L, 0x1, 1U 707 </pre></td></tr> 708 709 710 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>...</td></tr> 711 <tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. 712 713 Given 714 goto FOO; 715 FOO: bar(); 716 labelStmt() 717 matches 'FOO:' 718 </pre></td></tr> 719 720 721 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1LambdaExpr.html">LambdaExpr</a>>...</td></tr> 722 <tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. 723 724 Example matches [&](){return 5;} 725 [&](){return 5;} 726 </pre></td></tr> 727 728 729 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1MaterializeTemporaryExpr.html">MaterializeTemporaryExpr</a>>...</td></tr> 730 <tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. 731 732 Example: Given 733 struct T {void func()}; 734 T f(); 735 void g(T); 736 materializeTemporaryExpr() matches 'f()' in these statements 737 T u(f()); 738 g(f()); 739 but does not match 740 f(); 741 f().func(); 742 </pre></td></tr> 743 744 745 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('memberCallExpr0')"><a name="memberCallExpr0Anchor">memberCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>>...</td></tr> 746 <tr><td colspan="4" class="doc" id="memberCallExpr0"><pre>Matches member call expressions. 747 748 Example matches x.y() 749 X x; 750 x.y(); 751 </pre></td></tr> 752 753 754 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>...</td></tr> 755 <tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. 756 757 Given 758 class Y { 759 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 760 int a; static int b; 761 }; 762 memberExpr() 763 matches this->x, x, y.x, a, this->b 764 </pre></td></tr> 765 766 767 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('newExpr0')"><a name="newExpr0Anchor">newExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>...</td></tr> 768 <tr><td colspan="4" class="doc" id="newExpr0"><pre>Matches new expressions. 769 770 Given 771 new X; 772 newExpr() 773 matches 'new X'. 774 </pre></td></tr> 775 776 777 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('nullPtrLiteralExpr0')"><a name="nullPtrLiteralExpr0Anchor">nullPtrLiteralExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>>...</td></tr> 778 <tr><td colspan="4" class="doc" id="nullPtrLiteralExpr0"><pre>Matches nullptr literal. 779 </pre></td></tr> 780 781 782 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1NullStmt.html">NullStmt</a>>...</td></tr> 783 <tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. 784 785 foo();; 786 nullStmt() 787 matches the second ';' 788 </pre></td></tr> 789 790 791 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('operatorCallExpr0')"><a name="operatorCallExpr0Anchor">operatorCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>...</td></tr> 792 <tr><td colspan="4" class="doc" id="operatorCallExpr0"><pre>Matches overloaded operator calls. 793 794 Note that if an operator isn't overloaded, it won't match. Instead, use 795 binaryOperator matcher. 796 Currently it does not match operators such as new delete. 797 FIXME: figure out why these do not match? 798 799 Example matches both operator<<((o << b), c) and operator<<(o, b) 800 (matcher = operatorCallExpr()) 801 ostream &operator<< (ostream &out, int i) { }; 802 ostream &o; int b = 1, c = 1; 803 o << b << c; 804 </pre></td></tr> 805 806 807 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('reinterpretCastExpr0')"><a name="reinterpretCastExpr0Anchor">reinterpretCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>>...</td></tr> 808 <tr><td colspan="4" class="doc" id="reinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. 809 810 Either the source expression or the destination type can be matched 811 using has(), but hasDestinationType() is more specific and can be 812 more readable. 813 814 Example matches reinterpret_cast<char*>(&p) in 815 void* p = reinterpret_cast<char*>(&p); 816 </pre></td></tr> 817 818 819 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">ReturnStmt</a>>...</td></tr> 820 <tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. 821 822 Given 823 return 1; 824 returnStmt() 825 matches 'return 1' 826 </pre></td></tr> 827 828 829 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('staticCastExpr0')"><a name="staticCastExpr0Anchor">staticCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>>...</td></tr> 830 <tr><td colspan="4" class="doc" id="staticCastExpr0"><pre>Matches a C++ static_cast expression. 831 832 hasDestinationType 833 reinterpretCast 834 835 Example: 836 staticCastExpr() 837 matches 838 static_cast<long>(8) 839 in 840 long eight(static_cast<long>(8)); 841 </pre></td></tr> 842 843 844 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>...</td></tr> 845 <tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. 846 847 Given 848 { ++a; } 849 stmt() 850 matches both the compound statement '{ ++a; }' and '++a'. 851 </pre></td></tr> 852 853 854 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>>...</td></tr> 855 <tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). 856 857 Example matches "abcd", L"abcd" 858 char *s = "abcd"; wchar_t *ws = L"abcd" 859 </pre></td></tr> 860 861 862 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>>...</td></tr> 863 <tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. 864 865 Given 866 switch(a) { case 42: break; default: break; } 867 switchCase() 868 matches 'case 42: break;' and 'default: break;'. 869 </pre></td></tr> 870 871 872 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>>...</td></tr> 873 <tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. 874 875 Given 876 switch(a) { case 42: break; default: break; } 877 switchStmt() 878 matches 'switch(a)'. 879 </pre></td></tr> 880 881 882 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('thisExpr0')"><a name="thisExpr0Anchor">thisExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>>...</td></tr> 883 <tr><td colspan="4" class="doc" id="thisExpr0"><pre>Matches implicit and explicit this expressions. 884 885 Example matches the implicit this expression in "return i". 886 (matcher = thisExpr()) 887 struct foo { 888 int i; 889 int f() { return i; } 890 }; 891 </pre></td></tr> 892 893 894 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('throwExpr0')"><a name="throwExpr0Anchor">throwExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>>...</td></tr> 895 <tr><td colspan="4" class="doc" id="throwExpr0"><pre>Matches throw expressions. 896 897 try { throw 5; } catch(int i) {} 898 throwExpr() 899 matches 'throw 5' 900 </pre></td></tr> 901 902 903 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('tryStmt0')"><a name="tryStmt0Anchor">tryStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>>...</td></tr> 904 <tr><td colspan="4" class="doc" id="tryStmt0"><pre>Matches try statements. 905 906 try {} catch(int i) {} 907 tryStmt() 908 matches 'try {}' 909 </pre></td></tr> 910 911 912 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>>...</td></tr> 913 <tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) 914 915 Given 916 Foo x = bar; 917 int y = sizeof(x) + alignof(x); 918 unaryExprOrTypeTraitExpr() 919 matches sizeof(x) and alignof(x) 920 </pre></td></tr> 921 922 923 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1UnaryOperator.html">UnaryOperator</a>>...</td></tr> 924 <tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. 925 926 Example matches !a 927 !a || b 928 </pre></td></tr> 929 930 931 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('unresolvedConstructExpr0')"><a name="unresolvedConstructExpr0Anchor">unresolvedConstructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>...</td></tr> 932 <tr><td colspan="4" class="doc" id="unresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions. 933 934 Example matches T(t) in return statement of f 935 (matcher = unresolvedConstructExpr()) 936 template <typename T> 937 void f(const T& t) { return T(t); } 938 </pre></td></tr> 939 940 941 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1UserDefinedLiteral.html">UserDefinedLiteral</a>>...</td></tr> 942 <tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. 943 944 Example match: "foo"_suffix 945 </pre></td></tr> 946 947 948 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1WhileStmt.html">WhileStmt</a>>...</td></tr> 949 <tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. 950 951 Given 952 while (true) {} 953 whileStmt() 954 matches 'while (true) {}'. 955 </pre></td></tr> 956 957 958 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>...</td></tr> 959 <tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. 960 </pre></td></tr> 961 962 963 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>...</td></tr> 964 <tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. 965 966 Given 967 int a[] = { 2, 3 }; 968 int b[4]; 969 void f() { int c[a[0]]; } 970 arrayType() 971 matches "int a[]", "int b[4]" and "int c[a[0]]"; 972 </pre></td></tr> 973 974 975 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>>...</td></tr> 976 <tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. 977 978 Given 979 _Atomic(int) i; 980 atomicType() 981 matches "_Atomic(int) i" 982 </pre></td></tr> 983 984 985 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>>...</td></tr> 986 <tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. 987 988 Given: 989 auto n = 4; 990 int v[] = { 2, 3 } 991 for (auto i : v) { } 992 autoType() 993 matches "auto n" and "auto i" 994 </pre></td></tr> 995 996 997 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>...</td></tr> 998 <tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as 999 "void (^)(int)". 1000 1001 The pointee is always required to be a FunctionType. 1002 </pre></td></tr> 1003 1004 1005 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1BuiltinType.html">BuiltinType</a>>...</td></tr> 1006 <tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. 1007 1008 Given 1009 struct A {}; 1010 A a; 1011 int b; 1012 float c; 1013 bool d; 1014 builtinType() 1015 matches "int b", "float c" and "bool d" 1016 </pre></td></tr> 1017 1018 1019 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>>...</td></tr> 1020 <tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. 1021 1022 Given 1023 _Complex float f; 1024 complexType() 1025 matches "_Complex float f" 1026 </pre></td></tr> 1027 1028 1029 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>>...</td></tr> 1030 <tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. 1031 1032 Given 1033 void() { 1034 int a[2]; 1035 int b[] = { 2, 3 }; 1036 int c[b[0]]; 1037 } 1038 constantArrayType() 1039 matches "int a[2]" 1040 </pre></td></tr> 1041 1042 1043 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayType.html">DependentSizedArrayType</a>>...</td></tr> 1044 <tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. 1045 1046 Given 1047 template<typename T, int Size> 1048 class array { 1049 T data[Size]; 1050 }; 1051 dependentSizedArrayType 1052 matches "T data[Size]" 1053 </pre></td></tr> 1054 1055 1056 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>>...</td></tr> 1057 <tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a 1058 qualified name. 1059 1060 Given 1061 namespace N { 1062 namespace M { 1063 class D {}; 1064 } 1065 } 1066 class C {}; 1067 1068 class C c; 1069 N::M::D d; 1070 1071 elaboratedType() matches the type of the variable declarations of both 1072 c and d. 1073 </pre></td></tr> 1074 1075 1076 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1FunctionType.html">FunctionType</a>>...</td></tr> 1077 <tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. 1078 1079 Given 1080 int (*f)(int); 1081 void g(); 1082 functionType() 1083 matches "int (*f)(int)" and the type of "g". 1084 </pre></td></tr> 1085 1086 1087 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1IncompleteArrayType.html">IncompleteArrayType</a>>...</td></tr> 1088 <tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. 1089 1090 Given 1091 int a[] = { 2, 3 }; 1092 int b[42]; 1093 void f(int c[]) { int d[a[0]]; }; 1094 incompleteArrayType() 1095 matches "int a[]" and "int c[]" 1096 </pre></td></tr> 1097 1098 1099 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1LValueReferenceType.html">LValueReferenceType</a>>...</td></tr> 1100 <tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. 1101 1102 Given: 1103 int *a; 1104 int &b = *a; 1105 int &&c = 1; 1106 auto &d = b; 1107 auto &&e = c; 1108 auto &&f = 2; 1109 int g = 5; 1110 1111 lValueReferenceType() matches the types of b, d, and e. e is 1112 matched since the type is deduced as int& by reference collapsing rules. 1113 </pre></td></tr> 1114 1115 1116 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>...</td></tr> 1117 <tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. 1118 Given 1119 struct A { int i; } 1120 A::* ptr = A::i; 1121 memberPointerType() 1122 matches "A::* ptr" 1123 </pre></td></tr> 1124 1125 1126 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>>...</td></tr> 1127 <tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. 1128 1129 Given 1130 int (*ptr_to_array)[4]; 1131 int *array_of_ptrs[4]; 1132 1133 varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not 1134 array_of_ptrs. 1135 </pre></td></tr> 1136 1137 1138 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>...</td></tr> 1139 <tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types. 1140 1141 Given 1142 int *a; 1143 int &b = *a; 1144 int c = 5; 1145 pointerType() 1146 matches "int *a" 1147 </pre></td></tr> 1148 1149 1150 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1RValueReferenceType.html">RValueReferenceType</a>>...</td></tr> 1151 <tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. 1152 1153 Given: 1154 int *a; 1155 int &b = *a; 1156 int &&c = 1; 1157 auto &d = b; 1158 auto &&e = c; 1159 auto &&f = 2; 1160 int g = 5; 1161 1162 rValueReferenceType() matches the types of c and f. e is not 1163 matched as it is deduced to int& by reference collapsing rules. 1164 </pre></td></tr> 1165 1166 1167 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>...</td></tr> 1168 <tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). 1169 1170 Given 1171 class C {}; 1172 struct S {}; 1173 1174 C c; 1175 S s; 1176 1177 recordType() matches the type of the variable declarations of both c 1178 and s. 1179 </pre></td></tr> 1180 1181 1182 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>...</td></tr> 1183 <tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. 1184 1185 Given 1186 int *a; 1187 int &b = *a; 1188 int &&c = 1; 1189 auto &d = b; 1190 auto &&e = c; 1191 auto &&f = 2; 1192 int g = 5; 1193 1194 referenceType() matches the types of b, c, d, e, and f. 1195 </pre></td></tr> 1196 1197 1198 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>...</td></tr> 1199 <tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. 1200 1201 Given 1202 template <typename T> 1203 class C { }; 1204 1205 template class C<int>; A 1206 C<char> var; B 1207 1208 templateSpecializationType() matches the type of the explicit 1209 instantiation in A and the type of the variable declaration in B. 1210 </pre></td></tr> 1211 1212 1213 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>>...</td></tr> 1214 <tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. 1215 </pre></td></tr> 1216 1217 1218 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>...</td></tr> 1219 <tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. 1220 1221 Given 1222 typedef int X; 1223 typedefType() 1224 matches "typedef int X" 1225 </pre></td></tr> 1226 1227 1228 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1UnaryTransformType.html">UnaryTransformType</a>>...</td></tr> 1229 <tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. 1230 1231 Given: 1232 typedef __underlying_type(T) type; 1233 unaryTransformType() 1234 matches "__underlying_type(T)" 1235 </pre></td></tr> 1236 1237 1238 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1VariableArrayType.html">VariableArrayType</a>>...</td></tr> 1239 <tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an 1240 integer-constant-expression. 1241 1242 Given 1243 void f() { 1244 int a[] = { 2, 3 } 1245 int b[42]; 1246 int c[a[0]]; 1247 variableArrayType() 1248 matches "int c[a[0]]" 1249 </pre></td></tr> 1250 1251 <!--END_DECL_MATCHERS --> 1252 </table> 1253 1254 <!-- ======================================================================= --> 1255 <h2 id="narrowing-matchers">Narrowing Matchers</h2> 1256 <!-- ======================================================================= --> 1257 1258 <p>Narrowing matchers match certain attributes on the current node, thus 1259 narrowing down the set of nodes of the current type to match on.</p> 1260 1261 <p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) 1262 which allow users to create more powerful match expressions.</p> 1263 1264 <table> 1265 <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 1266 <!-- START_NARROWING_MATCHERS --> 1267 1268 <tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*> P1, Matcher<*> P2</td></tr> 1269 <tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. 1270 1271 Usable as: Any Matcher 1272 </pre></td></tr> 1273 1274 1275 <tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*> P1, Matcher<*> P2</td></tr> 1276 <tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. 1277 1278 Usable as: Any Matcher 1279 </pre></td></tr> 1280 1281 1282 <tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> 1283 <tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. 1284 1285 Useful when another matcher requires a child matcher, but there's no 1286 additional constraint. This will often be used with an explicit conversion 1287 to an internal::Matcher<> type such as TypeMatcher. 1288 1289 Example: DeclarationMatcher(anything()) matches all declarations, e.g., 1290 "int* p" and "void f()" in 1291 int* p; 1292 void f(); 1293 1294 Usable as: Any Matcher 1295 </pre></td></tr> 1296 1297 1298 <tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*> InnerMatcher</td></tr> 1299 <tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. 1300 1301 Example matches Y (matcher = recordDecl(unless(hasName("X")))) 1302 class X {}; 1303 class Y {}; 1304 1305 Usable as: Any Matcher 1306 </pre></td></tr> 1307 1308 1309 <tr><td>Matcher<<a href="http://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> 1310 <tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or 1311 unary). 1312 1313 Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 1314 !(a || b) 1315 </pre></td></tr> 1316 1317 1318 <tr><td>Matcher<CXXBoolLiteral></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>ValueT Value</td></tr> 1319 <tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value. 1320 1321 Example matches true (matcher = boolLiteral(equals(true))) 1322 true 1323 1324 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1325 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>> 1326 </pre></td></tr> 1327 1328 1329 <tr><td>Matcher<<a href="http://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> 1330 <tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has 1331 a specific number of arguments (including absent default arguments). 1332 1333 Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 1334 void f(int x, int y); 1335 f(0, 0); 1336 </pre></td></tr> 1337 1338 1339 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr> 1340 <tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a constructor declaration that has been implicitly added 1341 by the compiler (eg. implicit defaultcopy constructors). 1342 </pre></td></tr> 1343 1344 1345 <tr><td>Matcher<<a href="http://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> 1346 <tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a contructor initializer if it is explicitly written in 1347 code (as opposed to implicitly added by the compiler). 1348 1349 Given 1350 struct Foo { 1351 Foo() { } 1352 Foo(int) : foo_("A") { } 1353 string foo_; 1354 }; 1355 constructorDecl(hasAnyConstructorInitializer(isWritten())) 1356 will match Foo(int), but not Foo() 1357 </pre></td></tr> 1358 1359 1360 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr> 1361 <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. 1362 1363 Matches overloaded operator names specified in strings without the 1364 "operator" prefix: e.g. "<<". 1365 1366 Given: 1367 class A { int operator*(); }; 1368 const A &operator<<(const A &a, const A &b); 1369 A a; 1370 a << a; <-- This matches 1371 1372 operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified 1373 line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches 1374 the declaration of A. 1375 1376 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>> 1377 </pre></td></tr> 1378 1379 1380 <tr><td>Matcher<<a href="http://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> 1381 <tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. 1382 1383 Given 1384 struct A { 1385 void foo() const; 1386 void bar(); 1387 }; 1388 1389 methodDecl(isConst()) matches A::foo() but not A::bar() 1390 </pre></td></tr> 1391 1392 1393 <tr><td>Matcher<<a href="http://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> 1394 <tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. 1395 1396 Given 1397 class A { 1398 public: 1399 virtual void x(); 1400 }; 1401 class B : public A { 1402 public: 1403 virtual void x(); 1404 }; 1405 matches B::x 1406 </pre></td></tr> 1407 1408 1409 <tr><td>Matcher<<a href="http://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> 1410 <tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual. 1411 1412 Given 1413 class A { 1414 public: 1415 virtual void x(); 1416 }; 1417 matches A::x 1418 </pre></td></tr> 1419 1420 1421 <tr><td>Matcher<<a href="http://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> 1422 <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. 1423 1424 Matches overloaded operator names specified in strings without the 1425 "operator" prefix: e.g. "<<". 1426 1427 Given: 1428 class A { int operator*(); }; 1429 const A &operator<<(const A &a, const A &b); 1430 A a; 1431 a << a; <-- This matches 1432 1433 operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified 1434 line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches 1435 the declaration of A. 1436 1437 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>> 1438 </pre></td></tr> 1439 1440 1441 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isDerivedFrom1')"><a name="isDerivedFrom1Anchor">isDerivedFrom</a></td><td>StringRef BaseName</td></tr> 1442 <tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). 1443 </pre></td></tr> 1444 1445 1446 <tr><td>Matcher<<a href="http://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> 1447 <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or 1448 static member variable template instantiations. 1449 1450 Given 1451 template<typename T> void A(T t) { } 1452 template<> void A(int N) { } 1453 functionDecl(isExplicitTemplateSpecialization()) 1454 matches the specialization A<int>(). 1455 1456 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> 1457 </pre></td></tr> 1458 1459 1460 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isSameOrDerivedFrom1')"><a name="isSameOrDerivedFrom1Anchor">isSameOrDerivedFrom</a></td><td>StringRef BaseName</td></tr> 1461 <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for 1462 isSameOrDerivedFrom(hasName(...)). 1463 </pre></td></tr> 1464 1465 1466 <tr><td>Matcher<<a href="http://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> 1467 <tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static 1468 member variable template instantiations. 1469 1470 Given 1471 template <typename T> class X {}; class A {}; X<A> x; 1472 or 1473 template <typename T> class X {}; class A {}; template class X<A>; 1474 recordDecl(hasName("::X"), isTemplateInstantiation()) 1475 matches the template instantiation of X<A>. 1476 1477 But given 1478 template <typename T> class X {}; class A {}; 1479 template <> class X<A> {}; X<A> x; 1480 recordDecl(hasName("::X"), isTemplateInstantiation()) 1481 does not match, as X<A> is an explicit template specialization. 1482 1483 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> 1484 </pre></td></tr> 1485 1486 1487 <tr><td>Matcher<<a href="http://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> 1488 <tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has 1489 a specific number of arguments (including absent default arguments). 1490 1491 Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 1492 void f(int x, int y); 1493 f(0, 0); 1494 </pre></td></tr> 1495 1496 1497 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>></td><td class="name" onclick="toggle('equals3')"><a name="equals3Anchor">equals</a></td><td>ValueT Value</td></tr> 1498 <tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value. 1499 1500 Example matches true (matcher = boolLiteral(equals(true))) 1501 true 1502 1503 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1504 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>> 1505 </pre></td></tr> 1506 1507 1508 <tr><td>Matcher<<a href="http://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> 1509 <tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of 1510 child statements. 1511 1512 Example: Given 1513 { for (;;) {} } 1514 compoundStmt(statementCountIs(0))) 1515 matches '{}' 1516 but does not match the outer compound statement. 1517 </pre></td></tr> 1518 1519 1520 <tr><td>Matcher<<a href="http://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> 1521 <tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size. 1522 1523 Given 1524 int a[42]; 1525 int b[2 * 21]; 1526 int c[41], d[43]; 1527 constantArrayType(hasSize(42)) 1528 matches "int a[42]" and "int b[2 * 21]" 1529 </pre></td></tr> 1530 1531 1532 <tr><td>Matcher<<a href="http://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> 1533 <tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of 1534 declarations. 1535 1536 Example: Given 1537 int a, b; 1538 int c; 1539 int d = 2, e; 1540 declCountIs(2) 1541 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. 1542 </pre></td></tr> 1543 1544 1545 <tr><td>Matcher<<a href="http://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> 1546 <tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. 1547 1548 Matches a node if it equals the node previously bound to ID. 1549 1550 Given 1551 class X { int a; int b; }; 1552 recordDecl( 1553 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 1554 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 1555 matches the class X, as a and b have the same type. 1556 1557 Note that when multiple matches are involved via forEach* matchers, 1558 equalsBoundNodes acts as a filter. 1559 For example: 1560 compoundStmt( 1561 forEachDescendant(varDecl().bind("d")), 1562 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 1563 will trigger a match for each combination of variable declaration 1564 and reference to that variable declaration within a compound statement. 1565 </pre></td></tr> 1566 1567 1568 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('equalsNode0')"><a name="equalsNode0Anchor">equalsNode</a></td><td>Decl* Other</td></tr> 1569 <tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node. 1570 1571 Decl has pointer identity in the AST. 1572 </pre></td></tr> 1573 1574 1575 <tr><td>Matcher<<a href="http://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> 1576 <tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. 1577 1578 Given 1579 class C { 1580 public: int a; 1581 protected: int b; 1582 private: int c; 1583 }; 1584 fieldDecl(isPrivate()) 1585 matches 'int c;' 1586 </pre></td></tr> 1587 1588 1589 <tr><td>Matcher<<a href="http://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> 1590 <tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. 1591 1592 Given 1593 class C { 1594 public: int a; 1595 protected: int b; 1596 private: int c; 1597 }; 1598 fieldDecl(isProtected()) 1599 matches 'int b;' 1600 </pre></td></tr> 1601 1602 1603 <tr><td>Matcher<<a href="http://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> 1604 <tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. 1605 1606 Given 1607 class C { 1608 public: int a; 1609 protected: int b; 1610 private: int c; 1611 }; 1612 fieldDecl(isPublic()) 1613 matches 'int a;' 1614 </pre></td></tr> 1615 1616 1617 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>></td><td class="name" onclick="toggle('equals1')"><a name="equals1Anchor">equals</a></td><td>ValueT Value</td></tr> 1618 <tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value. 1619 1620 Example matches true (matcher = boolLiteral(equals(true))) 1621 true 1622 1623 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1624 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>> 1625 </pre></td></tr> 1626 1627 1628 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDefinition2')"><a name="isDefinition2Anchor">isDefinition</a></td><td></td></tr> 1629 <tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. 1630 1631 Example matches A, va, fa 1632 class A {}; 1633 class B; Doesn't match, as it has no body. 1634 int va; 1635 extern int vb; Doesn't match, as it doesn't define the variable. 1636 void fa() {} 1637 void fb(); Doesn't match, as it has no body. 1638 1639 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> 1640 </pre></td></tr> 1641 1642 1643 <tr><td>Matcher<<a href="http://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> 1644 <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or 1645 static member variable template instantiations. 1646 1647 Given 1648 template<typename T> void A(T t) { } 1649 template<> void A(int N) { } 1650 functionDecl(isExplicitTemplateSpecialization()) 1651 matches the specialization A<int>(). 1652 1653 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> 1654 </pre></td></tr> 1655 1656 1657 <tr><td>Matcher<<a href="http://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> 1658 <tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations. 1659 1660 Given: 1661 extern "C" void f() {} 1662 extern "C" { void g() {} } 1663 void h() {} 1664 functionDecl(isExternC()) 1665 matches the declaration of f and g, but not the declaration h 1666 </pre></td></tr> 1667 1668 1669 <tr><td>Matcher<<a href="http://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> 1670 <tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static 1671 member variable template instantiations. 1672 1673 Given 1674 template <typename T> class X {}; class A {}; X<A> x; 1675 or 1676 template <typename T> class X {}; class A {}; template class X<A>; 1677 recordDecl(hasName("::X"), isTemplateInstantiation()) 1678 matches the template instantiation of X<A>. 1679 1680 But given 1681 template <typename T> class X {}; class A {}; 1682 template <> class X<A> {}; X<A> x; 1683 recordDecl(hasName("::X"), isTemplateInstantiation()) 1684 does not match, as X<A> is an explicit template specialization. 1685 1686 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> 1687 </pre></td></tr> 1688 1689 1690 <tr><td>Matcher<<a href="http://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> 1691 <tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count. 1692 1693 Given 1694 void f(int i) {} 1695 void g(int i, int j) {} 1696 functionDecl(parameterCountIs(2)) 1697 matches g(int i, int j) {} 1698 </pre></td></tr> 1699 1700 1701 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals0')"><a name="equals0Anchor">equals</a></td><td>ValueT Value</td></tr> 1702 <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value. 1703 1704 Example matches true (matcher = boolLiteral(equals(true))) 1705 true 1706 1707 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1708 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>> 1709 </pre></td></tr> 1710 1711 1712 <tr><td>Matcher<<a href="http://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> 1713 <tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed 1714 to '.'. 1715 1716 Member calls on the implicit this pointer match as called with '->'. 1717 1718 Given 1719 class Y { 1720 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 1721 int a; 1722 static int b; 1723 }; 1724 memberExpr(isArrow()) 1725 matches this->x, x, y.x, a, this->b 1726 </pre></td></tr> 1727 1728 1729 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('hasName0')"><a name="hasName0Anchor">hasName</a></td><td>std::string Name</td></tr> 1730 <tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. 1731 1732 Supports specifying enclosing namespaces or classes by prefixing the name 1733 with '<enclosing>::'. 1734 Does not match typedefs of an underlying type with the given name. 1735 1736 Example matches X (Name == "X") 1737 class X; 1738 1739 Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") 1740 namespace a { namespace b { class X; } } 1741 </pre></td></tr> 1742 1743 1744 <tr><td>Matcher<<a href="http://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> 1745 <tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain 1746 a substring matched by the given RegExp. 1747 1748 Supports specifying enclosing namespaces or classes by 1749 prefixing the name with '<enclosing>::'. Does not match typedefs 1750 of an underlying type with the given name. 1751 1752 Example matches X (regexp == "::X") 1753 class X; 1754 1755 Example matches X (regexp is one of "::X", "^foo::.*X", among others) 1756 namespace foo { namespace bar { class X; } } 1757 </pre></td></tr> 1758 1759 1760 <tr><td>Matcher<<a href="http://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> 1761 <tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. 1762 1763 Given 1764 class Y { public: void x(); }; 1765 void z() { Y* y; y->x(); } 1766 callExpr(on(hasType(asString("class Y *")))) 1767 matches y->x() 1768 </pre></td></tr> 1769 1770 1771 <tr><td>Matcher<<a href="http://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> 1772 <tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. 1773 1774 Matches a node if it equals the node previously bound to ID. 1775 1776 Given 1777 class X { int a; int b; }; 1778 recordDecl( 1779 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 1780 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 1781 matches the class X, as a and b have the same type. 1782 1783 Note that when multiple matches are involved via forEach* matchers, 1784 equalsBoundNodes acts as a filter. 1785 For example: 1786 compoundStmt( 1787 forEachDescendant(varDecl().bind("d")), 1788 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 1789 will trigger a match for each combination of variable declaration 1790 and reference to that variable declaration within a compound statement. 1791 </pre></td></tr> 1792 1793 1794 <tr><td>Matcher<<a href="http://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> 1795 <tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to 1796 the node, not hidden within a typedef. 1797 1798 Given 1799 typedef const int const_int; 1800 const_int i; 1801 int *const j; 1802 int *volatile k; 1803 int m; 1804 varDecl(hasType(hasLocalQualifiers())) matches only j and k. 1805 i is const-qualified but the qualifier is not local. 1806 </pre></td></tr> 1807 1808 1809 <tr><td>Matcher<<a href="http://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> 1810 <tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that 1811 include "top-level" const. 1812 1813 Given 1814 void a(int); 1815 void b(int const); 1816 void c(const int); 1817 void d(const int*); 1818 void e(int const) {}; 1819 functionDecl(hasAnyParameter(hasType(isConstQualified()))) 1820 matches "void b(int const)", "void c(const int)" and 1821 "void e(int const) {}". It does not match d as there 1822 is no top-level const on the parameter type "const int *". 1823 </pre></td></tr> 1824 1825 1826 <tr><td>Matcher<<a href="http://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> 1827 <tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. 1828 1829 Given 1830 void a(int); 1831 void b(long); 1832 void c(double); 1833 functionDecl(hasAnyParameter(hasType(isInteger()))) 1834 matches "a(int)", "b(long)", but not "c(double)". 1835 </pre></td></tr> 1836 1837 1838 <tr><td>Matcher<<a href="http://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> 1839 <tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. 1840 1841 Matches a node if it equals the node previously bound to ID. 1842 1843 Given 1844 class X { int a; int b; }; 1845 recordDecl( 1846 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 1847 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 1848 matches the class X, as a and b have the same type. 1849 1850 Note that when multiple matches are involved via forEach* matchers, 1851 equalsBoundNodes acts as a filter. 1852 For example: 1853 compoundStmt( 1854 forEachDescendant(varDecl().bind("d")), 1855 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 1856 will trigger a match for each combination of variable declaration 1857 and reference to that variable declaration within a compound statement. 1858 </pre></td></tr> 1859 1860 1861 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('equalsNode1')"><a name="equalsNode1Anchor">equalsNode</a></td><td>Stmt* Other</td></tr> 1862 <tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node. 1863 1864 Stmt has pointer identity in the AST. 1865 1866 </pre></td></tr> 1867 1868 1869 <tr><td>Matcher<<a href="http://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> 1870 <tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. 1871 1872 Example matches A, va, fa 1873 class A {}; 1874 class B; Doesn't match, as it has no body. 1875 int va; 1876 extern int vb; Doesn't match, as it doesn't define the variable. 1877 void fa() {} 1878 void fb(); Doesn't match, as it has no body. 1879 1880 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> 1881 </pre></td></tr> 1882 1883 1884 <tr><td>Matcher<<a href="http://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> 1885 <tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. 1886 1887 Matches a node if it equals the node previously bound to ID. 1888 1889 Given 1890 class X { int a; int b; }; 1891 recordDecl( 1892 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 1893 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 1894 matches the class X, as a and b have the same type. 1895 1896 Note that when multiple matches are involved via forEach* matchers, 1897 equalsBoundNodes acts as a filter. 1898 For example: 1899 compoundStmt( 1900 forEachDescendant(varDecl().bind("d")), 1901 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 1902 will trigger a match for each combination of variable declaration 1903 and reference to that variable declaration within a compound statement. 1904 </pre></td></tr> 1905 1906 1907 <tr><td>Matcher<<a href="http://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> 1908 <tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. 1909 1910 Given 1911 int x; 1912 int s = sizeof(x) + alignof(x) 1913 unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) 1914 matches sizeof(x) 1915 </pre></td></tr> 1916 1917 1918 <tr><td>Matcher<<a href="http://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> 1919 <tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or 1920 unary). 1921 1922 Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 1923 !(a || b) 1924 </pre></td></tr> 1925 1926 1927 <tr><td>Matcher<<a href="http://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> 1928 <tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. 1929 1930 Example matches A, va, fa 1931 class A {}; 1932 class B; Doesn't match, as it has no body. 1933 int va; 1934 extern int vb; Doesn't match, as it doesn't define the variable. 1935 void fa() {} 1936 void fb(); Doesn't match, as it has no body. 1937 1938 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> 1939 </pre></td></tr> 1940 1941 1942 <tr><td>Matcher<<a href="http://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> 1943 <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or 1944 static member variable template instantiations. 1945 1946 Given 1947 template<typename T> void A(T t) { } 1948 template<> void A(int N) { } 1949 functionDecl(isExplicitTemplateSpecialization()) 1950 matches the specialization A<int>(). 1951 1952 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> 1953 </pre></td></tr> 1954 1955 1956 <tr><td>Matcher<<a href="http://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> 1957 <tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static 1958 member variable template instantiations. 1959 1960 Given 1961 template <typename T> class X {}; class A {}; X<A> x; 1962 or 1963 template <typename T> class X {}; class A {}; template class X<A>; 1964 recordDecl(hasName("::X"), isTemplateInstantiation()) 1965 matches the template instantiation of X<A>. 1966 1967 But given 1968 template <typename T> class X {}; class A {}; 1969 template <> class X<A> {}; X<A> x; 1970 recordDecl(hasName("::X"), isTemplateInstantiation()) 1971 does not match, as X<A> is an explicit template specialization. 1972 1973 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> 1974 </pre></td></tr> 1975 1976 <!--END_NARROWING_MATCHERS --> 1977 </table> 1978 1979 <!-- ======================================================================= --> 1980 <h2 id="traversal-matchers">AST Traversal Matchers</h2> 1981 <!-- ======================================================================= --> 1982 1983 <p>Traversal matchers specify the relationship to other nodes that are 1984 reachable from the current node.</p> 1985 1986 <p>Note that there are special traversal matchers (has, hasDescendant, forEach and 1987 forEachDescendant) which work on all nodes and allow users to write more generic 1988 match expressions.</p> 1989 1990 <table> 1991 <tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 1992 <!-- START_TRAVERSAL_MATCHERS --> 1993 1994 <tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*> P1, Matcher<*> P2</td></tr> 1995 <tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. 1996 1997 Unlike anyOf, eachOf will generate a match result for each 1998 matching submatcher. 1999 2000 For example, in: 2001 class A { int a; int b; }; 2002 The matcher: 2003 recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), 2004 has(fieldDecl(hasName("b")).bind("v")))) 2005 will generate two results binding "v", the first of which binds 2006 the field declaration of a, the second the field declaration of 2007 b. 2008 2009 Usable as: Any Matcher 2010 </pre></td></tr> 2011 2012 2013 <tr><td>Matcher<*></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<T> Matcher</td></tr> 2014 <tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. 2015 2016 Generates results for each match. 2017 2018 For example, in: 2019 class A { class B {}; class C {}; }; 2020 The matcher: 2021 recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m"))) 2022 will generate results for A, B and C. 2023 2024 Usable as: Any Matcher 2025 </pre></td></tr> 2026 2027 2028 <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<ChildT> ChildMatcher</td></tr> 2029 <tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the 2030 provided matcher. 2031 2032 Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X"))) 2033 class X {}; Matches X, because X::X is a class of name X inside X. 2034 class Y { class X {}; }; 2035 class Z { class Y { class X {}; }; }; Does not match Z. 2036 2037 ChildT must be an AST base type. 2038 2039 As opposed to 'has', 'forEach' will cause a match for each result that 2040 matches instead of only on the first one. 2041 2042 Usable as: Any Matcher 2043 </pre></td></tr> 2044 2045 2046 <tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<DescendantT> DescendantMatcher</td></tr> 2047 <tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 2048 provided matcher. 2049 2050 Example matches X, A, B, C 2051 (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X"))))) 2052 class X {}; Matches X, because X::X is a class of name X inside X. 2053 class A { class X {}; }; 2054 class B { class C { class X {}; }; }; 2055 2056 DescendantT must be an AST base type. 2057 2058 As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for 2059 each result that matches instead of only on the first one. 2060 2061 Note: Recursively combined ForEachDescendant can cause many matches: 2062 recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl())))) 2063 will match 10 times (plus injected class name matches) on: 2064 class A { class B { class C { class D { class E {}; }; }; }; }; 2065 2066 Usable as: Any Matcher 2067 </pre></td></tr> 2068 2069 2070 <tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<ChildT> ChildMatcher</td></tr> 2071 <tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the 2072 provided matcher. 2073 2074 Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X"))) 2075 class X {}; Matches X, because X::X is a class of name X inside X. 2076 class Y { class X {}; }; 2077 class Z { class Y { class X {}; }; }; Does not match Z. 2078 2079 ChildT must be an AST base type. 2080 2081 Usable as: Any Matcher 2082 </pre></td></tr> 2083 2084 2085 <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<AncestorT> AncestorMatcher</td></tr> 2086 <tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided 2087 matcher. 2088 2089 Given 2090 void f() { if (true) { int x = 42; } } 2091 void g() { for (;;) { int x = 43; } } 2092 expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. 2093 2094 Usable as: Any Matcher 2095 </pre></td></tr> 2096 2097 2098 <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<DescendantT> DescendantMatcher</td></tr> 2099 <tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 2100 provided matcher. 2101 2102 Example matches X, Y, Z 2103 (matcher = recordDecl(hasDescendant(recordDecl(hasName("X"))))) 2104 class X {}; Matches X, because X::X is a class of name X inside X. 2105 class Y { class X {}; }; 2106 class Z { class Y { class X {}; }; }; 2107 2108 DescendantT must be an AST base type. 2109 2110 Usable as: Any Matcher 2111 </pre></td></tr> 2112 2113 2114 <tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<ParentT> ParentMatcher</td></tr> 2115 <tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided 2116 matcher. 2117 2118 Given 2119 void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } 2120 compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". 2121 2122 Usable as: Any Matcher 2123 </pre></td></tr> 2124 2125 2126 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2127 <tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. 2128 2129 Given 2130 int i[5]; 2131 void f() { i[1] = 42; } 2132 arraySubscriptExpression(hasBase(implicitCastExpr( 2133 hasSourceExpression(declRefExpr())))) 2134 matches i[1] with the declRefExpr() matching i 2135 </pre></td></tr> 2136 2137 2138 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2139 <tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. 2140 2141 Given 2142 int i[5]; 2143 void f() { i[1] = 42; } 2144 arraySubscriptExpression(hasIndex(integerLiteral())) 2145 matches i[1] with the integerLiteral() matching 1 2146 </pre></td></tr> 2147 2148 2149 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayTypeLoc.html">ArrayTypeLoc</a>></td><td class="name" onclick="toggle('hasElementTypeLoc0')"><a name="hasElementTypeLoc0Anchor">hasElementTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> 2150 <tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element 2151 type. 2152 2153 Given 2154 struct A {}; 2155 A a[7]; 2156 int b[7]; 2157 arrayType(hasElementType(builtinType())) 2158 matches "int b[7]" 2159 2160 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>> 2161 </pre></td></tr> 2162 2163 2164 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 2165 <tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element 2166 type. 2167 2168 Given 2169 struct A {}; 2170 A a[7]; 2171 int b[7]; 2172 arrayType(hasElementType(builtinType())) 2173 matches "int b[7]" 2174 2175 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>> 2176 </pre></td></tr> 2177 2178 2179 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicTypeLoc.html">AtomicTypeLoc</a>></td><td class="name" onclick="toggle('hasValueTypeLoc0')"><a name="hasValueTypeLoc0Anchor">hasValueTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> 2180 <tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. 2181 2182 Given 2183 _Atomic(int) i; 2184 _Atomic(float) f; 2185 atomicType(hasValueType(isInteger())) 2186 matches "_Atomic(int) i" 2187 2188 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 2189 </pre></td></tr> 2190 2191 2192 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 2193 <tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. 2194 2195 Given 2196 _Atomic(int) i; 2197 _Atomic(float) f; 2198 atomicType(hasValueType(isInteger())) 2199 matches "_Atomic(int) i" 2200 2201 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 2202 </pre></td></tr> 2203 2204 2205 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 2206 <tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. 2207 2208 Note: There is no TypeLoc for the deduced type and thus no 2209 getDeducedLoc() matcher. 2210 2211 Given 2212 auto a = 1; 2213 auto b = 2.0; 2214 autoType(hasDeducedType(isInteger())) 2215 matches "auto a" 2216 2217 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> 2218 </pre></td></tr> 2219 2220 2221 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('hasEitherOperand0')"><a name="hasEitherOperand0Anchor">hasEitherOperand</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2222 <tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a 2223 binary operator matches. 2224 </pre></td></tr> 2225 2226 2227 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2228 <tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. 2229 2230 Example matches a (matcher = binaryOperator(hasLHS())) 2231 a || b 2232 </pre></td></tr> 2233 2234 2235 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2236 <tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. 2237 2238 Example matches b (matcher = binaryOperator(hasRHS())) 2239 a || b 2240 </pre></td></tr> 2241 2242 2243 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerTypeLoc.html">BlockPointerTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc0')"><a name="pointeeLoc0Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> 2244 <tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the 2245 pointee matches a given matcher. 2246 2247 Given 2248 int *a; 2249 int const *b; 2250 float const *f; 2251 pointerType(pointee(isConstQualified(), isInteger())) 2252 matches "int const *b" 2253 2254 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 2255 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 2256 </pre></td></tr> 2257 2258 2259 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 2260 <tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the 2261 pointee matches a given matcher. 2262 2263 Given 2264 int *a; 2265 int const *b; 2266 float const *f; 2267 pointerType(pointee(isConstQualified(), isInteger())) 2268 matches "int const *b" 2269 2270 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 2271 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 2272 </pre></td></tr> 2273 2274 2275 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2276 <tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call 2277 expression. 2278 2279 Given 2280 void x(int, int, int) { int y; x(1, y, 42); } 2281 callExpr(hasAnyArgument(declRefExpr())) 2282 matches x(1, y, 42) 2283 with hasAnyArgument(...) 2284 matching y 2285 2286 FIXME: Currently this will ignore parentheses and implicit casts on 2287 the argument before applying the inner matcher. We'll want to remove 2288 this to allow for greater control by the user once ignoreImplicit() 2289 has been implemented. 2290 </pre></td></tr> 2291 2292 2293 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2294 <tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor 2295 call expression. 2296 2297 Example matches y in x(y) 2298 (matcher = callExpr(hasArgument(0, declRefExpr()))) 2299 void x(int) { int y; x(y); } 2300 </pre></td></tr> 2301 2302 2303 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasDeclaration3')"><a name="hasDeclaration3Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 2304 <tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node 2305 matches the given matcher. 2306 2307 The associated declaration is: 2308 - for type nodes, the declaration of the underlying type 2309 - for CallExpr, the declaration of the callee 2310 - for MemberExpr, the declaration of the referenced member 2311 - for CXXConstructExpr, the declaration of the constructor 2312 2313 Also usable as Matcher<T> for any T supporting the getDecl() member 2314 function. e.g. various subtypes of clang::Type and various expressions. 2315 FIXME: Add all node types for which this is matcher is usable due to 2316 getDecl(). 2317 2318 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, 2319 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 2320 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> 2321 </pre></td></tr> 2322 2323 2324 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>> InnerMatcher</td></tr> 2325 <tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. 2326 2327 Given 2328 class A { A() : i(42), j(42) {} int i; int j; }; 2329 constructorDecl(forEachConstructorInitializer(forField(decl().bind("x")))) 2330 will trigger two matches, binding for 'i' and 'j' respectively. 2331 </pre></td></tr> 2332 2333 2334 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>> InnerMatcher</td></tr> 2335 <tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. 2336 2337 Given 2338 struct Foo { 2339 Foo() : foo_(1) { } 2340 int foo_; 2341 }; 2342 recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything())))) 2343 record matches Foo, hasAnyConstructorInitializer matches foo_(1) 2344 </pre></td></tr> 2345 2346 2347 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>> InnerMatcher</td></tr> 2348 <tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. 2349 2350 Given 2351 struct Foo { 2352 Foo() : foo_(1) { } 2353 int foo_; 2354 }; 2355 recordDecl(has(constructorDecl(hasAnyConstructorInitializer( 2356 forField(hasName("foo_")))))) 2357 matches Foo 2358 with forField matching foo_ 2359 </pre></td></tr> 2360 2361 2362 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2363 <tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. 2364 2365 Given 2366 struct Foo { 2367 Foo() : foo_(1) { } 2368 int foo_; 2369 }; 2370 recordDecl(has(constructorDecl(hasAnyConstructorInitializer( 2371 withInitializer(integerLiteral(equals(1))))))) 2372 matches Foo 2373 with withInitializer matching (1) 2374 </pre></td></tr> 2375 2376 2377 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2378 <tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. 2379 2380 Example matches y.x() (matcher = callExpr(on(hasType(recordDecl(hasName("Y")))))) 2381 class Y { public: void x(); }; 2382 void z() { Y y; y.x(); }", 2383 2384 FIXME: Overload to allow directly matching types? 2385 </pre></td></tr> 2386 2387 2388 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2389 <tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> 2390 2391 2392 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 2393 <tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. 2394 </pre></td></tr> 2395 2396 2397 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> InnerMatcher</td></tr> 2398 <tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration 2399 belongs to. 2400 2401 FIXME: Generalize this for other kinds of declarations. 2402 FIXME: What other kind of declarations would we need to generalize 2403 this to? 2404 2405 Example matches A() in the last line 2406 (matcher = constructExpr(hasDeclaration(methodDecl( 2407 ofClass(hasName("A")))))) 2408 class A { 2409 public: 2410 A(); 2411 }; 2412 A a = A(); 2413 </pre></td></tr> 2414 2415 2416 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>> InnerMatcher</td></tr> 2417 <tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. 2418 2419 Given: 2420 class A { void func(); }; 2421 class B { void member(); }; 2422 2423 recordDecl(hasMethod(hasName("func"))) matches the declaration of A 2424 but not B. 2425 </pre></td></tr> 2426 2427 2428 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> Base</td></tr> 2429 <tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from 2430 a class matching Base. 2431 2432 Note that a class is not considered to be derived from itself. 2433 2434 Example matches Y, Z, C (Base == hasName("X")) 2435 class X; 2436 class Y : public X {}; directly derived 2437 class Z : public Y {}; indirectly derived 2438 typedef X A; 2439 typedef A B; 2440 class C : public B {}; derived from a typedef of X 2441 2442 In the following example, Bar matches isDerivedFrom(hasName("X")): 2443 class Foo; 2444 typedef Foo X; 2445 class Bar : public Foo {}; derived from a type that X is a typedef of 2446 </pre></td></tr> 2447 2448 2449 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> Base</td></tr> 2450 <tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly 2451 match Base. 2452 </pre></td></tr> 2453 2454 2455 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 2456 <tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the 2457 given matcher. 2458 2459 Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x"))))) 2460 class Y { public: void x(); }; 2461 void z() { Y y; y.x(); 2462 </pre></td></tr> 2463 2464 2465 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2466 <tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call 2467 expression. 2468 2469 Given 2470 void x(int, int, int) { int y; x(1, y, 42); } 2471 callExpr(hasAnyArgument(declRefExpr())) 2472 matches x(1, y, 42) 2473 with hasAnyArgument(...) 2474 matching y 2475 2476 FIXME: Currently this will ignore parentheses and implicit casts on 2477 the argument before applying the inner matcher. We'll want to remove 2478 this to allow for greater control by the user once ignoreImplicit() 2479 has been implemented. 2480 </pre></td></tr> 2481 2482 2483 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2484 <tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor 2485 call expression. 2486 2487 Example matches y in x(y) 2488 (matcher = callExpr(hasArgument(0, declRefExpr()))) 2489 void x(int) { int y; x(y); } 2490 </pre></td></tr> 2491 2492 2493 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('hasDeclaration4')"><a name="hasDeclaration4Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 2494 <tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node 2495 matches the given matcher. 2496 2497 The associated declaration is: 2498 - for type nodes, the declaration of the underlying type 2499 - for CallExpr, the declaration of the callee 2500 - for MemberExpr, the declaration of the referenced member 2501 - for CXXConstructExpr, the declaration of the constructor 2502 2503 Also usable as Matcher<T> for any T supporting the getDecl() member 2504 function. e.g. various subtypes of clang::Type and various expressions. 2505 FIXME: Add all node types for which this is matcher is usable due to 2506 getDecl(). 2507 2508 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, 2509 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 2510 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> 2511 </pre></td></tr> 2512 2513 2514 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2515 <tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range 2516 extension, matches the constant given in the statement. 2517 2518 Given 2519 switch (1) { case 1: case 1+1: case 3 ... 4: ; } 2520 caseStmt(hasCaseConstant(integerLiteral())) 2521 matches "case 1:" 2522 </pre></td></tr> 2523 2524 2525 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2526 <tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher. 2527 2528 Example: matches "a string" (matcher = 2529 hasSourceExpression(constructExpr())) 2530 class URL { URL(string); }; 2531 URL url = "a string"; 2532 </pre></td></tr> 2533 2534 2535 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 2536 <tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one 2537 TemplateArgument matching the given InnerMatcher. 2538 2539 Given 2540 template<typename T> class A {}; 2541 template<> class A<double> {}; 2542 A<int> a; 2543 classTemplateSpecializationDecl(hasAnyTemplateArgument( 2544 refersToType(asString("int")))) 2545 matches the specialization A<int> 2546 </pre></td></tr> 2547 2548 2549 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 2550 <tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument 2551 matches the given InnerMatcher. 2552 2553 Given 2554 template<typename T, typename U> class A {}; 2555 A<bool, int> b; 2556 A<int, bool> c; 2557 classTemplateSpecializationDecl(hasTemplateArgument( 2558 1, refersToType(asString("int")))) 2559 matches the specialization A<bool, int> 2560 </pre></td></tr> 2561 2562 2563 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexTypeLoc.html">ComplexTypeLoc</a>></td><td class="name" onclick="toggle('hasElementTypeLoc1')"><a name="hasElementTypeLoc1Anchor">hasElementTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> 2564 <tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element 2565 type. 2566 2567 Given 2568 struct A {}; 2569 A a[7]; 2570 int b[7]; 2571 arrayType(hasElementType(builtinType())) 2572 matches "int b[7]" 2573 2574 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>> 2575 </pre></td></tr> 2576 2577 2578 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 2579 <tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element 2580 type. 2581 2582 Given 2583 struct A {}; 2584 A a[7]; 2585 int b[7]; 2586 arrayType(hasElementType(builtinType())) 2587 matches "int b[7]" 2588 2589 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>> 2590 </pre></td></tr> 2591 2592 2593 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 2594 <tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches 2595 a given matcher. 2596 2597 Given 2598 { {}; 1+2; } 2599 hasAnySubstatement(compoundStmt()) 2600 matches '{ {}; 1+2; }' 2601 with compoundStmt() 2602 matching '{}' 2603 </pre></td></tr> 2604 2605 2606 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>></td><td class="name" onclick="toggle('hasCondition4')"><a name="hasCondition4Anchor">hasCondition</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2607 <tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, 2608 or conditional operator. 2609 2610 Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 2611 if (true) {} 2612 </pre></td></tr> 2613 2614 2615 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>></td><td class="name" onclick="toggle('hasFalseExpression0')"><a name="hasFalseExpression0Anchor">hasFalseExpression</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2616 <tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator. 2617 2618 Example matches b 2619 condition ? a : b 2620 </pre></td></tr> 2621 2622 2623 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConditionalOperator.html">ConditionalOperator</a>></td><td class="name" onclick="toggle('hasTrueExpression0')"><a name="hasTrueExpression0Anchor">hasTrueExpression</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2624 <tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. 2625 2626 Example matches a 2627 condition ? a : b 2628 </pre></td></tr> 2629 2630 2631 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>> InnerMatcher</td></tr> 2632 <tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a 2633 specific using shadow declaration. 2634 2635 FIXME: This currently only works for functions. Fix. 2636 2637 Given 2638 namespace a { void f() {} } 2639 using a::f; 2640 void g() { 2641 f(); Matches this .. 2642 a::f(); .. but not this. 2643 } 2644 declRefExpr(throughUsingDeclaration(anything())) 2645 matches f() 2646 </pre></td></tr> 2647 2648 2649 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 2650 <tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the 2651 specified matcher. 2652 2653 Example matches x in if(x) 2654 (matcher = declRefExpr(to(varDecl(hasName("x"))))) 2655 bool x; 2656 if (x) {} 2657 </pre></td></tr> 2658 2659 2660 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 2661 <tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. 2662 2663 Note that this does not work for global declarations because the AST 2664 breaks up multiple-declaration DeclStmt's into multiple single-declaration 2665 DeclStmt's. 2666 Example: Given non-global declarations 2667 int a, b = 0; 2668 int c; 2669 int d = 2, e; 2670 declStmt(containsDeclaration( 2671 0, varDecl(hasInitializer(anything())))) 2672 matches only 'int d = 2, e;', and 2673 declStmt(containsDeclaration(1, varDecl())) 2674 matches 'int a, b = 0' as well as 'int d = 2, e;' 2675 but 'int c;' is not matched. 2676 </pre></td></tr> 2677 2678 2679 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 2680 <tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. 2681 2682 Given 2683 int a, b; 2684 int c; 2685 declStmt(hasSingleDecl(anything())) 2686 matches 'int c;' but not 'int a, b;'. 2687 </pre></td></tr> 2688 2689 2690 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 2691 <tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches 2692 the inner matcher. 2693 2694 Given 2695 int x; 2696 declaratorDecl(hasTypeLoc(loc(asString("int")))) 2697 matches int x 2698 </pre></td></tr> 2699 2700 2701 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 2702 <tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a 2703 Decl, matches InnerMatcher. 2704 2705 Given 2706 namespace N { 2707 namespace M { 2708 class D {}; 2709 } 2710 } 2711 2712 recordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the 2713 declaration of class D. 2714 </pre></td></tr> 2715 2716 2717 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 2718 <tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has 2719 a given body. 2720 2721 Given 2722 for (;;) {} 2723 hasBody(compoundStmt()) 2724 matches 'for (;;) {}' 2725 with compoundStmt() 2726 matching '{}' 2727 </pre></td></tr> 2728 2729 2730 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2731 <tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, 2732 or conditional operator. 2733 2734 Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 2735 if (true) {} 2736 </pre></td></tr> 2737 2738 2739 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr> 2740 <tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, 2741 matches InnerMatcher if the qualifier exists. 2742 2743 Given 2744 namespace N { 2745 namespace M { 2746 class D {}; 2747 } 2748 } 2749 N::M::D d; 2750 2751 elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) 2752 matches the type of the variable declaration of d. 2753 </pre></td></tr> 2754 2755 2756 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 2757 <tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. 2758 2759 Given 2760 namespace N { 2761 namespace M { 2762 class D {}; 2763 } 2764 } 2765 N::M::D d; 2766 2767 elaboratedType(namesType(recordType( 2768 hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable 2769 declaration of d. 2770 </pre></td></tr> 2771 2772 2773 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 2774 <tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. 2775 2776 (Note: Clang's AST refers to other conversions as "casts" too, and calls 2777 actual casts "explicit" casts.) 2778 </pre></td></tr> 2779 2780 2781 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('hasType2')"><a name="hasType2Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 2782 <tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value 2783 declaration's type. 2784 2785 In case of a value declaration (for example a variable declaration), 2786 this resolves one layer of indirection. For example, in the value 2787 declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, 2788 while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration 2789 of x." 2790 2791 Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 2792 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 2793 class X {}; 2794 void y(X &x) { x; X z; } 2795 2796 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>> 2797 </pre></td></tr> 2798 2799 2800 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2801 <tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts 2802 are stripped off. 2803 2804 Parentheses and explicit casts are not discarded. 2805 Given 2806 int arr[5]; 2807 int a = 0; 2808 char b = 0; 2809 const int c = a; 2810 int *d = arr; 2811 long e = (long) 0l; 2812 The matchers 2813 varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) 2814 varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) 2815 would match the declarations for a, b, c, and d, but not e. 2816 While 2817 varDecl(hasInitializer(integerLiteral())) 2818 varDecl(hasInitializer(declRefExpr())) 2819 only match the declarations for b, c, and d. 2820 </pre></td></tr> 2821 2822 2823 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2824 <tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and 2825 casts are stripped off. 2826 2827 Implicit and non-C Style casts are also discarded. 2828 Given 2829 int a = 0; 2830 char b = (0); 2831 void* c = reinterpret_cast<char*>(0); 2832 char d = char(0); 2833 The matcher 2834 varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) 2835 would match the declarations for a, b, c, and d. 2836 while 2837 varDecl(hasInitializer(integerLiteral())) 2838 only match the declaration for a. 2839 </pre></td></tr> 2840 2841 2842 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2843 <tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and 2844 parentheses are stripped off. 2845 2846 Explicit casts are not discarded. 2847 Given 2848 int arr[5]; 2849 int a = 0; 2850 char b = (0); 2851 const int c = a; 2852 int *d = (arr); 2853 long e = ((long) 0l); 2854 The matchers 2855 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) 2856 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) 2857 would match the declarations for a, b, c, and d, but not e. 2858 while 2859 varDecl(hasInitializer(integerLiteral())) 2860 varDecl(hasInitializer(declRefExpr())) 2861 would only match the declaration for a. 2862 </pre></td></tr> 2863 2864 2865 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 2866 <tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has 2867 a given body. 2868 2869 Given 2870 for (;;) {} 2871 hasBody(compoundStmt()) 2872 matches 'for (;;) {}' 2873 with compoundStmt() 2874 matching '{}' 2875 </pre></td></tr> 2876 2877 2878 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2879 <tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, 2880 or conditional operator. 2881 2882 Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 2883 if (true) {} 2884 </pre></td></tr> 2885 2886 2887 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 2888 <tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. 2889 2890 Example: 2891 forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) 2892 matches '++x' in 2893 for (x; x < N; ++x) { } 2894 </pre></td></tr> 2895 2896 2897 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 2898 <tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. 2899 2900 Example: 2901 forStmt(hasLoopInit(declStmt())) 2902 matches 'int x = 0' in 2903 for (int x = 0; x < N; ++x) { } 2904 </pre></td></tr> 2905 2906 2907 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> 2908 <tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration. 2909 2910 Does not match the 'this' parameter of a method. 2911 2912 Given 2913 class X { void f(int x, int y, int z) {} }; 2914 methodDecl(hasAnyParameter(hasName("y"))) 2915 matches f(int x, int y, int z) {} 2916 with hasAnyParameter(...) 2917 matching int y 2918 </pre></td></tr> 2919 2920 2921 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> 2922 <tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration. 2923 2924 Given 2925 class X { void f(int x) {} }; 2926 methodDecl(hasParameter(0, hasType(varDecl()))) 2927 matches f(int x) {} 2928 with hasParameter(...) 2929 matching int x 2930 </pre></td></tr> 2931 2932 2933 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 2934 <tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. 2935 2936 Given: 2937 class X { int f() { return 1; } }; 2938 methodDecl(returns(asString("int"))) 2939 matches int f() { return 1; } 2940 </pre></td></tr> 2941 2942 2943 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2944 <tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, 2945 or conditional operator. 2946 2947 Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 2948 if (true) {} 2949 </pre></td></tr> 2950 2951 2952 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>> InnerMatcher</td></tr> 2953 <tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. 2954 2955 Given 2956 if (A* a = GetAPointer()) {} 2957 hasConditionVariableStatment(...) 2958 matches 'A* a = GetAPointer()'. 2959 </pre></td></tr> 2960 2961 2962 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 2963 <tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given 2964 matcher. 2965 2966 FIXME: Unit test this matcher 2967 </pre></td></tr> 2968 2969 2970 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>></td><td class="name" onclick="toggle('hasDeclaration2')"><a name="hasDeclaration2Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 2971 <tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node 2972 matches the given matcher. 2973 2974 The associated declaration is: 2975 - for type nodes, the declaration of the underlying type 2976 - for CallExpr, the declaration of the callee 2977 - for MemberExpr, the declaration of the referenced member 2978 - for CXXConstructExpr, the declaration of the constructor 2979 2980 Also usable as Matcher<T> for any T supporting the getDecl() member 2981 function. e.g. various subtypes of clang::Type and various expressions. 2982 FIXME: Add all node types for which this is matcher is usable due to 2983 getDecl(). 2984 2985 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, 2986 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 2987 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> 2988 </pre></td></tr> 2989 2990 2991 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 2992 <tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is 2993 matched by a given matcher. 2994 2995 Given 2996 struct X { int m; }; 2997 void f(X x) { x.m; m; } 2998 memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X"))))))) 2999 matches "x.m" and "m" 3000 with hasObjectExpression(...) 3001 matching "x" and the implicit object expression of "m" which has type X*. 3002 </pre></td></tr> 3003 3004 3005 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>> InnerMatcher</td></tr> 3006 <tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a 3007 given matcher. 3008 3009 Given 3010 struct { int first, second; } first, second; 3011 int i(second.first); 3012 int j(first.second); 3013 memberExpr(member(hasName("first"))) 3014 matches second.first 3015 but not first.second (because the member name there is "second"). 3016 </pre></td></tr> 3017 3018 3019 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerTypeLoc.html">MemberPointerTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc1')"><a name="pointeeLoc1Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> 3020 <tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the 3021 pointee matches a given matcher. 3022 3023 Given 3024 int *a; 3025 int const *b; 3026 float const *f; 3027 pointerType(pointee(isConstQualified(), isInteger())) 3028 matches "int const *b" 3029 3030 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 3031 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 3032 </pre></td></tr> 3033 3034 3035 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 3036 <tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the 3037 pointee matches a given matcher. 3038 3039 Given 3040 int *a; 3041 int const *b; 3042 float const *f; 3043 pointerType(pointee(isConstQualified(), isInteger())) 3044 matches "int const *b" 3045 3046 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 3047 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 3048 </pre></td></tr> 3049 3050 3051 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>> InnerMatcher</td></tr> 3052 <tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. 3053 3054 Given 3055 struct A { struct B { struct C {}; }; }; 3056 A::B::C c; 3057 nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) 3058 matches "A::" 3059 </pre></td></tr> 3060 3061 3062 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr> 3063 <tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner 3064 NestedNameSpecifier-matcher matches. 3065 </pre></td></tr> 3066 3067 3068 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> InnerMatcher</td></tr> 3069 <tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the 3070 given TypeLoc. 3071 3072 Given 3073 struct A { struct B { struct C {}; }; }; 3074 A::B::C c; 3075 nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( 3076 hasDeclaration(recordDecl(hasName("A"))))))) 3077 matches "A::" 3078 </pre></td></tr> 3079 3080 3081 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr> 3082 <tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. 3083 3084 Given 3085 struct A { struct B { struct C {}; }; }; 3086 A::B::C c; 3087 nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and 3088 matches "A::" 3089 </pre></td></tr> 3090 3091 3092 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>> InnerMatcher</td></tr> 3093 <tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the 3094 given namespace matcher. 3095 3096 Given 3097 namespace ns { struct A {}; } 3098 ns::A a; 3099 nestedNameSpecifier(specifiesNamespace(hasName("ns"))) 3100 matches "ns::" 3101 </pre></td></tr> 3102 3103 3104 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 3105 <tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the 3106 given QualType matcher without qualifiers. 3107 3108 Given 3109 struct A { struct B { struct C {}; }; }; 3110 A::B::C c; 3111 nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A"))))) 3112 matches "A::" 3113 </pre></td></tr> 3114 3115 3116 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 3117 <tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. 3118 3119 Given 3120 int (*ptr_to_array)[4]; 3121 int (*ptr_to_func)(int); 3122 3123 varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches 3124 ptr_to_func but not ptr_to_array. 3125 3126 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> 3127 </pre></td></tr> 3128 3129 3130 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc2')"><a name="pointeeLoc2Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> 3131 <tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the 3132 pointee matches a given matcher. 3133 3134 Given 3135 int *a; 3136 int const *b; 3137 float const *f; 3138 pointerType(pointee(isConstQualified(), isInteger())) 3139 matches "int const *b" 3140 3141 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 3142 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 3143 </pre></td></tr> 3144 3145 3146 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 3147 <tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the 3148 pointee matches a given matcher. 3149 3150 Given 3151 int *a; 3152 int const *b; 3153 float const *f; 3154 pointerType(pointee(isConstQualified(), isInteger())) 3155 matches "int const *b" 3156 3157 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 3158 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 3159 </pre></td></tr> 3160 3161 3162 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 3163 <tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. 3164 3165 Given: 3166 typedef int &int_ref; 3167 int a; 3168 int_ref b = a; 3169 3170 varDecl(hasType(qualType(referenceType()))))) will not match the 3171 declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. 3172 </pre></td></tr> 3173 3174 3175 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasDeclaration5')"><a name="hasDeclaration5Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3176 <tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node 3177 matches the given matcher. 3178 3179 The associated declaration is: 3180 - for type nodes, the declaration of the underlying type 3181 - for CallExpr, the declaration of the callee 3182 - for MemberExpr, the declaration of the referenced member 3183 - for CXXConstructExpr, the declaration of the constructor 3184 3185 Also usable as Matcher<T> for any T supporting the getDecl() member 3186 function. e.g. various subtypes of clang::Type and various expressions. 3187 FIXME: Add all node types for which this is matcher is usable due to 3188 getDecl(). 3189 3190 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, 3191 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 3192 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> 3193 </pre></td></tr> 3194 3195 3196 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3197 <tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. 3198 </pre></td></tr> 3199 3200 3201 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3202 <tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. 3203 </pre></td></tr> 3204 3205 3206 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc3')"><a name="pointeeLoc3Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> 3207 <tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the 3208 pointee matches a given matcher. 3209 3210 Given 3211 int *a; 3212 int const *b; 3213 float const *f; 3214 pointerType(pointee(isConstQualified(), isInteger())) 3215 matches "int const *b" 3216 3217 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 3218 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 3219 </pre></td></tr> 3220 3221 3222 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 3223 <tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the 3224 pointee matches a given matcher. 3225 3226 Given 3227 int *a; 3228 int const *b; 3229 float const *f; 3230 pointerType(pointee(isConstQualified(), isInteger())) 3231 matches "int const *b" 3232 3233 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 3234 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 3235 </pre></td></tr> 3236 3237 3238 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('alignOfExpr0')"><a name="alignOfExpr0Anchor">alignOfExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr> 3239 <tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 3240 alignof. 3241 </pre></td></tr> 3242 3243 3244 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('sizeOfExpr0')"><a name="sizeOfExpr0Anchor">sizeOfExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr> 3245 <tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 3246 sizeof. 3247 </pre></td></tr> 3248 3249 3250 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>> InnerMatcher</td></tr> 3251 <tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch 3252 statement. This matcher may produce multiple matches. 3253 3254 Given 3255 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } 3256 switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") 3257 matches four times, with "c" binding each of "case 1:", "case 2:", 3258 "case 3:" and "case 4:", and "s" respectively binding "switch (1)", 3259 "switch (1)", "switch (2)" and "switch (2)". 3260 </pre></td></tr> 3261 3262 3263 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3264 <tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a TemplateArgument that refers to a certain declaration. 3265 3266 Given 3267 template<typename T> struct A {}; 3268 struct B { B* next; }; 3269 A<&B::next> a; 3270 classTemplateSpecializationDecl(hasAnyTemplateArgument( 3271 refersToDeclaration(fieldDecl(hasName("next")))) 3272 matches the specialization A<&B::next> with fieldDecl(...) matching 3273 B::next 3274 </pre></td></tr> 3275 3276 3277 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 3278 <tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. 3279 3280 Given 3281 struct X {}; 3282 template<typename T> struct A {}; 3283 A<X> a; 3284 classTemplateSpecializationDecl(hasAnyTemplateArgument( 3285 refersToType(class(hasName("X"))))) 3286 matches the specialization A<X> 3287 </pre></td></tr> 3288 3289 3290 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasDeclaration0')"><a name="hasDeclaration0Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3291 <tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node 3292 matches the given matcher. 3293 3294 The associated declaration is: 3295 - for type nodes, the declaration of the underlying type 3296 - for CallExpr, the declaration of the callee 3297 - for MemberExpr, the declaration of the referenced member 3298 - for CXXConstructExpr, the declaration of the constructor 3299 3300 Also usable as Matcher<T> for any T supporting the getDecl() member 3301 function. e.g. various subtypes of clang::Type and various expressions. 3302 FIXME: Add all node types for which this is matcher is usable due to 3303 getDecl(). 3304 3305 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, 3306 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 3307 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> 3308 </pre></td></tr> 3309 3310 3311 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 3312 <tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner 3313 QualType-matcher matches. 3314 </pre></td></tr> 3315 3316 3317 <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>></td><td class="name" onclick="toggle('hasDeclaration1')"><a name="hasDeclaration1Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3318 <tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node 3319 matches the given matcher. 3320 3321 The associated declaration is: 3322 - for type nodes, the declaration of the underlying type 3323 - for CallExpr, the declaration of the callee 3324 - for MemberExpr, the declaration of the referenced member 3325 - for CXXConstructExpr, the declaration of the constructor 3326 3327 Also usable as Matcher<T> for any T supporting the getDecl() member 3328 function. e.g. various subtypes of clang::Type and various expressions. 3329 FIXME: Add all node types for which this is matcher is usable due to 3330 getDecl(). 3331 3332 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, 3333 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 3334 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>> 3335 </pre></td></tr> 3336 3337 3338 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 3339 <tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. 3340 3341 Given 3342 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); 3343 unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) 3344 matches sizeof(a) and alignof(c) 3345 </pre></td></tr> 3346 3347 3348 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 3349 <tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. 3350 3351 Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true)))) 3352 !true 3353 </pre></td></tr> 3354 3355 3356 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1UsingShadowDecl.html">UsingShadowDecl</a>> InnerMatcher</td></tr> 3357 <tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. 3358 3359 Given 3360 namespace X { void b(); } 3361 using X::b; 3362 usingDecl(hasAnyUsingShadowDecl(hasName("b")))) 3363 matches using X::b </pre></td></tr> 3364 3365 3366 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> InnerMatcher</td></tr> 3367 <tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is 3368 matched by the given matcher. 3369 3370 Given 3371 namespace X { int a; void b(); } 3372 using X::a; 3373 using X::b; 3374 usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) 3375 matches using X::b but not using X::a </pre></td></tr> 3376 3377 3378 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3379 <tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value 3380 declaration's type. 3381 3382 In case of a value declaration (for example a variable declaration), 3383 this resolves one layer of indirection. For example, in the value 3384 declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, 3385 while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration 3386 of x." 3387 3388 Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 3389 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 3390 class X {}; 3391 void y(X &x) { x; X z; } 3392 3393 Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>> 3394 </pre></td></tr> 3395 3396 3397 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 3398 <tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression 3399 that matches the given matcher. 3400 3401 Example matches x (matcher = varDecl(hasInitializer(callExpr()))) 3402 bool y() { return true; } 3403 bool x = y(); 3404 </pre></td></tr> 3405 3406 3407 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 3408 <tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size 3409 expression. 3410 3411 Given 3412 void f(int b) { 3413 int a[b]; 3414 } 3415 variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( 3416 varDecl(hasName("b"))))))) 3417 matches "int a[b]" 3418 </pre></td></tr> 3419 3420 3421 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 3422 <tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has 3423 a given body. 3424 3425 Given 3426 for (;;) {} 3427 hasBody(compoundStmt()) 3428 matches 'for (;;) {}' 3429 with compoundStmt() 3430 matching '{}' 3431 </pre></td></tr> 3432 3433 3434 <tr><td>Matcher<<a href="http://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="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 3435 <tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, 3436 or conditional operator. 3437 3438 Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3439 if (true) {} 3440 </pre></td></tr> 3441 3442 <!--END_TRAVERSAL_MATCHERS --> 3443 </table> 3444 3445 </div> 3446 </body> 3447 </html> 3448 3449 3450