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<!-- ======================================================================= --> 61<h2 id="decl-matchers">Node Matchers</h2> 62<!-- ======================================================================= --> 63 64<p>Node matchers are at the core of matcher expressions - they specify the type 65of node that is expected. Every match expression starts with a node matcher, 66which can then be further refined with a narrowing or traversal matcher. All 67traversal matchers take node matchers as their arguments.</p> 68 69<p>For convenience, all node matchers take an arbitrary number of arguments 70and implicitly act as allOf matchers.</p> 71 72<p>Node matchers are the only matchers that support the bind("id") call to 73bind the matched node to the given string, to be later retrieved from the 74match callback.</p> 75 76<table> 77<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 78<!-- START_DECL_MATCHERS --> 79 80<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> 81<tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations. 82 83Example matches Z 84 template<class T> class Z {}; 85</pre></td></tr> 86 87 88<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> 89<tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations. 90 91Given 92 template<typename T> class A {}; 93 template<> class A<double> {}; 94 A<int> a; 95classTemplateSpecializationDecl() 96 matches the specializations A<int> and A<double> 97</pre></td></tr> 98 99 100<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> 101<tr><td colspan="4" class="doc" id="constructorDecl0"><pre>Matches C++ constructor declarations. 102 103Example matches Foo::Foo() and Foo::Foo(int) 104 class Foo { 105 public: 106 Foo(); 107 Foo(int); 108 int DoSomething(); 109 }; 110</pre></td></tr> 111 112 113<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> 114<tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations. 115 116Examples matches X, C, and the friend declaration inside C; 117 void X(); 118 class C { 119 friend X; 120 }; 121</pre></td></tr> 122 123 124<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> 125<tr><td colspan="4" class="doc" id="destructorDecl0"><pre>Matches explicit C++ destructor declarations. 126 127Example matches Foo::~Foo() 128 class Foo { 129 public: 130 virtual ~Foo(); 131 }; 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('enumConstantDecl0')"><a name="enumConstantDecl0Anchor">enumConstantDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumConstantDecl.html">EnumConstantDecl</a>>...</td></tr> 136<tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants. 137 138Example matches A, B, C 139 enum X { 140 A, B, C 141 }; 142</pre></td></tr> 143 144 145<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> 146<tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations. 147 148Example matches X 149 enum X { 150 A, B, C 151 }; 152</pre></td></tr> 153 154 155<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> 156<tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations. 157 158Given 159 class X { int m; }; 160fieldDecl() 161 matches 'm'. 162</pre></td></tr> 163 164 165<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> 166<tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations. 167 168Example matches f 169 void f(); 170</pre></td></tr> 171 172 173<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> 174<tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations. 175 176Example matches f 177 template<class T> void f(T t) {} 178</pre></td></tr> 179 180 181<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> 182<tr><td colspan="4" class="doc" id="methodDecl0"><pre>Matches method declarations. 183 184Example matches y 185 class X { void y() }; 186</pre></td></tr> 187 188 189<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> 190<tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name. 191 192Example matches X, S, the anonymous union type, i, and U; 193 typedef int X; 194 struct S { 195 union { 196 int i; 197 } U; 198 }; 199</pre></td></tr> 200 201 202<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> 203<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches C++ class declarations. 204 205Example matches X, Z 206 class X; 207 template<class T> class Z {}; 208</pre></td></tr> 209 210 211<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('usingDecl0')"><a name="usingDecl0Anchor">usingDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingDecl.html">UsingDecl</a>>...</td></tr> 212<tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations. 213 214Given 215 namespace X { int x; } 216 using X::x; 217usingDecl() 218 matches using X::x </pre></td></tr> 219 220 221<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('varDecl0')"><a name="varDecl0Anchor">varDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>>...</td></tr> 222<tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations. 223 224Note: this does not match declarations of member variables, which are 225"field" declarations in Clang parlance. 226 227Example matches a 228 int a; 229</pre></td></tr> 230 231 232<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> 233<tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. 234 235Given 236 int i = a[1]; 237arraySubscriptExpr() 238 matches "a[1]" 239</pre></td></tr> 240 241 242<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> 243<tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements. 244 245 int i = 100; 246 __asm("mov al, 2"); 247asmStmt() 248 matches '__asm("mov al, 2")' 249</pre></td></tr> 250 251 252<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> 253<tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. 254 255Example matches a || b 256 !(a || b) 257</pre></td></tr> 258 259 260<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> 261<tr><td colspan="4" class="doc" id="bindTemporaryExpr0"><pre>Matches nodes where temporaries are created. 262 263Example matches FunctionTakesString(GetStringByValue()) 264 (matcher = bindTemporaryExpr()) 265 FunctionTakesString(GetStringByValue()); 266 FunctionTakesStringByPointer(GetStringPointer()); 267</pre></td></tr> 268 269 270<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> 271<tr><td colspan="4" class="doc" id="boolLiteral0"><pre>Matches bool literals. 272 273Example matches true 274 true 275</pre></td></tr> 276 277 278<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> 279<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. 280 281Given 282 while (true) { break; } 283breakStmt() 284 matches 'break' 285</pre></td></tr> 286 287 288<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> 289<tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. 290 291Example: Matches (int*) 2.2f in 292 int i = (int) 2.2f; 293</pre></td></tr> 294 295 296<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> 297<tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. 298 299Example matches x.y() and y() 300 X x; 301 x.y(); 302 y(); 303</pre></td></tr> 304 305 306<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> 307<tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. 308 309Example: castExpr() matches each of the following: 310 (int) 3; 311 const_cast<Expr *>(SubExpr); 312 char c = 0; 313but does not match 314 int i = (0); 315 int k = 0; 316</pre></td></tr> 317 318 319<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> 320<tr><td colspan="4" class="doc" id="catchStmt0"><pre>Matches catch statements. 321 322 try {} catch(int i) {} 323catchStmt() 324 matches 'catch(int i)' 325</pre></td></tr> 326 327 328<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> 329<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). 330 331Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), 332though. 333 334Example matches 'a', L'a' 335 char ch = 'a'; wchar_t chw = L'a'; 336</pre></td></tr> 337 338 339<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> 340<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. 341 342Example matches '{}' and '{{}}'in 'for (;;) {{}}' 343 for (;;) {{}} 344</pre></td></tr> 345 346 347<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> 348<tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. 349 350Example matches a ? b : c 351 (a ? b : c) + 42 352</pre></td></tr> 353 354 355<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> 356<tr><td colspan="4" class="doc" id="constCastExpr0"><pre>Matches a const_cast expression. 357 358Example: Matches const_cast<int*>(&r) in 359 int n = 42; 360 const int &r(n); 361 int* p = const_cast<int*>(&r); 362</pre></td></tr> 363 364 365<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> 366<tr><td colspan="4" class="doc" id="constructExpr0"><pre>Matches constructor call expressions (including implicit ones). 367 368Example matches string(ptr, n) and ptr within arguments of f 369 (matcher = constructExpr()) 370 void f(const string &a, const string &b); 371 char *ptr; 372 int n; 373 f(string(ptr, n), ptr); 374</pre></td></tr> 375 376 377<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> 378<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. 379 380Given 381 while (true) { continue; } 382continueStmt() 383 matches 'continue' 384</pre></td></tr> 385 386 387<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> 388<tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. 389 390Example matches x in if (x) 391 bool x; 392 if (x) {} 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('declStmt0')"><a name="declStmt0Anchor">declStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclStmt.html">DeclStmt</a>>...</td></tr> 397<tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. 398 399Given 400 int a; 401declStmt() 402 matches 'int a'. 403</pre></td></tr> 404 405 406<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('defaultArgExpr0')"><a name="defaultArgExpr0Anchor">defaultArgExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>>...</td></tr> 407<tr><td colspan="4" class="doc" id="defaultArgExpr0"><pre>Matches the value of a default argument at the call site. 408 409Example matches the CXXDefaultArgExpr placeholder inserted for the 410 default value of the second parameter in the call expression f(42) 411 (matcher = defaultArgExpr()) 412 void f(int x, int y = 0); 413 f(42); 414</pre></td></tr> 415 416 417<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> 418<tr><td colspan="4" class="doc" id="deleteExpr0"><pre>Matches delete expressions. 419 420Given 421 delete X; 422deleteExpr() 423 matches 'delete X'. 424</pre></td></tr> 425 426 427<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> 428<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. 429 430Given 431 do {} while (true); 432doStmt() 433 matches 'do {} while(true)' 434</pre></td></tr> 435 436 437<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> 438<tr><td colspan="4" class="doc" id="dynamicCastExpr0"><pre>Matches a dynamic_cast expression. 439 440Example: 441 dynamicCastExpr() 442matches 443 dynamic_cast<D*>(&b); 444in 445 struct B { virtual ~B() {} }; struct D : B {}; 446 B b; 447 D* p = dynamic_cast<D*>(&b); 448</pre></td></tr> 449 450 451<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('explicitCastExpr0')"><a name="explicitCastExpr0Anchor">explicitCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ExplicitCastExpr.html">ExplicitCastExpr</a>>...</td></tr> 452<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. 453 454Matches any cast expression written in user code, whether it be a 455C-style cast, a functional-style cast, or a keyword cast. 456 457Does not match implicit conversions. 458 459Note: the name "explicitCast" is chosen to match Clang's terminology, as 460Clang uses the term "cast" to apply to implicit conversions as well as to 461actual cast expressions. 462 463hasDestinationType. 464 465Example: matches all five of the casts in 466 int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) 467but does not match the implicit conversion in 468 long ell = 42; 469</pre></td></tr> 470 471 472<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> 473<tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. 474 475Example matches x() 476 void f() { x(); } 477</pre></td></tr> 478 479 480<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> 481<tr><td colspan="4" class="doc" id="forRangeStmt0"><pre>Matches range-based for statements. 482 483forRangeStmt() matches 'for (auto a : i)' 484 int i[] = {1, 2, 3}; for (auto a : i); 485 for(int j = 0; j < 5; ++j); 486</pre></td></tr> 487 488 489<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> 490<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. 491 492Example matches 'for (;;) {}' 493 for (;;) {} 494 int i[] = {1, 2, 3}; for (auto a : i); 495</pre></td></tr> 496 497 498<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> 499<tr><td colspan="4" class="doc" id="functionalCastExpr0"><pre>Matches functional cast expressions 500 501Example: Matches Foo(bar); 502 Foo f = bar; 503 Foo g = (Foo) bar; 504 Foo h = Foo(bar); 505</pre></td></tr> 506 507 508<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> 509<tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. 510 511Given 512 goto FOO; 513 FOO: bar(); 514gotoStmt() 515 matches 'goto FOO' 516</pre></td></tr> 517 518 519<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('ifStmt0')"><a name="ifStmt0Anchor">ifStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>>...</td></tr> 520<tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. 521 522Example matches 'if (x) {}' 523 if (x) {} 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('implicitCastExpr0')"><a name="implicitCastExpr0Anchor">implicitCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ImplicitCastExpr.html">ImplicitCastExpr</a>>...</td></tr> 528<tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. 529 530This matches many different places, including function call return value 531eliding, as well as any type conversions. 532</pre></td></tr> 533 534 535<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> 536<tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. 537 538Given 539 int a[] = { 1, 2 }; 540 struct B { int x, y; }; 541 B b = { 5, 6 }; 542initList() 543 matches "{ 1, 2 }" and "{ 5, 6 }" 544</pre></td></tr> 545 546 547<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('integerLiteral0')"><a name="integerLiteral0Anchor">integerLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>>...</td></tr> 548<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings. 549 550Not matching character-encoded integers such as L'a'. 551 552Example matches 1, 1L, 0x1, 1U 553</pre></td></tr> 554 555 556<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> 557<tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. 558 559Given 560 goto FOO; 561 FOO: bar(); 562labelStmt() 563 matches 'FOO:' 564</pre></td></tr> 565 566 567<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> 568<tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. 569 570Example matches [&](){return 5;} 571 [&](){return 5;} 572</pre></td></tr> 573 574 575<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> 576<tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. 577 578Example: Given 579 struct T {void func()}; 580 T f(); 581 void g(T); 582materializeTemporaryExpr() matches 'f()' in these statements 583 T u(f()); 584 g(f()); 585but does not match 586 f(); 587 f().func(); 588</pre></td></tr> 589 590 591<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> 592<tr><td colspan="4" class="doc" id="memberCallExpr0"><pre>Matches member call expressions. 593 594Example matches x.y() 595 X x; 596 x.y(); 597</pre></td></tr> 598 599 600<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> 601<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. 602 603Given 604 class Y { 605 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 606 int a; static int b; 607 }; 608memberExpr() 609 matches this->x, x, y.x, a, this->b 610</pre></td></tr> 611 612 613<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> 614<tr><td colspan="4" class="doc" id="newExpr0"><pre>Matches new expressions. 615 616Given 617 new X; 618newExpr() 619 matches 'new X'. 620</pre></td></tr> 621 622 623<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('nullPtrLiteralExpr0')"><a name="nullPtrLiteralExpr0Anchor">nullPtrLiteralExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>>...</td></tr> 624<tr><td colspan="4" class="doc" id="nullPtrLiteralExpr0"><pre>Matches nullptr literal. 625</pre></td></tr> 626 627 628<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> 629<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. 630 631 foo();; 632nullStmt() 633 matches the second ';' 634</pre></td></tr> 635 636 637<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> 638<tr><td colspan="4" class="doc" id="operatorCallExpr0"><pre>Matches overloaded operator calls. 639 640Note that if an operator isn't overloaded, it won't match. Instead, use 641binaryOperator matcher. 642Currently it does not match operators such as new delete. 643FIXME: figure out why these do not match? 644 645Example matches both operator<<((o << b), c) and operator<<(o, b) 646 (matcher = operatorCallExpr()) 647 ostream &operator<< (ostream &out, int i) { }; 648 ostream &o; int b = 1, c = 1; 649 o << b << c; 650</pre></td></tr> 651 652 653<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> 654<tr><td colspan="4" class="doc" id="reinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. 655 656Either the source expression or the destination type can be matched 657using has(), but hasDestinationType() is more specific and can be 658more readable. 659 660Example matches reinterpret_cast<char*>(&p) in 661 void* p = reinterpret_cast<char*>(&p); 662</pre></td></tr> 663 664 665<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> 666<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. 667 668Given 669 return 1; 670returnStmt() 671 matches 'return 1' 672</pre></td></tr> 673 674 675<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> 676<tr><td colspan="4" class="doc" id="staticCastExpr0"><pre>Matches a C++ static_cast expression. 677 678hasDestinationType 679reinterpretCast 680 681Example: 682 staticCastExpr() 683matches 684 static_cast<long>(8) 685in 686 long eight(static_cast<long>(8)); 687</pre></td></tr> 688 689 690<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> 691<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. 692 693Given 694 { ++a; } 695stmt() 696 matches both the compound statement '{ ++a; }' and '++a'. 697</pre></td></tr> 698 699 700<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> 701<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). 702 703Example matches "abcd", L"abcd" 704 char *s = "abcd"; wchar_t *ws = L"abcd" 705</pre></td></tr> 706 707 708<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('switchCase0')"><a name="switchCase0Anchor">switchCase</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>>...</td></tr> 709<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. 710 711Given 712 switch(a) { case 42: break; default: break; } 713switchCase() 714 matches 'case 42: break;' and 'default: break;'. 715</pre></td></tr> 716 717 718<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> 719<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. 720 721Given 722 switch(a) { case 42: break; default: break; } 723switchStmt() 724 matches 'switch(a)'. 725</pre></td></tr> 726 727 728<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> 729<tr><td colspan="4" class="doc" id="thisExpr0"><pre>Matches implicit and explicit this expressions. 730 731Example matches the implicit this expression in "return i". 732 (matcher = thisExpr()) 733struct foo { 734 int i; 735 int f() { return i; } 736}; 737</pre></td></tr> 738 739 740<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> 741<tr><td colspan="4" class="doc" id="throwExpr0"><pre>Matches throw expressions. 742 743 try { throw 5; } catch(int i) {} 744throwExpr() 745 matches 'throw 5' 746</pre></td></tr> 747 748 749<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> 750<tr><td colspan="4" class="doc" id="tryStmt0"><pre>Matches try statements. 751 752 try {} catch(int i) {} 753tryStmt() 754 matches 'try {}' 755</pre></td></tr> 756 757 758<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> 759<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) 760 761Given 762 Foo x = bar; 763 int y = sizeof(x) + alignof(x); 764unaryExprOrTypeTraitExpr() 765 matches sizeof(x) and alignof(x) 766</pre></td></tr> 767 768 769<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> 770<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. 771 772Example matches !a 773 !a || b 774</pre></td></tr> 775 776 777<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> 778<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. 779 780Example match: "foo"_suffix 781</pre></td></tr> 782 783 784<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> 785<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. 786 787Given 788 while (true) {} 789whileStmt() 790 matches 'while (true) {}'. 791</pre></td></tr> 792 793 794<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> 795<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. 796</pre></td></tr> 797 798 799<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> 800<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. 801</pre></td></tr> 802 803<!--END_DECL_MATCHERS --> 804</table> 805 806<!-- ======================================================================= --> 807<h2 id="narrowing-matchers">Narrowing Matchers</h2> 808<!-- ======================================================================= --> 809 810<p>Narrowing matchers match certain attributes on the current node, thus 811narrowing down the set of nodes of the current type to match on.</p> 812 813<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) 814which allow users to create more powerful match expressions.</p> 815 816<table> 817<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 818<!-- START_NARROWING_MATCHERS --> 819 820<tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*> P1, Matcher<*> P2</td></tr> 821<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. 822 823Usable as: Any Matcher 824</pre></td></tr> 825 826 827<tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*> P1, Matcher<*> P2</td></tr> 828<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. 829 830Usable as: Any Matcher 831</pre></td></tr> 832 833 834<tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> 835<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. 836 837Useful when another matcher requires a child matcher, but there's no 838additional constraint. This will often be used with an explicit conversion 839to an internal::Matcher<> type such as TypeMatcher. 840 841Example: DeclarationMatcher(anything()) matches all declarations, e.g., 842"int* p" and "void f()" in 843 int* p; 844 void f(); 845 846Usable as: Any Matcher 847</pre></td></tr> 848 849 850<tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*> InnerMatcher</td></tr> 851<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. 852 853Example matches Y (matcher = recordDecl(unless(hasName("X")))) 854 class X {}; 855 class Y {}; 856 857Usable as: Any Matcher 858</pre></td></tr> 859 860 861<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> 862<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or 863unary). 864 865Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 866 !(a || b) 867</pre></td></tr> 868 869 870<tr><td>Matcher<CXXBoolLiteral></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>ValueT Value</td></tr> 871<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value. 872 873Example matches true (matcher = boolLiteral(equals(true))) 874 true 875 876Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 877 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>> 878</pre></td></tr> 879 880 881<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr> 882<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a constructor declaration that has been implicitly added 883by the compiler (eg. implicit defaultcopy constructors). 884</pre></td></tr> 885 886 887<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> 888<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a contructor initializer if it is explicitly written in 889code (as opposed to implicitly added by the compiler). 890 891Given 892 struct Foo { 893 Foo() { } 894 Foo(int) : foo_("A") { } 895 string foo_; 896 }; 897constructorDecl(hasAnyConstructorInitializer(isWritten())) 898 will match Foo(int), but not Foo() 899</pre></td></tr> 900 901 902<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>std::string Name</td></tr> 903<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. 904 905Matches overloaded operator names specified in strings without the 906"operator" prefix, such as "<<", for OverloadedOperatorCall's. 907 908Example matches a << b 909 (matcher == operatorCallExpr(hasOverloadedOperatorName("<<"))) 910 a << b; 911 c && d; assuming both operator<< 912 and operator&& are overloaded somewhere. 913</pre></td></tr> 914 915 916<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> 917<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). 918</pre></td></tr> 919 920 921<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isExplicitTemplateSpecialization0')"><a name="isExplicitTemplateSpecialization0Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr> 922<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or 923static member variable template instantiations. 924 925Given 926 template<typename T> void A(T t) { } 927 template<> void A(int N) { } 928functionDecl(isExplicitTemplateSpecialization()) 929 matches the specialization A<int>(). 930 931Usable 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>> 932</pre></td></tr> 933 934 935<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> 936<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for 937isSameOrDerivedFrom(hasName(...)). 938</pre></td></tr> 939 940 941<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isTemplateInstantiation0')"><a name="isTemplateInstantiation0Anchor">isTemplateInstantiation</a></td><td></td></tr> 942<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static 943member variable template instantiations. 944 945Given 946 template <typename T> class X {}; class A {}; X<A> x; 947or 948 template <typename T> class X {}; class A {}; template class X<A>; 949recordDecl(hasName("::X"), isTemplateInstantiation()) 950 matches the template instantiation of X<A>. 951 952But given 953 template <typename T> class X {}; class A {}; 954 template <> class X<A> {}; X<A> x; 955recordDecl(hasName("::X"), isTemplateInstantiation()) 956 does not match, as X<A> is an explicit template specialization. 957 958Usable 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>> 959</pre></td></tr> 960 961 962<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> 963<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has 964a specific number of arguments (including absent default arguments). 965 966Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 967 void f(int x, int y); 968 f(0, 0); 969</pre></td></tr> 970 971 972<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> 973<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value. 974 975Example matches true (matcher = boolLiteral(equals(true))) 976 true 977 978Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 979 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>> 980</pre></td></tr> 981 982 983<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> 984<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of 985child statements. 986 987Example: Given 988 { for (;;) {} } 989compoundStmt(statementCountIs(0))) 990 matches '{}' 991 but does not match the outer compound statement. 992</pre></td></tr> 993 994 995<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> 996<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches ConstantArrayType nodes that have the specified size. 997 998Given 999 int a[42]; 1000 int b[2 * 21]; 1001 int c[41], d[43]; 1002constantArrayType(hasSize(42)) 1003 matches "int a[42]" and "int b[2 * 21]" 1004</pre></td></tr> 1005 1006 1007<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> 1008<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of 1009declarations. 1010 1011Example: Given 1012 int a, b; 1013 int c; 1014 int d = 2, e; 1015declCountIs(2) 1016 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. 1017</pre></td></tr> 1018 1019 1020<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> 1021<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value. 1022 1023Example matches true (matcher = boolLiteral(equals(true))) 1024 true 1025 1026Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1027 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>> 1028</pre></td></tr> 1029 1030 1031<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDefinition0')"><a name="isDefinition0Anchor">isDefinition</a></td><td></td></tr> 1032<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. 1033 1034Example matches A, va, fa 1035 class A {}; 1036 class B; Doesn't match, as it has no body. 1037 int va; 1038 extern int vb; Doesn't match, as it doesn't define the variable. 1039 void fa() {} 1040 void fb(); Doesn't match, as it has no body. 1041 1042Usable 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>> 1043</pre></td></tr> 1044 1045 1046<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isExplicitTemplateSpecialization2')"><a name="isExplicitTemplateSpecialization2Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr> 1047<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or 1048static member variable template instantiations. 1049 1050Given 1051 template<typename T> void A(T t) { } 1052 template<> void A(int N) { } 1053functionDecl(isExplicitTemplateSpecialization()) 1054 matches the specialization A<int>(). 1055 1056Usable 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>> 1057</pre></td></tr> 1058 1059 1060<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> 1061<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function declarations. 1062 1063Given: 1064 extern "C" void f() {} 1065 extern "C" { void g() {} } 1066 void h() {} 1067functionDecl(isExternC()) 1068 matches the declaration of f and g, but not the declaration h 1069</pre></td></tr> 1070 1071 1072<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isTemplateInstantiation2')"><a name="isTemplateInstantiation2Anchor">isTemplateInstantiation</a></td><td></td></tr> 1073<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static 1074member variable template instantiations. 1075 1076Given 1077 template <typename T> class X {}; class A {}; X<A> x; 1078or 1079 template <typename T> class X {}; class A {}; template class X<A>; 1080recordDecl(hasName("::X"), isTemplateInstantiation()) 1081 matches the template instantiation of X<A>. 1082 1083But given 1084 template <typename T> class X {}; class A {}; 1085 template <> class X<A> {}; X<A> x; 1086recordDecl(hasName("::X"), isTemplateInstantiation()) 1087 does not match, as X<A> is an explicit template specialization. 1088 1089Usable 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>> 1090</pre></td></tr> 1091 1092 1093<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> 1094<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls that have a specific parameter count. 1095 1096Given 1097 void f(int i) {} 1098 void g(int i, int j) {} 1099functionDecl(parameterCountIs(2)) 1100 matches g(int i, int j) {} 1101</pre></td></tr> 1102 1103 1104<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> 1105<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value. 1106 1107Example matches true (matcher = boolLiteral(equals(true))) 1108 true 1109 1110Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<CXXBoolLiteral>, 1111 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>> 1112</pre></td></tr> 1113 1114 1115<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> 1116<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed 1117to '.'. 1118 1119Member calls on the implicit this pointer match as called with '->'. 1120 1121Given 1122 class Y { 1123 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 1124 int a; 1125 static int b; 1126 }; 1127memberExpr(isArrow()) 1128 matches this->x, x, y.x, a, this->b 1129</pre></td></tr> 1130 1131 1132<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> 1133<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. 1134 1135Supports specifying enclosing namespaces or classes by prefixing the name 1136with '<enclosing>::'. 1137Does not match typedefs of an underlying type with the given name. 1138 1139Example matches X (Name == "X") 1140 class X; 1141 1142Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") 1143 namespace a { namespace b { class X; } } 1144</pre></td></tr> 1145 1146 1147<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> 1148<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose full names partially match the 1149given RegExp. 1150 1151Supports specifying enclosing namespaces or classes by 1152prefixing the name with '<enclosing>::'. Does not match typedefs 1153of an underlying type with the given name. 1154 1155Example matches X (regexp == "::X") 1156 class X; 1157 1158Example matches X (regexp is one of "::X", "^foo::.*X", among others) 1159 namespace foo { namespace bar { class X; } } 1160</pre></td></tr> 1161 1162 1163<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> 1164<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. 1165 1166Given 1167 class Y { public: void x(); }; 1168 void z() { Y* y; y->x(); } 1169callExpr(on(hasType(asString("class Y *")))) 1170 matches y->x() 1171</pre></td></tr> 1172 1173 1174<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> 1175<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that 1176include "top-level" const. 1177 1178Given 1179 void a(int); 1180 void b(int const); 1181 void c(const int); 1182 void d(const int*); 1183 void e(int const) {}; 1184functionDecl(hasAnyParameter(hasType(isConstQualified()))) 1185 matches "void b(int const)", "void c(const int)" and 1186 "void e(int const) {}". It does not match d as there 1187 is no top-level const on the parameter type "const int *". 1188</pre></td></tr> 1189 1190 1191<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> 1192<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. 1193 1194Given 1195 void a(int); 1196 void b(long); 1197 void c(double); 1198functionDecl(hasAnyParameter(hasType(isInteger()))) 1199matches "a(int)", "b(long)", but not "c(double)". 1200</pre></td></tr> 1201 1202 1203<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>></td><td class="name" onclick="toggle('isDefinition2')"><a name="isDefinition2Anchor">isDefinition</a></td><td></td></tr> 1204<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. 1205 1206Example matches A, va, fa 1207 class A {}; 1208 class B; Doesn't match, as it has no body. 1209 int va; 1210 extern int vb; Doesn't match, as it doesn't define the variable. 1211 void fa() {} 1212 void fb(); Doesn't match, as it has no body. 1213 1214Usable 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>> 1215</pre></td></tr> 1216 1217 1218<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> 1219<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. 1220 1221Given 1222 int x; 1223 int s = sizeof(x) + alignof(x) 1224unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) 1225 matches sizeof(x) 1226</pre></td></tr> 1227 1228 1229<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> 1230<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or 1231unary). 1232 1233Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 1234 !(a || b) 1235</pre></td></tr> 1236 1237 1238<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> 1239<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. 1240 1241Example matches A, va, fa 1242 class A {}; 1243 class B; Doesn't match, as it has no body. 1244 int va; 1245 extern int vb; Doesn't match, as it doesn't define the variable. 1246 void fa() {} 1247 void fb(); Doesn't match, as it has no body. 1248 1249Usable 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>> 1250</pre></td></tr> 1251 1252 1253<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> 1254<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or 1255static member variable template instantiations. 1256 1257Given 1258 template<typename T> void A(T t) { } 1259 template<> void A(int N) { } 1260functionDecl(isExplicitTemplateSpecialization()) 1261 matches the specialization A<int>(). 1262 1263Usable 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>> 1264</pre></td></tr> 1265 1266 1267<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> 1268<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static 1269member variable template instantiations. 1270 1271Given 1272 template <typename T> class X {}; class A {}; X<A> x; 1273or 1274 template <typename T> class X {}; class A {}; template class X<A>; 1275recordDecl(hasName("::X"), isTemplateInstantiation()) 1276 matches the template instantiation of X<A>. 1277 1278But given 1279 template <typename T> class X {}; class A {}; 1280 template <> class X<A> {}; X<A> x; 1281recordDecl(hasName("::X"), isTemplateInstantiation()) 1282 does not match, as X<A> is an explicit template specialization. 1283 1284Usable 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>> 1285</pre></td></tr> 1286 1287<!--END_NARROWING_MATCHERS --> 1288</table> 1289 1290<!-- ======================================================================= --> 1291<h2 id="traversal-matchers">AST Traversal Matchers</h2> 1292<!-- ======================================================================= --> 1293 1294<p>Traversal matchers specify the relationship to other nodes that are 1295reachable from the current node.</p> 1296 1297<p>Note that there are special traversal matchers (has, hasDescendant, forEach and 1298forEachDescendant) which work on all nodes and allow users to write more generic 1299match expressions.</p> 1300 1301<table> 1302<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 1303<!-- START_TRAVERSAL_MATCHERS --> 1304 1305<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<ChildT> ChildMatcher</td></tr> 1306<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the 1307provided matcher. 1308 1309Example matches X, Y (matcher = recordDecl(forEach(recordDecl(hasName("X"))) 1310 class X {}; Matches X, because X::X is a class of name X inside X. 1311 class Y { class X {}; }; 1312 class Z { class Y { class X {}; }; }; Does not match Z. 1313 1314ChildT must be an AST base type. 1315 1316As opposed to 'has', 'forEach' will cause a match for each result that 1317matches instead of only on the first one. 1318 1319Usable as: Any Matcher 1320</pre></td></tr> 1321 1322 1323<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<DescendantT> DescendantMatcher</td></tr> 1324<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 1325provided matcher. 1326 1327Example matches X, A, B, C 1328 (matcher = recordDecl(forEachDescendant(recordDecl(hasName("X"))))) 1329 class X {}; Matches X, because X::X is a class of name X inside X. 1330 class A { class X {}; }; 1331 class B { class C { class X {}; }; }; 1332 1333DescendantT must be an AST base type. 1334 1335As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for 1336each result that matches instead of only on the first one. 1337 1338Note: Recursively combined ForEachDescendant can cause many matches: 1339 recordDecl(forEachDescendant(recordDecl(forEachDescendant(recordDecl())))) 1340will match 10 times (plus injected class name matches) on: 1341 class A { class B { class C { class D { class E {}; }; }; }; }; 1342 1343Usable as: Any Matcher 1344</pre></td></tr> 1345 1346 1347<tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<ChildT> ChildMatcher</td></tr> 1348<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the 1349provided matcher. 1350 1351Example matches X, Y (matcher = recordDecl(has(recordDecl(hasName("X"))) 1352 class X {}; Matches X, because X::X is a class of name X inside X. 1353 class Y { class X {}; }; 1354 class Z { class Y { class X {}; }; }; Does not match Z. 1355 1356ChildT must be an AST base type. 1357 1358Usable as: Any Matcher 1359</pre></td></tr> 1360 1361 1362<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<AncestorT> AncestorMatcher</td></tr> 1363<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided 1364matcher. 1365 1366Given 1367void f() { if (true) { int x = 42; } } 1368void g() { for (;;) { int x = 43; } } 1369expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. 1370 1371Usable as: Any Matcher 1372</pre></td></tr> 1373 1374 1375<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<DescendantT> DescendantMatcher</td></tr> 1376<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 1377provided matcher. 1378 1379Example matches X, Y, Z 1380 (matcher = recordDecl(hasDescendant(recordDecl(hasName("X"))))) 1381 class X {}; Matches X, because X::X is a class of name X inside X. 1382 class Y { class X {}; }; 1383 class Z { class Y { class X {}; }; }; 1384 1385DescendantT must be an AST base type. 1386 1387Usable as: Any Matcher 1388</pre></td></tr> 1389 1390 1391<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<ParentT> ParentMatcher</td></tr> 1392<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided 1393matcher. 1394 1395Given 1396void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } 1397compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". 1398 1399Usable as: Any Matcher 1400</pre></td></tr> 1401 1402 1403<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> 1404<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. 1405 1406Given 1407 int i[5]; 1408 void f() { i[1] = 42; } 1409arraySubscriptExpression(hasBase(implicitCastExpr( 1410 hasSourceExpression(declRefExpr())))) 1411 matches i[1] with the declRefExpr() matching i 1412</pre></td></tr> 1413 1414 1415<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> 1416<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. 1417 1418Given 1419 int i[5]; 1420 void f() { i[1] = 42; } 1421arraySubscriptExpression(hasIndex(integerLiteral())) 1422 matches i[1] with the integerLiteral() matching 1 1423</pre></td></tr> 1424 1425 1426<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> 1427<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a 1428binary operator matches. 1429</pre></td></tr> 1430 1431 1432<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> 1433<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. 1434 1435Example matches a (matcher = binaryOperator(hasLHS())) 1436 a || b 1437</pre></td></tr> 1438 1439 1440<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> 1441<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. 1442 1443Example matches b (matcher = binaryOperator(hasRHS())) 1444 a || b 1445</pre></td></tr> 1446 1447 1448<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</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> 1449<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a type if the declaration of the type matches the given 1450matcher. 1451 1452Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, 1453 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>> 1454</pre></td></tr> 1455 1456 1457<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> 1458<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. 1459 1460Given 1461 struct Foo { 1462 Foo() : foo_(1) { } 1463 int foo_; 1464 }; 1465recordDecl(has(constructorDecl(hasAnyConstructorInitializer(anything())))) 1466 record matches Foo, hasAnyConstructorInitializer matches foo_(1) 1467</pre></td></tr> 1468 1469 1470<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> 1471<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. 1472 1473Given 1474 struct Foo { 1475 Foo() : foo_(1) { } 1476 int foo_; 1477 }; 1478recordDecl(has(constructorDecl(hasAnyConstructorInitializer( 1479 forField(hasName("foo_")))))) 1480 matches Foo 1481with forField matching foo_ 1482</pre></td></tr> 1483 1484 1485<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> 1486<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. 1487 1488Given 1489 struct Foo { 1490 Foo() : foo_(1) { } 1491 int foo_; 1492 }; 1493recordDecl(has(constructorDecl(hasAnyConstructorInitializer( 1494 withInitializer(integerLiteral(equals(1))))))) 1495 matches Foo 1496with withInitializer matching (1) 1497</pre></td></tr> 1498 1499 1500<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> 1501<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. 1502 1503Example matches y.x() (matcher = callExpr(on(hasType(recordDecl(hasName("Y")))))) 1504 class Y { public: void x(); }; 1505 void z() { Y y; y.x(); }", 1506 1507FIXME: Overload to allow directly matching types? 1508</pre></td></tr> 1509 1510 1511<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> 1512<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> 1513 1514 1515<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> 1516<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. 1517</pre></td></tr> 1518 1519 1520<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> 1521<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration 1522belongs to. 1523 1524FIXME: Generalize this for other kinds of declarations. 1525FIXME: What other kind of declarations would we need to generalize 1526this to? 1527 1528Example matches A() in the last line 1529 (matcher = constructExpr(hasDeclaration(methodDecl( 1530 ofClass(hasName("A")))))) 1531 class A { 1532 public: 1533 A(); 1534 }; 1535 A a = A(); 1536</pre></td></tr> 1537 1538 1539<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> 1540<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from 1541a class matching Base. 1542 1543Note that a class is not considered to be derived from itself. 1544 1545Example matches Y, Z, C (Base == hasName("X")) 1546 class X; 1547 class Y : public X {}; directly derived 1548 class Z : public Y {}; indirectly derived 1549 typedef X A; 1550 typedef A B; 1551 class C : public B {}; derived from a typedef of X 1552 1553In the following example, Bar matches isDerivedFrom(hasName("X")): 1554 class Foo; 1555 typedef Foo X; 1556 class Bar : public Foo {}; derived from a type that X is a typedef of 1557</pre></td></tr> 1558 1559 1560<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> 1561<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly 1562match Base. 1563</pre></td></tr> 1564 1565 1566<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> 1567<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the 1568given matcher. 1569 1570Example matches y.x() (matcher = callExpr(callee(methodDecl(hasName("x"))))) 1571 class Y { public: void x(); }; 1572 void z() { Y y; y.x(); 1573</pre></td></tr> 1574 1575 1576<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> 1577<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call 1578expression. 1579 1580Given 1581 void x(int, int, int) { int y; x(1, y, 42); } 1582callExpr(hasAnyArgument(declRefExpr())) 1583 matches x(1, y, 42) 1584with hasAnyArgument(...) 1585 matching y 1586</pre></td></tr> 1587 1588 1589<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> 1590<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor 1591call expression. 1592 1593Example matches y in x(y) 1594 (matcher = callExpr(hasArgument(0, declRefExpr()))) 1595 void x(int) { int y; x(y); } 1596</pre></td></tr> 1597 1598 1599<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</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> 1600<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a type if the declaration of the type matches the given 1601matcher. 1602 1603Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, 1604 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>> 1605</pre></td></tr> 1606 1607 1608<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> 1609<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression matches the given matcher. 1610 1611Example: matches "a string" (matcher = 1612 hasSourceExpression(constructExpr())) 1613class URL { URL(string); }; 1614URL url = "a string"; 1615</pre></td></tr> 1616 1617 1618<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> 1619<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations that have at least one 1620TemplateArgument matching the given InnerMatcher. 1621 1622Given 1623 template<typename T> class A {}; 1624 template<> class A<double> {}; 1625 A<int> a; 1626classTemplateSpecializationDecl(hasAnyTemplateArgument( 1627 refersToType(asString("int")))) 1628 matches the specialization A<int> 1629</pre></td></tr> 1630 1631 1632<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> 1633<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations where the n'th TemplateArgument 1634matches the given InnerMatcher. 1635 1636Given 1637 template<typename T, typename U> class A {}; 1638 A<bool, int> b; 1639 A<int, bool> c; 1640classTemplateSpecializationDecl(hasTemplateArgument( 1641 1, refersToType(asString("int")))) 1642 matches the specialization A<bool, int> 1643</pre></td></tr> 1644 1645 1646<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> 1647<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches 1648a given matcher. 1649 1650Given 1651 { {}; 1+2; } 1652hasAnySubstatement(compoundStmt()) 1653 matches '{ {}; 1+2; }' 1654with compoundStmt() 1655 matching '{}' 1656</pre></td></tr> 1657 1658 1659<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> 1660<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, 1661or conditional operator. 1662 1663Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 1664 if (true) {} 1665</pre></td></tr> 1666 1667 1668<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> 1669<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator. 1670 1671Example matches b 1672 condition ? a : b 1673</pre></td></tr> 1674 1675 1676<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> 1677<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. 1678 1679Example matches a 1680 condition ? a : b 1681</pre></td></tr> 1682 1683 1684<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> 1685<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a 1686specific using shadow declaration. 1687 1688FIXME: This currently only works for functions. Fix. 1689 1690Given 1691 namespace a { void f() {} } 1692 using a::f; 1693 void g() { 1694 f(); Matches this .. 1695 a::f(); .. but not this. 1696 } 1697declRefExpr(throughUsingDeclaration(anything())) 1698 matches f() 1699</pre></td></tr> 1700 1701 1702<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> 1703<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the 1704specified matcher. 1705 1706Example matches x in if(x) 1707 (matcher = declRefExpr(to(varDecl(hasName("x"))))) 1708 bool x; 1709 if (x) {} 1710</pre></td></tr> 1711 1712 1713<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> 1714<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. 1715 1716Note that this does not work for global declarations because the AST 1717breaks up multiple-declaration DeclStmt's into multiple single-declaration 1718DeclStmt's. 1719Example: Given non-global declarations 1720 int a, b = 0; 1721 int c; 1722 int d = 2, e; 1723declStmt(containsDeclaration( 1724 0, varDecl(hasInitializer(anything())))) 1725 matches only 'int d = 2, e;', and 1726declStmt(containsDeclaration(1, varDecl())) 1727 matches 'int a, b = 0' as well as 'int d = 2, e;' 1728 but 'int c;' is not matched. 1729</pre></td></tr> 1730 1731 1732<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> 1733<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. 1734 1735Given 1736 int a, b; 1737 int c; 1738declStmt(hasSingleDecl(anything())) 1739 matches 'int c;' but not 'int a, b;'. 1740</pre></td></tr> 1741 1742 1743<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> 1744<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', or 'do while' statement that has 1745a given body. 1746 1747Given 1748 for (;;) {} 1749hasBody(compoundStmt()) 1750 matches 'for (;;) {}' 1751with compoundStmt() 1752 matching '{}' 1753</pre></td></tr> 1754 1755 1756<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> 1757<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, 1758or conditional operator. 1759 1760Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 1761 if (true) {} 1762</pre></td></tr> 1763 1764 1765<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> 1766<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. 1767 1768(Note: Clang's AST refers to other conversions as "casts" too, and calls 1769actual casts "explicit" casts.) 1770</pre></td></tr> 1771 1772 1773<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</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> 1774<tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value 1775declaration's type. 1776 1777In case of a value declaration (for example a variable declaration), 1778this resolves one layer of indirection. For example, in the value 1779declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, 1780while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration 1781of x." 1782 1783Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 1784 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 1785 class X {}; 1786 void y(X &x) { x; X z; } 1787 1788Usable 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>> 1789</pre></td></tr> 1790 1791 1792<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> 1793<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts 1794are stripped off. 1795 1796Parentheses and explicit casts are not discarded. 1797Given 1798 int arr[5]; 1799 int a = 0; 1800 char b = 0; 1801 const int c = a; 1802 int *d = arr; 1803 long e = (long) 0l; 1804The matchers 1805 varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) 1806 varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) 1807would match the declarations for a, b, c, and d, but not e. 1808While 1809 varDecl(hasInitializer(integerLiteral())) 1810 varDecl(hasInitializer(declRefExpr())) 1811only match the declarations for b, c, and d. 1812</pre></td></tr> 1813 1814 1815<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> 1816<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and 1817casts are stripped off. 1818 1819Implicit and non-C Style casts are also discarded. 1820Given 1821 int a = 0; 1822 char b = (0); 1823 void* c = reinterpret_cast<char*>(0); 1824 char d = char(0); 1825The matcher 1826 varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) 1827would match the declarations for a, b, c, and d. 1828while 1829 varDecl(hasInitializer(integerLiteral())) 1830only match the declaration for a. 1831</pre></td></tr> 1832 1833 1834<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> 1835<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and 1836parentheses are stripped off. 1837 1838Explicit casts are not discarded. 1839Given 1840 int arr[5]; 1841 int a = 0; 1842 char b = (0); 1843 const int c = a; 1844 int *d = (arr); 1845 long e = ((long) 0l); 1846The matchers 1847 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) 1848 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) 1849would match the declarations for a, b, c, and d, but not e. 1850while 1851 varDecl(hasInitializer(integerLiteral())) 1852 varDecl(hasInitializer(declRefExpr())) 1853would only match the declaration for a. 1854</pre></td></tr> 1855 1856 1857<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> 1858<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', or 'do while' statement that has 1859a given body. 1860 1861Given 1862 for (;;) {} 1863hasBody(compoundStmt()) 1864 matches 'for (;;) {}' 1865with compoundStmt() 1866 matching '{}' 1867</pre></td></tr> 1868 1869 1870<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> 1871<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, 1872or conditional operator. 1873 1874Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 1875 if (true) {} 1876</pre></td></tr> 1877 1878 1879<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> 1880<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. 1881 1882Example: 1883 forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) 1884matches '++x' in 1885 for (x; x < N; ++x) { } 1886</pre></td></tr> 1887 1888 1889<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> 1890<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. 1891 1892Example: 1893 forStmt(hasLoopInit(declStmt())) 1894matches 'int x = 0' in 1895 for (int x = 0; x < N; ++x) { } 1896</pre></td></tr> 1897 1898 1899<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> 1900<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function declaration. 1901 1902Does not match the 'this' parameter of a method. 1903 1904Given 1905 class X { void f(int x, int y, int z) {} }; 1906methodDecl(hasAnyParameter(hasName("y"))) 1907 matches f(int x, int y, int z) {} 1908with hasAnyParameter(...) 1909 matching int y 1910</pre></td></tr> 1911 1912 1913<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> 1914<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function declaration. 1915 1916Given 1917 class X { void f(int x) {} }; 1918methodDecl(hasParameter(0, hasType(varDecl()))) 1919 matches f(int x) {} 1920with hasParameter(...) 1921 matching int x 1922</pre></td></tr> 1923 1924 1925<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> 1926<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. 1927 1928Given: 1929 class X { int f() { return 1; } }; 1930methodDecl(returns(asString("int"))) 1931 matches int f() { return 1; } 1932</pre></td></tr> 1933 1934 1935<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> 1936<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, 1937or conditional operator. 1938 1939Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 1940 if (true) {} 1941</pre></td></tr> 1942 1943 1944<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> 1945<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. 1946 1947Given 1948 if (A* a = GetAPointer()) {} 1949hasConditionVariableStatment(...) 1950 matches 'A* a = GetAPointer()'. 1951</pre></td></tr> 1952 1953 1954<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> 1955<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given 1956matcher. 1957 1958FIXME: Unit test this matcher 1959</pre></td></tr> 1960 1961 1962<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</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> 1963<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a type if the declaration of the type matches the given 1964matcher. 1965 1966Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, 1967 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>> 1968</pre></td></tr> 1969 1970 1971<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> 1972<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is 1973matched by a given matcher. 1974 1975Given 1976 struct X { int m; }; 1977 void f(X x) { x.m; m; } 1978memberExpr(hasObjectExpression(hasType(recordDecl(hasName("X"))))))) 1979 matches "x.m" and "m" 1980with hasObjectExpression(...) 1981 matching "x" and the implicit object expression of "m" which has type X*. 1982</pre></td></tr> 1983 1984 1985<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> 1986<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a 1987given matcher. 1988 1989Given 1990 struct { int first, second; } first, second; 1991 int i(second.first); 1992 int j(first.second); 1993memberExpr(member(hasName("first"))) 1994 matches second.first 1995 but not first.second (because the member name there is "second"). 1996</pre></td></tr> 1997 1998 1999<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> 2000<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. 2001 2002Given 2003 struct A { struct B { struct C {}; }; }; 2004 A::B::C c; 2005nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) 2006 matches "A::" 2007</pre></td></tr> 2008 2009 2010<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> 2011<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the 2012given TypeLoc. 2013 2014Given 2015 struct A { struct B { struct C {}; }; }; 2016 A::B::C c; 2017nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( 2018 hasDeclaration(recordDecl(hasName("A"))))))) 2019 matches "A::" 2020</pre></td></tr> 2021 2022 2023<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> 2024<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. 2025 2026Given 2027 struct A { struct B { struct C {}; }; }; 2028 A::B::C c; 2029nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and 2030 matches "A::" 2031</pre></td></tr> 2032 2033 2034<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> 2035<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the 2036given namespace matcher. 2037 2038Given 2039 namespace ns { struct A {}; } 2040 ns::A a; 2041nestedNameSpecifier(specifiesNamespace(hasName("ns"))) 2042 matches "ns::" 2043</pre></td></tr> 2044 2045 2046<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> 2047<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the 2048given QualType matcher without qualifiers. 2049 2050Given 2051 struct A { struct B { struct C {}; }; }; 2052 A::B::C c; 2053nestedNameSpecifier(specifiesType(hasDeclaration(recordDecl(hasName("A"))))) 2054 matches "A::" 2055</pre></td></tr> 2056 2057 2058<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</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> 2059<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a type if the declaration of the type matches the given 2060matcher. 2061 2062Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, 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>>, 2063 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>> 2064</pre></td></tr> 2065 2066 2067<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> 2068<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. 2069</pre></td></tr> 2070 2071 2072<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> 2073<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. 2074</pre></td></tr> 2075 2076 2077<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> 2078<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 2079alignof. 2080</pre></td></tr> 2081 2082 2083<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> 2084<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 2085sizeof. 2086</pre></td></tr> 2087 2088 2089<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> 2090<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a TemplateArgument that refers to a certain declaration. 2091 2092Given 2093 template<typename T> struct A {}; 2094 struct B { B* next; }; 2095 A<&B::next> a; 2096classTemplateSpecializationDecl(hasAnyTemplateArgument( 2097 refersToDeclaration(fieldDecl(hasName("next")))) 2098 matches the specialization A<&B::next> with fieldDecl(...) matching 2099 B::next 2100</pre></td></tr> 2101 2102 2103<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> 2104<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. 2105 2106Given 2107 struct X {}; 2108 template<typename T> struct A {}; 2109 A<X> a; 2110classTemplateSpecializationDecl(hasAnyTemplateArgument( 2111 refersToType(class(hasName("X"))))) 2112 matches the specialization A<X> 2113</pre></td></tr> 2114 2115 2116<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>></td><td class="name" onclick="toggle('hasDecl0')"><a name="hasDecl0Anchor">hasDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>> InnerMatcher</td></tr> 2117<tr><td colspan="4" class="doc" id="hasDecl0"><pre>Matches TypedefTypes referring to a specific 2118TypedefNameDecl. 2119</pre></td></tr> 2120 2121 2122<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> 2123<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. 2124 2125Given 2126 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); 2127unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) 2128 matches sizeof(a) and alignof(c) 2129</pre></td></tr> 2130 2131 2132<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> 2133<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. 2134 2135Example matches true (matcher = hasUnaryOperand(boolLiteral(equals(true)))) 2136 !true 2137</pre></td></tr> 2138 2139 2140<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> 2141<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. 2142 2143Given 2144 namespace X { void b(); } 2145 using X::b; 2146usingDecl(hasAnyUsingShadowDecl(hasName("b")))) 2147 matches using X::b </pre></td></tr> 2148 2149 2150<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> 2151<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is 2152matched by the given matcher. 2153 2154Given 2155 namespace X { int a; void b(); } 2156 using X::a; 2157 using X::b; 2158usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) 2159 matches using X::b but not using X::a </pre></td></tr> 2160 2161 2162<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</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> 2163<tr><td colspan="4" class="doc" id="hasType2"><pre>Overloaded to match the declaration of the expression's or value 2164declaration's type. 2165 2166In case of a value declaration (for example a variable declaration), 2167this resolves one layer of indirection. For example, in the value 2168declaration "X x;", recordDecl(hasName("X")) matches the declaration of X, 2169while varDecl(hasType(recordDecl(hasName("X")))) matches the declaration 2170of x." 2171 2172Example matches x (matcher = expr(hasType(recordDecl(hasName("X"))))) 2173 and z (matcher = varDecl(hasType(recordDecl(hasName("X"))))) 2174 class X {}; 2175 void y(X &x) { x; X z; } 2176 2177Usable 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>> 2178</pre></td></tr> 2179 2180 2181<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> 2182<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression 2183that matches the given matcher. 2184 2185Example matches x (matcher = varDecl(hasInitializer(callExpr()))) 2186 bool y() { return true; } 2187 bool x = y(); 2188</pre></td></tr> 2189 2190 2191<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> 2192<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size 2193expression. 2194 2195Given 2196 void f(int b) { 2197 int a[b]; 2198 } 2199variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( 2200 varDecl(hasName("b"))))))) 2201 matches "int a[b]" 2202</pre></td></tr> 2203 2204 2205<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> 2206<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', or 'do while' statement that has 2207a given body. 2208 2209Given 2210 for (;;) {} 2211hasBody(compoundStmt()) 2212 matches 'for (;;) {}' 2213with compoundStmt() 2214 matching '{}' 2215</pre></td></tr> 2216 2217 2218<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> 2219<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, 2220or conditional operator. 2221 2222Example matches true (matcher = hasCondition(boolLiteral(equals(true)))) 2223 if (true) {} 2224</pre></td></tr> 2225 2226<!--END_TRAVERSAL_MATCHERS --> 2227</table> 2228 2229</div> 2230</body> 2231</html> 2232 2233 2234