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