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('isTemplateInstantiation0')"><a name="isTemplateInstantiation0Anchor">isTemplateInstantiation</a></td><td></td></tr> 2073<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static 2074member variable template instantiations. 2075 2076Given 2077 template <typename T> class X {}; class A {}; X<A> x; 2078or 2079 template <typename T> class X {}; class A {}; template class X<A>; 2080recordDecl(hasName("::X"), isTemplateInstantiation()) 2081 matches the template instantiation of X<A>. 2082 2083But given 2084 template <typename T> class X {}; class A {}; 2085 template <> class X<A> {}; X<A> x; 2086recordDecl(hasName("::X"), isTemplateInstantiation()) 2087 does not match, as X<A> is an explicit template specialization. 2088 2089Usable 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>> 2090</pre></td></tr> 2091 2092 2093<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> 2094<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count. 2095 2096Given 2097 void f(int i) {} 2098 void g(int i, int j) {} 2099functionDecl(parameterCountIs(2)) 2100 matches g(int i, int j) {} 2101</pre></td></tr> 2102 2103 2104<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> 2105<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value. 2106 2107Example matches true (matcher = boolLiteral(equals(true))) 2108 true 2109 2110Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 2111 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>> 2112</pre></td></tr> 2113 2114 2115<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> 2116<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed 2117to '.'. 2118 2119Member calls on the implicit this pointer match as called with '->'. 2120 2121Given 2122 class Y { 2123 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 2124 int a; 2125 static int b; 2126 }; 2127memberExpr(isArrow()) 2128 matches this->x, x, y.x, a, this->b 2129</pre></td></tr> 2130 2131 2132<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> 2133<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. 2134 2135Supports specifying enclosing namespaces or classes by prefixing the name 2136with '<enclosing>::'. 2137Does not match typedefs of an underlying type with the given name. 2138 2139Example matches X (Name == "X") 2140 class X; 2141 2142Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") 2143 namespace a { namespace b { class X; } } 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('matchesName0')"><a name="matchesName0Anchor">matchesName</a></td><td>std::string RegExp</td></tr> 2148<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain 2149a substring matched by the given RegExp. 2150 2151Supports specifying enclosing namespaces or classes by 2152prefixing the name with '<enclosing>::'. Does not match typedefs 2153of an underlying type with the given name. 2154 2155Example matches X (regexp == "::X") 2156 class X; 2157 2158Example matches X (regexp is one of "::X", "^foo::.*X", among others) 2159 namespace foo { namespace bar { class X; } } 2160</pre></td></tr> 2161 2162 2163<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> 2164<tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has 2165a specific number of arguments (including absent default arguments). 2166 2167Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 2168 void f(int x, int y); 2169 f(0, 0); 2170</pre></td></tr> 2171 2172 2173<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> 2174<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre></pre></td></tr> 2175 2176 2177<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> 2178<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector 2179 2180Matches only when the selector of the objCMessageExpr is NULL. This may 2181represent an error condition in the tree! 2182</pre></td></tr> 2183 2184 2185<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> 2186<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() 2187 2188 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); 2189 matches the outer message expr in the code below, but NOT the message 2190 invocation for self.bodyView. 2191 [self.bodyView loadHTMLString:html baseURL:NULL]; 2192</pre></td></tr> 2193 2194 2195<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> 2196<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector 2197 2198 matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); 2199 matches self.bodyView in the code below, but NOT the outer message 2200 invocation of "loadHTMLString:baseURL:". 2201 [self.bodyView loadHTMLString:html baseURL:NULL]; 2202</pre></td></tr> 2203 2204 2205<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> 2206<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains 2207a substring matched by the given RegExp. 2208 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message 2209 invocation for self.bodyView. 2210 [self.bodyView loadHTMLString:html baseURL:NULL]; 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('numSelectorArgs0')"><a name="numSelectorArgs0Anchor">numSelectorArgs</a></td><td>unsigned N</td></tr> 2215<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments 2216 2217 matcher = objCMessageExpr(numSelectorArgs(1)); 2218 matches self.bodyView in the code below 2219 2220 matcher = objCMessageExpr(numSelectorArgs(2)); 2221 matches the invocation of "loadHTMLString:baseURL:" but not that 2222 of self.bodyView 2223 [self.bodyView loadHTMLString:html baseURL:NULL]; 2224</pre></td></tr> 2225 2226 2227<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> 2228<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. 2229 2230Given 2231 class Y { public: void x(); }; 2232 void z() { Y* y; y->x(); } 2233memberCallExpr(on(hasType(asString("class Y *")))) 2234 matches y->x() 2235</pre></td></tr> 2236 2237 2238<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> 2239<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. 2240 2241Matches a node if it equals the node previously bound to ID. 2242 2243Given 2244 class X { int a; int b; }; 2245recordDecl( 2246 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2247 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2248 matches the class X, as a and b have the same type. 2249 2250Note that when multiple matches are involved via forEach* matchers, 2251equalsBoundNodes acts as a filter. 2252For example: 2253compoundStmt( 2254 forEachDescendant(varDecl().bind("d")), 2255 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2256will trigger a match for each combination of variable declaration 2257and reference to that variable declaration within a compound statement. 2258</pre></td></tr> 2259 2260 2261<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> 2262<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to 2263the node, not hidden within a typedef. 2264 2265Given 2266 typedef const int const_int; 2267 const_int i; 2268 int *const j; 2269 int *volatile k; 2270 int m; 2271varDecl(hasType(hasLocalQualifiers())) matches only j and k. 2272i is const-qualified but the qualifier is not local. 2273</pre></td></tr> 2274 2275 2276<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> 2277<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that 2278include "top-level" const. 2279 2280Given 2281 void a(int); 2282 void b(int const); 2283 void c(const int); 2284 void d(const int*); 2285 void e(int const) {}; 2286functionDecl(hasAnyParameter(hasType(isConstQualified()))) 2287 matches "void b(int const)", "void c(const int)" and 2288 "void e(int const) {}". It does not match d as there 2289 is no top-level const on the parameter type "const int *". 2290</pre></td></tr> 2291 2292 2293<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> 2294<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. 2295 2296Given 2297 void a(int); 2298 void b(long); 2299 void c(double); 2300functionDecl(hasAnyParameter(hasType(isInteger()))) 2301matches "a(int)", "b(long)", but not "c(double)". 2302</pre></td></tr> 2303 2304 2305<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> 2306<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. 2307 2308Matches a node if it equals the node previously bound to ID. 2309 2310Given 2311 class X { int a; int b; }; 2312recordDecl( 2313 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2314 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2315 matches the class X, as a and b have the same type. 2316 2317Note that when multiple matches are involved via forEach* matchers, 2318equalsBoundNodes acts as a filter. 2319For example: 2320compoundStmt( 2321 forEachDescendant(varDecl().bind("d")), 2322 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2323will trigger a match for each combination of variable declaration 2324and reference to that variable declaration within a compound statement. 2325</pre></td></tr> 2326 2327 2328<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> 2329<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is 2330partially matching a given regex. 2331 2332Example matches Y but not X 2333 (matcher = recordDecl(isExpansionInFileMatching("AST.*")) 2334 #include "ASTMatcher.h" 2335 class X {}; 2336ASTMatcher.h: 2337 class Y {}; 2338 2339Usable 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>> 2340</pre></td></tr> 2341 2342 2343<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> 2344<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. 2345 2346Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile()) 2347 #include <Y.h> 2348 class X {}; 2349Y.h: 2350 class Y {}; 2351 2352Usable 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>> 2353</pre></td></tr> 2354 2355 2356<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> 2357<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. 2358 2359Example matches Y but not X 2360 (matcher = recordDecl(isExpansionInSystemHeader()) 2361 #include <SystemHeader.h> 2362 class X {}; 2363SystemHeader.h: 2364 class Y {}; 2365 2366Usable 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>> 2367</pre></td></tr> 2368 2369 2370<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> 2371<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. 2372 2373Example matches A, va, fa 2374 class A {}; 2375 class B; Doesn't match, as it has no body. 2376 int va; 2377 extern int vb; Doesn't match, as it doesn't define the variable. 2378 void fa() {} 2379 void fb(); Doesn't match, as it has no body. 2380 2381Usable 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>> 2382</pre></td></tr> 2383 2384 2385<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> 2386<tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. 2387 2388Note that 'Value' is a string as the template argument's value is 2389an arbitrary precision integer. 'Value' must be euqal to the canonical 2390representation of that integral value in base 10. 2391 2392Given 2393 template<int T> struct A {}; 2394 C<42> c; 2395classTemplateSpecializationDecl( 2396 hasAnyTemplateArgument(equalsIntegralValue("42"))) 2397 matches the implicit instantiation of C in C<42>. 2398</pre></td></tr> 2399 2400 2401<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> 2402<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. 2403 2404Given 2405 template<int T> struct A {}; 2406 C<42> c; 2407classTemplateSpecializationDecl( 2408 hasAnyTemplateArgument(isIntegral())) 2409 matches the implicit instantiation of C in C<42> 2410 with isIntegral() matching 42. 2411</pre></td></tr> 2412 2413 2414<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> 2415<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. 2416 2417Given 2418 template<typename T> struct C {}; 2419 C<int> c; 2420classTemplateSpecializationDecl(templateArgumentCountIs(1)) 2421 matches C<int>. 2422</pre></td></tr> 2423 2424 2425<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> 2426<tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is 2427partially matching a given regex. 2428 2429Example matches Y but not X 2430 (matcher = recordDecl(isExpansionInFileMatching("AST.*")) 2431 #include "ASTMatcher.h" 2432 class X {}; 2433ASTMatcher.h: 2434 class Y {}; 2435 2436Usable 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>> 2437</pre></td></tr> 2438 2439 2440<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> 2441<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. 2442 2443Example matches X but not Y (matcher = recordDecl(isExpansionInMainFile()) 2444 #include <Y.h> 2445 class X {}; 2446Y.h: 2447 class Y {}; 2448 2449Usable 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>> 2450</pre></td></tr> 2451 2452 2453<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> 2454<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. 2455 2456Example matches Y but not X 2457 (matcher = recordDecl(isExpansionInSystemHeader()) 2458 #include <SystemHeader.h> 2459 class X {}; 2460SystemHeader.h: 2461 class Y {}; 2462 2463Usable 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>> 2464</pre></td></tr> 2465 2466 2467<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> 2468<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. 2469 2470Matches a node if it equals the node previously bound to ID. 2471 2472Given 2473 class X { int a; int b; }; 2474recordDecl( 2475 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2476 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2477 matches the class X, as a and b have the same type. 2478 2479Note that when multiple matches are involved via forEach* matchers, 2480equalsBoundNodes acts as a filter. 2481For example: 2482compoundStmt( 2483 forEachDescendant(varDecl().bind("d")), 2484 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2485will trigger a match for each combination of variable declaration 2486and reference to that variable declaration within a compound statement. 2487</pre></td></tr> 2488 2489 2490<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> 2491<tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. 2492 2493Given 2494 struct S { void func(); }; 2495functionDecl(returns(voidType())) 2496 matches "void func();" 2497</pre></td></tr> 2498 2499 2500<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> 2501<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. 2502 2503Given 2504 int x; 2505 int s = sizeof(x) + alignof(x) 2506unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) 2507 matches sizeof(x) 2508</pre></td></tr> 2509 2510 2511<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> 2512<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or 2513unary). 2514 2515Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 2516 !(a || b) 2517</pre></td></tr> 2518 2519 2520<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> 2521<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. 2522 2523Example matches y and z (matcher = varDecl(hasGlobalStorage()) 2524void f() { 2525 int x; 2526 static int y; 2527} 2528int z; 2529</pre></td></tr> 2530 2531 2532<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> 2533<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a 2534non-static local variable. 2535 2536Example matches x (matcher = varDecl(hasLocalStorage()) 2537void f() { 2538 int x; 2539 static int y; 2540} 2541int z; 2542</pre></td></tr> 2543 2544 2545<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> 2546<tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations. 2547 2548Given: 2549 constexpr int foo = 42; 2550 constexpr int bar(); 2551varDecl(isConstexpr()) 2552 matches the declaration of foo. 2553functionDecl(isConstexpr()) 2554 matches the declaration of bar. 2555</pre></td></tr> 2556 2557 2558<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> 2559<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. 2560 2561Example matches A, va, fa 2562 class A {}; 2563 class B; Doesn't match, as it has no body. 2564 int va; 2565 extern int vb; Doesn't match, as it doesn't define the variable. 2566 void fa() {} 2567 void fb(); Doesn't match, as it has no body. 2568 2569Usable 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>> 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('isExceptionVariable0')"><a name="isExceptionVariable0Anchor">isExceptionVariable</a></td><td></td></tr> 2574<tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from 2575a C++ catch block, or an Objective-C statement. 2576 2577Example matches x (matcher = varDecl(isExceptionVariable()) 2578void f(int y) { 2579 try { 2580 } catch (int x) { 2581 } 2582} 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('isExplicitTemplateSpecialization1')"><a name="isExplicitTemplateSpecialization1Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr> 2587<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or 2588static member variable template instantiations. 2589 2590Given 2591 template<typename T> void A(T t) { } 2592 template<> void A(int N) { } 2593functionDecl(isExplicitTemplateSpecialization()) 2594 matches the specialization A<int>(). 2595 2596Usable 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>> 2597</pre></td></tr> 2598 2599 2600<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> 2601<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static 2602member variable template instantiations. 2603 2604Given 2605 template <typename T> class X {}; class A {}; X<A> x; 2606or 2607 template <typename T> class X {}; class A {}; template class X<A>; 2608recordDecl(hasName("::X"), isTemplateInstantiation()) 2609 matches the template instantiation of X<A>. 2610 2611But given 2612 template <typename T> class X {}; class A {}; 2613 template <> class X<A> {}; X<A> x; 2614recordDecl(hasName("::X"), isTemplateInstantiation()) 2615 does not match, as X<A> is an explicit template specialization. 2616 2617Usable 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>> 2618</pre></td></tr> 2619 2620 2621<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> 2622<tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside 2623template instantiations. 2624 2625Given 2626 template<typename T> void A(T t) { T i; } 2627 A(0); 2628 A(0U); 2629functionDecl(isInstantiated()) 2630 matches 'A(int) {...};' and 'A(unsigned) {...}'. 2631</pre></td></tr> 2632 2633 2634<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> 2635<tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. 2636 2637Given 2638 int j; 2639 template<typename T> void A(T t) { T i; j += 42;} 2640 A(0); 2641 A(0U); 2642declStmt(isInTemplateInstantiation()) 2643 matches 'int i;' and 'unsigned i'. 2644unless(stmt(isInTemplateInstantiation())) 2645 will NOT match j += 42; as it's shared between the template definition and 2646 instantiation. 2647</pre></td></tr> 2648 2649<!--END_NARROWING_MATCHERS --> 2650</table> 2651 2652<!-- ======================================================================= --> 2653<h2 id="traversal-matchers">AST Traversal Matchers</h2> 2654<!-- ======================================================================= --> 2655 2656<p>Traversal matchers specify the relationship to other nodes that are 2657reachable from the current node.</p> 2658 2659<p>Note that there are special traversal matchers (has, hasDescendant, forEach and 2660forEachDescendant) which work on all nodes and allow users to write more generic 2661match expressions.</p> 2662 2663<table> 2664<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 2665<!-- START_TRAVERSAL_MATCHERS --> 2666 2667<tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 2668<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. 2669 2670Unlike anyOf, eachOf will generate a match result for each 2671matching submatcher. 2672 2673For example, in: 2674 class A { int a; int b; }; 2675The matcher: 2676 recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), 2677 has(fieldDecl(hasName("b")).bind("v")))) 2678will generate two results binding "v", the first of which binds 2679the field declaration of a, the second the field declaration of 2680b. 2681 2682Usable as: Any Matcher 2683</pre></td></tr> 2684 2685 2686<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> 2687<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 2688provided matcher. 2689 2690Example matches X, A, B, C 2691 (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X"))))) 2692 class X {}; Matches X, because X::X is a class of name X inside X. 2693 class A { class X {}; }; 2694 class B { class C { class X {}; }; }; 2695 2696DescendantT must be an AST base type. 2697 2698As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for 2699each result that matches instead of only on the first one. 2700 2701Note: Recursively combined ForEachDescendant can cause many matches: 2702 recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl())))) 2703will match 10 times (plus injected class name matches) on: 2704 class A { class B { class C { class D { class E {}; }; }; }; }; 2705 2706Usable as: Any Matcher 2707</pre></td></tr> 2708 2709 2710<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> 2711<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the 2712provided matcher. 2713 2714Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X"))) 2715 class X {}; Matches X, because X::X is a class of name X inside X. 2716 class Y { class X {}; }; 2717 class Z { class Y { class X {}; }; }; Does not match Z. 2718 2719ChildT must be an AST base type. 2720 2721As opposed to 'has', 'forEach' will cause a match for each result that 2722matches instead of only on the first one. 2723 2724Usable as: Any Matcher 2725</pre></td></tr> 2726 2727 2728<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> 2729<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided 2730matcher. 2731 2732Given 2733void f() { if (true) { int x = 42; } } 2734void g() { for (;;) { int x = 43; } } 2735expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. 2736 2737Usable as: Any Matcher 2738</pre></td></tr> 2739 2740 2741<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> 2742<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 2743provided matcher. 2744 2745Example matches X, Y, Z 2746 (matcher = recordDecl(hasDescendant(recordDecl(hasName("X"))))) 2747 class X {}; Matches X, because X::X is a class of name X inside X. 2748 class Y { class X {}; }; 2749 class Z { class Y { class X {}; }; }; 2750 2751DescendantT must be an AST base type. 2752 2753Usable as: Any Matcher 2754</pre></td></tr> 2755 2756 2757<tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> 2758<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the 2759provided matcher. 2760 2761Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X"))) 2762 class X {}; Matches X, because X::X is a class of name X inside X. 2763 class Y { class X {}; }; 2764 class Z { class Y { class X {}; }; }; Does not match Z. 2765 2766ChildT must be an AST base type. 2767 2768Usable as: Any Matcher 2769</pre></td></tr> 2770 2771 2772<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> 2773<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided 2774matcher. 2775 2776Given 2777void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } 2778compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". 2779 2780Usable as: Any Matcher 2781</pre></td></tr> 2782 2783 2784<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> 2785<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. 2786 2787Given 2788 int i[5]; 2789 void f() { i[1] = 42; } 2790arraySubscriptExpression(hasBase(implicitCastExpr( 2791 hasSourceExpression(declRefExpr())))) 2792 matches i[1] with the declRefExpr() matching i 2793</pre></td></tr> 2794 2795 2796<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> 2797<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. 2798 2799Given 2800 int i[5]; 2801 void f() { i[1] = 42; } 2802arraySubscriptExpression(hasIndex(integerLiteral())) 2803 matches i[1] with the integerLiteral() matching 1 2804</pre></td></tr> 2805 2806 2807<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> 2808<tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element 2809type. 2810 2811Given 2812 struct A {}; 2813 A a[7]; 2814 int b[7]; 2815arrayType(hasElementType(builtinType())) 2816 matches "int b[7]" 2817 2818Usable 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>> 2819</pre></td></tr> 2820 2821 2822<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> 2823<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element 2824type. 2825 2826Given 2827 struct A {}; 2828 A a[7]; 2829 int b[7]; 2830arrayType(hasElementType(builtinType())) 2831 matches "int b[7]" 2832 2833Usable 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>> 2834</pre></td></tr> 2835 2836 2837<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> 2838<tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. 2839 2840Given 2841 _Atomic(int) i; 2842 _Atomic(float) f; 2843atomicType(hasValueType(isInteger())) 2844 matches "_Atomic(int) i" 2845 2846Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 2847</pre></td></tr> 2848 2849 2850<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> 2851<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. 2852 2853Given 2854 _Atomic(int) i; 2855 _Atomic(float) f; 2856atomicType(hasValueType(isInteger())) 2857 matches "_Atomic(int) i" 2858 2859Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 2860</pre></td></tr> 2861 2862 2863<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> 2864<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. 2865 2866Note: There is no TypeLoc for the deduced type and thus no 2867getDeducedLoc() matcher. 2868 2869Given 2870 auto a = 1; 2871 auto b = 2.0; 2872autoType(hasDeducedType(isInteger())) 2873 matches "auto a" 2874 2875Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> 2876</pre></td></tr> 2877 2878 2879<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> 2880<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a 2881binary operator matches. 2882</pre></td></tr> 2883 2884 2885<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> 2886<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. 2887 2888Example matches a (matcher = binaryOperator(hasLHS())) 2889 a || b 2890</pre></td></tr> 2891 2892 2893<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> 2894<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. 2895 2896Example matches b (matcher = binaryOperator(hasRHS())) 2897 a || b 2898</pre></td></tr> 2899 2900 2901<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> 2902<tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the 2903pointee matches a given matcher. 2904 2905Given 2906 int *a; 2907 int const *b; 2908 float const *f; 2909pointerType(pointee(isConstQualified(), isInteger())) 2910 matches "int const *b" 2911 2912Usable 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>>, 2913 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>> 2914</pre></td></tr> 2915 2916 2917<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> 2918<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the 2919pointee matches a given matcher. 2920 2921Given 2922 int *a; 2923 int const *b; 2924 float const *f; 2925pointerType(pointee(isConstQualified(), isInteger())) 2926 matches "int const *b" 2927 2928Usable 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>>, 2929 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>> 2930</pre></td></tr> 2931 2932 2933<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> 2934<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call 2935expression. 2936 2937Given 2938 void x(int, int, int) { int y; x(1, y, 42); } 2939callExpr(hasAnyArgument(declRefExpr())) 2940 matches x(1, y, 42) 2941with hasAnyArgument(...) 2942 matching y 2943 2944FIXME: Currently this will ignore parentheses and implicit casts on 2945the argument before applying the inner matcher. We'll want to remove 2946this to allow for greater control by the user once ignoreImplicit() 2947has been implemented. 2948</pre></td></tr> 2949 2950 2951<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> 2952<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor 2953call expression. 2954 2955Example matches y in x(y) 2956 (matcher = callExpr(hasArgument(0, declRefExpr()))) 2957 void x(int) { int y; x(y); } 2958</pre></td></tr> 2959 2960 2961<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> 2962<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node 2963matches the given matcher. 2964 2965The associated declaration is: 2966- for type nodes, the declaration of the underlying type 2967- for CallExpr, the declaration of the callee 2968- for MemberExpr, the declaration of the referenced member 2969- for CXXConstructExpr, the declaration of the constructor 2970 2971Also usable as Matcher<T> for any T supporting the getDecl() member 2972function. e.g. various subtypes of clang::Type and various expressions. 2973 2974Usable 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>>, 2975 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>>, 2976 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>>, 2977 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>>, 2978 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>>, 2979 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>> 2980</pre></td></tr> 2981 2982 2983<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> 2984<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. 2985 2986Given 2987 class A { A() : i(42), j(42) {} int i; int j; }; 2988constructorDecl(forEachConstructorInitializer(forField(decl().bind("x")))) 2989 will trigger two matches, binding for 'i' and 'j' respectively. 2990</pre></td></tr> 2991 2992 2993<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> 2994<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. 2995 2996Given 2997 struct Foo { 2998 Foo() : foo_(1) { } 2999 int foo_; 3000 }; 3001recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything())))) 3002 record matches Foo, hasAnyConstructorInitializer matches foo_(1) 3003</pre></td></tr> 3004 3005 3006<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> 3007<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. 3008 3009Given 3010 struct Foo { 3011 Foo() : foo_(1) { } 3012 int foo_; 3013 }; 3014recordDecl(has(constructorDecl(hasAnyConstructorInitializer( 3015 forField(hasName("foo_")))))) 3016 matches Foo 3017with forField matching foo_ 3018</pre></td></tr> 3019 3020 3021<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> 3022<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. 3023 3024Given 3025 struct Foo { 3026 Foo() : foo_(1) { } 3027 int foo_; 3028 }; 3029recordDecl(has(constructorDecl(hasAnyConstructorInitializer( 3030 withInitializer(integerLiteral(equals(1))))))) 3031 matches Foo 3032with withInitializer matching (1) 3033</pre></td></tr> 3034 3035 3036<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> 3037<tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', or 'do while' statement that has 3038a given body. 3039 3040Given 3041 for (;;) {} 3042hasBody(compoundStmt()) 3043 matches 'for (;;) {}' 3044with compoundStmt() 3045 matching '{}' 3046</pre></td></tr> 3047 3048 3049<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> 3050<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. 3051 3052Example: 3053 forStmt(hasLoopVariable(anything())) 3054matches 'int x' in 3055 for (int x : a) { } 3056</pre></td></tr> 3057 3058 3059<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> 3060<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. 3061 3062Example: 3063 forStmt(hasRangeInit(anything())) 3064matches 'a' in 3065 for (int x : a) { } 3066</pre></td></tr> 3067 3068 3069<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> 3070<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> 3071 3072 3073<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> 3074<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. 3075 3076Example matches y.x() 3077 (matcher = memberCallExpr(on(hasType(recordDecl(hasName("Y")))))) 3078 class Y { public: void x(); }; 3079 void z() { Y y; y.x(); }", 3080 3081FIXME: Overload to allow directly matching types? 3082</pre></td></tr> 3083 3084 3085<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> 3086<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. 3087</pre></td></tr> 3088 3089 3090<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> 3091<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified 3092matcher, or is a pointer to a type that matches the InnerMatcher. 3093</pre></td></tr> 3094 3095 3096<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> 3097<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration 3098belongs to. 3099 3100FIXME: Generalize this for other kinds of declarations. 3101FIXME: What other kind of declarations would we need to generalize 3102this to? 3103 3104Example matches A() in the last line 3105 (matcher = constructExpr(hasDeclaration(methodDecl( 3106 ofClass(hasName("A")))))) 3107 class A { 3108 public: 3109 A(); 3110 }; 3111 A a = A(); 3112</pre></td></tr> 3113 3114 3115<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> 3116<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. 3117 3118Given: 3119 class A { void func(); }; 3120 class B { void member(); }; 3121 3122recordDecl(hasMethod(hasName("func"))) matches the declaration of A 3123but not B. 3124</pre></td></tr> 3125 3126 3127<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> 3128<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from 3129a class matching Base. 3130 3131Note that a class is not considered to be derived from itself. 3132 3133Example matches Y, Z, C (Base == hasName("X")) 3134 class X; 3135 class Y : public X {}; directly derived 3136 class Z : public Y {}; indirectly derived 3137 typedef X A; 3138 typedef A B; 3139 class C : public B {}; derived from a typedef of X 3140 3141In the following example, Bar matches isDerivedFrom(hasName("X")): 3142 class Foo; 3143 typedef Foo X; 3144 class Bar : public Foo {}; derived from a type that X is a typedef of 3145</pre></td></tr> 3146 3147 3148<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> 3149<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly 3150match Base. 3151</pre></td></tr> 3152 3153 3154<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> 3155<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the 3156given matcher. 3157 3158Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x"))))) 3159 class Y { public: void x(); }; 3160 void z() { Y y; y.x(); } 3161</pre></td></tr> 3162 3163 3164<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> 3165<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. 3166 3167Given 3168 class Y { void x() { this->x(); x(); Y y; y.x(); } }; 3169 void f() { f(); } 3170callExpr(callee(expr())) 3171 matches this->x(), x(), y.x(), f() 3172with callee(...) 3173 matching this->x, x, y.x, f respectively 3174 3175Note: Callee cannot take the more general internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> 3176because this introduces ambiguous overloads with calls to Callee taking a 3177internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely 3178implemented in terms of implicit casts. 3179</pre></td></tr> 3180 3181 3182<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> 3183<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call 3184expression. 3185 3186Given 3187 void x(int, int, int) { int y; x(1, y, 42); } 3188callExpr(hasAnyArgument(declRefExpr())) 3189 matches x(1, y, 42) 3190with hasAnyArgument(...) 3191 matching y 3192 3193FIXME: Currently this will ignore parentheses and implicit casts on 3194the argument before applying the inner matcher. We'll want to remove 3195this to allow for greater control by the user once ignoreImplicit() 3196has been implemented. 3197</pre></td></tr> 3198 3199 3200<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> 3201<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor 3202call expression. 3203 3204Example matches y in x(y) 3205 (matcher = callExpr(hasArgument(0, declRefExpr()))) 3206 void x(int) { int y; x(y); } 3207</pre></td></tr> 3208 3209 3210<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> 3211<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node 3212matches the given matcher. 3213 3214The associated declaration is: 3215- for type nodes, the declaration of the underlying type 3216- for CallExpr, the declaration of the callee 3217- for MemberExpr, the declaration of the referenced member 3218- for CXXConstructExpr, the declaration of the constructor 3219 3220Also usable as Matcher<T> for any T supporting the getDecl() member 3221function. e.g. various subtypes of clang::Type and various expressions. 3222 3223Usable 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>>, 3224 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>>, 3225 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>>, 3226 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>>, 3227 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>>, 3228 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>> 3229</pre></td></tr> 3230 3231 3232<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> 3233<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range 3234extension, matches the constant given in the statement. 3235 3236Given 3237 switch (1) { case 1: case 1+1: case 3 ... 4: ; } 3238caseStmt(hasCaseConstant(integerLiteral())) 3239 matches "case 1:" 3240</pre></td></tr> 3241 3242 3243<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> 3244<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher. 3245 3246Example: matches "a string" (matcher = 3247 hasSourceExpression(constructExpr())) 3248class URL { URL(string); }; 3249URL url = "a string"; 3250</pre></td></tr> 3251 3252 3253<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> 3254<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one 3255TemplateArgument matching the given InnerMatcher. 3256 3257Given 3258 template<typename T> class A {}; 3259 template<> class A<double> {}; 3260 A<int> a; 3261classTemplateSpecializationDecl(hasAnyTemplateArgument( 3262 refersToType(asString("int")))) 3263 matches the specialization A<int> 3264</pre></td></tr> 3265 3266 3267<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> 3268<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument 3269matches the given InnerMatcher. 3270 3271Given 3272 template<typename T, typename U> class A {}; 3273 A<bool, int> b; 3274 A<int, bool> c; 3275classTemplateSpecializationDecl(hasTemplateArgument( 3276 1, refersToType(asString("int")))) 3277 matches the specialization A<bool, int> 3278</pre></td></tr> 3279 3280 3281<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> 3282<tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element 3283type. 3284 3285Given 3286 struct A {}; 3287 A a[7]; 3288 int b[7]; 3289arrayType(hasElementType(builtinType())) 3290 matches "int b[7]" 3291 3292Usable 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>> 3293</pre></td></tr> 3294 3295 3296<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> 3297<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element 3298type. 3299 3300Given 3301 struct A {}; 3302 A a[7]; 3303 int b[7]; 3304arrayType(hasElementType(builtinType())) 3305 matches "int b[7]" 3306 3307Usable 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>> 3308</pre></td></tr> 3309 3310 3311<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> 3312<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches 3313a given matcher. 3314 3315Given 3316 { {}; 1+2; } 3317hasAnySubstatement(compoundStmt()) 3318 matches '{ {}; 1+2; }' 3319with compoundStmt() 3320 matching '{}' 3321</pre></td></tr> 3322 3323 3324<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> 3325<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, 3326or conditional operator. 3327 3328Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3329 if (true) {} 3330</pre></td></tr> 3331 3332 3333<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> 3334<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator. 3335 3336Example matches b 3337 condition ? a : b 3338</pre></td></tr> 3339 3340 3341<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> 3342<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. 3343 3344Example matches a 3345 condition ? a : b 3346</pre></td></tr> 3347 3348 3349<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> 3350<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node 3351matches the given matcher. 3352 3353The associated declaration is: 3354- for type nodes, the declaration of the underlying type 3355- for CallExpr, the declaration of the callee 3356- for MemberExpr, the declaration of the referenced member 3357- for CXXConstructExpr, the declaration of the constructor 3358 3359Also usable as Matcher<T> for any T supporting the getDecl() member 3360function. e.g. various subtypes of clang::Type and various expressions. 3361 3362Usable 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>>, 3363 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>>, 3364 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>>, 3365 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>>, 3366 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>>, 3367 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>> 3368</pre></td></tr> 3369 3370 3371<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> 3372<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a 3373specific using shadow declaration. 3374 3375Given 3376 namespace a { void f() {} } 3377 using a::f; 3378 void g() { 3379 f(); Matches this .. 3380 a::f(); .. but not this. 3381 } 3382declRefExpr(throughUsingDecl(anything())) 3383 matches f() 3384</pre></td></tr> 3385 3386 3387<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> 3388<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the 3389specified matcher. 3390 3391Example matches x in if(x) 3392 (matcher = declRefExpr(to(varDecl(hasName("x"))))) 3393 bool x; 3394 if (x) {} 3395</pre></td></tr> 3396 3397 3398<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> 3399<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. 3400 3401Note that this does not work for global declarations because the AST 3402breaks up multiple-declaration DeclStmt's into multiple single-declaration 3403DeclStmt's. 3404Example: Given non-global declarations 3405 int a, b = 0; 3406 int c; 3407 int d = 2, e; 3408declStmt(containsDeclaration( 3409 0, varDecl(hasInitializer(anything())))) 3410 matches only 'int d = 2, e;', and 3411declStmt(containsDeclaration(1, varDecl())) 3412 matches 'int a, b = 0' as well as 'int d = 2, e;' 3413 but 'int c;' is not matched. 3414</pre></td></tr> 3415 3416 3417<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> 3418<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. 3419 3420Given 3421 int a, b; 3422 int c; 3423declStmt(hasSingleDecl(anything())) 3424 matches 'int c;' but not 'int a, b;'. 3425</pre></td></tr> 3426 3427 3428<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> 3429<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches 3430the inner matcher. 3431 3432Given 3433 int x; 3434declaratorDecl(hasTypeLoc(loc(asString("int")))) 3435 matches int x 3436</pre></td></tr> 3437 3438 3439<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> 3440<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a 3441Decl, matches InnerMatcher. 3442 3443Given 3444 namespace N { 3445 namespace M { 3446 class D {}; 3447 } 3448 } 3449 3450recordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the 3451declaration of class D. 3452</pre></td></tr> 3453 3454 3455<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> 3456<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has 3457a given body. 3458 3459Given 3460 for (;;) {} 3461hasBody(compoundStmt()) 3462 matches 'for (;;) {}' 3463with compoundStmt() 3464 matching '{}' 3465</pre></td></tr> 3466 3467 3468<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> 3469<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, 3470or conditional operator. 3471 3472Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3473 if (true) {} 3474</pre></td></tr> 3475 3476 3477<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> 3478<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, 3479matches InnerMatcher if the qualifier exists. 3480 3481Given 3482 namespace N { 3483 namespace M { 3484 class D {}; 3485 } 3486 } 3487 N::M::D d; 3488 3489elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) 3490matches the type of the variable declaration of d. 3491</pre></td></tr> 3492 3493 3494<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> 3495<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. 3496 3497Given 3498 namespace N { 3499 namespace M { 3500 class D {}; 3501 } 3502 } 3503 N::M::D d; 3504 3505elaboratedType(namesType(recordType( 3506hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable 3507declaration of d. 3508</pre></td></tr> 3509 3510 3511<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> 3512<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node 3513matches the given matcher. 3514 3515The associated declaration is: 3516- for type nodes, the declaration of the underlying type 3517- for CallExpr, the declaration of the callee 3518- for MemberExpr, the declaration of the referenced member 3519- for CXXConstructExpr, the declaration of the constructor 3520 3521Also usable as Matcher<T> for any T supporting the getDecl() member 3522function. e.g. various subtypes of clang::Type and various expressions. 3523 3524Usable 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>>, 3525 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>>, 3526 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>>, 3527 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>>, 3528 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>>, 3529 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>> 3530</pre></td></tr> 3531 3532 3533<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> 3534<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. 3535 3536(Note: Clang's AST refers to other conversions as "casts" too, and calls 3537actual casts "explicit" casts.) 3538</pre></td></tr> 3539 3540 3541<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> 3542<tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value 3543declaration's type. 3544 3545In case of a value declaration (for example a variable declaration), 3546this resolves one layer of indirection. For example, in the value 3547declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, 3548while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration 3549of x." 3550 3551Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 3552 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 3553 class X {}; 3554 void y(X &x) { x; X z; } 3555 3556Usable 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>> 3557</pre></td></tr> 3558 3559 3560<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> 3561<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type 3562matcher. 3563 3564Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 3565 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 3566 class X {}; 3567 void y(X &x) { x; X z; } 3568</pre></td></tr> 3569 3570 3571<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> 3572<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts 3573are stripped off. 3574 3575Parentheses and explicit casts are not discarded. 3576Given 3577 int arr[5]; 3578 int a = 0; 3579 char b = 0; 3580 const int c = a; 3581 int *d = arr; 3582 long e = (long) 0l; 3583The matchers 3584 varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) 3585 varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) 3586would match the declarations for a, b, c, and d, but not e. 3587While 3588 varDecl(hasInitializer(integerLiteral())) 3589 varDecl(hasInitializer(declRefExpr())) 3590only match the declarations for b, c, and d. 3591</pre></td></tr> 3592 3593 3594<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> 3595<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and 3596casts are stripped off. 3597 3598Implicit and non-C Style casts are also discarded. 3599Given 3600 int a = 0; 3601 char b = (0); 3602 void* c = reinterpret_cast<char*>(0); 3603 char d = char(0); 3604The matcher 3605 varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) 3606would match the declarations for a, b, c, and d. 3607while 3608 varDecl(hasInitializer(integerLiteral())) 3609only match the declaration for a. 3610</pre></td></tr> 3611 3612 3613<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> 3614<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and 3615parentheses are stripped off. 3616 3617Explicit casts are not discarded. 3618Given 3619 int arr[5]; 3620 int a = 0; 3621 char b = (0); 3622 const int c = a; 3623 int *d = (arr); 3624 long e = ((long) 0l); 3625The matchers 3626 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) 3627 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) 3628would match the declarations for a, b, c, and d, but not e. 3629while 3630 varDecl(hasInitializer(integerLiteral())) 3631 varDecl(hasInitializer(declRefExpr())) 3632would only match the declaration for a. 3633</pre></td></tr> 3634 3635 3636<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> 3637<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has 3638a given body. 3639 3640Given 3641 for (;;) {} 3642hasBody(compoundStmt()) 3643 matches 'for (;;) {}' 3644with compoundStmt() 3645 matching '{}' 3646</pre></td></tr> 3647 3648 3649<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> 3650<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, 3651or conditional operator. 3652 3653Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3654 if (true) {} 3655</pre></td></tr> 3656 3657 3658<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> 3659<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. 3660 3661Example: 3662 forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) 3663matches '++x' in 3664 for (x; x < N; ++x) { } 3665</pre></td></tr> 3666 3667 3668<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> 3669<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. 3670 3671Example: 3672 forStmt(hasLoopInit(declStmt())) 3673matches 'int x = 0' in 3674 for (int x = 0; x < N; ++x) { } 3675</pre></td></tr> 3676 3677 3678<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> 3679<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration. 3680 3681Does not match the 'this' parameter of a method. 3682 3683Given 3684 class X { void f(int x, int y, int z) {} }; 3685methodDecl(hasAnyParameter(hasName("y"))) 3686 matches f(int x, int y, int z) {} 3687with hasAnyParameter(...) 3688 matching int y 3689</pre></td></tr> 3690 3691 3692<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> 3693<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration. 3694 3695Given 3696 class X { void f(int x) {} }; 3697methodDecl(hasParameter(0, hasType(varDecl()))) 3698 matches f(int x) {} 3699with hasParameter(...) 3700 matching int x 3701</pre></td></tr> 3702 3703 3704<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> 3705<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. 3706 3707Given: 3708 class X { int f() { return 1; } }; 3709methodDecl(returns(asString("int"))) 3710 matches int f() { return 1; } 3711</pre></td></tr> 3712 3713 3714<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> 3715<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, 3716or conditional operator. 3717 3718Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3719 if (true) {} 3720</pre></td></tr> 3721 3722 3723<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> 3724<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. 3725 3726Given 3727 if (A* a = GetAPointer()) {} 3728hasConditionVariableStatement(...) 3729 matches 'A* a = GetAPointer()'. 3730</pre></td></tr> 3731 3732 3733<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> 3734<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. 3735 3736Examples matches the if statement 3737 (matcher = ifStmt(hasElse(boolLiteral(equals(true))))) 3738 if (false) false; else true; 3739</pre></td></tr> 3740 3741 3742<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> 3743<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. 3744 3745Examples matches the if statement 3746 (matcher = ifStmt(hasThen(boolLiteral(equals(true))))) 3747 if (false) true; else false; 3748</pre></td></tr> 3749 3750 3751<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> 3752<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given 3753matcher. 3754 3755FIXME: Unit test this matcher 3756</pre></td></tr> 3757 3758 3759<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> 3760<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node 3761matches the given matcher. 3762 3763The associated declaration is: 3764- for type nodes, the declaration of the underlying type 3765- for CallExpr, the declaration of the callee 3766- for MemberExpr, the declaration of the referenced member 3767- for CXXConstructExpr, the declaration of the constructor 3768 3769Also usable as Matcher<T> for any T supporting the getDecl() member 3770function. e.g. various subtypes of clang::Type and various expressions. 3771 3772Usable 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>>, 3773 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>>, 3774 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>>, 3775 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>>, 3776 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>>, 3777 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>> 3778</pre></td></tr> 3779 3780 3781<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> 3782<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node 3783matches the given matcher. 3784 3785The associated declaration is: 3786- for type nodes, the declaration of the underlying type 3787- for CallExpr, the declaration of the callee 3788- for MemberExpr, the declaration of the referenced member 3789- for CXXConstructExpr, the declaration of the constructor 3790 3791Also usable as Matcher<T> for any T supporting the getDecl() member 3792function. e.g. various subtypes of clang::Type and various expressions. 3793 3794Usable 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>>, 3795 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>>, 3796 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>>, 3797 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>>, 3798 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>>, 3799 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>> 3800</pre></td></tr> 3801 3802 3803<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> 3804<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node 3805matches the given matcher. 3806 3807The associated declaration is: 3808- for type nodes, the declaration of the underlying type 3809- for CallExpr, the declaration of the callee 3810- for MemberExpr, the declaration of the referenced member 3811- for CXXConstructExpr, the declaration of the constructor 3812 3813Also usable as Matcher<T> for any T supporting the getDecl() member 3814function. e.g. various subtypes of clang::Type and various expressions. 3815 3816Usable 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>>, 3817 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>>, 3818 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>>, 3819 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>>, 3820 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>>, 3821 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>> 3822</pre></td></tr> 3823 3824 3825<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> 3826<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is 3827matched by a given matcher. 3828 3829Given 3830 struct X { int m; }; 3831 void f(X x) { x.m; m; } 3832memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X"))))))) 3833 matches "x.m" and "m" 3834with hasObjectExpression(...) 3835 matching "x" and the implicit object expression of "m" which has type X*. 3836</pre></td></tr> 3837 3838 3839<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> 3840<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a 3841given matcher. 3842 3843Given 3844 struct { int first, second; } first, second; 3845 int i(second.first); 3846 int j(first.second); 3847memberExpr(member(hasName("first"))) 3848 matches second.first 3849 but not first.second (because the member name there is "second"). 3850</pre></td></tr> 3851 3852 3853<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> 3854<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the 3855pointee matches a given matcher. 3856 3857Given 3858 int *a; 3859 int const *b; 3860 float const *f; 3861pointerType(pointee(isConstQualified(), isInteger())) 3862 matches "int const *b" 3863 3864Usable 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>>, 3865 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>> 3866</pre></td></tr> 3867 3868 3869<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> 3870<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the 3871pointee matches a given matcher. 3872 3873Given 3874 int *a; 3875 int const *b; 3876 float const *f; 3877pointerType(pointee(isConstQualified(), isInteger())) 3878 matches "int const *b" 3879 3880Usable 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>>, 3881 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>> 3882</pre></td></tr> 3883 3884 3885<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> 3886<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. 3887 3888Given 3889 struct A { struct B { struct C {}; }; }; 3890 A::B::C c; 3891nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) 3892 matches "A::" 3893</pre></td></tr> 3894 3895 3896<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> 3897<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the 3898given TypeLoc. 3899 3900Given 3901 struct A { struct B { struct C {}; }; }; 3902 A::B::C c; 3903nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( 3904 hasDeclaration(recordDecl(hasName("A"))))))) 3905 matches "A::" 3906</pre></td></tr> 3907 3908 3909<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> 3910<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. 3911 3912Given 3913 struct A { struct B { struct C {}; }; }; 3914 A::B::C c; 3915nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and 3916 matches "A::" 3917</pre></td></tr> 3918 3919 3920<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> 3921<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the 3922given namespace matcher. 3923 3924Given 3925 namespace ns { struct A {}; } 3926 ns::A a; 3927nestedNameSpecifier(specifiesNamespace(hasName("ns"))) 3928 matches "ns::" 3929</pre></td></tr> 3930 3931 3932<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> 3933<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the 3934given QualType matcher without qualifiers. 3935 3936Given 3937 struct A { struct B { struct C {}; }; }; 3938 A::B::C c; 3939nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A"))))) 3940 matches "A::" 3941</pre></td></tr> 3942 3943 3944<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> 3945<tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor 3946call expression. 3947 3948Example matches y in x(y) 3949 (matcher = callExpr(hasArgument(0, declRefExpr()))) 3950 void x(int) { int y; x(y); } 3951</pre></td></tr> 3952 3953 3954<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> 3955<tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. 3956 3957Example 3958matcher = objCMessageExpr(hasRecieverType(asString("UIWebView *"))); 3959matches the [webView ...] message invocation. 3960 NSString *webViewJavaScript = ... 3961 UIWebView *webView = ... 3962 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; 3963</pre></td></tr> 3964 3965 3966<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> 3967<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. 3968 3969Given 3970 int (*ptr_to_array)[4]; 3971 int (*ptr_to_func)(int); 3972 3973varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches 3974ptr_to_func but not ptr_to_array. 3975 3976Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> 3977</pre></td></tr> 3978 3979 3980<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> 3981<tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the 3982pointee matches a given matcher. 3983 3984Given 3985 int *a; 3986 int const *b; 3987 float const *f; 3988pointerType(pointee(isConstQualified(), isInteger())) 3989 matches "int const *b" 3990 3991Usable 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>>, 3992 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>> 3993</pre></td></tr> 3994 3995 3996<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> 3997<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the 3998pointee matches a given matcher. 3999 4000Given 4001 int *a; 4002 int const *b; 4003 float const *f; 4004pointerType(pointee(isConstQualified(), isInteger())) 4005 matches "int const *b" 4006 4007Usable 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>>, 4008 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>> 4009</pre></td></tr> 4010 4011 4012<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> 4013<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. 4014 4015Given: 4016 typedef int &int_ref; 4017 int a; 4018 int_ref b = a; 4019 4020varDecl(hasType(qualType(referenceType()))))) will not match the 4021declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. 4022</pre></td></tr> 4023 4024 4025<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> 4026<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node 4027matches the given matcher. 4028 4029The associated declaration is: 4030- for type nodes, the declaration of the underlying type 4031- for CallExpr, the declaration of the callee 4032- for MemberExpr, the declaration of the referenced member 4033- for CXXConstructExpr, the declaration of the constructor 4034 4035Also usable as Matcher<T> for any T supporting the getDecl() member 4036function. e.g. various subtypes of clang::Type and various expressions. 4037 4038Usable 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>>, 4039 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>>, 4040 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>>, 4041 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>>, 4042 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>>, 4043 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>> 4044</pre></td></tr> 4045 4046 4047<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> 4048<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. 4049</pre></td></tr> 4050 4051 4052<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> 4053<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type 4054matches the specified matcher. 4055 4056Example matches y->x() 4057 (matcher = memberCallExpr(on(hasType(pointsTo 4058 recordDecl(hasName("Y"))))))) 4059 class Y { public: void x(); }; 4060 void z() { Y *y; y->x(); } 4061</pre></td></tr> 4062 4063 4064<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> 4065<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. 4066</pre></td></tr> 4067 4068 4069<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> 4070<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced 4071type matches the specified matcher. 4072 4073Example matches X &x and const X &y 4074 (matcher = varDecl(hasType(references(recordDecl(hasName("X")))))) 4075 class X { 4076 void a(X b) { 4077 X &x = b; 4078 const X &y = b; 4079 } 4080 }; 4081</pre></td></tr> 4082 4083 4084<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> 4085<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node 4086matches the given matcher. 4087 4088The associated declaration is: 4089- for type nodes, the declaration of the underlying type 4090- for CallExpr, the declaration of the callee 4091- for MemberExpr, the declaration of the referenced member 4092- for CXXConstructExpr, the declaration of the constructor 4093 4094Also usable as Matcher<T> for any T supporting the getDecl() member 4095function. e.g. various subtypes of clang::Type and various expressions. 4096 4097Usable 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>>, 4098 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>>, 4099 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>>, 4100 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>>, 4101 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>>, 4102 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>> 4103</pre></td></tr> 4104 4105 4106<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> 4107<tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the 4108pointee matches a given matcher. 4109 4110Given 4111 int *a; 4112 int const *b; 4113 float const *f; 4114pointerType(pointee(isConstQualified(), isInteger())) 4115 matches "int const *b" 4116 4117Usable 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>>, 4118 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>> 4119</pre></td></tr> 4120 4121 4122<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> 4123<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the 4124pointee matches a given matcher. 4125 4126Given 4127 int *a; 4128 int const *b; 4129 float const *f; 4130pointerType(pointee(isConstQualified(), isInteger())) 4131 matches "int const *b" 4132 4133Usable 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>>, 4134 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>> 4135</pre></td></tr> 4136 4137 4138<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> 4139<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 4140alignof. 4141</pre></td></tr> 4142 4143 4144<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> 4145<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 4146sizeof. 4147</pre></td></tr> 4148 4149 4150<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> 4151<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch 4152statement. This matcher may produce multiple matches. 4153 4154Given 4155 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } 4156switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") 4157 matches four times, with "c" binding each of "case 1:", "case 2:", 4158"case 3:" and "case 4:", and "s" respectively binding "switch (1)", 4159"switch (1)", "switch (2)" and "switch (2)". 4160</pre></td></tr> 4161 4162 4163<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> 4164<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node 4165matches the given matcher. 4166 4167The associated declaration is: 4168- for type nodes, the declaration of the underlying type 4169- for CallExpr, the declaration of the callee 4170- for MemberExpr, the declaration of the referenced member 4171- for CXXConstructExpr, the declaration of the constructor 4172 4173Also usable as Matcher<T> for any T supporting the getDecl() member 4174function. e.g. various subtypes of clang::Type and various expressions. 4175 4176Usable 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>>, 4177 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>>, 4178 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>>, 4179 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>>, 4180 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>>, 4181 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>> 4182</pre></td></tr> 4183 4184 4185<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> 4186<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. 4187 4188Given 4189 template<typename T> struct A {}; 4190 struct B { B* next; }; 4191 A<&B::next> a; 4192templateSpecializationType(hasAnyTemplateArgument( 4193 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) 4194 matches the specialization A<&B::next> with fieldDecl(...) matching 4195 B::next 4196</pre></td></tr> 4197 4198 4199<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> 4200<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain 4201declaration. 4202 4203Given 4204 template<typename T> struct A {}; 4205 struct B { B* next; }; 4206 A<&B::next> a; 4207classTemplateSpecializationDecl(hasAnyTemplateArgument( 4208 refersToDeclaration(fieldDecl(hasName("next")))) 4209 matches the specialization A<&B::next> with fieldDecl(...) matching 4210 B::next 4211</pre></td></tr> 4212 4213 4214<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> 4215<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type. 4216 4217Given 4218 template<int T> struct A {}; 4219 C<42> c; 4220classTemplateSpecializationDecl( 4221 hasAnyTemplateArgument(refersToIntegralType(asString("int")))) 4222 matches the implicit instantiation of C in C<42>. 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('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> 4227<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. 4228 4229Given 4230 struct X {}; 4231 template<typename T> struct A {}; 4232 A<X> a; 4233classTemplateSpecializationDecl(hasAnyTemplateArgument( 4234 refersToType(class(hasName("X"))))) 4235 matches the specialization A<X> 4236</pre></td></tr> 4237 4238 4239<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> 4240<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations that have at least one 4241TemplateArgument matching the given InnerMatcher. 4242 4243Given 4244 template<typename T> class A {}; 4245 template<> class A<double> {}; 4246 A<int> a; 4247classTemplateSpecializationDecl(hasAnyTemplateArgument( 4248 refersToType(asString("int")))) 4249 matches the specialization A<int> 4250</pre></td></tr> 4251 4252 4253<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> 4254<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node 4255matches the given matcher. 4256 4257The associated declaration is: 4258- for type nodes, the declaration of the underlying type 4259- for CallExpr, the declaration of the callee 4260- for MemberExpr, the declaration of the referenced member 4261- for CXXConstructExpr, the declaration of the constructor 4262 4263Also usable as Matcher<T> for any T supporting the getDecl() member 4264function. e.g. various subtypes of clang::Type and various expressions. 4265 4266Usable 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>>, 4267 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>>, 4268 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>>, 4269 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>>, 4270 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>>, 4271 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>> 4272</pre></td></tr> 4273 4274 4275<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> 4276<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument 4277matches the given InnerMatcher. 4278 4279Given 4280 template<typename T, typename U> class A {}; 4281 A<bool, int> b; 4282 A<int, bool> c; 4283classTemplateSpecializationDecl(hasTemplateArgument( 4284 1, refersToType(asString("int")))) 4285 matches the specialization A<bool, int> 4286</pre></td></tr> 4287 4288 4289<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> 4290<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node 4291matches the given matcher. 4292 4293The associated declaration is: 4294- for type nodes, the declaration of the underlying type 4295- for CallExpr, the declaration of the callee 4296- for MemberExpr, the declaration of the referenced member 4297- for CXXConstructExpr, the declaration of the constructor 4298 4299Also usable as Matcher<T> for any T supporting the getDecl() member 4300function. e.g. various subtypes of clang::Type and various expressions. 4301 4302Usable 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>>, 4303 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>>, 4304 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>>, 4305 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>>, 4306 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>>, 4307 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>> 4308</pre></td></tr> 4309 4310 4311<tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<T> Matcher</td></tr> 4312<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. 4313 4314Generates results for each match. 4315 4316For example, in: 4317 class A { class B {}; class C {}; }; 4318The matcher: 4319 recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m"))) 4320will generate results for A, B and C. 4321 4322Usable as: Any Matcher 4323</pre></td></tr> 4324 4325 4326<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> 4327<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node 4328matches the given matcher. 4329 4330The associated declaration is: 4331- for type nodes, the declaration of the underlying type 4332- for CallExpr, the declaration of the callee 4333- for MemberExpr, the declaration of the referenced member 4334- for CXXConstructExpr, the declaration of the constructor 4335 4336Also usable as Matcher<T> for any T supporting the getDecl() member 4337function. e.g. various subtypes of clang::Type and various expressions. 4338 4339Usable 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>>, 4340 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>>, 4341 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>>, 4342 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>>, 4343 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>>, 4344 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>> 4345</pre></td></tr> 4346 4347 4348<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> 4349<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. 4350 4351Given 4352 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); 4353unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) 4354 matches sizeof(a) and alignof(c) 4355</pre></td></tr> 4356 4357 4358<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> 4359<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. 4360 4361Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true)))) 4362 !true 4363</pre></td></tr> 4364 4365 4366<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> 4367<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node 4368matches the given matcher. 4369 4370The associated declaration is: 4371- for type nodes, the declaration of the underlying type 4372- for CallExpr, the declaration of the callee 4373- for MemberExpr, the declaration of the referenced member 4374- for CXXConstructExpr, the declaration of the constructor 4375 4376Also usable as Matcher<T> for any T supporting the getDecl() member 4377function. e.g. various subtypes of clang::Type and various expressions. 4378 4379Usable 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>>, 4380 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>>, 4381 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>>, 4382 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>>, 4383 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>>, 4384 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>> 4385</pre></td></tr> 4386 4387 4388<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> 4389<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. 4390 4391Given 4392 namespace X { void b(); } 4393 using X::b; 4394usingDecl(hasAnyUsingShadowDecl(hasName("b")))) 4395 matches using X::b </pre></td></tr> 4396 4397 4398<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> 4399<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is 4400matched by the given matcher. 4401 4402Given 4403 namespace X { int a; void b(); } 4404 using X::a; 4405 using X::b; 4406usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) 4407 matches using X::b but not using X::a </pre></td></tr> 4408 4409 4410<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> 4411<tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value 4412declaration's type. 4413 4414In case of a value declaration (for example a variable declaration), 4415this resolves one layer of indirection. For example, in the value 4416declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, 4417while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration 4418of x." 4419 4420Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 4421 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 4422 class X {}; 4423 void y(X &x) { x; X z; } 4424 4425Usable 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>> 4426</pre></td></tr> 4427 4428 4429<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> 4430<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type 4431matcher. 4432 4433Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 4434 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 4435 class X {}; 4436 void y(X &x) { x; X z; } 4437</pre></td></tr> 4438 4439 4440<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> 4441<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression 4442that matches the given matcher. 4443 4444Example matches x (matcher = varDecl(hasInitializer(callExpr()))) 4445 bool y() { return true; } 4446 bool x = y(); 4447</pre></td></tr> 4448 4449 4450<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> 4451<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size 4452expression. 4453 4454Given 4455 void f(int b) { 4456 int a[b]; 4457 } 4458variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( 4459 varDecl(hasName("b"))))))) 4460 matches "int a[b]" 4461</pre></td></tr> 4462 4463 4464<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> 4465<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has 4466a given body. 4467 4468Given 4469 for (;;) {} 4470hasBody(compoundStmt()) 4471 matches 'for (;;) {}' 4472with compoundStmt() 4473 matching '{}' 4474</pre></td></tr> 4475 4476 4477<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> 4478<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, 4479or conditional operator. 4480 4481Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 4482 if (true) {} 4483</pre></td></tr> 4484 4485 4486<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> 4487<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner 4488NestedNameSpecifier-matcher matches. 4489</pre></td></tr> 4490 4491 4492<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> 4493<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner 4494QualType-matcher matches. 4495</pre></td></tr> 4496 4497<!--END_TRAVERSAL_MATCHERS --> 4498</table> 4499 4500</div> 4501</body> 4502</html> 4503 4504 4505