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