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 kernel<<<i,j>>>() 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('hasCudaDeviceAttr0')"><a name="hasCudaDeviceAttr0Anchor">hasCudaDeviceAttr</a></td><td></td></tr> 1616<tr><td colspan="4" class="doc" id="hasCudaDeviceAttr0"><pre>Matches declaration that has CUDA device attribute. 1617 1618Given 1619 __attribute__((device)) void f() { ... } 1620matches the function declaration of f. 1621</pre></td></tr> 1622 1623 1624<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('hasCudaGlobalAttr0')"><a name="hasCudaGlobalAttr0Anchor">hasCudaGlobalAttr</a></td><td></td></tr> 1625<tr><td colspan="4" class="doc" id="hasCudaGlobalAttr0"><pre>Matches declaration that has CUDA global attribute. 1626 1627Given 1628 __attribute__((global)) void f() { ... } 1629matches the function declaration of f. 1630</pre></td></tr> 1631 1632 1633<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('hasCudaHostAttr0')"><a name="hasCudaHostAttr0Anchor">hasCudaHostAttr</a></td><td></td></tr> 1634<tr><td colspan="4" class="doc" id="hasCudaHostAttr0"><pre>Matches declaration that has CUDA host attribute. 1635 1636Given 1637 __attribute__((host)) void f() { ... } 1638matches the function declaration of f. 1639</pre></td></tr> 1640 1641 1642<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> 1643<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added 1644by the compiler (eg. implicit defaultcopy constructors). 1645</pre></td></tr> 1646 1647 1648<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> 1649<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. 1650 1651Given 1652 class C { 1653 public: int a; 1654 protected: int b; 1655 private: int c; 1656 }; 1657fieldDecl(isPrivate()) 1658 matches 'int c;' 1659</pre></td></tr> 1660 1661 1662<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> 1663<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. 1664 1665Given 1666 class C { 1667 public: int a; 1668 protected: int b; 1669 private: int c; 1670 }; 1671fieldDecl(isProtected()) 1672 matches 'int b;' 1673</pre></td></tr> 1674 1675 1676<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isPublic0')"><a name="isPublic0Anchor">isPublic</a></td><td></td></tr> 1677<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. 1678 1679Given 1680 class C { 1681 public: int a; 1682 protected: int b; 1683 private: int c; 1684 }; 1685fieldDecl(isPublic()) 1686 matches 'int a;' 1687</pre></td></tr> 1688 1689 1690<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> 1691<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value. 1692 1693Example matches true (matcher = boolLiteral(equals(true))) 1694 true 1695 1696Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1697 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>> 1698</pre></td></tr> 1699 1700 1701<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> 1702<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. 1703 1704Matches overloaded operator names specified in strings without the 1705"operator" prefix: e.g. "<<". 1706 1707Given: 1708 class A { int operator*(); }; 1709 const A &operator<<(const A &a, const A &b); 1710 A a; 1711 a << a; <-- This matches 1712 1713operatorCallExpr(hasOverloadedOperatorName("<<"))) matches the specified 1714line and recordDecl(hasMethod(hasOverloadedOperatorName("*"))) matches 1715the declaration of A. 1716 1717Usable 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>> 1718</pre></td></tr> 1719 1720 1721<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> 1722<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. 1723 1724Example matches A, va, fa 1725 class A {}; 1726 class B; Doesn't match, as it has no body. 1727 int va; 1728 extern int vb; Doesn't match, as it doesn't define the variable. 1729 void fa() {} 1730 void fb(); Doesn't match, as it has no body. 1731 1732Usable 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>> 1733</pre></td></tr> 1734 1735 1736<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> 1737<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or 1738static member variable template instantiations. 1739 1740Given 1741 template<typename T> void A(T t) { } 1742 template<> void A(int N) { } 1743functionDecl(isExplicitTemplateSpecialization()) 1744 matches the specialization A<int>(). 1745 1746Usable 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>> 1747</pre></td></tr> 1748 1749 1750<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> 1751<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations. 1752 1753Given: 1754 extern "C" void f() {} 1755 extern "C" { void g() {} } 1756 void h() {} 1757functionDecl(isExternC()) 1758 matches the declaration of f and g, but not the declaration h 1759</pre></td></tr> 1760 1761 1762<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> 1763<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static 1764member variable template instantiations. 1765 1766Given 1767 template <typename T> class X {}; class A {}; X<A> x; 1768or 1769 template <typename T> class X {}; class A {}; template class X<A>; 1770recordDecl(hasName("::X"), isTemplateInstantiation()) 1771 matches the template instantiation of X<A>. 1772 1773But given 1774 template <typename T> class X {}; class A {}; 1775 template <> class X<A> {}; X<A> x; 1776recordDecl(hasName("::X"), isTemplateInstantiation()) 1777 does not match, as X<A> is an explicit template specialization. 1778 1779Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>> 1780</pre></td></tr> 1781 1782 1783<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('parameterCountIs0')"><a name="parameterCountIs0Anchor">parameterCountIs</a></td><td>unsigned N</td></tr> 1784<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count. 1785 1786Given 1787 void f(int i) {} 1788 void g(int i, int j) {} 1789functionDecl(parameterCountIs(2)) 1790 matches g(int i, int j) {} 1791</pre></td></tr> 1792 1793 1794<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> 1795<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value. 1796 1797Example matches true (matcher = boolLiteral(equals(true))) 1798 true 1799 1800Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1801 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>> 1802</pre></td></tr> 1803 1804 1805<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> 1806<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed 1807to '.'. 1808 1809Member calls on the implicit this pointer match as called with '->'. 1810 1811Given 1812 class Y { 1813 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 1814 int a; 1815 static int b; 1816 }; 1817memberExpr(isArrow()) 1818 matches this->x, x, y.x, a, this->b 1819</pre></td></tr> 1820 1821 1822<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> 1823<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. 1824 1825Supports specifying enclosing namespaces or classes by prefixing the name 1826with '<enclosing>::'. 1827Does not match typedefs of an underlying type with the given name. 1828 1829Example matches X (Name == "X") 1830 class X; 1831 1832Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") 1833 namespace a { namespace b { class X; } } 1834</pre></td></tr> 1835 1836 1837<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> 1838<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain 1839a substring matched by the given RegExp. 1840 1841Supports specifying enclosing namespaces or classes by 1842prefixing the name with '<enclosing>::'. Does not match typedefs 1843of an underlying type with the given name. 1844 1845Example matches X (regexp == "::X") 1846 class X; 1847 1848Example matches X (regexp is one of "::X", "^foo::.*X", among others) 1849 namespace foo { namespace bar { class X; } } 1850</pre></td></tr> 1851 1852 1853<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> 1854<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. 1855 1856Given 1857 class Y { public: void x(); }; 1858 void z() { Y* y; y->x(); } 1859callExpr(on(hasType(asString("class Y *")))) 1860 matches y->x() 1861</pre></td></tr> 1862 1863 1864<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> 1865<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. 1866 1867Matches a node if it equals the node previously bound to ID. 1868 1869Given 1870 class X { int a; int b; }; 1871recordDecl( 1872 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 1873 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 1874 matches the class X, as a and b have the same type. 1875 1876Note that when multiple matches are involved via forEach* matchers, 1877equalsBoundNodes acts as a filter. 1878For example: 1879compoundStmt( 1880 forEachDescendant(varDecl().bind("d")), 1881 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 1882will trigger a match for each combination of variable declaration 1883and reference to that variable declaration within a compound statement. 1884</pre></td></tr> 1885 1886 1887<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> 1888<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to 1889the node, not hidden within a typedef. 1890 1891Given 1892 typedef const int const_int; 1893 const_int i; 1894 int *const j; 1895 int *volatile k; 1896 int m; 1897varDecl(hasType(hasLocalQualifiers())) matches only j and k. 1898i is const-qualified but the qualifier is not local. 1899</pre></td></tr> 1900 1901 1902<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> 1903<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that 1904include "top-level" const. 1905 1906Given 1907 void a(int); 1908 void b(int const); 1909 void c(const int); 1910 void d(const int*); 1911 void e(int const) {}; 1912functionDecl(hasAnyParameter(hasType(isConstQualified()))) 1913 matches "void b(int const)", "void c(const int)" and 1914 "void e(int const) {}". It does not match d as there 1915 is no top-level const on the parameter type "const int *". 1916</pre></td></tr> 1917 1918 1919<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> 1920<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. 1921 1922Given 1923 void a(int); 1924 void b(long); 1925 void c(double); 1926functionDecl(hasAnyParameter(hasType(isInteger()))) 1927matches "a(int)", "b(long)", but not "c(double)". 1928</pre></td></tr> 1929 1930 1931<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> 1932<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. 1933 1934Matches a node if it equals the node previously bound to ID. 1935 1936Given 1937 class X { int a; int b; }; 1938recordDecl( 1939 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 1940 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 1941 matches the class X, as a and b have the same type. 1942 1943Note that when multiple matches are involved via forEach* matchers, 1944equalsBoundNodes acts as a filter. 1945For example: 1946compoundStmt( 1947 forEachDescendant(varDecl().bind("d")), 1948 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 1949will trigger a match for each combination of variable declaration 1950and reference to that variable declaration within a compound statement. 1951</pre></td></tr> 1952 1953 1954<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> 1955<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. 1956 1957Example matches A, va, fa 1958 class A {}; 1959 class B; Doesn't match, as it has no body. 1960 int va; 1961 extern int vb; Doesn't match, as it doesn't define the variable. 1962 void fa() {} 1963 void fb(); Doesn't match, as it has no body. 1964 1965Usable 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>> 1966</pre></td></tr> 1967 1968 1969<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> 1970<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. 1971 1972Matches a node if it equals the node previously bound to ID. 1973 1974Given 1975 class X { int a; int b; }; 1976recordDecl( 1977 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 1978 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 1979 matches the class X, as a and b have the same type. 1980 1981Note that when multiple matches are involved via forEach* matchers, 1982equalsBoundNodes acts as a filter. 1983For example: 1984compoundStmt( 1985 forEachDescendant(varDecl().bind("d")), 1986 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 1987will trigger a match for each combination of variable declaration 1988and reference to that variable declaration within a compound statement. 1989</pre></td></tr> 1990 1991 1992<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> 1993<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. 1994 1995Given 1996 int x; 1997 int s = sizeof(x) + alignof(x) 1998unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) 1999 matches sizeof(x) 2000</pre></td></tr> 2001 2002 2003<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> 2004<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or 2005unary). 2006 2007Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 2008 !(a || b) 2009</pre></td></tr> 2010 2011 2012<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> 2013<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. 2014 2015Example matches y and z (matcher = varDecl(hasGlobalStorage()) 2016void f() { 2017 int x; 2018 static int y; 2019} 2020int z; 2021</pre></td></tr> 2022 2023 2024<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> 2025<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a 2026non-static local variable. 2027 2028Example matches x (matcher = varDecl(hasLocalStorage()) 2029void f() { 2030 int x; 2031 static int y; 2032} 2033int z; 2034</pre></td></tr> 2035 2036 2037<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> 2038<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. 2039 2040Example matches A, va, fa 2041 class A {}; 2042 class B; Doesn't match, as it has no body. 2043 int va; 2044 extern int vb; Doesn't match, as it doesn't define the variable. 2045 void fa() {} 2046 void fb(); Doesn't match, as it has no body. 2047 2048Usable 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>> 2049</pre></td></tr> 2050 2051 2052<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> 2053<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or 2054static member variable template instantiations. 2055 2056Given 2057 template<typename T> void A(T t) { } 2058 template<> void A(int N) { } 2059functionDecl(isExplicitTemplateSpecialization()) 2060 matches the specialization A<int>(). 2061 2062Usable 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>> 2063</pre></td></tr> 2064 2065 2066<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> 2067<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static 2068member variable template instantiations. 2069 2070Given 2071 template <typename T> class X {}; class A {}; X<A> x; 2072or 2073 template <typename T> class X {}; class A {}; template class X<A>; 2074recordDecl(hasName("::X"), isTemplateInstantiation()) 2075 matches the template instantiation of X<A>. 2076 2077But given 2078 template <typename T> class X {}; class A {}; 2079 template <> class X<A> {}; X<A> x; 2080recordDecl(hasName("::X"), isTemplateInstantiation()) 2081 does not match, as X<A> is an explicit template specialization. 2082 2083Usable 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>> 2084</pre></td></tr> 2085 2086<!--END_NARROWING_MATCHERS --> 2087</table> 2088 2089<!-- ======================================================================= --> 2090<h2 id="traversal-matchers">AST Traversal Matchers</h2> 2091<!-- ======================================================================= --> 2092 2093<p>Traversal matchers specify the relationship to other nodes that are 2094reachable from the current node.</p> 2095 2096<p>Note that there are special traversal matchers (has, hasDescendant, forEach and 2097forEachDescendant) which work on all nodes and allow users to write more generic 2098match expressions.</p> 2099 2100<table> 2101<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 2102<!-- START_TRAVERSAL_MATCHERS --> 2103 2104<tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 2105<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. 2106 2107Unlike anyOf, eachOf will generate a match result for each 2108matching submatcher. 2109 2110For example, in: 2111 class A { int a; int b; }; 2112The matcher: 2113 recordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), 2114 has(fieldDecl(hasName("b")).bind("v")))) 2115will generate two results binding "v", the first of which binds 2116the field declaration of a, the second the field declaration of 2117b. 2118 2119Usable as: Any Matcher 2120</pre></td></tr> 2121 2122 2123<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> 2124<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 2125provided matcher. 2126 2127Example matches X, A, B, C 2128 (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X"))))) 2129 class X {}; Matches X, because X::X is a class of name X inside X. 2130 class A { class X {}; }; 2131 class B { class C { class X {}; }; }; 2132 2133DescendantT must be an AST base type. 2134 2135As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for 2136each result that matches instead of only on the first one. 2137 2138Note: Recursively combined ForEachDescendant can cause many matches: 2139 recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl())))) 2140will match 10 times (plus injected class name matches) on: 2141 class A { class B { class C { class D { class E {}; }; }; }; }; 2142 2143Usable as: Any Matcher 2144</pre></td></tr> 2145 2146 2147<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> 2148<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the 2149provided matcher. 2150 2151Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X"))) 2152 class X {}; Matches X, because X::X is a class of name X inside X. 2153 class Y { class X {}; }; 2154 class Z { class Y { class X {}; }; }; Does not match Z. 2155 2156ChildT must be an AST base type. 2157 2158As opposed to 'has', 'forEach' will cause a match for each result that 2159matches instead of only on the first one. 2160 2161Usable as: Any Matcher 2162</pre></td></tr> 2163 2164 2165<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> 2166<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided 2167matcher. 2168 2169Given 2170void f() { if (true) { int x = 42; } } 2171void g() { for (;;) { int x = 43; } } 2172expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. 2173 2174Usable as: Any Matcher 2175</pre></td></tr> 2176 2177 2178<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> 2179<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 2180provided matcher. 2181 2182Example matches X, Y, Z 2183 (matcher = recordDecl(hasDescendant(recordDecl(hasName("X"))))) 2184 class X {}; Matches X, because X::X is a class of name X inside X. 2185 class Y { class X {}; }; 2186 class Z { class Y { class X {}; }; }; 2187 2188DescendantT must be an AST base type. 2189 2190Usable as: Any Matcher 2191</pre></td></tr> 2192 2193 2194<tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> 2195<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the 2196provided matcher. 2197 2198Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X"))) 2199 class X {}; Matches X, because X::X is a class of name X inside X. 2200 class Y { class X {}; }; 2201 class Z { class Y { class X {}; }; }; Does not match Z. 2202 2203ChildT must be an AST base type. 2204 2205Usable as: Any Matcher 2206</pre></td></tr> 2207 2208 2209<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> 2210<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided 2211matcher. 2212 2213Given 2214void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } 2215compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". 2216 2217Usable as: Any Matcher 2218</pre></td></tr> 2219 2220 2221<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> 2222<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. 2223 2224Given 2225 int i[5]; 2226 void f() { i[1] = 42; } 2227arraySubscriptExpression(hasBase(implicitCastExpr( 2228 hasSourceExpression(declRefExpr())))) 2229 matches i[1] with the declRefExpr() matching i 2230</pre></td></tr> 2231 2232 2233<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> 2234<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. 2235 2236Given 2237 int i[5]; 2238 void f() { i[1] = 42; } 2239arraySubscriptExpression(hasIndex(integerLiteral())) 2240 matches i[1] with the integerLiteral() matching 1 2241</pre></td></tr> 2242 2243 2244<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> 2245<tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element 2246type. 2247 2248Given 2249 struct A {}; 2250 A a[7]; 2251 int b[7]; 2252arrayType(hasElementType(builtinType())) 2253 matches "int b[7]" 2254 2255Usable 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>> 2256</pre></td></tr> 2257 2258 2259<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> 2260<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element 2261type. 2262 2263Given 2264 struct A {}; 2265 A a[7]; 2266 int b[7]; 2267arrayType(hasElementType(builtinType())) 2268 matches "int b[7]" 2269 2270Usable 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>> 2271</pre></td></tr> 2272 2273 2274<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> 2275<tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. 2276 2277Given 2278 _Atomic(int) i; 2279 _Atomic(float) f; 2280atomicType(hasValueType(isInteger())) 2281 matches "_Atomic(int) i" 2282 2283Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 2284</pre></td></tr> 2285 2286 2287<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> 2288<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. 2289 2290Given 2291 _Atomic(int) i; 2292 _Atomic(float) f; 2293atomicType(hasValueType(isInteger())) 2294 matches "_Atomic(int) i" 2295 2296Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 2297</pre></td></tr> 2298 2299 2300<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> 2301<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. 2302 2303Note: There is no TypeLoc for the deduced type and thus no 2304getDeducedLoc() matcher. 2305 2306Given 2307 auto a = 1; 2308 auto b = 2.0; 2309autoType(hasDeducedType(isInteger())) 2310 matches "auto a" 2311 2312Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> 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('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> 2317<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a 2318binary operator matches. 2319</pre></td></tr> 2320 2321 2322<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> 2323<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. 2324 2325Example matches a (matcher = binaryOperator(hasLHS())) 2326 a || b 2327</pre></td></tr> 2328 2329 2330<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> 2331<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. 2332 2333Example matches b (matcher = binaryOperator(hasRHS())) 2334 a || b 2335</pre></td></tr> 2336 2337 2338<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> 2339<tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the 2340pointee matches a given matcher. 2341 2342Given 2343 int *a; 2344 int const *b; 2345 float const *f; 2346pointerType(pointee(isConstQualified(), isInteger())) 2347 matches "int const *b" 2348 2349Usable 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>>, 2350 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>> 2351</pre></td></tr> 2352 2353 2354<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> 2355<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the 2356pointee matches a given matcher. 2357 2358Given 2359 int *a; 2360 int const *b; 2361 float const *f; 2362pointerType(pointee(isConstQualified(), isInteger())) 2363 matches "int const *b" 2364 2365Usable 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>>, 2366 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>> 2367</pre></td></tr> 2368 2369 2370<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> 2371<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call 2372expression. 2373 2374Given 2375 void x(int, int, int) { int y; x(1, y, 42); } 2376callExpr(hasAnyArgument(declRefExpr())) 2377 matches x(1, y, 42) 2378with hasAnyArgument(...) 2379 matching y 2380 2381FIXME: Currently this will ignore parentheses and implicit casts on 2382the argument before applying the inner matcher. We'll want to remove 2383this to allow for greater control by the user once ignoreImplicit() 2384has been implemented. 2385</pre></td></tr> 2386 2387 2388<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> 2389<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor 2390call expression. 2391 2392Example matches y in x(y) 2393 (matcher = callExpr(hasArgument(0, declRefExpr()))) 2394 void x(int) { int y; x(y); } 2395</pre></td></tr> 2396 2397 2398<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> 2399<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node 2400matches the given matcher. 2401 2402The associated declaration is: 2403- for type nodes, the declaration of the underlying type 2404- for CallExpr, the declaration of the callee 2405- for MemberExpr, the declaration of the referenced member 2406- for CXXConstructExpr, the declaration of the constructor 2407 2408Also usable as Matcher<T> for any T supporting the getDecl() member 2409function. e.g. various subtypes of clang::Type and various expressions. 2410 2411Usable 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>>, 2412 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>>, 2413 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>>, 2414 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>>, 2415 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>>, 2416 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>> 2417</pre></td></tr> 2418 2419 2420<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> 2421<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. 2422 2423Given 2424 class A { A() : i(42), j(42) {} int i; int j; }; 2425constructorDecl(forEachConstructorInitializer(forField(decl().bind("x")))) 2426 will trigger two matches, binding for 'i' and 'j' respectively. 2427</pre></td></tr> 2428 2429 2430<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> 2431<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. 2432 2433Given 2434 struct Foo { 2435 Foo() : foo_(1) { } 2436 int foo_; 2437 }; 2438recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything())))) 2439 record matches Foo, hasAnyConstructorInitializer matches foo_(1) 2440</pre></td></tr> 2441 2442 2443<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> 2444<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. 2445 2446Given 2447 struct Foo { 2448 Foo() : foo_(1) { } 2449 int foo_; 2450 }; 2451recordDecl(has(constructorDecl(hasAnyConstructorInitializer( 2452 forField(hasName("foo_")))))) 2453 matches Foo 2454with forField matching foo_ 2455</pre></td></tr> 2456 2457 2458<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> 2459<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. 2460 2461Given 2462 struct Foo { 2463 Foo() : foo_(1) { } 2464 int foo_; 2465 }; 2466recordDecl(has(constructorDecl(hasAnyConstructorInitializer( 2467 withInitializer(integerLiteral(equals(1))))))) 2468 matches Foo 2469with withInitializer matching (1) 2470</pre></td></tr> 2471 2472 2473<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> 2474<tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', or 'do while' statement that has 2475a given body. 2476 2477Given 2478 for (;;) {} 2479hasBody(compoundStmt()) 2480 matches 'for (;;) {}' 2481with compoundStmt() 2482 matching '{}' 2483</pre></td></tr> 2484 2485 2486<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> 2487<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. 2488 2489Example: 2490 forStmt(hasLoopVariable(anything())) 2491matches 'int x' in 2492 for (int x : a) { } 2493</pre></td></tr> 2494 2495 2496<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> 2497<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. 2498 2499Example: 2500 forStmt(hasRangeInit(anything())) 2501matches 'a' in 2502 for (int x : a) { } 2503</pre></td></tr> 2504 2505 2506<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> 2507<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> 2508 2509 2510<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> 2511<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. 2512 2513Example matches y.x() (matcher = callExpr(on(hasType(recordDecl(hasName("Y")))))) 2514 class Y { public: void x(); }; 2515 void z() { Y y; y.x(); }", 2516 2517FIXME: Overload to allow directly matching types? 2518</pre></td></tr> 2519 2520 2521<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> 2522<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. 2523</pre></td></tr> 2524 2525 2526<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> 2527<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified 2528matcher, or is a pointer to a type that matches the InnerMatcher. 2529</pre></td></tr> 2530 2531 2532<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> 2533<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration 2534belongs to. 2535 2536FIXME: Generalize this for other kinds of declarations. 2537FIXME: What other kind of declarations would we need to generalize 2538this to? 2539 2540Example matches A() in the last line 2541 (matcher = constructExpr(hasDeclaration(methodDecl( 2542 ofClass(hasName("A")))))) 2543 class A { 2544 public: 2545 A(); 2546 }; 2547 A a = A(); 2548</pre></td></tr> 2549 2550 2551<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> 2552<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. 2553 2554Given: 2555 class A { void func(); }; 2556 class B { void member(); }; 2557 2558recordDecl(hasMethod(hasName("func"))) matches the declaration of A 2559but not B. 2560</pre></td></tr> 2561 2562 2563<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> 2564<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from 2565a class matching Base. 2566 2567Note that a class is not considered to be derived from itself. 2568 2569Example matches Y, Z, C (Base == hasName("X")) 2570 class X; 2571 class Y : public X {}; directly derived 2572 class Z : public Y {}; indirectly derived 2573 typedef X A; 2574 typedef A B; 2575 class C : public B {}; derived from a typedef of X 2576 2577In the following example, Bar matches isDerivedFrom(hasName("X")): 2578 class Foo; 2579 typedef Foo X; 2580 class Bar : public Foo {}; derived from a type that X is a typedef of 2581</pre></td></tr> 2582 2583 2584<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> 2585<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly 2586match Base. 2587</pre></td></tr> 2588 2589 2590<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> 2591<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the 2592given matcher. 2593 2594Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x"))))) 2595 class Y { public: void x(); }; 2596 void z() { Y y; y.x(); } 2597</pre></td></tr> 2598 2599 2600<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> 2601<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. 2602 2603Given 2604 class Y { void x() { this->x(); x(); Y y; y.x(); } }; 2605 void f() { f(); } 2606callExpr(callee(expr())) 2607 matches this->x(), x(), y.x(), f() 2608with callee(...) 2609 matching this->x, x, y.x, f respectively 2610 2611Note: Callee cannot take the more general internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> 2612because this introduces ambiguous overloads with calls to Callee taking a 2613internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely 2614implemented in terms of implicit casts. 2615</pre></td></tr> 2616 2617 2618<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> 2619<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call 2620expression. 2621 2622Given 2623 void x(int, int, int) { int y; x(1, y, 42); } 2624callExpr(hasAnyArgument(declRefExpr())) 2625 matches x(1, y, 42) 2626with hasAnyArgument(...) 2627 matching y 2628 2629FIXME: Currently this will ignore parentheses and implicit casts on 2630the argument before applying the inner matcher. We'll want to remove 2631this to allow for greater control by the user once ignoreImplicit() 2632has been implemented. 2633</pre></td></tr> 2634 2635 2636<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> 2637<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor 2638call expression. 2639 2640Example matches y in x(y) 2641 (matcher = callExpr(hasArgument(0, declRefExpr()))) 2642 void x(int) { int y; x(y); } 2643</pre></td></tr> 2644 2645 2646<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> 2647<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node 2648matches the given matcher. 2649 2650The associated declaration is: 2651- for type nodes, the declaration of the underlying type 2652- for CallExpr, the declaration of the callee 2653- for MemberExpr, the declaration of the referenced member 2654- for CXXConstructExpr, the declaration of the constructor 2655 2656Also usable as Matcher<T> for any T supporting the getDecl() member 2657function. e.g. various subtypes of clang::Type and various expressions. 2658 2659Usable 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>>, 2660 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>>, 2661 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>>, 2662 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>>, 2663 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>>, 2664 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>> 2665</pre></td></tr> 2666 2667 2668<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> 2669<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range 2670extension, matches the constant given in the statement. 2671 2672Given 2673 switch (1) { case 1: case 1+1: case 3 ... 4: ; } 2674caseStmt(hasCaseConstant(integerLiteral())) 2675 matches "case 1:" 2676</pre></td></tr> 2677 2678 2679<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> 2680<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher. 2681 2682Example: matches "a string" (matcher = 2683 hasSourceExpression(constructExpr())) 2684class URL { URL(string); }; 2685URL url = "a string"; 2686</pre></td></tr> 2687 2688 2689<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> 2690<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one 2691TemplateArgument matching the given InnerMatcher. 2692 2693Given 2694 template<typename T> class A {}; 2695 template<> class A<double> {}; 2696 A<int> a; 2697classTemplateSpecializationDecl(hasAnyTemplateArgument( 2698 refersToType(asString("int")))) 2699 matches the specialization A<int> 2700</pre></td></tr> 2701 2702 2703<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> 2704<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument 2705matches the given InnerMatcher. 2706 2707Given 2708 template<typename T, typename U> class A {}; 2709 A<bool, int> b; 2710 A<int, bool> c; 2711classTemplateSpecializationDecl(hasTemplateArgument( 2712 1, refersToType(asString("int")))) 2713 matches the specialization A<bool, int> 2714</pre></td></tr> 2715 2716 2717<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> 2718<tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element 2719type. 2720 2721Given 2722 struct A {}; 2723 A a[7]; 2724 int b[7]; 2725arrayType(hasElementType(builtinType())) 2726 matches "int b[7]" 2727 2728Usable 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>> 2729</pre></td></tr> 2730 2731 2732<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> 2733<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element 2734type. 2735 2736Given 2737 struct A {}; 2738 A a[7]; 2739 int b[7]; 2740arrayType(hasElementType(builtinType())) 2741 matches "int b[7]" 2742 2743Usable 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>> 2744</pre></td></tr> 2745 2746 2747<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> 2748<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches 2749a given matcher. 2750 2751Given 2752 { {}; 1+2; } 2753hasAnySubstatement(compoundStmt()) 2754 matches '{ {}; 1+2; }' 2755with compoundStmt() 2756 matching '{}' 2757</pre></td></tr> 2758 2759 2760<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> 2761<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, 2762or conditional operator. 2763 2764Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 2765 if (true) {} 2766</pre></td></tr> 2767 2768 2769<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> 2770<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator. 2771 2772Example matches b 2773 condition ? a : b 2774</pre></td></tr> 2775 2776 2777<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> 2778<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. 2779 2780Example matches a 2781 condition ? a : b 2782</pre></td></tr> 2783 2784 2785<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> 2786<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node 2787matches the given matcher. 2788 2789The associated declaration is: 2790- for type nodes, the declaration of the underlying type 2791- for CallExpr, the declaration of the callee 2792- for MemberExpr, the declaration of the referenced member 2793- for CXXConstructExpr, the declaration of the constructor 2794 2795Also usable as Matcher<T> for any T supporting the getDecl() member 2796function. e.g. various subtypes of clang::Type and various expressions. 2797 2798Usable 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>>, 2799 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>>, 2800 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>>, 2801 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>>, 2802 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>>, 2803 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>> 2804</pre></td></tr> 2805 2806 2807<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> 2808<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a 2809specific using shadow declaration. 2810 2811FIXME: This currently only works for functions. Fix. 2812 2813Given 2814 namespace a { void f() {} } 2815 using a::f; 2816 void g() { 2817 f(); Matches this .. 2818 a::f(); .. but not this. 2819 } 2820declRefExpr(throughUsingDeclaration(anything())) 2821 matches f() 2822</pre></td></tr> 2823 2824 2825<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> 2826<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the 2827specified matcher. 2828 2829Example matches x in if(x) 2830 (matcher = declRefExpr(to(varDecl(hasName("x"))))) 2831 bool x; 2832 if (x) {} 2833</pre></td></tr> 2834 2835 2836<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> 2837<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. 2838 2839Note that this does not work for global declarations because the AST 2840breaks up multiple-declaration DeclStmt's into multiple single-declaration 2841DeclStmt's. 2842Example: Given non-global declarations 2843 int a, b = 0; 2844 int c; 2845 int d = 2, e; 2846declStmt(containsDeclaration( 2847 0, varDecl(hasInitializer(anything())))) 2848 matches only 'int d = 2, e;', and 2849declStmt(containsDeclaration(1, varDecl())) 2850 matches 'int a, b = 0' as well as 'int d = 2, e;' 2851 but 'int c;' is not matched. 2852</pre></td></tr> 2853 2854 2855<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> 2856<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. 2857 2858Given 2859 int a, b; 2860 int c; 2861declStmt(hasSingleDecl(anything())) 2862 matches 'int c;' but not 'int a, b;'. 2863</pre></td></tr> 2864 2865 2866<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> 2867<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches 2868the inner matcher. 2869 2870Given 2871 int x; 2872declaratorDecl(hasTypeLoc(loc(asString("int")))) 2873 matches int x 2874</pre></td></tr> 2875 2876 2877<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> 2878<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a 2879Decl, matches InnerMatcher. 2880 2881Given 2882 namespace N { 2883 namespace M { 2884 class D {}; 2885 } 2886 } 2887 2888recordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the 2889declaration of class D. 2890</pre></td></tr> 2891 2892 2893<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> 2894<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has 2895a given body. 2896 2897Given 2898 for (;;) {} 2899hasBody(compoundStmt()) 2900 matches 'for (;;) {}' 2901with compoundStmt() 2902 matching '{}' 2903</pre></td></tr> 2904 2905 2906<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> 2907<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, 2908or conditional operator. 2909 2910Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 2911 if (true) {} 2912</pre></td></tr> 2913 2914 2915<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> 2916<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, 2917matches InnerMatcher if the qualifier exists. 2918 2919Given 2920 namespace N { 2921 namespace M { 2922 class D {}; 2923 } 2924 } 2925 N::M::D d; 2926 2927elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) 2928matches the type of the variable declaration of d. 2929</pre></td></tr> 2930 2931 2932<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> 2933<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. 2934 2935Given 2936 namespace N { 2937 namespace M { 2938 class D {}; 2939 } 2940 } 2941 N::M::D d; 2942 2943elaboratedType(namesType(recordType( 2944hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable 2945declaration of d. 2946</pre></td></tr> 2947 2948 2949<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> 2950<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node 2951matches the given matcher. 2952 2953The associated declaration is: 2954- for type nodes, the declaration of the underlying type 2955- for CallExpr, the declaration of the callee 2956- for MemberExpr, the declaration of the referenced member 2957- for CXXConstructExpr, the declaration of the constructor 2958 2959Also usable as Matcher<T> for any T supporting the getDecl() member 2960function. e.g. various subtypes of clang::Type and various expressions. 2961 2962Usable 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>>, 2963 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>>, 2964 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>>, 2965 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>>, 2966 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>>, 2967 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>> 2968</pre></td></tr> 2969 2970 2971<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> 2972<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. 2973 2974(Note: Clang's AST refers to other conversions as "casts" too, and calls 2975actual casts "explicit" casts.) 2976</pre></td></tr> 2977 2978 2979<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> 2980<tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value 2981declaration's type. 2982 2983In case of a value declaration (for example a variable declaration), 2984this resolves one layer of indirection. For example, in the value 2985declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, 2986while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration 2987of x." 2988 2989Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 2990 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 2991 class X {}; 2992 void y(X &x) { x; X z; } 2993 2994Usable 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>> 2995</pre></td></tr> 2996 2997 2998<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> 2999<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type 3000matcher. 3001 3002Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 3003 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 3004 class X {}; 3005 void y(X &x) { x; X z; } 3006</pre></td></tr> 3007 3008 3009<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> 3010<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts 3011are stripped off. 3012 3013Parentheses and explicit casts are not discarded. 3014Given 3015 int arr[5]; 3016 int a = 0; 3017 char b = 0; 3018 const int c = a; 3019 int *d = arr; 3020 long e = (long) 0l; 3021The matchers 3022 varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) 3023 varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) 3024would match the declarations for a, b, c, and d, but not e. 3025While 3026 varDecl(hasInitializer(integerLiteral())) 3027 varDecl(hasInitializer(declRefExpr())) 3028only match the declarations for b, c, and d. 3029</pre></td></tr> 3030 3031 3032<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> 3033<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and 3034casts are stripped off. 3035 3036Implicit and non-C Style casts are also discarded. 3037Given 3038 int a = 0; 3039 char b = (0); 3040 void* c = reinterpret_cast<char*>(0); 3041 char d = char(0); 3042The matcher 3043 varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) 3044would match the declarations for a, b, c, and d. 3045while 3046 varDecl(hasInitializer(integerLiteral())) 3047only match the declaration for a. 3048</pre></td></tr> 3049 3050 3051<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> 3052<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and 3053parentheses are stripped off. 3054 3055Explicit casts are not discarded. 3056Given 3057 int arr[5]; 3058 int a = 0; 3059 char b = (0); 3060 const int c = a; 3061 int *d = (arr); 3062 long e = ((long) 0l); 3063The matchers 3064 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) 3065 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) 3066would match the declarations for a, b, c, and d, but not e. 3067while 3068 varDecl(hasInitializer(integerLiteral())) 3069 varDecl(hasInitializer(declRefExpr())) 3070would only match the declaration for a. 3071</pre></td></tr> 3072 3073 3074<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> 3075<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has 3076a given body. 3077 3078Given 3079 for (;;) {} 3080hasBody(compoundStmt()) 3081 matches 'for (;;) {}' 3082with compoundStmt() 3083 matching '{}' 3084</pre></td></tr> 3085 3086 3087<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> 3088<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, 3089or conditional operator. 3090 3091Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3092 if (true) {} 3093</pre></td></tr> 3094 3095 3096<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> 3097<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. 3098 3099Example: 3100 forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) 3101matches '++x' in 3102 for (x; x < N; ++x) { } 3103</pre></td></tr> 3104 3105 3106<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> 3107<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. 3108 3109Example: 3110 forStmt(hasLoopInit(declStmt())) 3111matches 'int x = 0' in 3112 for (int x = 0; x < N; ++x) { } 3113</pre></td></tr> 3114 3115 3116<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> 3117<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration. 3118 3119Does not match the 'this' parameter of a method. 3120 3121Given 3122 class X { void f(int x, int y, int z) {} }; 3123methodDecl(hasAnyParameter(hasName("y"))) 3124 matches f(int x, int y, int z) {} 3125with hasAnyParameter(...) 3126 matching int y 3127</pre></td></tr> 3128 3129 3130<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> 3131<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration. 3132 3133Given 3134 class X { void f(int x) {} }; 3135methodDecl(hasParameter(0, hasType(varDecl()))) 3136 matches f(int x) {} 3137with hasParameter(...) 3138 matching int x 3139</pre></td></tr> 3140 3141 3142<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> 3143<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. 3144 3145Given: 3146 class X { int f() { return 1; } }; 3147methodDecl(returns(asString("int"))) 3148 matches int f() { return 1; } 3149</pre></td></tr> 3150 3151 3152<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> 3153<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, 3154or conditional operator. 3155 3156Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3157 if (true) {} 3158</pre></td></tr> 3159 3160 3161<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> 3162<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. 3163 3164Given 3165 if (A* a = GetAPointer()) {} 3166hasConditionVariableStatement(...) 3167 matches 'A* a = GetAPointer()'. 3168</pre></td></tr> 3169 3170 3171<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> 3172<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. 3173 3174Examples matches the if statement 3175 (matcher = ifStmt(hasElse(boolLiteral(equals(true))))) 3176 if (false) false; else true; 3177</pre></td></tr> 3178 3179 3180<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> 3181<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. 3182 3183Examples matches the if statement 3184 (matcher = ifStmt(hasThen(boolLiteral(equals(true))))) 3185 if (false) true; else false; 3186</pre></td></tr> 3187 3188 3189<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> 3190<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given 3191matcher. 3192 3193FIXME: Unit test this matcher 3194</pre></td></tr> 3195 3196 3197<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> 3198<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node 3199matches the given matcher. 3200 3201The associated declaration is: 3202- for type nodes, the declaration of the underlying type 3203- for CallExpr, the declaration of the callee 3204- for MemberExpr, the declaration of the referenced member 3205- for CXXConstructExpr, the declaration of the constructor 3206 3207Also usable as Matcher<T> for any T supporting the getDecl() member 3208function. e.g. various subtypes of clang::Type and various expressions. 3209 3210Usable 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>>, 3211 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>>, 3212 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>>, 3213 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>>, 3214 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>>, 3215 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>> 3216</pre></td></tr> 3217 3218 3219<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> 3220<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node 3221matches the given matcher. 3222 3223The associated declaration is: 3224- for type nodes, the declaration of the underlying type 3225- for CallExpr, the declaration of the callee 3226- for MemberExpr, the declaration of the referenced member 3227- for CXXConstructExpr, the declaration of the constructor 3228 3229Also usable as Matcher<T> for any T supporting the getDecl() member 3230function. e.g. various subtypes of clang::Type and various expressions. 3231 3232Usable 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>>, 3233 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>>, 3234 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>>, 3235 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>>, 3236 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>>, 3237 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>> 3238</pre></td></tr> 3239 3240 3241<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> 3242<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node 3243matches the given matcher. 3244 3245The associated declaration is: 3246- for type nodes, the declaration of the underlying type 3247- for CallExpr, the declaration of the callee 3248- for MemberExpr, the declaration of the referenced member 3249- for CXXConstructExpr, the declaration of the constructor 3250 3251Also usable as Matcher<T> for any T supporting the getDecl() member 3252function. e.g. various subtypes of clang::Type and various expressions. 3253 3254Usable 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>>, 3255 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>>, 3256 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>>, 3257 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>>, 3258 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>>, 3259 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>> 3260</pre></td></tr> 3261 3262 3263<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> 3264<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is 3265matched by a given matcher. 3266 3267Given 3268 struct X { int m; }; 3269 void f(X x) { x.m; m; } 3270memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X"))))))) 3271 matches "x.m" and "m" 3272with hasObjectExpression(...) 3273 matching "x" and the implicit object expression of "m" which has type X*. 3274</pre></td></tr> 3275 3276 3277<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> 3278<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a 3279given matcher. 3280 3281Given 3282 struct { int first, second; } first, second; 3283 int i(second.first); 3284 int j(first.second); 3285memberExpr(member(hasName("first"))) 3286 matches second.first 3287 but not first.second (because the member name there is "second"). 3288</pre></td></tr> 3289 3290 3291<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> 3292<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the 3293pointee matches a given matcher. 3294 3295Given 3296 int *a; 3297 int const *b; 3298 float const *f; 3299pointerType(pointee(isConstQualified(), isInteger())) 3300 matches "int const *b" 3301 3302Usable 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>>, 3303 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>> 3304</pre></td></tr> 3305 3306 3307<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> 3308<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the 3309pointee matches a given matcher. 3310 3311Given 3312 int *a; 3313 int const *b; 3314 float const *f; 3315pointerType(pointee(isConstQualified(), isInteger())) 3316 matches "int const *b" 3317 3318Usable 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>>, 3319 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>> 3320</pre></td></tr> 3321 3322 3323<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> 3324<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. 3325 3326Given 3327 struct A { struct B { struct C {}; }; }; 3328 A::B::C c; 3329nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) 3330 matches "A::" 3331</pre></td></tr> 3332 3333 3334<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> 3335<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the 3336given TypeLoc. 3337 3338Given 3339 struct A { struct B { struct C {}; }; }; 3340 A::B::C c; 3341nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( 3342 hasDeclaration(recordDecl(hasName("A"))))))) 3343 matches "A::" 3344</pre></td></tr> 3345 3346 3347<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> 3348<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. 3349 3350Given 3351 struct A { struct B { struct C {}; }; }; 3352 A::B::C c; 3353nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and 3354 matches "A::" 3355</pre></td></tr> 3356 3357 3358<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> 3359<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the 3360given namespace matcher. 3361 3362Given 3363 namespace ns { struct A {}; } 3364 ns::A a; 3365nestedNameSpecifier(specifiesNamespace(hasName("ns"))) 3366 matches "ns::" 3367</pre></td></tr> 3368 3369 3370<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> 3371<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the 3372given QualType matcher without qualifiers. 3373 3374Given 3375 struct A { struct B { struct C {}; }; }; 3376 A::B::C c; 3377nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A"))))) 3378 matches "A::" 3379</pre></td></tr> 3380 3381 3382<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> 3383<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. 3384 3385Given 3386 int (*ptr_to_array)[4]; 3387 int (*ptr_to_func)(int); 3388 3389varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches 3390ptr_to_func but not ptr_to_array. 3391 3392Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> 3393</pre></td></tr> 3394 3395 3396<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> 3397<tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the 3398pointee matches a given matcher. 3399 3400Given 3401 int *a; 3402 int const *b; 3403 float const *f; 3404pointerType(pointee(isConstQualified(), isInteger())) 3405 matches "int const *b" 3406 3407Usable 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>>, 3408 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>> 3409</pre></td></tr> 3410 3411 3412<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> 3413<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the 3414pointee matches a given matcher. 3415 3416Given 3417 int *a; 3418 int const *b; 3419 float const *f; 3420pointerType(pointee(isConstQualified(), isInteger())) 3421 matches "int const *b" 3422 3423Usable 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>>, 3424 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>> 3425</pre></td></tr> 3426 3427 3428<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> 3429<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. 3430 3431Given: 3432 typedef int &int_ref; 3433 int a; 3434 int_ref b = a; 3435 3436varDecl(hasType(qualType(referenceType()))))) will not match the 3437declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. 3438</pre></td></tr> 3439 3440 3441<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> 3442<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node 3443matches the given matcher. 3444 3445The associated declaration is: 3446- for type nodes, the declaration of the underlying type 3447- for CallExpr, the declaration of the callee 3448- for MemberExpr, the declaration of the referenced member 3449- for CXXConstructExpr, the declaration of the constructor 3450 3451Also usable as Matcher<T> for any T supporting the getDecl() member 3452function. e.g. various subtypes of clang::Type and various expressions. 3453 3454Usable 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>>, 3455 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>>, 3456 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>>, 3457 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>>, 3458 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>>, 3459 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>> 3460</pre></td></tr> 3461 3462 3463<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> 3464<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. 3465</pre></td></tr> 3466 3467 3468<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> 3469<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type 3470matches the specified matcher. 3471 3472Example matches y->x() 3473 (matcher = callExpr(on(hasType(pointsTo(recordDecl(hasName("Y"))))))) 3474 class Y { public: void x(); }; 3475 void z() { Y *y; y->x(); } 3476</pre></td></tr> 3477 3478 3479<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> 3480<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. 3481</pre></td></tr> 3482 3483 3484<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> 3485<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced 3486type matches the specified matcher. 3487 3488Example matches X &x and const X &y 3489 (matcher = varDecl(hasType(references(recordDecl(hasName("X")))))) 3490 class X { 3491 void a(X b) { 3492 X &x = b; 3493 const X &y = b; 3494 } 3495 }; 3496</pre></td></tr> 3497 3498 3499<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> 3500<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node 3501matches the given matcher. 3502 3503The associated declaration is: 3504- for type nodes, the declaration of the underlying type 3505- for CallExpr, the declaration of the callee 3506- for MemberExpr, the declaration of the referenced member 3507- for CXXConstructExpr, the declaration of the constructor 3508 3509Also usable as Matcher<T> for any T supporting the getDecl() member 3510function. e.g. various subtypes of clang::Type and various expressions. 3511 3512Usable 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>>, 3513 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>>, 3514 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>>, 3515 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>>, 3516 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>>, 3517 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>> 3518</pre></td></tr> 3519 3520 3521<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> 3522<tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the 3523pointee matches a given matcher. 3524 3525Given 3526 int *a; 3527 int const *b; 3528 float const *f; 3529pointerType(pointee(isConstQualified(), isInteger())) 3530 matches "int const *b" 3531 3532Usable 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>>, 3533 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>> 3534</pre></td></tr> 3535 3536 3537<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> 3538<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the 3539pointee matches a given matcher. 3540 3541Given 3542 int *a; 3543 int const *b; 3544 float const *f; 3545pointerType(pointee(isConstQualified(), isInteger())) 3546 matches "int const *b" 3547 3548Usable 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>>, 3549 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>> 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('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> 3554<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 3555alignof. 3556</pre></td></tr> 3557 3558 3559<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> 3560<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 3561sizeof. 3562</pre></td></tr> 3563 3564 3565<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> 3566<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch 3567statement. This matcher may produce multiple matches. 3568 3569Given 3570 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } 3571switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") 3572 matches four times, with "c" binding each of "case 1:", "case 2:", 3573"case 3:" and "case 4:", and "s" respectively binding "switch (1)", 3574"switch (1)", "switch (2)" and "switch (2)". 3575</pre></td></tr> 3576 3577 3578<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> 3579<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node 3580matches the given matcher. 3581 3582The associated declaration is: 3583- for type nodes, the declaration of the underlying type 3584- for CallExpr, the declaration of the callee 3585- for MemberExpr, the declaration of the referenced member 3586- for CXXConstructExpr, the declaration of the constructor 3587 3588Also usable as Matcher<T> for any T supporting the getDecl() member 3589function. e.g. various subtypes of clang::Type and various expressions. 3590 3591Usable 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>>, 3592 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>>, 3593 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>>, 3594 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>>, 3595 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>>, 3596 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>> 3597</pre></td></tr> 3598 3599 3600<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> 3601<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. 3602 3603Given 3604 template<typename T> struct A {}; 3605 struct B { B* next; }; 3606 A<&B::next> a; 3607templateSpecializationType(hasAnyTemplateArgument( 3608 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) 3609 matches the specialization A<&B::next> with fieldDecl(...) matching 3610 B::next 3611</pre></td></tr> 3612 3613 3614<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> 3615<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain 3616declaration. 3617 3618Given 3619 template<typename T> struct A {}; 3620 struct B { B* next; }; 3621 A<&B::next> a; 3622classTemplateSpecializationDecl(hasAnyTemplateArgument( 3623 refersToDeclaration(fieldDecl(hasName("next")))) 3624 matches the specialization A<&B::next> with fieldDecl(...) matching 3625 B::next 3626</pre></td></tr> 3627 3628 3629<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> 3630<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. 3631 3632Given 3633 struct X {}; 3634 template<typename T> struct A {}; 3635 A<X> a; 3636classTemplateSpecializationDecl(hasAnyTemplateArgument( 3637 refersToType(class(hasName("X"))))) 3638 matches the specialization A<X> 3639</pre></td></tr> 3640 3641 3642<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> 3643<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations that have at least one 3644TemplateArgument matching the given InnerMatcher. 3645 3646Given 3647 template<typename T> class A {}; 3648 template<> class A<double> {}; 3649 A<int> a; 3650classTemplateSpecializationDecl(hasAnyTemplateArgument( 3651 refersToType(asString("int")))) 3652 matches the specialization A<int> 3653</pre></td></tr> 3654 3655 3656<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> 3657<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node 3658matches the given matcher. 3659 3660The associated declaration is: 3661- for type nodes, the declaration of the underlying type 3662- for CallExpr, the declaration of the callee 3663- for MemberExpr, the declaration of the referenced member 3664- for CXXConstructExpr, the declaration of the constructor 3665 3666Also usable as Matcher<T> for any T supporting the getDecl() member 3667function. e.g. various subtypes of clang::Type and various expressions. 3668 3669Usable 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>>, 3670 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>>, 3671 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>>, 3672 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>>, 3673 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>>, 3674 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>> 3675</pre></td></tr> 3676 3677 3678<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> 3679<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument 3680matches the given InnerMatcher. 3681 3682Given 3683 template<typename T, typename U> class A {}; 3684 A<bool, int> b; 3685 A<int, bool> c; 3686classTemplateSpecializationDecl(hasTemplateArgument( 3687 1, refersToType(asString("int")))) 3688 matches the specialization A<bool, int> 3689</pre></td></tr> 3690 3691 3692<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> 3693<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node 3694matches the given matcher. 3695 3696The associated declaration is: 3697- for type nodes, the declaration of the underlying type 3698- for CallExpr, the declaration of the callee 3699- for MemberExpr, the declaration of the referenced member 3700- for CXXConstructExpr, the declaration of the constructor 3701 3702Also usable as Matcher<T> for any T supporting the getDecl() member 3703function. e.g. various subtypes of clang::Type and various expressions. 3704 3705Usable 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>>, 3706 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>>, 3707 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>>, 3708 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>>, 3709 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>>, 3710 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>> 3711</pre></td></tr> 3712 3713 3714<tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>Matcher<T> Matcher</td></tr> 3715<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. 3716 3717Generates results for each match. 3718 3719For example, in: 3720 class A { class B {}; class C {}; }; 3721The matcher: 3722 recordDecl(hasName("::A"), findAll(recordDecl(isDefinition()).bind("m"))) 3723will generate results for A, B and C. 3724 3725Usable as: Any Matcher 3726</pre></td></tr> 3727 3728 3729<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> 3730<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node 3731matches the given matcher. 3732 3733The associated declaration is: 3734- for type nodes, the declaration of the underlying type 3735- for CallExpr, the declaration of the callee 3736- for MemberExpr, the declaration of the referenced member 3737- for CXXConstructExpr, the declaration of the constructor 3738 3739Also usable as Matcher<T> for any T supporting the getDecl() member 3740function. e.g. various subtypes of clang::Type and various expressions. 3741 3742Usable 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>>, 3743 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>>, 3744 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>>, 3745 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>>, 3746 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>>, 3747 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>> 3748</pre></td></tr> 3749 3750 3751<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> 3752<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. 3753 3754Given 3755 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); 3756unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) 3757 matches sizeof(a) and alignof(c) 3758</pre></td></tr> 3759 3760 3761<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> 3762<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. 3763 3764Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true)))) 3765 !true 3766</pre></td></tr> 3767 3768 3769<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> 3770<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node 3771matches the given matcher. 3772 3773The associated declaration is: 3774- for type nodes, the declaration of the underlying type 3775- for CallExpr, the declaration of the callee 3776- for MemberExpr, the declaration of the referenced member 3777- for CXXConstructExpr, the declaration of the constructor 3778 3779Also usable as Matcher<T> for any T supporting the getDecl() member 3780function. e.g. various subtypes of clang::Type and various expressions. 3781 3782Usable 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>>, 3783 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>>, 3784 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>>, 3785 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>>, 3786 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>>, 3787 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>> 3788</pre></td></tr> 3789 3790 3791<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> 3792<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. 3793 3794Given 3795 namespace X { void b(); } 3796 using X::b; 3797usingDecl(hasAnyUsingShadowDecl(hasName("b")))) 3798 matches using X::b </pre></td></tr> 3799 3800 3801<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> 3802<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is 3803matched by the given matcher. 3804 3805Given 3806 namespace X { int a; void b(); } 3807 using X::a; 3808 using X::b; 3809usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) 3810 matches using X::b but not using X::a </pre></td></tr> 3811 3812 3813<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> 3814<tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value 3815declaration's type. 3816 3817In case of a value declaration (for example a variable declaration), 3818this resolves one layer of indirection. For example, in the value 3819declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, 3820while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration 3821of x." 3822 3823Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 3824 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 3825 class X {}; 3826 void y(X &x) { x; X z; } 3827 3828Usable 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>> 3829</pre></td></tr> 3830 3831 3832<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> 3833<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type 3834matcher. 3835 3836Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 3837 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 3838 class X {}; 3839 void y(X &x) { x; X z; } 3840</pre></td></tr> 3841 3842 3843<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> 3844<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression 3845that matches the given matcher. 3846 3847Example matches x (matcher = varDecl(hasInitializer(callExpr()))) 3848 bool y() { return true; } 3849 bool x = y(); 3850</pre></td></tr> 3851 3852 3853<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> 3854<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size 3855expression. 3856 3857Given 3858 void f(int b) { 3859 int a[b]; 3860 } 3861variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( 3862 varDecl(hasName("b"))))))) 3863 matches "int a[b]" 3864</pre></td></tr> 3865 3866 3867<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> 3868<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has 3869a given body. 3870 3871Given 3872 for (;;) {} 3873hasBody(compoundStmt()) 3874 matches 'for (;;) {}' 3875with compoundStmt() 3876 matching '{}' 3877</pre></td></tr> 3878 3879 3880<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> 3881<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, 3882or conditional operator. 3883 3884Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 3885 if (true) {} 3886</pre></td></tr> 3887 3888 3889<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> 3890<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner 3891NestedNameSpecifier-matcher matches. 3892</pre></td></tr> 3893 3894 3895<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> 3896<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner 3897QualType-matcher matches. 3898</pre></td></tr> 3899 3900<!--END_TRAVERSAL_MATCHERS --> 3901</table> 3902 3903</div> 3904</body> 3905</html> 3906 3907 3908