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"> 9td { 10 padding: .33em; 11} 12td.doc { 13 display: none; 14 border-bottom: 1px solid black; 15} 16td.name:hover { 17 color: blue; 18 cursor: pointer; 19} 20</style> 21<script type="text/javascript"> 22function 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 41by category and node type they match. You can click on matcher names to show the 42matcher'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. 53Note that if a matcher can match multiple node types, it will it will appear 54multiple times. This means that by searching for Matcher<Stmt> you can 55find 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 58are 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 61them into matcher expressions. You will usually want to form matcher expressions 62that read like english sentences by alternating between node matchers and 63narrowing or traversal matchers, like this: 64<pre> 65recordDecl(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 77of node that is expected. Every match expression starts with a node matcher, 78which can then be further refined with a narrowing or traversal matcher. All 79traversal matchers take node matchers as their arguments.</p> 80 81<p>For convenience, all node matchers take an arbitrary number of arguments 82and implicitly act as allOf matchers.</p> 83 84<p>Node matchers are the only matchers that support the bind("id") call to 85bind the matched node to the given string, to be later retrieved from the 86match callback.</p> 87 88<p>It is important to remember that the arguments to node matchers are 89predicates on the same node, just with additional information about the type. 90This is often useful to make matcher expression more readable by inlining bind 91calls 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. 95recordDecl(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 106Examples 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 117Given 118 class C { 119 public: 120 int a; 121 }; 122accessSpecDecl() 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 130Example 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 138Given 139 template<typename T> class A {}; 140 template<> class A<double> {}; 141 A<int> a; 142classTemplateSpecializationDecl() 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 150Example 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('conversionDecl0')"><a name="conversionDecl0Anchor">conversionDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>>...</td></tr> 161<tr><td colspan="4" class="doc" id="conversionDecl0"><pre>Matches conversion operator declarations. 162 163Example matches the operator. 164 class X { operator int() const; }; 165</pre></td></tr> 166 167 168<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> 169<tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations. 170 171Examples matches X, C, and the friend declaration inside C; 172 void X(); 173 class C { 174 friend X; 175 }; 176</pre></td></tr> 177 178 179<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> 180<tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function 181and non-type template parameter declarations). 182 183Given 184 class X { int y; }; 185declaratorDecl() 186 matches int y. 187</pre></td></tr> 188 189 190<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> 191<tr><td colspan="4" class="doc" id="destructorDecl0"><pre>Matches explicit C++ destructor declarations. 192 193Example matches Foo::~Foo() 194 class Foo { 195 public: 196 virtual ~Foo(); 197 }; 198</pre></td></tr> 199 200 201<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> 202<tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants. 203 204Example matches A, B, C 205 enum X { 206 A, B, C 207 }; 208</pre></td></tr> 209 210 211<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> 212<tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations. 213 214Example matches X 215 enum X { 216 A, B, C 217 }; 218</pre></td></tr> 219 220 221<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> 222<tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations. 223 224Given 225 class X { int m; }; 226fieldDecl() 227 matches 'm'. 228</pre></td></tr> 229 230 231<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> 232<tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations. 233 234Given 235 class X { friend void foo(); }; 236friendDecl() 237 matches 'friend void foo()'. 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('functionDecl0')"><a name="functionDecl0Anchor">functionDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>...</td></tr> 242<tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations. 243 244Example matches f 245 void f(); 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('functionTemplateDecl0')"><a name="functionTemplateDecl0Anchor">functionTemplateDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionTemplateDecl.html">FunctionTemplateDecl</a>>...</td></tr> 250<tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations. 251 252Example matches f 253 template<class T> void f(T t) {} 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('linkageSpecDecl0')"><a name="linkageSpecDecl0Anchor">linkageSpecDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LinkageSpecDecl.html">LinkageSpecDecl</a>>...</td></tr> 258<tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification. 259 260Given 261 extern "C" {} 262linkageSpecDecl() 263 matches "extern "C" {}" 264</pre></td></tr> 265 266 267<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> 268<tr><td colspan="4" class="doc" id="methodDecl0"><pre>Matches method declarations. 269 270Example matches y 271 class X { void y(); }; 272</pre></td></tr> 273 274 275<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> 276<tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name. 277 278Example matches X, S, the anonymous union type, i, and U; 279 typedef int X; 280 struct S { 281 union { 282 int i; 283 } U; 284 }; 285</pre></td></tr> 286 287 288<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> 289<tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace. 290 291Given 292 namespace {} 293 namespace test {} 294namespaceDecl() 295 matches "namespace {}" and "namespace test {}" 296</pre></td></tr> 297 298 299<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> 300<tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations. 301 302Given 303 void f(int x); 304parmVarDecl() 305 matches int x. 306</pre></td></tr> 307 308 309<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> 310<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches C++ class declarations. 311 312Example matches X, Z 313 class X; 314 template<class T> class Z {}; 315</pre></td></tr> 316 317 318<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('staticAssertDecl0')"><a name="staticAssertDecl0Anchor">staticAssertDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StaticAssertDecl.html">StaticAssertDecl</a>>...</td></tr> 319<tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration. 320 321Example: 322 staticAssertExpr() 323matches 324 static_assert(sizeof(S) == sizeof(int)) 325in 326 struct S { 327 int x; 328 }; 329 static_assert(sizeof(S) == sizeof(int)); 330</pre></td></tr> 331 332 333<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('translationUnitDecl0')"><a name="translationUnitDecl0Anchor">translationUnitDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TranslationUnitDecl.html">TranslationUnitDecl</a>>...</td></tr> 334<tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context. 335 336Given 337 int X; 338 namespace NS { 339 int Y; 340 } namespace NS 341decl(hasDeclContext(translationUnitDecl())) 342 matches "int X", but not "int Y". 343</pre></td></tr> 344 345 346<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('typedefDecl0')"><a name="typedefDecl0Anchor">typedefDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html">TypedefDecl</a>>...</td></tr> 347<tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations. 348 349Given 350 typedef int X; 351typedefDecl() 352 matches "typedef int X" 353</pre></td></tr> 354 355 356<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> 357<tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations. 358 359Given 360 template<typename X> 361 class C : private X { 362 using X::x; 363 }; 364unresolvedUsingValueDecl() 365 matches using X::x </pre></td></tr> 366 367 368<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> 369<tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations. 370 371Given 372 namespace X { int x; } 373 using X::x; 374usingDecl() 375 matches using X::x </pre></td></tr> 376 377 378<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('usingDirectiveDecl0')"><a name="usingDirectiveDecl0Anchor">usingDirectiveDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingDirectiveDecl.html">UsingDirectiveDecl</a>>...</td></tr> 379<tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations. 380 381Given 382 namespace X { int x; } 383 using namespace X; 384usingDirectiveDecl() 385 matches using namespace X </pre></td></tr> 386 387 388<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('valueDecl0')"><a name="valueDecl0Anchor">valueDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>>...</td></tr> 389<tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration. 390 391Example matches A, B, C and F 392 enum X { A, B, C }; 393 void F(); 394</pre></td></tr> 395 396 397<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> 398<tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations. 399 400Note: this does not match declarations of member variables, which are 401"field" declarations in Clang parlance. 402 403Example matches a 404 int a; 405</pre></td></tr> 406 407 408<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> 409<tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. 410</pre></td></tr> 411 412 413<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> 414<tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers. 415 416Given 417 namespace ns { 418 struct A { static void f(); }; 419 void A::f() {} 420 void g() { A::f(); } 421 } 422 ns::A a; 423nestedNameSpecifier() 424 matches "ns::" and both "A::" 425</pre></td></tr> 426 427 428<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> 429<tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST. 430</pre></td></tr> 431 432 433<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('CUDAKernelCallExpr0')"><a name="CUDAKernelCallExpr0Anchor">CUDAKernelCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html">CUDAKernelCallExpr</a>>...</td></tr> 434<tr><td colspan="4" class="doc" id="CUDAKernelCallExpr0"><pre>Matches CUDA kernel call expression. 435 436Example matches, 437 kernel<<<i,j>>>(); 438</pre></td></tr> 439 440 441<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> 442<tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. 443 444Given 445 int i = a[1]; 446arraySubscriptExpr() 447 matches "a[1]" 448</pre></td></tr> 449 450 451<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> 452<tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements. 453 454 int i = 100; 455 __asm("mov al, 2"); 456asmStmt() 457 matches '__asm("mov al, 2")' 458</pre></td></tr> 459 460 461<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> 462<tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. 463 464Example matches a || b 465 !(a || b) 466</pre></td></tr> 467 468 469<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> 470<tr><td colspan="4" class="doc" id="bindTemporaryExpr0"><pre>Matches nodes where temporaries are created. 471 472Example matches FunctionTakesString(GetStringByValue()) 473 (matcher = bindTemporaryExpr()) 474 FunctionTakesString(GetStringByValue()); 475 FunctionTakesStringByPointer(GetStringPointer()); 476</pre></td></tr> 477 478 479<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> 480<tr><td colspan="4" class="doc" id="boolLiteral0"><pre>Matches bool literals. 481 482Example matches true 483 true 484</pre></td></tr> 485 486 487<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> 488<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. 489 490Given 491 while (true) { break; } 492breakStmt() 493 matches 'break' 494</pre></td></tr> 495 496 497<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> 498<tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. 499 500Example: Matches (int*) 2.2f in 501 int i = (int) 2.2f; 502</pre></td></tr> 503 504 505<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> 506<tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. 507 508Example matches x.y() and y() 509 X x; 510 x.y(); 511 y(); 512</pre></td></tr> 513 514 515<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> 516<tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements. 517 518Given 519 switch(a) { case 42: break; default: break; } 520caseStmt() 521 matches 'case 42: break;'. 522</pre></td></tr> 523 524 525<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> 526<tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. 527 528Example: castExpr() matches each of the following: 529 (int) 3; 530 const_cast<Expr *>(SubExpr); 531 char c = 0; 532but does not match 533 int i = (0); 534 int k = 0; 535</pre></td></tr> 536 537 538<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> 539<tr><td colspan="4" class="doc" id="catchStmt0"><pre>Matches catch statements. 540 541 try {} catch(int i) {} 542catchStmt() 543 matches 'catch(int i)' 544</pre></td></tr> 545 546 547<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> 548<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). 549 550Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), 551though. 552 553Example matches 'a', L'a' 554 char ch = 'a'; wchar_t chw = L'a'; 555</pre></td></tr> 556 557 558<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> 559<tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals 560 561Example match: {1}, (1, 2) 562 int array[4] = {1}; vector int myvec = (vector int)(1, 2); 563</pre></td></tr> 564 565 566<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> 567<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. 568 569Example matches '{}' and '{{}}'in 'for (;;) {{}}' 570 for (;;) {{}} 571</pre></td></tr> 572 573 574<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> 575<tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. 576 577Example matches a ? b : c 578 (a ? b : c) + 42 579</pre></td></tr> 580 581 582<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> 583<tr><td colspan="4" class="doc" id="constCastExpr0"><pre>Matches a const_cast expression. 584 585Example: Matches const_cast<int*>(&r) in 586 int n = 42; 587 const int &r(n); 588 int* p = const_cast<int*>(&r); 589</pre></td></tr> 590 591 592<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> 593<tr><td colspan="4" class="doc" id="constructExpr0"><pre>Matches constructor call expressions (including implicit ones). 594 595Example matches string(ptr, n) and ptr within arguments of f 596 (matcher = constructExpr()) 597 void f(const string &a, const string &b); 598 char *ptr; 599 int n; 600 f(string(ptr, n), ptr); 601</pre></td></tr> 602 603 604<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> 605<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. 606 607Given 608 while (true) { continue; } 609continueStmt() 610 matches 'continue' 611</pre></td></tr> 612 613 614<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> 615<tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. 616 617Example matches x in if (x) 618 bool x; 619 if (x) {} 620</pre></td></tr> 621 622 623<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> 624<tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. 625 626Given 627 int a; 628declStmt() 629 matches 'int a'. 630</pre></td></tr> 631 632 633<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> 634<tr><td colspan="4" class="doc" id="defaultArgExpr0"><pre>Matches the value of a default argument at the call site. 635 636Example matches the CXXDefaultArgExpr placeholder inserted for the 637 default value of the second parameter in the call expression f(42) 638 (matcher = defaultArgExpr()) 639 void f(int x, int y = 0); 640 f(42); 641</pre></td></tr> 642 643 644<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> 645<tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements. 646 647Given 648 switch(a) { case 42: break; default: break; } 649defaultStmt() 650 matches 'default: break;'. 651</pre></td></tr> 652 653 654<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> 655<tr><td colspan="4" class="doc" id="deleteExpr0"><pre>Matches delete expressions. 656 657Given 658 delete X; 659deleteExpr() 660 matches 'delete X'. 661</pre></td></tr> 662 663 664<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> 665<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. 666 667Given 668 do {} while (true); 669doStmt() 670 matches 'do {} while(true)' 671</pre></td></tr> 672 673 674<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> 675<tr><td colspan="4" class="doc" id="dynamicCastExpr0"><pre>Matches a dynamic_cast expression. 676 677Example: 678 dynamicCastExpr() 679matches 680 dynamic_cast<D*>(&b); 681in 682 struct B { virtual ~B() {} }; struct D : B {}; 683 B b; 684 D* p = dynamic_cast<D*>(&b); 685</pre></td></tr> 686 687 688<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> 689<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. 690 691Matches any cast expression written in user code, whether it be a 692C-style cast, a functional-style cast, or a keyword cast. 693 694Does not match implicit conversions. 695 696Note: the name "explicitCast" is chosen to match Clang's terminology, as 697Clang uses the term "cast" to apply to implicit conversions as well as to 698actual cast expressions. 699 700hasDestinationType. 701 702Example: matches all five of the casts in 703 int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) 704but does not match the implicit conversion in 705 long ell = 42; 706</pre></td></tr> 707 708 709<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> 710<tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. 711 712Example matches x() 713 void f() { x(); } 714</pre></td></tr> 715 716 717<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('exprWithCleanups0')"><a name="exprWithCleanups0Anchor">exprWithCleanups</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ExprWithCleanups.html">ExprWithCleanups</a>>...</td></tr> 718<tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end 719of the sub-expression's evaluation. 720 721Example matches std::string() 722 const std::string str = std::string(); 723</pre></td></tr> 724 725 726<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('floatLiteral0')"><a name="floatLiteral0Anchor">floatLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>...</td></tr> 727<tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes encodings, e.g. 7281.0, 1.0f, 1.0L and 1e10. 729 730Does not match implicit conversions such as 731 float a = 10; 732</pre></td></tr> 733 734 735<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> 736<tr><td colspan="4" class="doc" id="forRangeStmt0"><pre>Matches range-based for statements. 737 738forRangeStmt() matches 'for (auto a : i)' 739 int i[] = {1, 2, 3}; for (auto a : i); 740 for(int j = 0; j < 5; ++j); 741</pre></td></tr> 742 743 744<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> 745<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. 746 747Example matches 'for (;;) {}' 748 for (;;) {} 749 int i[] = {1, 2, 3}; for (auto a : i); 750</pre></td></tr> 751 752 753<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> 754<tr><td colspan="4" class="doc" id="functionalCastExpr0"><pre>Matches functional cast expressions 755 756Example: Matches Foo(bar); 757 Foo f = bar; 758 Foo g = (Foo) bar; 759 Foo h = Foo(bar); 760</pre></td></tr> 761 762 763<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('gnuNullExpr0')"><a name="gnuNullExpr0Anchor">gnuNullExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1GNUNullExpr.html">GNUNullExpr</a>>...</td></tr> 764<tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression. 765</pre></td></tr> 766 767 768<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> 769<tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. 770 771Given 772 goto FOO; 773 FOO: bar(); 774gotoStmt() 775 matches 'goto FOO' 776</pre></td></tr> 777 778 779<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> 780<tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. 781 782Example matches 'if (x) {}' 783 if (x) {} 784</pre></td></tr> 785 786 787<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> 788<tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. 789 790This matches many different places, including function call return value 791eliding, as well as any type conversions. 792</pre></td></tr> 793 794 795<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> 796<tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. 797 798Given 799 int a[] = { 1, 2 }; 800 struct B { int x, y; }; 801 B b = { 5, 6 }; 802initListExpr() 803 matches "{ 1, 2 }" and "{ 5, 6 }" 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('integerLiteral0')"><a name="integerLiteral0Anchor">integerLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>>...</td></tr> 808<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings, e.g. 8091, 1L, 0x1 and 1U. 810 811Does not match character-encoded integers such as L'a'. 812</pre></td></tr> 813 814 815<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> 816<tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. 817 818Given 819 goto FOO; 820 FOO: bar(); 821labelStmt() 822 matches 'FOO:' 823</pre></td></tr> 824 825 826<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> 827<tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. 828 829Example matches [&](){return 5;} 830 [&](){return 5;} 831</pre></td></tr> 832 833 834<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> 835<tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. 836 837Example: Given 838 struct T {void func()}; 839 T f(); 840 void g(T); 841materializeTemporaryExpr() matches 'f()' in these statements 842 T u(f()); 843 g(f()); 844but does not match 845 f(); 846 f().func(); 847</pre></td></tr> 848 849 850<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> 851<tr><td colspan="4" class="doc" id="memberCallExpr0"><pre>Matches member call expressions. 852 853Example matches x.y() 854 X x; 855 x.y(); 856</pre></td></tr> 857 858 859<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> 860<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. 861 862Given 863 class Y { 864 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 865 int a; static int b; 866 }; 867memberExpr() 868 matches this->x, x, y.x, a, this->b 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('newExpr0')"><a name="newExpr0Anchor">newExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>...</td></tr> 873<tr><td colspan="4" class="doc" id="newExpr0"><pre>Matches new expressions. 874 875Given 876 new X; 877newExpr() 878 matches 'new X'. 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('nullPtrLiteralExpr0')"><a name="nullPtrLiteralExpr0Anchor">nullPtrLiteralExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>>...</td></tr> 883<tr><td colspan="4" class="doc" id="nullPtrLiteralExpr0"><pre>Matches nullptr literal. 884</pre></td></tr> 885 886 887<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> 888<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. 889 890 foo();; 891nullStmt() 892 matches the second ';' 893</pre></td></tr> 894 895 896<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcMessageExpr0')"><a name="objcMessageExpr0Anchor">objcMessageExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>>...</td></tr> 897<tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions. 898 899The innermost message send invokes the "alloc" class method on the 900NSString class, while the outermost message send invokes the 901"initWithString" instance method on the object returned from 902NSString's "alloc". This matcher should match both message sends. 903 [[NSString alloc] initWithString:@"Hello"] 904</pre></td></tr> 905 906 907<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> 908<tr><td colspan="4" class="doc" id="operatorCallExpr0"><pre>Matches overloaded operator calls. 909 910Note that if an operator isn't overloaded, it won't match. Instead, use 911binaryOperator matcher. 912Currently it does not match operators such as new delete. 913FIXME: figure out why these do not match? 914 915Example matches both operator<<((o << b), c) and operator<<(o, b) 916 (matcher = operatorCallExpr()) 917 ostream &operator<< (ostream &out, int i) { }; 918 ostream &o; int b = 1, c = 1; 919 o << b << c; 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('reinterpretCastExpr0')"><a name="reinterpretCastExpr0Anchor">reinterpretCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>>...</td></tr> 924<tr><td colspan="4" class="doc" id="reinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. 925 926Either the source expression or the destination type can be matched 927using has(), but hasDestinationType() is more specific and can be 928more readable. 929 930Example matches reinterpret_cast<char*>(&p) in 931 void* p = reinterpret_cast<char*>(&p); 932</pre></td></tr> 933 934 935<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> 936<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. 937 938Given 939 return 1; 940returnStmt() 941 matches 'return 1' 942</pre></td></tr> 943 944 945<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> 946<tr><td colspan="4" class="doc" id="staticCastExpr0"><pre>Matches a C++ static_cast expression. 947 948hasDestinationType 949reinterpretCast 950 951Example: 952 staticCastExpr() 953matches 954 static_cast<long>(8) 955in 956 long eight(static_cast<long>(8)); 957</pre></td></tr> 958 959 960<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> 961<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. 962 963Given 964 { ++a; } 965stmt() 966 matches both the compound statement '{ ++a; }' and '++a'. 967</pre></td></tr> 968 969 970<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> 971<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). 972 973Example matches "abcd", L"abcd" 974 char *s = "abcd"; wchar_t *ws = L"abcd" 975</pre></td></tr> 976 977 978<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('substNonTypeTemplateParmExpr0')"><a name="substNonTypeTemplateParmExpr0Anchor">substNonTypeTemplateParmExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SubstNonTypeTemplateParmExpr.html">SubstNonTypeTemplateParmExpr</a>>...</td></tr> 979<tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters. 980 981Given 982 template <int N> 983 struct A { static const int n = N; }; 984 struct B : public A<42> {}; 985substNonTypeTemplateParmExpr() 986 matches "N" in the right-hand side of "static const int n = N;" 987</pre></td></tr> 988 989 990<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> 991<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. 992 993Given 994 switch(a) { case 42: break; default: break; } 995switchCase() 996 matches 'case 42: break;' and 'default: break;'. 997</pre></td></tr> 998 999 1000<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> 1001<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. 1002 1003Given 1004 switch(a) { case 42: break; default: break; } 1005switchStmt() 1006 matches 'switch(a)'. 1007</pre></td></tr> 1008 1009 1010<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('temporaryObjectExpr0')"><a name="temporaryObjectExpr0Anchor">temporaryObjectExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>...</td></tr> 1011<tr><td colspan="4" class="doc" id="temporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments 1012 1013Example: Matches Foo(bar, bar) 1014 Foo h = Foo(bar, bar); 1015</pre></td></tr> 1016 1017 1018<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> 1019<tr><td colspan="4" class="doc" id="thisExpr0"><pre>Matches implicit and explicit this expressions. 1020 1021Example matches the implicit this expression in "return i". 1022 (matcher = thisExpr()) 1023struct foo { 1024 int i; 1025 int f() { return i; } 1026}; 1027</pre></td></tr> 1028 1029 1030<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> 1031<tr><td colspan="4" class="doc" id="throwExpr0"><pre>Matches throw expressions. 1032 1033 try { throw 5; } catch(int i) {} 1034throwExpr() 1035 matches 'throw 5' 1036</pre></td></tr> 1037 1038 1039<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> 1040<tr><td colspan="4" class="doc" id="tryStmt0"><pre>Matches try statements. 1041 1042 try {} catch(int i) {} 1043tryStmt() 1044 matches 'try {}' 1045</pre></td></tr> 1046 1047 1048<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> 1049<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) 1050 1051Given 1052 Foo x = bar; 1053 int y = sizeof(x) + alignof(x); 1054unaryExprOrTypeTraitExpr() 1055 matches sizeof(x) and alignof(x) 1056</pre></td></tr> 1057 1058 1059<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> 1060<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. 1061 1062Example matches !a 1063 !a || b 1064</pre></td></tr> 1065 1066 1067<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> 1068<tr><td colspan="4" class="doc" id="unresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions. 1069 1070Example matches T(t) in return statement of f 1071 (matcher = unresolvedConstructExpr()) 1072 template <typename T> 1073 void f(const T& t) { return T(t); } 1074</pre></td></tr> 1075 1076 1077<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> 1078<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. 1079 1080Example match: "foo"_suffix 1081</pre></td></tr> 1082 1083 1084<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> 1085<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. 1086 1087Given 1088 while (true) {} 1089whileStmt() 1090 matches 'while (true) {}'. 1091</pre></td></tr> 1092 1093 1094<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('templateArgument0')"><a name="templateArgument0Anchor">templateArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>>...</td></tr> 1095<tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments. 1096 1097Given 1098 template <typename T> struct C {}; 1099 C<int> c; 1100templateArgument() 1101 matches 'int' in C<int>. 1102</pre></td></tr> 1103 1104 1105<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> 1106<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. 1107</pre></td></tr> 1108 1109 1110<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> 1111<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. 1112 1113Given 1114 int a[] = { 2, 3 }; 1115 int b[4]; 1116 void f() { int c[a[0]]; } 1117arrayType() 1118 matches "int a[]", "int b[4]" and "int c[a[0]]"; 1119</pre></td></tr> 1120 1121 1122<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> 1123<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. 1124 1125Given 1126 _Atomic(int) i; 1127atomicType() 1128 matches "_Atomic(int) i" 1129</pre></td></tr> 1130 1131 1132<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> 1133<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. 1134 1135Given: 1136 auto n = 4; 1137 int v[] = { 2, 3 } 1138 for (auto i : v) { } 1139autoType() 1140 matches "auto n" and "auto i" 1141</pre></td></tr> 1142 1143 1144<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> 1145<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as 1146"void (^)(int)". 1147 1148The pointee is always required to be a FunctionType. 1149</pre></td></tr> 1150 1151 1152<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> 1153<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. 1154 1155Given 1156 struct A {}; 1157 A a; 1158 int b; 1159 float c; 1160 bool d; 1161builtinType() 1162 matches "int b", "float c" and "bool d" 1163</pre></td></tr> 1164 1165 1166<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> 1167<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. 1168 1169Given 1170 _Complex float f; 1171complexType() 1172 matches "_Complex float f" 1173</pre></td></tr> 1174 1175 1176<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> 1177<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. 1178 1179Given 1180 void() { 1181 int a[2]; 1182 int b[] = { 2, 3 }; 1183 int c[b[0]]; 1184 } 1185constantArrayType() 1186 matches "int a[2]" 1187</pre></td></tr> 1188 1189 1190<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> 1191<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. 1192 1193Given 1194 template<typename T, int Size> 1195 class array { 1196 T data[Size]; 1197 }; 1198dependentSizedArrayType 1199 matches "T data[Size]" 1200</pre></td></tr> 1201 1202 1203<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> 1204<tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a 1205qualified name. 1206 1207Given 1208 namespace N { 1209 namespace M { 1210 class D {}; 1211 } 1212 } 1213 class C {}; 1214 1215 class C c; 1216 N::M::D d; 1217 1218elaboratedType() matches the type of the variable declarations of both 1219c and d. 1220</pre></td></tr> 1221 1222 1223<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> 1224<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. 1225 1226Given 1227 int (*f)(int); 1228 void g(); 1229functionType() 1230 matches "int (*f)(int)" and the type of "g". 1231</pre></td></tr> 1232 1233 1234<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> 1235<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. 1236 1237Given 1238 int a[] = { 2, 3 }; 1239 int b[42]; 1240 void f(int c[]) { int d[a[0]]; }; 1241incompleteArrayType() 1242 matches "int a[]" and "int c[]" 1243</pre></td></tr> 1244 1245 1246<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> 1247<tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. 1248 1249Given: 1250 int *a; 1251 int &b = *a; 1252 int &&c = 1; 1253 auto &d = b; 1254 auto &&e = c; 1255 auto &&f = 2; 1256 int g = 5; 1257 1258lValueReferenceType() matches the types of b, d, and e. e is 1259matched since the type is deduced as int& by reference collapsing rules. 1260</pre></td></tr> 1261 1262 1263<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> 1264<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. 1265Given 1266 struct A { int i; } 1267 A::* ptr = A::i; 1268memberPointerType() 1269 matches "A::* ptr" 1270</pre></td></tr> 1271 1272 1273<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> 1274<tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. 1275 1276Given 1277 int (*ptr_to_array)[4]; 1278 int *array_of_ptrs[4]; 1279 1280varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not 1281array_of_ptrs. 1282</pre></td></tr> 1283 1284 1285<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> 1286<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types. 1287 1288Given 1289 int *a; 1290 int &b = *a; 1291 int c = 5; 1292pointerType() 1293 matches "int *a" 1294</pre></td></tr> 1295 1296 1297<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> 1298<tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. 1299 1300Given: 1301 int *a; 1302 int &b = *a; 1303 int &&c = 1; 1304 auto &d = b; 1305 auto &&e = c; 1306 auto &&f = 2; 1307 int g = 5; 1308 1309rValueReferenceType() matches the types of c and f. e is not 1310matched as it is deduced to int& by reference collapsing rules. 1311</pre></td></tr> 1312 1313 1314<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> 1315<tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). 1316 1317Given 1318 class C {}; 1319 struct S {}; 1320 1321 C c; 1322 S s; 1323 1324recordType() matches the type of the variable declarations of both c 1325and s. 1326</pre></td></tr> 1327 1328 1329<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> 1330<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. 1331 1332Given 1333 int *a; 1334 int &b = *a; 1335 int &&c = 1; 1336 auto &d = b; 1337 auto &&e = c; 1338 auto &&f = 2; 1339 int g = 5; 1340 1341referenceType() matches the types of b, c, d, e, and f. 1342</pre></td></tr> 1343 1344 1345<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> 1346<tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. 1347 1348Given 1349 template <typename T> 1350 class C { }; 1351 1352 template class C<int>; A 1353 C<char> var; B 1354 1355templateSpecializationType() matches the type of the explicit 1356instantiation in A and the type of the variable declaration in B. 1357</pre></td></tr> 1358 1359 1360<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> 1361<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. 1362</pre></td></tr> 1363 1364 1365<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> 1366<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. 1367 1368Given 1369 typedef int X; 1370typedefType() 1371 matches "typedef int X" 1372</pre></td></tr> 1373 1374 1375<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> 1376<tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. 1377 1378Given: 1379 typedef __underlying_type(T) type; 1380unaryTransformType() 1381 matches "__underlying_type(T)" 1382</pre></td></tr> 1383 1384 1385<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> 1386<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an 1387integer-constant-expression. 1388 1389Given 1390 void f() { 1391 int a[] = { 2, 3 } 1392 int b[42]; 1393 int c[a[0]]; 1394 } 1395variableArrayType() 1396 matches "int c[a[0]]" 1397</pre></td></tr> 1398 1399<!--END_DECL_MATCHERS --> 1400</table> 1401 1402<!-- ======================================================================= --> 1403<h2 id="narrowing-matchers">Narrowing Matchers</h2> 1404<!-- ======================================================================= --> 1405 1406<p>Narrowing matchers match certain attributes on the current node, thus 1407narrowing down the set of nodes of the current type to match on.</p> 1408 1409<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) 1410which allow users to create more powerful match expressions.</p> 1411 1412<table> 1413<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 1414<!-- START_NARROWING_MATCHERS --> 1415 1416<tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 1417<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. 1418 1419Usable as: Any Matcher 1420</pre></td></tr> 1421 1422 1423<tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 1424<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. 1425 1426Usable as: Any Matcher 1427</pre></td></tr> 1428 1429 1430<tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> 1431<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. 1432 1433Useful when another matcher requires a child matcher, but there's no 1434additional constraint. This will often be used with an explicit conversion 1435to an internal::Matcher<> type such as TypeMatcher. 1436 1437Example: DeclarationMatcher(anything()) matches all declarations, e.g., 1438"int* p" and "void f()" in 1439 int* p; 1440 void f(); 1441 1442Usable as: Any Matcher 1443</pre></td></tr> 1444 1445 1446<tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> 1447<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. 1448 1449Example matches Y (matcher = recordDecl(unless(hasName("X")))) 1450 class X {}; 1451 class Y {}; 1452 1453Usable as: Any Matcher 1454</pre></td></tr> 1455 1456 1457<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> 1458<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or 1459unary). 1460 1461Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 1462 !(a || b) 1463</pre></td></tr> 1464 1465 1466<tr><td>Matcher<CXXBoolLiteral></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>ValueT Value</td></tr> 1467<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value. 1468 1469Example matches true (matcher = boolLiteral(equals(true))) 1470 true 1471 1472Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1473 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>> 1474</pre></td></tr> 1475 1476 1477<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>></td><td class="name" onclick="toggle('isCatchAll0')"><a name="isCatchAll0Anchor">isCatchAll</a></td><td></td></tr> 1478<tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler. 1479 1480Given 1481 try { 1482 ... 1483 } catch (int) { 1484 ... 1485 } catch (...) { 1486 ... 1487 } 1488endcode 1489catchStmt(isCatchAll()) matches catch(...) but not catch(int). 1490</pre></td></tr> 1491 1492 1493<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> 1494<tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has 1495a specific number of arguments (including absent default arguments). 1496 1497Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 1498 void f(int x, int y); 1499 f(0, 0); 1500</pre></td></tr> 1501 1502 1503<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('isListInitialization0')"><a name="isListInitialization0Anchor">isListInitialization</a></td><td></td></tr> 1504<tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. 1505</pre></td></tr> 1506 1507 1508<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isCopyConstructor0')"><a name="isCopyConstructor0Anchor">isCopyConstructor</a></td><td></td></tr> 1509<tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors. 1510 1511Given 1512 struct S { 1513 S(); #1 1514 S(const S &); #2 1515 S(S &&); #3 1516 }; 1517constructorDecl(isCopyConstructor()) will match #2, but not #1 or #3. 1518</pre></td></tr> 1519 1520 1521<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isDefaultConstructor0')"><a name="isDefaultConstructor0Anchor">isDefaultConstructor</a></td><td></td></tr> 1522<tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors. 1523 1524Given 1525 struct S { 1526 S(); #1 1527 S(const S &); #2 1528 S(S &&); #3 1529 }; 1530constructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3. 1531</pre></td></tr> 1532 1533 1534<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isExplicit0')"><a name="isExplicit0Anchor">isExplicit</a></td><td></td></tr> 1535<tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor and conversion declarations that are marked with 1536the explicit keyword. 1537 1538Given 1539 struct S { 1540 S(int); #1 1541 explicit S(double); #2 1542 operator int(); #3 1543 explicit operator bool(); #4 1544 }; 1545constructorDecl(isExplicit()) will match #2, but not #1. 1546conversionDecl(isExplicit()) will match #4, but not #3. 1547</pre></td></tr> 1548 1549 1550<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isMoveConstructor0')"><a name="isMoveConstructor0Anchor">isMoveConstructor</a></td><td></td></tr> 1551<tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors. 1552 1553Given 1554 struct S { 1555 S(); #1 1556 S(const S &); #2 1557 S(S &&); #3 1558 }; 1559constructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. 1560</pre></td></tr> 1561 1562 1563<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>></td><td class="name" onclick="toggle('isExplicit1')"><a name="isExplicit1Anchor">isExplicit</a></td><td></td></tr> 1564<tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor and conversion declarations that are marked with 1565the explicit keyword. 1566 1567Given 1568 struct S { 1569 S(int); #1 1570 explicit S(double); #2 1571 operator int(); #3 1572 explicit operator bool(); #4 1573 }; 1574constructorDecl(isExplicit()) will match #2, but not #1. 1575conversionDecl(isExplicit()) will match #4, but not #3. 1576</pre></td></tr> 1577 1578 1579<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('isBaseInitializer0')"><a name="isBaseInitializer0Anchor">isBaseInitializer</a></td><td></td></tr> 1580<tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as 1581opposed to a member. 1582 1583Given 1584 struct B {}; 1585 struct D : B { 1586 int I; 1587 D(int i) : I(i) {} 1588 }; 1589 struct E : B { 1590 E() : B() {} 1591 }; 1592constructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) 1593 will match E(), but not match D(int). 1594</pre></td></tr> 1595 1596 1597<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('isMemberInitializer0')"><a name="isMemberInitializer0Anchor">isMemberInitializer</a></td><td></td></tr> 1598<tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as 1599opposed to a base. 1600 1601Given 1602 struct B {}; 1603 struct D : B { 1604 int I; 1605 D(int i) : I(i) {} 1606 }; 1607 struct E : B { 1608 E() : B() {} 1609 }; 1610constructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) 1611 will match D(int), but not match E(). 1612</pre></td></tr> 1613 1614 1615<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> 1616<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in 1617code (as opposed to implicitly added by the compiler). 1618 1619Given 1620 struct Foo { 1621 Foo() { } 1622 Foo(int) : foo_("A") { } 1623 string foo_; 1624 }; 1625constructorDecl(hasAnyConstructorInitializer(isWritten())) 1626 will match Foo(int), but not Foo() 1627</pre></td></tr> 1628 1629 1630<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> 1631<tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. 1632 1633Given 1634struct A { 1635 void foo() const; 1636 void bar(); 1637}; 1638 1639methodDecl(isConst()) matches A::foo() but not A::bar() 1640</pre></td></tr> 1641 1642 1643<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isFinal1')"><a name="isFinal1Anchor">isFinal</a></td><td></td></tr> 1644<tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final. 1645 1646Given: 1647 class A final {}; 1648 1649 struct B { 1650 virtual void f(); 1651 }; 1652 1653 struct C : B { 1654 void f() final; 1655 }; 1656matches A and C::f, but not B, C, or B::f 1657</pre></td></tr> 1658 1659 1660<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> 1661<tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. 1662 1663Given 1664 class A { 1665 public: 1666 virtual void x(); 1667 }; 1668 class B : public A { 1669 public: 1670 virtual void x(); 1671 }; 1672 matches B::x 1673</pre></td></tr> 1674 1675 1676<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isPure0')"><a name="isPure0Anchor">isPure</a></td><td></td></tr> 1677<tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. 1678 1679Given 1680 class A { 1681 public: 1682 virtual void x() = 0; 1683 }; 1684 matches A::x 1685</pre></td></tr> 1686 1687 1688<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> 1689<tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual. 1690 1691Given 1692 class A { 1693 public: 1694 virtual void x(); 1695 }; 1696 matches A::x 1697</pre></td></tr> 1698 1699 1700<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> 1701<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. 1702 1703Matches overloaded operator names specified in strings without the 1704"operator" prefix: e.g. "<<". 1705 1706Given: 1707 class A { int operator*(); }; 1708 const A &operator<<(const A &a, const A &b); 1709 A a; 1710 a << a; <-- This matches 1711 1712operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified 1713line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches 1714the declaration of A. 1715 1716Usable 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_1FunctionDecl.html">FunctionDecl</a>> 1717</pre></td></tr> 1718 1719 1720<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>std::string BaseName</td></tr> 1721<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). 1722</pre></td></tr> 1723 1724 1725<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> 1726<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or 1727static member variable template instantiations. 1728 1729Given 1730 template<typename T> void A(T t) { } 1731 template<> void A(int N) { } 1732functionDecl(isExplicitTemplateSpecialization()) 1733 matches the specialization A<int>(). 1734 1735Usable 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>> 1736</pre></td></tr> 1737 1738 1739<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isFinal0')"><a name="isFinal0Anchor">isFinal</a></td><td></td></tr> 1740<tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final. 1741 1742Given: 1743 class A final {}; 1744 1745 struct B { 1746 virtual void f(); 1747 }; 1748 1749 struct C : B { 1750 void f() final; 1751 }; 1752matches A and C::f, but not B, C, or B::f 1753</pre></td></tr> 1754 1755 1756<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>std::string BaseName</td></tr> 1757<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for 1758isSameOrDerivedFrom(hasName(...)). 1759</pre></td></tr> 1760 1761 1762<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> 1763<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static 1764member variable template instantiations. 1765 1766Given 1767 template <typename T> class X {}; class A {}; X<A> x; 1768or 1769 template <typename T> class X {}; class A {}; template class X<A>; 1770recordDecl(hasName("::X"), isTemplateInstantiation()) 1771 matches the template instantiation of X<A>. 1772 1773But given 1774 template <typename T> class X {}; class A {}; 1775 template <> class X<A> {}; X<A> x; 1776recordDecl(hasName("::X"), isTemplateInstantiation()) 1777 does not match, as X<A> is an explicit template specialization. 1778 1779Usable 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>> 1780</pre></td></tr> 1781 1782 1783<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> 1784<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has 1785a specific number of arguments (including absent default arguments). 1786 1787Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 1788 void f(int x, int y); 1789 f(0, 0); 1790</pre></td></tr> 1791 1792 1793<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> 1794<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value. 1795 1796Example matches true (matcher = boolLiteral(equals(true))) 1797 true 1798 1799Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1800 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>> 1801</pre></td></tr> 1802 1803 1804<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('templateArgumentCountIs0')"><a name="templateArgumentCountIs0Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr> 1805<tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N. 1806 1807Given 1808 template<typename T> struct C {}; 1809 C<int> c; 1810classTemplateSpecializationDecl(templateArgumentCountIs(1)) 1811 matches C<int>. 1812</pre></td></tr> 1813 1814 1815<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> 1816<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of 1817child statements. 1818 1819Example: Given 1820 { for (;;) {} } 1821compoundStmt(statementCountIs(0))) 1822 matches '{}' 1823 but does not match the outer compound statement. 1824</pre></td></tr> 1825 1826 1827<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> 1828<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size. 1829 1830Given 1831 int a[42]; 1832 int b[2 * 21]; 1833 int c[41], d[43]; 1834constantArrayType(hasSize(42)) 1835 matches "int a[42]" and "int b[2 * 21]" 1836</pre></td></tr> 1837 1838 1839<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> 1840<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of 1841declarations. 1842 1843Example: Given 1844 int a, b; 1845 int c; 1846 int d = 2, e; 1847declCountIs(2) 1848 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. 1849</pre></td></tr> 1850 1851 1852<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> 1853<tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. 1854 1855Matches a node if it equals the node previously bound to ID. 1856 1857Given 1858 class X { int a; int b; }; 1859recordDecl( 1860 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 1861 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 1862 matches the class X, as a and b have the same type. 1863 1864Note that when multiple matches are involved via forEach* matchers, 1865equalsBoundNodes acts as a filter. 1866For example: 1867compoundStmt( 1868 forEachDescendant(varDecl().bind("d")), 1869 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 1870will trigger a match for each combination of variable declaration 1871and reference to that variable declaration within a compound statement. 1872</pre></td></tr> 1873 1874 1875<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('hasAttr0')"><a name="hasAttr0Anchor">hasAttr</a></td><td>attr::Kind AttrKind</td></tr> 1876<tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute. 1877 1878Given 1879 __attribute__((device)) void f() { ... } 1880decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of 1881f. If the matcher is use from clang-query, attr::Kind parameter should be 1882passed as a quoted string. e.g., hasAttr("attr::CUDADevice"). 1883</pre></td></tr> 1884 1885 1886<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching0')"><a name="isExpansionInFileMatching0Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr> 1887<tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is 1888partially matching a given regex. 1889 1890Example matches Y but not X 1891 (matcher = recordDecl(isExpansionInFileMatching("AST.*")) 1892 #include "ASTMatcher.h" 1893 class X {}; 1894ASTMatcher.h: 1895 class Y {}; 1896 1897Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 1898</pre></td></tr> 1899 1900 1901<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInMainFile0')"><a name="isExpansionInMainFile0Anchor">isExpansionInMainFile</a></td><td></td></tr> 1902<tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file. 1903 1904Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile()) 1905 #include <Y.h> 1906 class X {}; 1907Y.h: 1908 class Y {}; 1909 1910Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 1911</pre></td></tr> 1912 1913 1914<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInSystemHeader0')"><a name="isExpansionInSystemHeader0Anchor">isExpansionInSystemHeader</a></td><td></td></tr> 1915<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files. 1916 1917Example matches Y but not X 1918 (matcher = recordDecl(isExpansionInSystemHeader()) 1919 #include <SystemHeader.h> 1920 class X {}; 1921SystemHeader.h: 1922 class Y {}; 1923 1924Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 1925</pre></td></tr> 1926 1927 1928<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr> 1929<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added 1930by the compiler (eg. implicit defaultcopy constructors). 1931</pre></td></tr> 1932 1933 1934<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> 1935<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. 1936 1937Given 1938 class C { 1939 public: int a; 1940 protected: int b; 1941 private: int c; 1942 }; 1943fieldDecl(isPrivate()) 1944 matches 'int c;' 1945</pre></td></tr> 1946 1947 1948<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> 1949<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. 1950 1951Given 1952 class C { 1953 public: int a; 1954 protected: int b; 1955 private: int c; 1956 }; 1957fieldDecl(isProtected()) 1958 matches 'int b;' 1959</pre></td></tr> 1960 1961 1962<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> 1963<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. 1964 1965Given 1966 class C { 1967 public: int a; 1968 protected: int b; 1969 private: int c; 1970 }; 1971fieldDecl(isPublic()) 1972 matches 'int a;' 1973</pre></td></tr> 1974 1975 1976<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> 1977<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value. 1978 1979Example matches true (matcher = boolLiteral(equals(true))) 1980 true 1981 1982Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1983 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>> 1984</pre></td></tr> 1985 1986 1987<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr> 1988<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. 1989 1990Matches overloaded operator names specified in strings without the 1991"operator" prefix: e.g. "<<". 1992 1993Given: 1994 class A { int operator*(); }; 1995 const A &operator<<(const A &a, const A &b); 1996 A a; 1997 a << a; <-- This matches 1998 1999operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified 2000line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches 2001the declaration of A. 2002 2003Usable 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_1FunctionDecl.html">FunctionDecl</a>> 2004</pre></td></tr> 2005 2006 2007<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isConstexpr1')"><a name="isConstexpr1Anchor">isConstexpr</a></td><td></td></tr> 2008<tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations. 2009 2010Given: 2011 constexpr int foo = 42; 2012 constexpr int bar(); 2013varDecl(isConstexpr()) 2014 matches the declaration of foo. 2015functionDecl(isConstexpr()) 2016 matches the declaration of bar. 2017</pre></td></tr> 2018 2019 2020<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> 2021<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. 2022 2023Example matches A, va, fa 2024 class A {}; 2025 class B; Doesn't match, as it has no body. 2026 int va; 2027 extern int vb; Doesn't match, as it doesn't define the variable. 2028 void fa() {} 2029 void fb(); Doesn't match, as it has no body. 2030 2031Usable 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>> 2032</pre></td></tr> 2033 2034 2035<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDeleted0')"><a name="isDeleted0Anchor">isDeleted</a></td><td></td></tr> 2036<tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. 2037 2038Given: 2039 void Func(); 2040 void DeletedFunc() = delete; 2041functionDecl(isDeleted()) 2042 matches the declaration of DeletedFunc, but not Func. 2043</pre></td></tr> 2044 2045 2046<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> 2047<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or 2048static member variable template instantiations. 2049 2050Given 2051 template<typename T> void A(T t) { } 2052 template<> void A(int N) { } 2053functionDecl(isExplicitTemplateSpecialization()) 2054 matches the specialization A<int>(). 2055 2056Usable 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>> 2057</pre></td></tr> 2058 2059 2060<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> 2061<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations. 2062 2063Given: 2064 extern "C" void f() {} 2065 extern "C" { void g() {} } 2066 void h() {} 2067functionDecl(isExternC()) 2068 matches the declaration of f and g, but not the declaration h 2069</pre></td></tr> 2070 2071 2072<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isInline1')"><a name="isInline1Anchor">isInline</a></td><td></td></tr> 2073<tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with 2074the inline keyword. 2075 2076Given 2077 inline void f(); 2078 void g(); 2079 namespace n { 2080 inline namespace m {} 2081 } 2082functionDecl(isInline()) will match ::f(). 2083namespaceDecl(isInline()) will match n::m. 2084</pre></td></tr> 2085 2086 2087<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> 2088<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static 2089member variable template instantiations. 2090 2091Given 2092 template <typename T> class X {}; class A {}; X<A> x; 2093or 2094 template <typename T> class X {}; class A {}; template class X<A>; 2095recordDecl(hasName("::X"), isTemplateInstantiation()) 2096 matches the template instantiation of X<A>. 2097 2098But given 2099 template <typename T> class X {}; class A {}; 2100 template <> class X<A> {}; X<A> x; 2101recordDecl(hasName("::X"), isTemplateInstantiation()) 2102 does not match, as X<A> is an explicit template specialization. 2103 2104Usable 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>> 2105</pre></td></tr> 2106 2107 2108<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> 2109<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count. 2110 2111Given 2112 void f(int i) {} 2113 void g(int i, int j) {} 2114functionDecl(parameterCountIs(2)) 2115 matches g(int i, int j) {} 2116</pre></td></tr> 2117 2118 2119<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> 2120<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value. 2121 2122Example matches true (matcher = boolLiteral(equals(true))) 2123 true 2124 2125Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 2126 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>> 2127</pre></td></tr> 2128 2129 2130<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> 2131<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed 2132to '.'. 2133 2134Member calls on the implicit this pointer match as called with '->'. 2135 2136Given 2137 class Y { 2138 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 2139 int a; 2140 static int b; 2141 }; 2142memberExpr(isArrow()) 2143 matches this->x, x, y.x, a, this->b 2144</pre></td></tr> 2145 2146 2147<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> 2148<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. 2149 2150Supports specifying enclosing namespaces or classes by prefixing the name 2151with '<enclosing>::'. 2152Does not match typedefs of an underlying type with the given name. 2153 2154Example matches X (Name == "X") 2155 class X; 2156 2157Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") 2158 namespace a { namespace b { class X; } } 2159</pre></td></tr> 2160 2161 2162<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> 2163<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain 2164a substring matched by the given RegExp. 2165 2166Supports specifying enclosing namespaces or classes by 2167prefixing the name with '<enclosing>::'. Does not match typedefs 2168of an underlying type with the given name. 2169 2170Example matches X (regexp == "::X") 2171 class X; 2172 2173Example matches X (regexp is one of "::X", "^foo::.*X", among others) 2174 namespace foo { namespace bar { class X; } } 2175</pre></td></tr> 2176 2177 2178<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>></td><td class="name" onclick="toggle('isAnonymous0')"><a name="isAnonymous0Anchor">isAnonymous</a></td><td></td></tr> 2179<tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. 2180 2181Given 2182 namespace n { 2183 namespace {} #1 2184 } 2185namespaceDecl(isAnonymous()) will match #1 but not ::n. 2186</pre></td></tr> 2187 2188 2189<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>></td><td class="name" onclick="toggle('isInline0')"><a name="isInline0Anchor">isInline</a></td><td></td></tr> 2190<tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with 2191the inline keyword. 2192 2193Given 2194 inline void f(); 2195 void g(); 2196 namespace n { 2197 inline namespace m {} 2198 } 2199functionDecl(isInline()) will match ::f(). 2200namespaceDecl(isInline()) will match n::m. 2201</pre></td></tr> 2202 2203 2204<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('argumentCountIs2')"><a name="argumentCountIs2Anchor">argumentCountIs</a></td><td>unsigned N</td></tr> 2205<tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has 2206a specific number of arguments (including absent default arguments). 2207 2208Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 2209 void f(int x, int y); 2210 f(0, 0); 2211</pre></td></tr> 2212 2213 2214<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasKeywordSelector0')"><a name="hasKeywordSelector0Anchor">hasKeywordSelector</a></td><td></td></tr> 2215<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre></pre></td></tr> 2216 2217 2218<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasNullSelector0')"><a name="hasNullSelector0Anchor">hasNullSelector</a></td><td></td></tr> 2219<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector 2220 2221Matches only when the selector of the objCMessageExpr is NULL. This may 2222represent an error condition in the tree! 2223</pre></td></tr> 2224 2225 2226<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasSelector0')"><a name="hasSelector0Anchor">hasSelector</a></td><td>std::string BaseName</td></tr> 2227<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() 2228 2229 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); 2230 matches the outer message expr in the code below, but NOT the message 2231 invocation for self.bodyView. 2232 [self.bodyView loadHTMLString:html baseURL:NULL]; 2233</pre></td></tr> 2234 2235 2236<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasUnarySelector0')"><a name="hasUnarySelector0Anchor">hasUnarySelector</a></td><td></td></tr> 2237<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector 2238 2239 matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); 2240 matches self.bodyView in the code below, but NOT the outer message 2241 invocation of "loadHTMLString:baseURL:". 2242 [self.bodyView loadHTMLString:html baseURL:NULL]; 2243</pre></td></tr> 2244 2245 2246<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('matchesSelector0')"><a name="matchesSelector0Anchor">matchesSelector</a></td><td>std::string RegExp</td></tr> 2247<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains 2248a substring matched by the given RegExp. 2249 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message 2250 invocation for self.bodyView. 2251 [self.bodyView loadHTMLString:html baseURL:NULL]; 2252</pre></td></tr> 2253 2254 2255<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('numSelectorArgs0')"><a name="numSelectorArgs0Anchor">numSelectorArgs</a></td><td>unsigned N</td></tr> 2256<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments 2257 2258 matcher = objCMessageExpr(numSelectorArgs(1)); 2259 matches self.bodyView in the code below 2260 2261 matcher = objCMessageExpr(numSelectorArgs(2)); 2262 matches the invocation of "loadHTMLString:baseURL:" but not that 2263 of self.bodyView 2264 [self.bodyView loadHTMLString:html baseURL:NULL]; 2265</pre></td></tr> 2266 2267 2268<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> 2269<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. 2270 2271Given 2272 class Y { public: void x(); }; 2273 void z() { Y* y; y->x(); } 2274memberCallExpr(on(hasType(asString("class Y *")))) 2275 matches y->x() 2276</pre></td></tr> 2277 2278 2279<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> 2280<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. 2281 2282Matches a node if it equals the node previously bound to ID. 2283 2284Given 2285 class X { int a; int b; }; 2286recordDecl( 2287 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2288 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2289 matches the class X, as a and b have the same type. 2290 2291Note that when multiple matches are involved via forEach* matchers, 2292equalsBoundNodes acts as a filter. 2293For example: 2294compoundStmt( 2295 forEachDescendant(varDecl().bind("d")), 2296 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2297will trigger a match for each combination of variable declaration 2298and reference to that variable declaration within a compound statement. 2299</pre></td></tr> 2300 2301 2302<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> 2303<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to 2304the node, not hidden within a typedef. 2305 2306Given 2307 typedef const int const_int; 2308 const_int i; 2309 int *const j; 2310 int *volatile k; 2311 int m; 2312varDecl(hasType(hasLocalQualifiers())) matches only j and k. 2313i is const-qualified but the qualifier is not local. 2314</pre></td></tr> 2315 2316 2317<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> 2318<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that 2319include "top-level" const. 2320 2321Given 2322 void a(int); 2323 void b(int const); 2324 void c(const int); 2325 void d(const int*); 2326 void e(int const) {}; 2327functionDecl(hasAnyParameter(hasType(isConstQualified()))) 2328 matches "void b(int const)", "void c(const int)" and 2329 "void e(int const) {}". It does not match d as there 2330 is no top-level const on the parameter type "const int *". 2331</pre></td></tr> 2332 2333 2334<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> 2335<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. 2336 2337Given 2338 void a(int); 2339 void b(long); 2340 void c(double); 2341functionDecl(hasAnyParameter(hasType(isInteger()))) 2342matches "a(int)", "b(long)", but not "c(double)". 2343</pre></td></tr> 2344 2345 2346<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> 2347<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. 2348 2349Matches a node if it equals the node previously bound to ID. 2350 2351Given 2352 class X { int a; int b; }; 2353recordDecl( 2354 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2355 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2356 matches the class X, as a and b have the same type. 2357 2358Note that when multiple matches are involved via forEach* matchers, 2359equalsBoundNodes acts as a filter. 2360For example: 2361compoundStmt( 2362 forEachDescendant(varDecl().bind("d")), 2363 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2364will trigger a match for each combination of variable declaration 2365and reference to that variable declaration within a compound statement. 2366</pre></td></tr> 2367 2368 2369<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching1')"><a name="isExpansionInFileMatching1Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr> 2370<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is 2371partially matching a given regex. 2372 2373Example matches Y but not X 2374 (matcher = recordDecl(isExpansionInFileMatching("AST.*")) 2375 #include "ASTMatcher.h" 2376 class X {}; 2377ASTMatcher.h: 2378 class Y {}; 2379 2380Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 2381</pre></td></tr> 2382 2383 2384<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInMainFile1')"><a name="isExpansionInMainFile1Anchor">isExpansionInMainFile</a></td><td></td></tr> 2385<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. 2386 2387Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile()) 2388 #include <Y.h> 2389 class X {}; 2390Y.h: 2391 class Y {}; 2392 2393Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 2394</pre></td></tr> 2395 2396 2397<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInSystemHeader1')"><a name="isExpansionInSystemHeader1Anchor">isExpansionInSystemHeader</a></td><td></td></tr> 2398<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. 2399 2400Example matches Y but not X 2401 (matcher = recordDecl(isExpansionInSystemHeader()) 2402 #include <SystemHeader.h> 2403 class X {}; 2404SystemHeader.h: 2405 class Y {}; 2406 2407Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 2408</pre></td></tr> 2409 2410 2411<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> 2412<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. 2413 2414Example matches A, va, fa 2415 class A {}; 2416 class B; Doesn't match, as it has no body. 2417 int va; 2418 extern int vb; Doesn't match, as it doesn't define the variable. 2419 void fa() {} 2420 void fb(); Doesn't match, as it has no body. 2421 2422Usable 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>> 2423</pre></td></tr> 2424 2425 2426<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('equalsIntegralValue0')"><a name="equalsIntegralValue0Anchor">equalsIntegralValue</a></td><td>std::string Value</td></tr> 2427<tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. 2428 2429Note that 'Value' is a string as the template argument's value is 2430an arbitrary precision integer. 'Value' must be euqal to the canonical 2431representation of that integral value in base 10. 2432 2433Given 2434 template<int T> struct A {}; 2435 C<42> c; 2436classTemplateSpecializationDecl( 2437 hasAnyTemplateArgument(equalsIntegralValue("42"))) 2438 matches the implicit instantiation of C in C<42>. 2439</pre></td></tr> 2440 2441 2442<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('isIntegral0')"><a name="isIntegral0Anchor">isIntegral</a></td><td></td></tr> 2443<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. 2444 2445Given 2446 template<int T> struct A {}; 2447 C<42> c; 2448classTemplateSpecializationDecl( 2449 hasAnyTemplateArgument(isIntegral())) 2450 matches the implicit instantiation of C in C<42> 2451 with isIntegral() matching 42. 2452</pre></td></tr> 2453 2454 2455<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('templateArgumentCountIs1')"><a name="templateArgumentCountIs1Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr> 2456<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. 2457 2458Given 2459 template<typename T> struct C {}; 2460 C<int> c; 2461classTemplateSpecializationDecl(templateArgumentCountIs(1)) 2462 matches C<int>. 2463</pre></td></tr> 2464 2465 2466<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching2')"><a name="isExpansionInFileMatching2Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr> 2467<tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is 2468partially matching a given regex. 2469 2470Example matches Y but not X 2471 (matcher = recordDecl(isExpansionInFileMatching("AST.*")) 2472 #include "ASTMatcher.h" 2473 class X {}; 2474ASTMatcher.h: 2475 class Y {}; 2476 2477Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 2478</pre></td></tr> 2479 2480 2481<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpansionInMainFile2')"><a name="isExpansionInMainFile2Anchor">isExpansionInMainFile</a></td><td></td></tr> 2482<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. 2483 2484Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile()) 2485 #include <Y.h> 2486 class X {}; 2487Y.h: 2488 class Y {}; 2489 2490Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 2491</pre></td></tr> 2492 2493 2494<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpansionInSystemHeader2')"><a name="isExpansionInSystemHeader2Anchor">isExpansionInSystemHeader</a></td><td></td></tr> 2495<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. 2496 2497Example matches Y but not X 2498 (matcher = recordDecl(isExpansionInSystemHeader()) 2499 #include <SystemHeader.h> 2500 class X {}; 2501SystemHeader.h: 2502 class Y {}; 2503 2504Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 2505</pre></td></tr> 2506 2507 2508<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> 2509<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. 2510 2511Matches a node if it equals the node previously bound to ID. 2512 2513Given 2514 class X { int a; int b; }; 2515recordDecl( 2516 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2517 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2518 matches the class X, as a and b have the same type. 2519 2520Note that when multiple matches are involved via forEach* matchers, 2521equalsBoundNodes acts as a filter. 2522For example: 2523compoundStmt( 2524 forEachDescendant(varDecl().bind("d")), 2525 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2526will trigger a match for each combination of variable declaration 2527and reference to that variable declaration within a compound statement. 2528</pre></td></tr> 2529 2530 2531<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('voidType0')"><a name="voidType0Anchor">voidType</a></td><td></td></tr> 2532<tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. 2533 2534Given 2535 struct S { void func(); }; 2536functionDecl(returns(voidType())) 2537 matches "void func();" 2538</pre></td></tr> 2539 2540 2541<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> 2542<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. 2543 2544Given 2545 int x; 2546 int s = sizeof(x) + alignof(x) 2547unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) 2548 matches sizeof(x) 2549</pre></td></tr> 2550 2551 2552<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> 2553<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or 2554unary). 2555 2556Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 2557 !(a || b) 2558</pre></td></tr> 2559 2560 2561<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasGlobalStorage0')"><a name="hasGlobalStorage0Anchor">hasGlobalStorage</a></td><td></td></tr> 2562<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. 2563 2564Example matches y and z (matcher = varDecl(hasGlobalStorage()) 2565void f() { 2566 int x; 2567 static int y; 2568} 2569int z; 2570</pre></td></tr> 2571 2572 2573<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasLocalStorage0')"><a name="hasLocalStorage0Anchor">hasLocalStorage</a></td><td></td></tr> 2574<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a 2575non-static local variable. 2576 2577Example matches x (matcher = varDecl(hasLocalStorage()) 2578void f() { 2579 int x; 2580 static int y; 2581} 2582int z; 2583</pre></td></tr> 2584 2585 2586<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isConstexpr0')"><a name="isConstexpr0Anchor">isConstexpr</a></td><td></td></tr> 2587<tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations. 2588 2589Given: 2590 constexpr int foo = 42; 2591 constexpr int bar(); 2592varDecl(isConstexpr()) 2593 matches the declaration of foo. 2594functionDecl(isConstexpr()) 2595 matches the declaration of bar. 2596</pre></td></tr> 2597 2598 2599<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> 2600<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. 2601 2602Example matches A, va, fa 2603 class A {}; 2604 class B; Doesn't match, as it has no body. 2605 int va; 2606 extern int vb; Doesn't match, as it doesn't define the variable. 2607 void fa() {} 2608 void fb(); Doesn't match, as it has no body. 2609 2610Usable 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>> 2611</pre></td></tr> 2612 2613 2614<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isExceptionVariable0')"><a name="isExceptionVariable0Anchor">isExceptionVariable</a></td><td></td></tr> 2615<tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from 2616a C++ catch block, or an Objective-C statement. 2617 2618Example matches x (matcher = varDecl(isExceptionVariable()) 2619void f(int y) { 2620 try { 2621 } catch (int x) { 2622 } 2623} 2624</pre></td></tr> 2625 2626 2627<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> 2628<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or 2629static member variable template instantiations. 2630 2631Given 2632 template<typename T> void A(T t) { } 2633 template<> void A(int N) { } 2634functionDecl(isExplicitTemplateSpecialization()) 2635 matches the specialization A<int>(). 2636 2637Usable 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>> 2638</pre></td></tr> 2639 2640 2641<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> 2642<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static 2643member variable template instantiations. 2644 2645Given 2646 template <typename T> class X {}; class A {}; X<A> x; 2647or 2648 template <typename T> class X {}; class A {}; template class X<A>; 2649recordDecl(hasName("::X"), isTemplateInstantiation()) 2650 matches the template instantiation of X<A>. 2651 2652But given 2653 template <typename T> class X {}; class A {}; 2654 template <> class X<A> {}; X<A> x; 2655recordDecl(hasName("::X"), isTemplateInstantiation()) 2656 does not match, as X<A> is an explicit template specialization. 2657 2658Usable 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>> 2659</pre></td></tr> 2660 2661 2662<tr><td>Matcher<internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>></td><td class="name" onclick="toggle('isInstantiated0')"><a name="isInstantiated0Anchor">isInstantiated</a></td><td></td></tr> 2663<tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside 2664template instantiations. 2665 2666Given 2667 template<typename T> void A(T t) { T i; } 2668 A(0); 2669 A(0U); 2670functionDecl(isInstantiated()) 2671 matches 'A(int) {...};' and 'A(unsigned) {...}'. 2672</pre></td></tr> 2673 2674 2675<tr><td>Matcher<internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>></td><td class="name" onclick="toggle('isInTemplateInstantiation0')"><a name="isInTemplateInstantiation0Anchor">isInTemplateInstantiation</a></td><td></td></tr> 2676<tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. 2677 2678Given 2679 int j; 2680 template<typename T> void A(T t) { T i; j += 42;} 2681 A(0); 2682 A(0U); 2683declStmt(isInTemplateInstantiation()) 2684 matches 'int i;' and 'unsigned i'. 2685unless(stmt(isInTemplateInstantiation())) 2686 will NOT match j += 42; as it's shared between the template definition and 2687 instantiation. 2688</pre></td></tr> 2689 2690<!--END_NARROWING_MATCHERS --> 2691</table> 2692 2693<!-- ======================================================================= --> 2694<h2 id="traversal-matchers">AST Traversal Matchers</h2> 2695<!-- ======================================================================= --> 2696 2697<p>Traversal matchers specify the relationship to other nodes that are 2698reachable from the current node.</p> 2699 2700<p>Note that there are special traversal matchers (has, hasDescendant, forEach and 2701forEachDescendant) which work on all nodes and allow users to write more generic 2702match expressions.</p> 2703 2704<table> 2705<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 2706<!-- START_TRAVERSAL_MATCHERS --> 2707 2708<tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 2709<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. 2710 2711Unlike anyOf, eachOf will generate a match result for each 2712matching submatcher. 2713 2714For example, in: 2715 class A { int a; int b; }; 2716The matcher: 2717 recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), 2718 has(fieldDecl(hasName("b")).bind("v")))) 2719will generate two results binding "v", the first of which binds 2720the field declaration of a, the second the field declaration of 2721b. 2722 2723Usable as: Any Matcher 2724</pre></td></tr> 2725 2726 2727<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> 2728<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 2729provided matcher. 2730 2731Example matches X, A, B, C 2732 (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X"))))) 2733 class X {}; Matches X, because X::X is a class of name X inside X. 2734 class A { class X {}; }; 2735 class B { class C { class X {}; }; }; 2736 2737DescendantT must be an AST base type. 2738 2739As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for 2740each result that matches instead of only on the first one. 2741 2742Note: Recursively combined ForEachDescendant can cause many matches: 2743 recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl())))) 2744will match 10 times (plus injected class name matches) on: 2745 class A { class B { class C { class D { class E {}; }; }; }; }; 2746 2747Usable as: Any Matcher 2748</pre></td></tr> 2749 2750 2751<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> 2752<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the 2753provided matcher. 2754 2755Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X"))) 2756 class X {}; Matches X, because X::X is a class of name X inside X. 2757 class Y { class X {}; }; 2758 class Z { class Y { class X {}; }; }; Does not match Z. 2759 2760ChildT must be an AST base type. 2761 2762As opposed to 'has', 'forEach' will cause a match for each result that 2763matches instead of only on the first one. 2764 2765Usable as: Any Matcher 2766</pre></td></tr> 2767 2768 2769<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> 2770<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided 2771matcher. 2772 2773Given 2774void f() { if (true) { int x = 42; } } 2775void g() { for (;;) { int x = 43; } } 2776expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. 2777 2778Usable as: Any Matcher 2779</pre></td></tr> 2780 2781 2782<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> 2783<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 2784provided matcher. 2785 2786Example matches X, Y, Z 2787 (matcher = recordDecl(hasDescendant(recordDecl(hasName("X"))))) 2788 class X {}; Matches X, because X::X is a class of name X inside X. 2789 class Y { class X {}; }; 2790 class Z { class Y { class X {}; }; }; 2791 2792DescendantT must be an AST base type. 2793 2794Usable as: Any Matcher 2795</pre></td></tr> 2796 2797 2798<tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> 2799<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the 2800provided matcher. 2801 2802Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X"))) 2803 class X {}; Matches X, because X::X is a class of name X inside X. 2804 class Y { class X {}; }; 2805 class Z { class Y { class X {}; }; }; Does not match Z. 2806 2807ChildT must be an AST base type. 2808 2809Usable as: Any Matcher 2810</pre></td></tr> 2811 2812 2813<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> 2814<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided 2815matcher. 2816 2817Given 2818void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } 2819compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". 2820 2821Usable as: Any Matcher 2822</pre></td></tr> 2823 2824 2825<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> 2826<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. 2827 2828Given 2829 int i[5]; 2830 void f() { i[1] = 42; } 2831arraySubscriptExpression(hasBase(implicitCastExpr( 2832 hasSourceExpression(declRefExpr())))) 2833 matches i[1] with the declRefExpr() matching i 2834</pre></td></tr> 2835 2836 2837<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> 2838<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. 2839 2840Given 2841 int i[5]; 2842 void f() { i[1] = 42; } 2843arraySubscriptExpression(hasIndex(integerLiteral())) 2844 matches i[1] with the integerLiteral() matching 1 2845</pre></td></tr> 2846 2847 2848<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> 2849<tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element 2850type. 2851 2852Given 2853 struct A {}; 2854 A a[7]; 2855 int b[7]; 2856arrayType(hasElementType(builtinType())) 2857 matches "int b[7]" 2858 2859Usable 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>> 2860</pre></td></tr> 2861 2862 2863<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> 2864<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element 2865type. 2866 2867Given 2868 struct A {}; 2869 A a[7]; 2870 int b[7]; 2871arrayType(hasElementType(builtinType())) 2872 matches "int b[7]" 2873 2874Usable 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>> 2875</pre></td></tr> 2876 2877 2878<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> 2879<tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. 2880 2881Given 2882 _Atomic(int) i; 2883 _Atomic(float) f; 2884atomicType(hasValueType(isInteger())) 2885 matches "_Atomic(int) i" 2886 2887Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 2888</pre></td></tr> 2889 2890 2891<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> 2892<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. 2893 2894Given 2895 _Atomic(int) i; 2896 _Atomic(float) f; 2897atomicType(hasValueType(isInteger())) 2898 matches "_Atomic(int) i" 2899 2900Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 2901</pre></td></tr> 2902 2903 2904<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> 2905<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. 2906 2907Note: There is no TypeLoc for the deduced type and thus no 2908getDeducedLoc() matcher. 2909 2910Given 2911 auto a = 1; 2912 auto b = 2.0; 2913autoType(hasDeducedType(isInteger())) 2914 matches "auto a" 2915 2916Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> 2917</pre></td></tr> 2918 2919 2920<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> 2921<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a 2922binary operator matches. 2923</pre></td></tr> 2924 2925 2926<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> 2927<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. 2928 2929Example matches a (matcher = binaryOperator(hasLHS())) 2930 a || b 2931</pre></td></tr> 2932 2933 2934<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> 2935<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. 2936 2937Example matches b (matcher = binaryOperator(hasRHS())) 2938 a || b 2939</pre></td></tr> 2940 2941 2942<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> 2943<tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the 2944pointee matches a given matcher. 2945 2946Given 2947 int *a; 2948 int const *b; 2949 float const *f; 2950pointerType(pointee(isConstQualified(), isInteger())) 2951 matches "int const *b" 2952 2953Usable 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>>, 2954 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>> 2955</pre></td></tr> 2956 2957 2958<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> 2959<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the 2960pointee matches a given matcher. 2961 2962Given 2963 int *a; 2964 int const *b; 2965 float const *f; 2966pointerType(pointee(isConstQualified(), isInteger())) 2967 matches "int const *b" 2968 2969Usable 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>>, 2970 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>> 2971</pre></td></tr> 2972 2973 2974<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> 2975<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call 2976expression. 2977 2978Given 2979 void x(int, int, int) { int y; x(1, y, 42); } 2980callExpr(hasAnyArgument(declRefExpr())) 2981 matches x(1, y, 42) 2982with hasAnyArgument(...) 2983 matching y 2984 2985FIXME: Currently this will ignore parentheses and implicit casts on 2986the argument before applying the inner matcher. We'll want to remove 2987this to allow for greater control by the user once ignoreImplicit() 2988has been implemented. 2989</pre></td></tr> 2990 2991 2992<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> 2993<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor 2994call expression. 2995 2996Example matches y in x(y) 2997 (matcher = callExpr(hasArgument(0, declRefExpr()))) 2998 void x(int) { int y; x(y); } 2999</pre></td></tr> 3000 3001 3002<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasDeclaration12')"><a name="hasDeclaration12Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3003<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node 3004matches the given matcher. 3005 3006The associated declaration is: 3007- for type nodes, the declaration of the underlying type 3008- for CallExpr, the declaration of the callee 3009- for MemberExpr, the declaration of the referenced member 3010- for CXXConstructExpr, the declaration of the constructor 3011 3012Also usable as Matcher<T> for any T supporting the getDecl() member 3013function. e.g. various subtypes of clang::Type and various expressions. 3014 3015Usable as: 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>>, 3016 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, 3017 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 3018 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, 3019 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, 3020 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 3021</pre></td></tr> 3022 3023 3024<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> 3025<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. 3026 3027Given 3028 class A { A() : i(42), j(42) {} int i; int j; }; 3029constructorDecl(forEachConstructorInitializer(forField(decl().bind("x")))) 3030 will trigger two matches, binding for 'i' and 'j' respectively. 3031</pre></td></tr> 3032 3033 3034<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> 3035<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. 3036 3037Given 3038 struct Foo { 3039 Foo() : foo_(1) { } 3040 int foo_; 3041 }; 3042recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything())))) 3043 record matches Foo, hasAnyConstructorInitializer matches foo_(1) 3044</pre></td></tr> 3045 3046 3047<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> 3048<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. 3049 3050Given 3051 struct Foo { 3052 Foo() : foo_(1) { } 3053 int foo_; 3054 }; 3055recordDecl(has(constructorDecl(hasAnyConstructorInitializer( 3056 forField(hasName("foo_")))))) 3057 matches Foo 3058with forField matching foo_ 3059</pre></td></tr> 3060 3061 3062<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> 3063<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. 3064 3065Given 3066 struct Foo { 3067 Foo() : foo_(1) { } 3068 int foo_; 3069 }; 3070recordDecl(has(constructorDecl(hasAnyConstructorInitializer( 3071 withInitializer(integerLiteral(equals(1))))))) 3072 matches Foo 3073with withInitializer matching (1) 3074</pre></td></tr> 3075 3076 3077<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasBody3')"><a name="hasBody3Anchor">hasBody</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 3078<tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', or 'do while' statement that has 3079a given body. 3080 3081Given 3082 for (;;) {} 3083hasBody(compoundStmt()) 3084 matches 'for (;;) {}' 3085with compoundStmt() 3086 matching '{}' 3087</pre></td></tr> 3088 3089 3090<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasLoopVariable0')"><a name="hasLoopVariable0Anchor">hasLoopVariable</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>> InnerMatcher</td></tr> 3091<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. 3092 3093Example: 3094 forStmt(hasLoopVariable(anything())) 3095matches 'int x' in 3096 for (int x : a) { } 3097</pre></td></tr> 3098 3099 3100<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasRangeInit0')"><a name="hasRangeInit0Anchor">hasRangeInit</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 3101<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. 3102 3103Example: 3104 forStmt(hasRangeInit(anything())) 3105matches 'a' in 3106 for (int x : a) { } 3107</pre></td></tr> 3108 3109 3110<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> 3111<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> 3112 3113 3114<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> 3115<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. 3116 3117Example matches y.x() 3118 (matcher = memberCallExpr(on(hasType(recordDecl(hasName("Y")))))) 3119 class Y { public: void x(); }; 3120 void z() { Y y; y.x(); }", 3121 3122FIXME: Overload to allow directly matching types? 3123</pre></td></tr> 3124 3125 3126<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> 3127<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. 3128</pre></td></tr> 3129 3130 3131<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>></td><td class="name" onclick="toggle('thisPointerType0')"><a name="thisPointerType0Anchor">thisPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 3132<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified 3133matcher, or is a pointer to a type that matches the InnerMatcher. 3134</pre></td></tr> 3135 3136 3137<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> 3138<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration 3139belongs to. 3140 3141FIXME: Generalize this for other kinds of declarations. 3142FIXME: What other kind of declarations would we need to generalize 3143this to? 3144 3145Example matches A() in the last line 3146 (matcher = constructExpr(hasDeclaration(methodDecl( 3147 ofClass(hasName("A")))))) 3148 class A { 3149 public: 3150 A(); 3151 }; 3152 A a = A(); 3153</pre></td></tr> 3154 3155 3156<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> 3157<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. 3158 3159Given: 3160 class A { void func(); }; 3161 class B { void member(); }; 3162 3163recordDecl(hasMethod(hasName("func"))) matches the declaration of A 3164but not B. 3165</pre></td></tr> 3166 3167 3168<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> 3169<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from 3170a class matching Base. 3171 3172Note that a class is not considered to be derived from itself. 3173 3174Example matches Y, Z, C (Base == hasName("X")) 3175 class X; 3176 class Y : public X {}; directly derived 3177 class Z : public Y {}; indirectly derived 3178 typedef X A; 3179 typedef A B; 3180 class C : public B {}; derived from a typedef of X 3181 3182In the following example, Bar matches isDerivedFrom(hasName("X")): 3183 class Foo; 3184 typedef Foo X; 3185 class Bar : public Foo {}; derived from a type that X is a typedef of 3186</pre></td></tr> 3187 3188 3189<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> 3190<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly 3191match Base. 3192</pre></td></tr> 3193 3194 3195<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> 3196<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the 3197given matcher. 3198 3199Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x"))))) 3200 class Y { public: void x(); }; 3201 void z() { Y y; y.x(); } 3202</pre></td></tr> 3203 3204 3205<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('callee0')"><a name="callee0Anchor">callee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 3206<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. 3207 3208Given 3209 class Y { void x() { this->x(); x(); Y y; y.x(); } }; 3210 void f() { f(); } 3211callExpr(callee(expr())) 3212 matches this->x(), x(), y.x(), f() 3213with callee(...) 3214 matching this->x, x, y.x, f respectively 3215 3216Note: Callee cannot take the more general internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> 3217because this introduces ambiguous overloads with calls to Callee taking a 3218internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely 3219implemented in terms of implicit casts. 3220</pre></td></tr> 3221 3222 3223<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> 3224<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call 3225expression. 3226 3227Given 3228 void x(int, int, int) { int y; x(1, y, 42); } 3229callExpr(hasAnyArgument(declRefExpr())) 3230 matches x(1, y, 42) 3231with hasAnyArgument(...) 3232 matching y 3233 3234FIXME: Currently this will ignore parentheses and implicit casts on 3235the argument before applying the inner matcher. We'll want to remove 3236this to allow for greater control by the user once ignoreImplicit() 3237has been implemented. 3238</pre></td></tr> 3239 3240 3241<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> 3242<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor 3243call expression. 3244 3245Example matches y in x(y) 3246 (matcher = callExpr(hasArgument(0, declRefExpr()))) 3247 void x(int) { int y; x(y); } 3248</pre></td></tr> 3249 3250 3251<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('hasDeclaration13')"><a name="hasDeclaration13Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3252<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node 3253matches the given matcher. 3254 3255The associated declaration is: 3256- for type nodes, the declaration of the underlying type 3257- for CallExpr, the declaration of the callee 3258- for MemberExpr, the declaration of the referenced member 3259- for CXXConstructExpr, the declaration of the constructor 3260 3261Also usable as Matcher<T> for any T supporting the getDecl() member 3262function. e.g. various subtypes of clang::Type and various expressions. 3263 3264Usable as: 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>>, 3265 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, 3266 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 3267 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, 3268 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, 3269 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 3270</pre></td></tr> 3271 3272 3273<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> 3274<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range 3275extension, matches the constant given in the statement. 3276 3277Given 3278 switch (1) { case 1: case 1+1: case 3 ... 4: ; } 3279caseStmt(hasCaseConstant(integerLiteral())) 3280 matches "case 1:" 3281</pre></td></tr> 3282 3283 3284<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> 3285<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher. 3286 3287Example: matches "a string" (matcher = 3288 hasSourceExpression(constructExpr())) 3289class URL { URL(string); }; 3290URL url = "a string"; 3291</pre></td></tr> 3292 3293 3294<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> 3295<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one 3296TemplateArgument matching the given InnerMatcher. 3297 3298Given 3299 template<typename T> class A {}; 3300 template<> class A<double> {}; 3301 A<int> a; 3302classTemplateSpecializationDecl(hasAnyTemplateArgument( 3303 refersToType(asString("int")))) 3304 matches the specialization A<int> 3305</pre></td></tr> 3306 3307 3308<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> 3309<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument 3310matches the given InnerMatcher. 3311 3312Given 3313 template<typename T, typename U> class A {}; 3314 A<bool, int> b; 3315 A<int, bool> c; 3316classTemplateSpecializationDecl(hasTemplateArgument( 3317 1, refersToType(asString("int")))) 3318 matches the specialization A<bool, int> 3319</pre></td></tr> 3320 3321 3322<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> 3323<tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element 3324type. 3325 3326Given 3327 struct A {}; 3328 A a[7]; 3329 int b[7]; 3330arrayType(hasElementType(builtinType())) 3331 matches "int b[7]" 3332 3333Usable 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>> 3334</pre></td></tr> 3335 3336 3337<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> 3338<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element 3339type. 3340 3341Given 3342 struct A {}; 3343 A a[7]; 3344 int b[7]; 3345arrayType(hasElementType(builtinType())) 3346 matches "int b[7]" 3347 3348Usable 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>> 3349</pre></td></tr> 3350 3351 3352<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> 3353<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches 3354a given matcher. 3355 3356Given 3357 { {}; 1+2; } 3358hasAnySubstatement(compoundStmt()) 3359 matches '{ {}; 1+2; }' 3360with compoundStmt() 3361 matching '{}' 3362</pre></td></tr> 3363 3364 3365<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> 3366<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, 3367or conditional operator. 3368 3369Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3370 if (true) {} 3371</pre></td></tr> 3372 3373 3374<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> 3375<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator. 3376 3377Example matches b 3378 condition ? a : b 3379</pre></td></tr> 3380 3381 3382<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> 3383<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. 3384 3385Example matches a 3386 condition ? a : b 3387</pre></td></tr> 3388 3389 3390<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>></td><td class="name" onclick="toggle('hasDeclaration11')"><a name="hasDeclaration11Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3391<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node 3392matches the given matcher. 3393 3394The associated declaration is: 3395- for type nodes, the declaration of the underlying type 3396- for CallExpr, the declaration of the callee 3397- for MemberExpr, the declaration of the referenced member 3398- for CXXConstructExpr, the declaration of the constructor 3399 3400Also usable as Matcher<T> for any T supporting the getDecl() member 3401function. e.g. various subtypes of clang::Type and various expressions. 3402 3403Usable as: 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>>, 3404 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, 3405 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 3406 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, 3407 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, 3408 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 3409</pre></td></tr> 3410 3411 3412<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> 3413<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a 3414specific using shadow declaration. 3415 3416Given 3417 namespace a { void f() {} } 3418 using a::f; 3419 void g() { 3420 f(); Matches this .. 3421 a::f(); .. but not this. 3422 } 3423declRefExpr(throughUsingDecl(anything())) 3424 matches f() 3425</pre></td></tr> 3426 3427 3428<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> 3429<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the 3430specified matcher. 3431 3432Example matches x in if(x) 3433 (matcher = declRefExpr(to(varDecl(hasName("x"))))) 3434 bool x; 3435 if (x) {} 3436</pre></td></tr> 3437 3438 3439<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> 3440<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. 3441 3442Note that this does not work for global declarations because the AST 3443breaks up multiple-declaration DeclStmt's into multiple single-declaration 3444DeclStmt's. 3445Example: Given non-global declarations 3446 int a, b = 0; 3447 int c; 3448 int d = 2, e; 3449declStmt(containsDeclaration( 3450 0, varDecl(hasInitializer(anything())))) 3451 matches only 'int d = 2, e;', and 3452declStmt(containsDeclaration(1, varDecl())) 3453 matches 'int a, b = 0' as well as 'int d = 2, e;' 3454 but 'int c;' is not matched. 3455</pre></td></tr> 3456 3457 3458<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> 3459<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. 3460 3461Given 3462 int a, b; 3463 int c; 3464declStmt(hasSingleDecl(anything())) 3465 matches 'int c;' but not 'int a, b;'. 3466</pre></td></tr> 3467 3468 3469<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> 3470<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches 3471the inner matcher. 3472 3473Given 3474 int x; 3475declaratorDecl(hasTypeLoc(loc(asString("int")))) 3476 matches int x 3477</pre></td></tr> 3478 3479 3480<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> 3481<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a 3482Decl, matches InnerMatcher. 3483 3484Given 3485 namespace N { 3486 namespace M { 3487 class D {}; 3488 } 3489 } 3490 3491recordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the 3492declaration of class D. 3493</pre></td></tr> 3494 3495 3496<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> 3497<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has 3498a given body. 3499 3500Given 3501 for (;;) {} 3502hasBody(compoundStmt()) 3503 matches 'for (;;) {}' 3504with compoundStmt() 3505 matching '{}' 3506</pre></td></tr> 3507 3508 3509<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> 3510<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, 3511or conditional operator. 3512 3513Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3514 if (true) {} 3515</pre></td></tr> 3516 3517 3518<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> 3519<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, 3520matches InnerMatcher if the qualifier exists. 3521 3522Given 3523 namespace N { 3524 namespace M { 3525 class D {}; 3526 } 3527 } 3528 N::M::D d; 3529 3530elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) 3531matches the type of the variable declaration of d. 3532</pre></td></tr> 3533 3534 3535<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> 3536<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. 3537 3538Given 3539 namespace N { 3540 namespace M { 3541 class D {}; 3542 } 3543 } 3544 N::M::D d; 3545 3546elaboratedType(namesType(recordType( 3547hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable 3548declaration of d. 3549</pre></td></tr> 3550 3551 3552<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>></td><td class="name" onclick="toggle('hasDeclaration10')"><a name="hasDeclaration10Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3553<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node 3554matches the given matcher. 3555 3556The associated declaration is: 3557- for type nodes, the declaration of the underlying type 3558- for CallExpr, the declaration of the callee 3559- for MemberExpr, the declaration of the referenced member 3560- for CXXConstructExpr, the declaration of the constructor 3561 3562Also usable as Matcher<T> for any T supporting the getDecl() member 3563function. e.g. various subtypes of clang::Type and various expressions. 3564 3565Usable as: 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>>, 3566 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, 3567 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 3568 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, 3569 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, 3570 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 3571</pre></td></tr> 3572 3573 3574<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> 3575<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. 3576 3577(Note: Clang's AST refers to other conversions as "casts" too, and calls 3578actual casts "explicit" casts.) 3579</pre></td></tr> 3580 3581 3582<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> 3583<tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value 3584declaration's type. 3585 3586In case of a value declaration (for example a variable declaration), 3587this resolves one layer of indirection. For example, in the value 3588declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, 3589while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration 3590of x." 3591 3592Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 3593 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 3594 class X {}; 3595 void y(X &x) { x; X z; } 3596 3597Usable 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>> 3598</pre></td></tr> 3599 3600 3601<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('hasType0')"><a name="hasType0Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 3602<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type 3603matcher. 3604 3605Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 3606 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 3607 class X {}; 3608 void y(X &x) { x; X z; } 3609</pre></td></tr> 3610 3611 3612<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> 3613<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts 3614are stripped off. 3615 3616Parentheses and explicit casts are not discarded. 3617Given 3618 int arr[5]; 3619 int a = 0; 3620 char b = 0; 3621 const int c = a; 3622 int *d = arr; 3623 long e = (long) 0l; 3624The matchers 3625 varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) 3626 varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) 3627would match the declarations for a, b, c, and d, but not e. 3628While 3629 varDecl(hasInitializer(integerLiteral())) 3630 varDecl(hasInitializer(declRefExpr())) 3631only match the declarations for b, c, and d. 3632</pre></td></tr> 3633 3634 3635<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> 3636<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and 3637casts are stripped off. 3638 3639Implicit and non-C Style casts are also discarded. 3640Given 3641 int a = 0; 3642 char b = (0); 3643 void* c = reinterpret_cast<char*>(0); 3644 char d = char(0); 3645The matcher 3646 varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) 3647would match the declarations for a, b, c, and d. 3648while 3649 varDecl(hasInitializer(integerLiteral())) 3650only match the declaration for a. 3651</pre></td></tr> 3652 3653 3654<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> 3655<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and 3656parentheses are stripped off. 3657 3658Explicit casts are not discarded. 3659Given 3660 int arr[5]; 3661 int a = 0; 3662 char b = (0); 3663 const int c = a; 3664 int *d = (arr); 3665 long e = ((long) 0l); 3666The matchers 3667 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) 3668 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) 3669would match the declarations for a, b, c, and d, but not e. 3670while 3671 varDecl(hasInitializer(integerLiteral())) 3672 varDecl(hasInitializer(declRefExpr())) 3673would only match the declaration for a. 3674</pre></td></tr> 3675 3676 3677<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> 3678<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has 3679a given body. 3680 3681Given 3682 for (;;) {} 3683hasBody(compoundStmt()) 3684 matches 'for (;;) {}' 3685with compoundStmt() 3686 matching '{}' 3687</pre></td></tr> 3688 3689 3690<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> 3691<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, 3692or conditional operator. 3693 3694Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3695 if (true) {} 3696</pre></td></tr> 3697 3698 3699<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> 3700<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. 3701 3702Example: 3703 forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) 3704matches '++x' in 3705 for (x; x < N; ++x) { } 3706</pre></td></tr> 3707 3708 3709<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> 3710<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. 3711 3712Example: 3713 forStmt(hasLoopInit(declStmt())) 3714matches 'int x = 0' in 3715 for (int x = 0; x < N; ++x) { } 3716</pre></td></tr> 3717 3718 3719<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> 3720<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration. 3721 3722Does not match the 'this' parameter of a method. 3723 3724Given 3725 class X { void f(int x, int y, int z) {} }; 3726methodDecl(hasAnyParameter(hasName("y"))) 3727 matches f(int x, int y, int z) {} 3728with hasAnyParameter(...) 3729 matching int y 3730</pre></td></tr> 3731 3732 3733<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> 3734<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration. 3735 3736Given 3737 class X { void f(int x) {} }; 3738methodDecl(hasParameter(0, hasType(varDecl()))) 3739 matches f(int x) {} 3740with hasParameter(...) 3741 matching int x 3742</pre></td></tr> 3743 3744 3745<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> 3746<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. 3747 3748Given: 3749 class X { int f() { return 1; } }; 3750methodDecl(returns(asString("int"))) 3751 matches int f() { return 1; } 3752</pre></td></tr> 3753 3754 3755<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> 3756<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, 3757or conditional operator. 3758 3759Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3760 if (true) {} 3761</pre></td></tr> 3762 3763 3764<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> 3765<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. 3766 3767Given 3768 if (A* a = GetAPointer()) {} 3769hasConditionVariableStatement(...) 3770 matches 'A* a = GetAPointer()'. 3771</pre></td></tr> 3772 3773 3774<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('hasElse0')"><a name="hasElse0Anchor">hasElse</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 3775<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. 3776 3777Examples matches the if statement 3778 (matcher = ifStmt(hasElse(boolLiteral(equals(true))))) 3779 if (false) false; else true; 3780</pre></td></tr> 3781 3782 3783<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('hasThen0')"><a name="hasThen0Anchor">hasThen</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 3784<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. 3785 3786Examples matches the if statement 3787 (matcher = ifStmt(hasThen(boolLiteral(equals(true))))) 3788 if (false) true; else false; 3789</pre></td></tr> 3790 3791 3792<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> 3793<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given 3794matcher. 3795 3796FIXME: Unit test this matcher 3797</pre></td></tr> 3798 3799 3800<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>></td><td class="name" onclick="toggle('hasDeclaration9')"><a name="hasDeclaration9Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3801<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node 3802matches the given matcher. 3803 3804The associated declaration is: 3805- for type nodes, the declaration of the underlying type 3806- for CallExpr, the declaration of the callee 3807- for MemberExpr, the declaration of the referenced member 3808- for CXXConstructExpr, the declaration of the constructor 3809 3810Also usable as Matcher<T> for any T supporting the getDecl() member 3811function. e.g. various subtypes of clang::Type and various expressions. 3812 3813Usable as: 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>>, 3814 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, 3815 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 3816 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, 3817 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, 3818 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 3819</pre></td></tr> 3820 3821 3822<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>></td><td class="name" onclick="toggle('hasDeclaration8')"><a name="hasDeclaration8Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3823<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node 3824matches the given matcher. 3825 3826The associated declaration is: 3827- for type nodes, the declaration of the underlying type 3828- for CallExpr, the declaration of the callee 3829- for MemberExpr, the declaration of the referenced member 3830- for CXXConstructExpr, the declaration of the constructor 3831 3832Also usable as Matcher<T> for any T supporting the getDecl() member 3833function. e.g. various subtypes of clang::Type and various expressions. 3834 3835Usable as: 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>>, 3836 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, 3837 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 3838 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, 3839 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, 3840 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 3841</pre></td></tr> 3842 3843 3844<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>></td><td class="name" onclick="toggle('hasDeclaration7')"><a name="hasDeclaration7Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 3845<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node 3846matches the given matcher. 3847 3848The associated declaration is: 3849- for type nodes, the declaration of the underlying type 3850- for CallExpr, the declaration of the callee 3851- for MemberExpr, the declaration of the referenced member 3852- for CXXConstructExpr, the declaration of the constructor 3853 3854Also usable as Matcher<T> for any T supporting the getDecl() member 3855function. e.g. various subtypes of clang::Type and various expressions. 3856 3857Usable as: 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>>, 3858 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, 3859 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 3860 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, 3861 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, 3862 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 3863</pre></td></tr> 3864 3865 3866<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> 3867<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is 3868matched by a given matcher. 3869 3870Given 3871 struct X { int m; }; 3872 void f(X x) { x.m; m; } 3873memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X"))))))) 3874 matches "x.m" and "m" 3875with hasObjectExpression(...) 3876 matching "x" and the implicit object expression of "m" which has type X*. 3877</pre></td></tr> 3878 3879 3880<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> 3881<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a 3882given matcher. 3883 3884Given 3885 struct { int first, second; } first, second; 3886 int i(second.first); 3887 int j(first.second); 3888memberExpr(member(hasName("first"))) 3889 matches second.first 3890 but not first.second (because the member name there is "second"). 3891</pre></td></tr> 3892 3893 3894<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> 3895<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the 3896pointee matches a given matcher. 3897 3898Given 3899 int *a; 3900 int const *b; 3901 float const *f; 3902pointerType(pointee(isConstQualified(), isInteger())) 3903 matches "int const *b" 3904 3905Usable 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>>, 3906 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>> 3907</pre></td></tr> 3908 3909 3910<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> 3911<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the 3912pointee matches a given matcher. 3913 3914Given 3915 int *a; 3916 int const *b; 3917 float const *f; 3918pointerType(pointee(isConstQualified(), isInteger())) 3919 matches "int const *b" 3920 3921Usable 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>>, 3922 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>> 3923</pre></td></tr> 3924 3925 3926<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> 3927<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. 3928 3929Given 3930 struct A { struct B { struct C {}; }; }; 3931 A::B::C c; 3932nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) 3933 matches "A::" 3934</pre></td></tr> 3935 3936 3937<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> 3938<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the 3939given TypeLoc. 3940 3941Given 3942 struct A { struct B { struct C {}; }; }; 3943 A::B::C c; 3944nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( 3945 hasDeclaration(recordDecl(hasName("A"))))))) 3946 matches "A::" 3947</pre></td></tr> 3948 3949 3950<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> 3951<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. 3952 3953Given 3954 struct A { struct B { struct C {}; }; }; 3955 A::B::C c; 3956nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and 3957 matches "A::" 3958</pre></td></tr> 3959 3960 3961<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> 3962<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the 3963given namespace matcher. 3964 3965Given 3966 namespace ns { struct A {}; } 3967 ns::A a; 3968nestedNameSpecifier(specifiesNamespace(hasName("ns"))) 3969 matches "ns::" 3970</pre></td></tr> 3971 3972 3973<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> 3974<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the 3975given QualType matcher without qualifiers. 3976 3977Given 3978 struct A { struct B { struct C {}; }; }; 3979 A::B::C c; 3980nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A"))))) 3981 matches "A::" 3982</pre></td></tr> 3983 3984 3985<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasArgument2')"><a name="hasArgument2Anchor">hasArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 3986<tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor 3987call expression. 3988 3989Example matches y in x(y) 3990 (matcher = callExpr(hasArgument(0, declRefExpr()))) 3991 void x(int) { int y; x(y); } 3992</pre></td></tr> 3993 3994 3995<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasReceiverType0')"><a name="hasReceiverType0Anchor">hasReceiverType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 3996<tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. 3997 3998Example 3999matcher = objCMessageExpr(hasRecieverType(asString("UIWebView *"))); 4000matches the [webView ...] message invocation. 4001 NSString *webViewJavaScript = ... 4002 UIWebView *webView = ... 4003 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; 4004</pre></td></tr> 4005 4006 4007<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> 4008<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. 4009 4010Given 4011 int (*ptr_to_array)[4]; 4012 int (*ptr_to_func)(int); 4013 4014varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches 4015ptr_to_func but not ptr_to_array. 4016 4017Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> 4018</pre></td></tr> 4019 4020 4021<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> 4022<tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the 4023pointee matches a given matcher. 4024 4025Given 4026 int *a; 4027 int const *b; 4028 float const *f; 4029pointerType(pointee(isConstQualified(), isInteger())) 4030 matches "int const *b" 4031 4032Usable 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>>, 4033 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>> 4034</pre></td></tr> 4035 4036 4037<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> 4038<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the 4039pointee matches a given matcher. 4040 4041Given 4042 int *a; 4043 int const *b; 4044 float const *f; 4045pointerType(pointee(isConstQualified(), isInteger())) 4046 matches "int const *b" 4047 4048Usable 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>>, 4049 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>> 4050</pre></td></tr> 4051 4052 4053<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> 4054<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. 4055 4056Given: 4057 typedef int &int_ref; 4058 int a; 4059 int_ref b = a; 4060 4061varDecl(hasType(qualType(referenceType()))))) will not match the 4062declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. 4063</pre></td></tr> 4064 4065 4066<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasDeclaration6')"><a name="hasDeclaration6Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4067<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node 4068matches the given matcher. 4069 4070The associated declaration is: 4071- for type nodes, the declaration of the underlying type 4072- for CallExpr, the declaration of the callee 4073- for MemberExpr, the declaration of the referenced member 4074- for CXXConstructExpr, the declaration of the constructor 4075 4076Also usable as Matcher<T> for any T supporting the getDecl() member 4077function. e.g. various subtypes of clang::Type and various expressions. 4078 4079Usable as: 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>>, 4080 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, 4081 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 4082 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, 4083 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, 4084 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4085</pre></td></tr> 4086 4087 4088<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> 4089<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. 4090</pre></td></tr> 4091 4092 4093<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('pointsTo0')"><a name="pointsTo0Anchor">pointsTo</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 4094<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type 4095matches the specified matcher. 4096 4097Example matches y->x() 4098 (matcher = memberCallExpr(on(hasType(pointsTo 4099 recordDecl(hasName("Y"))))))) 4100 class Y { public: void x(); }; 4101 void z() { Y *y; y->x(); } 4102</pre></td></tr> 4103 4104 4105<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> 4106<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. 4107</pre></td></tr> 4108 4109 4110<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('references0')"><a name="references0Anchor">references</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 4111<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced 4112type matches the specified matcher. 4113 4114Example matches X &x and const X &y 4115 (matcher = varDecl(hasType(references(recordDecl(hasName("X")))))) 4116 class X { 4117 void a(X b) { 4118 X &x = b; 4119 const X &y = b; 4120 } 4121 }; 4122</pre></td></tr> 4123 4124 4125<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>></td><td class="name" onclick="toggle('hasDeclaration5')"><a name="hasDeclaration5Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4126<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node 4127matches the given matcher. 4128 4129The associated declaration is: 4130- for type nodes, the declaration of the underlying type 4131- for CallExpr, the declaration of the callee 4132- for MemberExpr, the declaration of the referenced member 4133- for CXXConstructExpr, the declaration of the constructor 4134 4135Also usable as Matcher<T> for any T supporting the getDecl() member 4136function. e.g. various subtypes of clang::Type and various expressions. 4137 4138Usable as: 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>>, 4139 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, 4140 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 4141 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, 4142 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, 4143 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4144</pre></td></tr> 4145 4146 4147<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> 4148<tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the 4149pointee matches a given matcher. 4150 4151Given 4152 int *a; 4153 int const *b; 4154 float const *f; 4155pointerType(pointee(isConstQualified(), isInteger())) 4156 matches "int const *b" 4157 4158Usable 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>>, 4159 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>> 4160</pre></td></tr> 4161 4162 4163<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> 4164<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the 4165pointee matches a given matcher. 4166 4167Given 4168 int *a; 4169 int const *b; 4170 float const *f; 4171pointerType(pointee(isConstQualified(), isInteger())) 4172 matches "int const *b" 4173 4174Usable 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>>, 4175 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>> 4176</pre></td></tr> 4177 4178 4179<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> 4180<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 4181alignof. 4182</pre></td></tr> 4183 4184 4185<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> 4186<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 4187sizeof. 4188</pre></td></tr> 4189 4190 4191<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> 4192<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch 4193statement. This matcher may produce multiple matches. 4194 4195Given 4196 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } 4197switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") 4198 matches four times, with "c" binding each of "case 1:", "case 2:", 4199"case 3:" and "case 4:", and "s" respectively binding "switch (1)", 4200"switch (1)", "switch (2)" and "switch (2)". 4201</pre></td></tr> 4202 4203 4204<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>></td><td class="name" onclick="toggle('hasDeclaration4')"><a name="hasDeclaration4Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4205<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node 4206matches the given matcher. 4207 4208The associated declaration is: 4209- for type nodes, the declaration of the underlying type 4210- for CallExpr, the declaration of the callee 4211- for MemberExpr, the declaration of the referenced member 4212- for CXXConstructExpr, the declaration of the constructor 4213 4214Also usable as Matcher<T> for any T supporting the getDecl() member 4215function. e.g. various subtypes of clang::Type and various expressions. 4216 4217Usable as: 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>>, 4218 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, 4219 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 4220 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, 4221 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, 4222 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4223</pre></td></tr> 4224 4225 4226<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('isExpr0')"><a name="isExpr0Anchor">isExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 4227<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. 4228 4229Given 4230 template<typename T> struct A {}; 4231 struct B { B* next; }; 4232 A<&B::next> a; 4233templateSpecializationType(hasAnyTemplateArgument( 4234 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) 4235 matches the specialization A<&B::next> with fieldDecl(...) matching 4236 B::next 4237</pre></td></tr> 4238 4239 4240<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> 4241<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain 4242declaration. 4243 4244Given 4245 template<typename T> struct A {}; 4246 struct B { B* next; }; 4247 A<&B::next> a; 4248classTemplateSpecializationDecl(hasAnyTemplateArgument( 4249 refersToDeclaration(fieldDecl(hasName("next")))) 4250 matches the specialization A<&B::next> with fieldDecl(...) matching 4251 B::next 4252</pre></td></tr> 4253 4254 4255<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('refersToIntegralType0')"><a name="refersToIntegralType0Anchor">refersToIntegralType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 4256<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type. 4257 4258Given 4259 template<int T> struct A {}; 4260 C<42> c; 4261classTemplateSpecializationDecl( 4262 hasAnyTemplateArgument(refersToIntegralType(asString("int")))) 4263 matches the implicit instantiation of C in C<42>. 4264</pre></td></tr> 4265 4266 4267<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> 4268<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. 4269 4270Given 4271 struct X {}; 4272 template<typename T> struct A {}; 4273 A<X> a; 4274classTemplateSpecializationDecl(hasAnyTemplateArgument( 4275 refersToType(class(hasName("X"))))) 4276 matches the specialization A<X> 4277</pre></td></tr> 4278 4279 4280<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgument1')"><a name="hasAnyTemplateArgument1Anchor">hasAnyTemplateArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 4281<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations that have at least one 4282TemplateArgument matching the given InnerMatcher. 4283 4284Given 4285 template<typename T> class A {}; 4286 template<> class A<double> {}; 4287 A<int> a; 4288classTemplateSpecializationDecl(hasAnyTemplateArgument( 4289 refersToType(asString("int")))) 4290 matches the specialization A<int> 4291</pre></td></tr> 4292 4293 4294<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasDeclaration3')"><a name="hasDeclaration3Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4295<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node 4296matches the given matcher. 4297 4298The associated declaration is: 4299- for type nodes, the declaration of the underlying type 4300- for CallExpr, the declaration of the callee 4301- for MemberExpr, the declaration of the referenced member 4302- for CXXConstructExpr, the declaration of the constructor 4303 4304Also usable as Matcher<T> for any T supporting the getDecl() member 4305function. e.g. various subtypes of clang::Type and various expressions. 4306 4307Usable as: 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>>, 4308 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, 4309 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 4310 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, 4311 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, 4312 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4313</pre></td></tr> 4314 4315 4316<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasTemplateArgument1')"><a name="hasTemplateArgument1Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 4317<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument 4318matches the given InnerMatcher. 4319 4320Given 4321 template<typename T, typename U> class A {}; 4322 A<bool, int> b; 4323 A<int, bool> c; 4324classTemplateSpecializationDecl(hasTemplateArgument( 4325 1, refersToType(asString("int")))) 4326 matches the specialization A<bool, int> 4327</pre></td></tr> 4328 4329 4330<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>></td><td class="name" onclick="toggle('hasDeclaration2')"><a name="hasDeclaration2Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4331<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node 4332matches the given matcher. 4333 4334The associated declaration is: 4335- for type nodes, the declaration of the underlying type 4336- for CallExpr, the declaration of the callee 4337- for MemberExpr, the declaration of the referenced member 4338- for CXXConstructExpr, the declaration of the constructor 4339 4340Also usable as Matcher<T> for any T supporting the getDecl() member 4341function. e.g. various subtypes of clang::Type and various expressions. 4342 4343Usable as: 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>>, 4344 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, 4345 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 4346 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, 4347 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, 4348 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4349</pre></td></tr> 4350 4351 4352<tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<T> Matcher</td></tr> 4353<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. 4354 4355Generates results for each match. 4356 4357For example, in: 4358 class A { class B {}; class C {}; }; 4359The matcher: 4360 recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m"))) 4361will generate results for A, B and C. 4362 4363Usable as: Any Matcher 4364</pre></td></tr> 4365 4366 4367<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> 4368<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node 4369matches the given matcher. 4370 4371The associated declaration is: 4372- for type nodes, the declaration of the underlying type 4373- for CallExpr, the declaration of the callee 4374- for MemberExpr, the declaration of the referenced member 4375- for CXXConstructExpr, the declaration of the constructor 4376 4377Also usable as Matcher<T> for any T supporting the getDecl() member 4378function. e.g. various subtypes of clang::Type and various expressions. 4379 4380Usable as: 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>>, 4381 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, 4382 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 4383 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, 4384 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, 4385 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4386</pre></td></tr> 4387 4388 4389<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> 4390<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. 4391 4392Given 4393 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); 4394unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) 4395 matches sizeof(a) and alignof(c) 4396</pre></td></tr> 4397 4398 4399<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> 4400<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. 4401 4402Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true)))) 4403 !true 4404</pre></td></tr> 4405 4406 4407<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>></td><td class="name" onclick="toggle('hasDeclaration0')"><a name="hasDeclaration0Anchor">hasDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4408<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node 4409matches the given matcher. 4410 4411The associated declaration is: 4412- for type nodes, the declaration of the underlying type 4413- for CallExpr, the declaration of the callee 4414- for MemberExpr, the declaration of the referenced member 4415- for CXXConstructExpr, the declaration of the constructor 4416 4417Also usable as Matcher<T> for any T supporting the getDecl() member 4418function. e.g. various subtypes of clang::Type and various expressions. 4419 4420Usable as: 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>>, 4421 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, 4422 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 4423 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, 4424 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, 4425 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4426</pre></td></tr> 4427 4428 4429<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> 4430<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. 4431 4432Given 4433 namespace X { void b(); } 4434 using X::b; 4435usingDecl(hasAnyUsingShadowDecl(hasName("b")))) 4436 matches using X::b </pre></td></tr> 4437 4438 4439<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> 4440<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is 4441matched by the given matcher. 4442 4443Given 4444 namespace X { int a; void b(); } 4445 using X::a; 4446 using X::b; 4447usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) 4448 matches using X::b but not using X::a </pre></td></tr> 4449 4450 4451<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> 4452<tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value 4453declaration's type. 4454 4455In case of a value declaration (for example a variable declaration), 4456this resolves one layer of indirection. For example, in the value 4457declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, 4458while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration 4459of x." 4460 4461Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 4462 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 4463 class X {}; 4464 void y(X &x) { x; X z; } 4465 4466Usable 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>> 4467</pre></td></tr> 4468 4469 4470<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType1')"><a name="hasType1Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 4471<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type 4472matcher. 4473 4474Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 4475 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 4476 class X {}; 4477 void y(X &x) { x; X z; } 4478</pre></td></tr> 4479 4480 4481<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> 4482<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression 4483that matches the given matcher. 4484 4485Example matches x (matcher = varDecl(hasInitializer(callExpr()))) 4486 bool y() { return true; } 4487 bool x = y(); 4488</pre></td></tr> 4489 4490 4491<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> 4492<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size 4493expression. 4494 4495Given 4496 void f(int b) { 4497 int a[b]; 4498 } 4499variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( 4500 varDecl(hasName("b"))))))) 4501 matches "int a[b]" 4502</pre></td></tr> 4503 4504 4505<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> 4506<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has 4507a given body. 4508 4509Given 4510 for (;;) {} 4511hasBody(compoundStmt()) 4512 matches 'for (;;) {}' 4513with compoundStmt() 4514 matching '{}' 4515</pre></td></tr> 4516 4517 4518<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> 4519<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, 4520or conditional operator. 4521 4522Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 4523 if (true) {} 4524</pre></td></tr> 4525 4526 4527<tr><td>Matcher<internal::BindableMatcher<<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> 4528<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner 4529NestedNameSpecifier-matcher matches. 4530</pre></td></tr> 4531 4532 4533<tr><td>Matcher<internal::BindableMatcher<<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> 4534<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner 4535QualType-matcher matches. 4536</pre></td></tr> 4537 4538<!--END_TRAVERSAL_MATCHERS --> 4539</table> 4540 4541</div> 4542</body> 4543</html> 4544 4545 4546