1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 2 "http://www.w3.org/TR/html4/strict.dtd"> 3<html> 4<head> 5<title>AST Matcher Reference</title> 6<link type="text/css" rel="stylesheet" href="../menu.css" /> 7<link type="text/css" rel="stylesheet" href="../content.css" /> 8<style type="text/css"> 9td { 10 padding: .33em; 11} 12td.doc { 13 display: none; 14 border-bottom: 1px solid black; 15} 16td.name:hover { 17 color: blue; 18 cursor: pointer; 19} 20</style> 21<script type="text/javascript"> 22function toggle(id) { 23 if (!id) return; 24 row = document.getElementById(id); 25 if (row.style.display != 'table-cell') 26 row.style.display = 'table-cell'; 27 else 28 row.style.display = 'none'; 29} 30</script> 31</head> 32<body onLoad="toggle(location.hash.substring(1, location.hash.length - 6))"> 33 34<!--#include virtual="../menu.html.incl"--> 35 36<div id="content"> 37 38<h1>AST Matcher Reference</h1> 39 40<p>This document shows all currently implemented matchers. The matchers are grouped 41by category and node type they match. You can click on matcher names to show the 42matcher's source documentation.</p> 43 44<p>There are three different basic categories of matchers: 45<ul> 46<li><a href="#decl-matchers">Node Matchers:</a> Matchers that match a specific type of AST node.</li> 47<li><a href="#narrowing-matchers">Narrowing Matchers:</a> Matchers that match attributes on AST nodes.</li> 48<li><a href="#traversal-matchers">Traversal Matchers:</a> Matchers that allow traversal between AST nodes.</li> 49</ul> 50</p> 51 52<p>Within each category the matchers are ordered by node type they match on. 53Note that if a matcher can match multiple node types, it will it will appear 54multiple times. This means that by searching for Matcher<Stmt> you can 55find all matchers that can be used to match on Stmt nodes.</p> 56 57<p>The exception to that rule are matchers that can match on any node. Those 58are marked with a * and are listed in the beginning of each category.</p> 59 60<p>Note that the categorization of matchers is a great help when you combine 61them into matcher expressions. You will usually want to form matcher expressions 62that read like english sentences by alternating between node matchers and 63narrowing or traversal matchers, like this: 64<pre> 65recordDecl(hasDescendant( 66 ifStmt(hasTrueExpression( 67 expr(hasDescendant( 68 ifStmt())))))) 69</pre> 70</p> 71 72<!-- ======================================================================= --> 73<h2 id="decl-matchers">Node Matchers</h2> 74<!-- ======================================================================= --> 75 76<p>Node matchers are at the core of matcher expressions - they specify the type 77of node that is expected. Every match expression starts with a node matcher, 78which can then be further refined with a narrowing or traversal matcher. All 79traversal matchers take node matchers as their arguments.</p> 80 81<p>For convenience, all node matchers take an arbitrary number of arguments 82and implicitly act as allOf matchers.</p> 83 84<p>Node matchers are the only matchers that support the bind("id") call to 85bind the matched node to the given string, to be later retrieved from the 86match callback.</p> 87 88<p>It is important to remember that the arguments to node matchers are 89predicates on the same node, just with additional information about the type. 90This is often useful to make matcher expression more readable by inlining bind 91calls into redundant node matchers inside another node matcher: 92<pre> 93// This binds the CXXRecordDecl to "id", as the decl() matcher will stay on 94// the same node. 95recordDecl(decl().bind("id"), hasName("::MyClass")) 96</pre> 97</p> 98 99<table> 100<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 101<!-- START_DECL_MATCHERS --> 102 103<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('cxxCtorInitializer0')"><a name="cxxCtorInitializer0Anchor">cxxCtorInitializer</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>>...</td></tr> 104<tr><td colspan="4" class="doc" id="cxxCtorInitializer0"><pre>Matches constructor initializers. 105 106Examples matches i(42). 107 class C { 108 C() : i(42) {} 109 int i; 110 }; 111</pre></td></tr> 112 113 114<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('accessSpecDecl0')"><a name="accessSpecDecl0Anchor">accessSpecDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AccessSpecDecl.html">AccessSpecDecl</a>>...</td></tr> 115<tr><td colspan="4" class="doc" id="accessSpecDecl0"><pre>Matches C++ access specifier declarations. 116 117Given 118 class C { 119 public: 120 int a; 121 }; 122accessSpecDecl() 123 matches 'public:' 124</pre></td></tr> 125 126 127<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('blockDecl0')"><a name="blockDecl0Anchor">blockDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>>...</td></tr> 128<tr><td colspan="4" class="doc" id="blockDecl0"><pre>Matches block declarations. 129 130Example matches the declaration of the nameless block printing an input 131integer. 132 133 myFunc(^(int p) { 134 printf("%d", p); 135 }) 136</pre></td></tr> 137 138 139<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> 140<tr><td colspan="4" class="doc" id="classTemplateDecl0"><pre>Matches C++ class template declarations. 141 142Example matches Z 143 template<class T> class Z {}; 144</pre></td></tr> 145 146 147<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('classTemplateSpecializationDecl0')"><a name="classTemplateSpecializationDecl0Anchor">classTemplateSpecializationDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>>...</td></tr> 148<tr><td colspan="4" class="doc" id="classTemplateSpecializationDecl0"><pre>Matches C++ class template specializations. 149 150Given 151 template<typename T> class A {}; 152 template<> class A<double> {}; 153 A<int> a; 154classTemplateSpecializationDecl() 155 matches the specializations A<int> and A<double> 156</pre></td></tr> 157 158 159<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxConstructorDecl0')"><a name="cxxConstructorDecl0Anchor">cxxConstructorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>>...</td></tr> 160<tr><td colspan="4" class="doc" id="cxxConstructorDecl0"><pre>Matches C++ constructor declarations. 161 162Example matches Foo::Foo() and Foo::Foo(int) 163 class Foo { 164 public: 165 Foo(); 166 Foo(int); 167 int DoSomething(); 168 }; 169</pre></td></tr> 170 171 172<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxConversionDecl0')"><a name="cxxConversionDecl0Anchor">cxxConversionDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>>...</td></tr> 173<tr><td colspan="4" class="doc" id="cxxConversionDecl0"><pre>Matches conversion operator declarations. 174 175Example matches the operator. 176 class X { operator int() const; }; 177</pre></td></tr> 178 179 180<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxDestructorDecl0')"><a name="cxxDestructorDecl0Anchor">cxxDestructorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDestructorDecl.html">CXXDestructorDecl</a>>...</td></tr> 181<tr><td colspan="4" class="doc" id="cxxDestructorDecl0"><pre>Matches explicit C++ destructor declarations. 182 183Example matches Foo::~Foo() 184 class Foo { 185 public: 186 virtual ~Foo(); 187 }; 188</pre></td></tr> 189 190 191<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxMethodDecl0')"><a name="cxxMethodDecl0Anchor">cxxMethodDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>>...</td></tr> 192<tr><td colspan="4" class="doc" id="cxxMethodDecl0"><pre>Matches method declarations. 193 194Example matches y 195 class X { void y(); }; 196</pre></td></tr> 197 198 199<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('cxxRecordDecl0')"><a name="cxxRecordDecl0Anchor">cxxRecordDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>>...</td></tr> 200<tr><td colspan="4" class="doc" id="cxxRecordDecl0"><pre>Matches C++ class declarations. 201 202Example matches X, Z 203 class X; 204 template<class T> class Z {}; 205</pre></td></tr> 206 207 208<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> 209<tr><td colspan="4" class="doc" id="decl0"><pre>Matches declarations. 210 211Examples matches X, C, and the friend declaration inside C; 212 void X(); 213 class C { 214 friend X; 215 }; 216</pre></td></tr> 217 218 219<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('declaratorDecl0')"><a name="declaratorDecl0Anchor">declaratorDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>>...</td></tr> 220<tr><td colspan="4" class="doc" id="declaratorDecl0"><pre>Matches declarator declarations (field, variable, function 221and non-type template parameter declarations). 222 223Given 224 class X { int y; }; 225declaratorDecl() 226 matches int y. 227</pre></td></tr> 228 229 230<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> 231<tr><td colspan="4" class="doc" id="enumConstantDecl0"><pre>Matches enum constants. 232 233Example matches A, B, C 234 enum X { 235 A, B, C 236 }; 237</pre></td></tr> 238 239 240<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> 241<tr><td colspan="4" class="doc" id="enumDecl0"><pre>Matches enum declarations. 242 243Example matches X 244 enum X { 245 A, B, C 246 }; 247</pre></td></tr> 248 249 250<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> 251<tr><td colspan="4" class="doc" id="fieldDecl0"><pre>Matches field declarations. 252 253Given 254 class X { int m; }; 255fieldDecl() 256 matches 'm'. 257</pre></td></tr> 258 259 260<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('friendDecl0')"><a name="friendDecl0Anchor">friendDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FriendDecl.html">FriendDecl</a>>...</td></tr> 261<tr><td colspan="4" class="doc" id="friendDecl0"><pre>Matches friend declarations. 262 263Given 264 class X { friend void foo(); }; 265friendDecl() 266 matches 'friend void foo()'. 267</pre></td></tr> 268 269 270<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('functionDecl0')"><a name="functionDecl0Anchor">functionDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>>...</td></tr> 271<tr><td colspan="4" class="doc" id="functionDecl0"><pre>Matches function declarations. 272 273Example matches f 274 void f(); 275</pre></td></tr> 276 277 278<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> 279<tr><td colspan="4" class="doc" id="functionTemplateDecl0"><pre>Matches C++ function template declarations. 280 281Example matches f 282 template<class T> void f(T t) {} 283</pre></td></tr> 284 285 286<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('labelDecl0')"><a name="labelDecl0Anchor">labelDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelDecl.html">LabelDecl</a>>...</td></tr> 287<tr><td colspan="4" class="doc" id="labelDecl0"><pre>Matches a declaration of label. 288 289Given 290 goto FOO; 291 FOO: bar(); 292labelDecl() 293 matches 'FOO:' 294</pre></td></tr> 295 296 297<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('linkageSpecDecl0')"><a name="linkageSpecDecl0Anchor">linkageSpecDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LinkageSpecDecl.html">LinkageSpecDecl</a>>...</td></tr> 298<tr><td colspan="4" class="doc" id="linkageSpecDecl0"><pre>Matches a declaration of a linkage specification. 299 300Given 301 extern "C" {} 302linkageSpecDecl() 303 matches "extern "C" {}" 304</pre></td></tr> 305 306 307<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> 308<tr><td colspan="4" class="doc" id="namedDecl0"><pre>Matches a declaration of anything that could have a name. 309 310Example matches X, S, the anonymous union type, i, and U; 311 typedef int X; 312 struct S { 313 union { 314 int i; 315 } U; 316 }; 317</pre></td></tr> 318 319 320<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('namespaceAliasDecl0')"><a name="namespaceAliasDecl0Anchor">namespaceAliasDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceAliasDecl.html">NamespaceAliasDecl</a>>...</td></tr> 321<tr><td colspan="4" class="doc" id="namespaceAliasDecl0"><pre>Matches a declaration of a namespace alias. 322 323Given 324 namespace test {} 325 namespace alias = ::test; 326namespaceAliasDecl() 327 matches "namespace alias" but not "namespace test" 328</pre></td></tr> 329 330 331<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('namespaceDecl0')"><a name="namespaceDecl0Anchor">namespaceDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>>...</td></tr> 332<tr><td colspan="4" class="doc" id="namespaceDecl0"><pre>Matches a declaration of a namespace. 333 334Given 335 namespace {} 336 namespace test {} 337namespaceDecl() 338 matches "namespace {}" and "namespace test {}" 339</pre></td></tr> 340 341 342<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('nonTypeTemplateParmDecl0')"><a name="nonTypeTemplateParmDecl0Anchor">nonTypeTemplateParmDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NonTypeTemplateParmDecl.html">NonTypeTemplateParmDecl</a>>...</td></tr> 343<tr><td colspan="4" class="doc" id="nonTypeTemplateParmDecl0"><pre>Matches non-type template parameter declarations. 344 345Given 346 template <typename T, int N> struct C {}; 347nonTypeTemplateParmDecl() 348 matches 'N', but not 'T'. 349</pre></td></tr> 350 351 352<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcCategoryDecl0')"><a name="objcCategoryDecl0Anchor">objcCategoryDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryDecl.html">ObjCCategoryDecl</a>>...</td></tr> 353<tr><td colspan="4" class="doc" id="objcCategoryDecl0"><pre>Matches Objective-C category declarations. 354 355Example matches Foo (Additions) 356 @interface Foo (Additions) 357 @end 358</pre></td></tr> 359 360 361<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcCategoryImplDecl0')"><a name="objcCategoryImplDecl0Anchor">objcCategoryImplDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCCategoryImplDecl.html">ObjCCategoryImplDecl</a>>...</td></tr> 362<tr><td colspan="4" class="doc" id="objcCategoryImplDecl0"><pre>Matches Objective-C category definitions. 363 364Example matches Foo (Additions) 365 @implementation Foo (Additions) 366 @end 367</pre></td></tr> 368 369 370<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcImplementationDecl0')"><a name="objcImplementationDecl0Anchor">objcImplementationDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCImplementationDecl.html">ObjCImplementationDecl</a>>...</td></tr> 371<tr><td colspan="4" class="doc" id="objcImplementationDecl0"><pre>Matches Objective-C implementation declarations. 372 373Example matches Foo 374 @implementation Foo 375 @end 376</pre></td></tr> 377 378 379<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcInterfaceDecl0')"><a name="objcInterfaceDecl0Anchor">objcInterfaceDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCInterfaceDecl.html">ObjCInterfaceDecl</a>>...</td></tr> 380<tr><td colspan="4" class="doc" id="objcInterfaceDecl0"><pre>Matches Objective-C interface declarations. 381 382Example matches Foo 383 @interface Foo 384 @end 385</pre></td></tr> 386 387 388<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcIvarDecl0')"><a name="objcIvarDecl0Anchor">objcIvarDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCIvarDecl.html">ObjCIvarDecl</a>>...</td></tr> 389<tr><td colspan="4" class="doc" id="objcIvarDecl0"><pre>Matches Objective-C instance variable declarations. 390 391Example matches _enabled 392 @implementation Foo { 393 BOOL _enabled; 394 } 395 @end 396</pre></td></tr> 397 398 399<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcMethodDecl0')"><a name="objcMethodDecl0Anchor">objcMethodDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>>...</td></tr> 400<tr><td colspan="4" class="doc" id="objcMethodDecl0"><pre>Matches Objective-C method declarations. 401 402Example matches both declaration and definition of -[Foo method] 403 @interface Foo 404 - (void)method; 405 @end 406 407 @implementation Foo 408 - (void)method {} 409 @end 410</pre></td></tr> 411 412 413<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcPropertyDecl0')"><a name="objcPropertyDecl0Anchor">objcPropertyDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCPropertyDecl.html">ObjCPropertyDecl</a>>...</td></tr> 414<tr><td colspan="4" class="doc" id="objcPropertyDecl0"><pre>Matches Objective-C property declarations. 415 416Example matches enabled 417 @interface Foo 418 @property BOOL enabled; 419 @end 420</pre></td></tr> 421 422 423<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('objcProtocolDecl0')"><a name="objcProtocolDecl0Anchor">objcProtocolDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCProtocolDecl.html">ObjCProtocolDecl</a>>...</td></tr> 424<tr><td colspan="4" class="doc" id="objcProtocolDecl0"><pre>Matches Objective-C protocol declarations. 425 426Example matches FooDelegate 427 @protocol FooDelegate 428 @end 429</pre></td></tr> 430 431 432<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('parmVarDecl0')"><a name="parmVarDecl0Anchor">parmVarDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>>...</td></tr> 433<tr><td colspan="4" class="doc" id="parmVarDecl0"><pre>Matches parameter variable declarations. 434 435Given 436 void f(int x); 437parmVarDecl() 438 matches int x. 439</pre></td></tr> 440 441 442<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_1RecordDecl.html">RecordDecl</a>>...</td></tr> 443<tr><td colspan="4" class="doc" id="recordDecl0"><pre>Matches class, struct, and union declarations. 444 445Example matches X, Z, U, and S 446 class X; 447 template<class T> class Z {}; 448 struct S {}; 449 union U {}; 450</pre></td></tr> 451 452 453<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('staticAssertDecl0')"><a name="staticAssertDecl0Anchor">staticAssertDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StaticAssertDecl.html">StaticAssertDecl</a>>...</td></tr> 454<tr><td colspan="4" class="doc" id="staticAssertDecl0"><pre>Matches a C++ static_assert declaration. 455 456Example: 457 staticAssertExpr() 458matches 459 static_assert(sizeof(S) == sizeof(int)) 460in 461 struct S { 462 int x; 463 }; 464 static_assert(sizeof(S) == sizeof(int)); 465</pre></td></tr> 466 467 468<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('templateTypeParmDecl0')"><a name="templateTypeParmDecl0Anchor">templateTypeParmDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmDecl.html">TemplateTypeParmDecl</a>>...</td></tr> 469<tr><td colspan="4" class="doc" id="templateTypeParmDecl0"><pre>Matches template type parameter declarations. 470 471Given 472 template <typename T, int N> struct C {}; 473templateTypeParmDecl() 474 matches 'T', but not 'N'. 475</pre></td></tr> 476 477 478<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('translationUnitDecl0')"><a name="translationUnitDecl0Anchor">translationUnitDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TranslationUnitDecl.html">TranslationUnitDecl</a>>...</td></tr> 479<tr><td colspan="4" class="doc" id="translationUnitDecl0"><pre>Matches the top declaration context. 480 481Given 482 int X; 483 namespace NS { 484 int Y; 485 } namespace NS 486decl(hasDeclContext(translationUnitDecl())) 487 matches "int X", but not "int Y". 488</pre></td></tr> 489 490 491<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('typeAliasDecl0')"><a name="typeAliasDecl0Anchor">typeAliasDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeAliasDecl.html">TypeAliasDecl</a>>...</td></tr> 492<tr><td colspan="4" class="doc" id="typeAliasDecl0"><pre>Matches type alias declarations. 493 494Given 495 typedef int X; 496 using Y = int; 497typeAliasDecl() 498 matches "using Y = int", but not "typedef int X" 499</pre></td></tr> 500 501 502<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('typeAliasTemplateDecl0')"><a name="typeAliasTemplateDecl0Anchor">typeAliasTemplateDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeAliasTemplateDecl.html">TypeAliasTemplateDecl</a>>...</td></tr> 503<tr><td colspan="4" class="doc" id="typeAliasTemplateDecl0"><pre>Matches type alias template declarations. 504 505typeAliasTemplateDecl() matches 506 template <typename T> 507 using Y = X<T>; 508</pre></td></tr> 509 510 511<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('typedefDecl0')"><a name="typedefDecl0Anchor">typedefDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html">TypedefDecl</a>>...</td></tr> 512<tr><td colspan="4" class="doc" id="typedefDecl0"><pre>Matches typedef declarations. 513 514Given 515 typedef int X; 516 using Y = int; 517typedefDecl() 518 matches "typedef int X", but not "using Y = int" 519</pre></td></tr> 520 521 522<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('typedefNameDecl0')"><a name="typedefNameDecl0Anchor">typedefNameDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>>...</td></tr> 523<tr><td colspan="4" class="doc" id="typedefNameDecl0"><pre>Matches typedef name declarations. 524 525Given 526 typedef int X; 527 using Y = int; 528typedefNameDecl() 529 matches "typedef int X" and "using Y = int" 530</pre></td></tr> 531 532 533<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('unresolvedUsingTypenameDecl0')"><a name="unresolvedUsingTypenameDecl0Anchor">unresolvedUsingTypenameDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingTypenameDecl.html">UnresolvedUsingTypenameDecl</a>>...</td></tr> 534<tr><td colspan="4" class="doc" id="unresolvedUsingTypenameDecl0"><pre>Matches unresolved using value declarations that involve the 535typename. 536 537Given 538 template <typename T> 539 struct Base { typedef T Foo; }; 540 541 template<typename T> 542 struct S : private Base<T> { 543 using typename Base<T>::Foo; 544 }; 545unresolvedUsingTypenameDecl() 546 matches using Base<T>::Foo </pre></td></tr> 547 548 549<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('unresolvedUsingValueDecl0')"><a name="unresolvedUsingValueDecl0Anchor">unresolvedUsingValueDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingValueDecl.html">UnresolvedUsingValueDecl</a>>...</td></tr> 550<tr><td colspan="4" class="doc" id="unresolvedUsingValueDecl0"><pre>Matches unresolved using value declarations. 551 552Given 553 template<typename X> 554 class C : private X { 555 using X::x; 556 }; 557unresolvedUsingValueDecl() 558 matches using X::x </pre></td></tr> 559 560 561<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> 562<tr><td colspan="4" class="doc" id="usingDecl0"><pre>Matches using declarations. 563 564Given 565 namespace X { int x; } 566 using X::x; 567usingDecl() 568 matches using X::x </pre></td></tr> 569 570 571<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('usingDirectiveDecl0')"><a name="usingDirectiveDecl0Anchor">usingDirectiveDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UsingDirectiveDecl.html">UsingDirectiveDecl</a>>...</td></tr> 572<tr><td colspan="4" class="doc" id="usingDirectiveDecl0"><pre>Matches using namespace declarations. 573 574Given 575 namespace X { int x; } 576 using namespace X; 577usingDirectiveDecl() 578 matches using namespace X </pre></td></tr> 579 580 581<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('valueDecl0')"><a name="valueDecl0Anchor">valueDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>>...</td></tr> 582<tr><td colspan="4" class="doc" id="valueDecl0"><pre>Matches any value declaration. 583 584Example matches A, B, C and F 585 enum X { A, B, C }; 586 void F(); 587</pre></td></tr> 588 589 590<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> 591<tr><td colspan="4" class="doc" id="varDecl0"><pre>Matches variable declarations. 592 593Note: this does not match declarations of member variables, which are 594"field" declarations in Clang parlance. 595 596Example matches a 597 int a; 598</pre></td></tr> 599 600 601<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>></td><td class="name" onclick="toggle('nestedNameSpecifierLoc0')"><a name="nestedNameSpecifierLoc0Anchor">nestedNameSpecifierLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>>...</td></tr> 602<tr><td colspan="4" class="doc" id="nestedNameSpecifierLoc0"><pre>Same as nestedNameSpecifier but matches NestedNameSpecifierLoc. 603</pre></td></tr> 604 605 606<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>></td><td class="name" onclick="toggle('nestedNameSpecifier0')"><a name="nestedNameSpecifier0Anchor">nestedNameSpecifier</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>>...</td></tr> 607<tr><td colspan="4" class="doc" id="nestedNameSpecifier0"><pre>Matches nested name specifiers. 608 609Given 610 namespace ns { 611 struct A { static void f(); }; 612 void A::f() {} 613 void g() { A::f(); } 614 } 615 ns::A a; 616nestedNameSpecifier() 617 matches "ns::" and both "A::" 618</pre></td></tr> 619 620 621<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('qualType0')"><a name="qualType0Anchor">qualType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>...</td></tr> 622<tr><td colspan="4" class="doc" id="qualType0"><pre>Matches QualTypes in the clang AST. 623</pre></td></tr> 624 625 626<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('addrLabelExpr0')"><a name="addrLabelExpr0Anchor">addrLabelExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>...</td></tr> 627<tr><td colspan="4" class="doc" id="addrLabelExpr0"><pre>Matches address of label statements (GNU extension). 628 629Given 630 FOO: bar(); 631 void *ptr = &&FOO; 632 goto *bar; 633addrLabelExpr() 634 matches '&&FOO' 635</pre></td></tr> 636 637 638<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> 639<tr><td colspan="4" class="doc" id="arraySubscriptExpr0"><pre>Matches array subscript expressions. 640 641Given 642 int i = a[1]; 643arraySubscriptExpr() 644 matches "a[1]" 645</pre></td></tr> 646 647 648<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> 649<tr><td colspan="4" class="doc" id="asmStmt0"><pre>Matches asm statements. 650 651 int i = 100; 652 __asm("mov al, 2"); 653asmStmt() 654 matches '__asm("mov al, 2")' 655</pre></td></tr> 656 657 658<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('atomicExpr0')"><a name="atomicExpr0Anchor">atomicExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicExpr.html">AtomicExpr</a>>...</td></tr> 659<tr><td colspan="4" class="doc" id="atomicExpr0"><pre>Matches atomic builtins. 660Example matches __atomic_load_n(ptr, 1) 661 void foo() { int *ptr; __atomic_load_n(ptr, 1); } 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('binaryConditionalOperator0')"><a name="binaryConditionalOperator0Anchor">binaryConditionalOperator</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryConditionalOperator.html">BinaryConditionalOperator</a>>...</td></tr> 666<tr><td colspan="4" class="doc" id="binaryConditionalOperator0"><pre>Matches binary conditional operator expressions (GNU extension). 667 668Example matches a ?: b 669 (a ?: b) + 42; 670</pre></td></tr> 671 672 673<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> 674<tr><td colspan="4" class="doc" id="binaryOperator0"><pre>Matches binary operator expressions. 675 676Example matches a || b 677 !(a || b) 678</pre></td></tr> 679 680 681<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> 682<tr><td colspan="4" class="doc" id="breakStmt0"><pre>Matches break statements. 683 684Given 685 while (true) { break; } 686breakStmt() 687 matches 'break' 688</pre></td></tr> 689 690 691<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> 692<tr><td colspan="4" class="doc" id="cStyleCastExpr0"><pre>Matches a C-style cast expression. 693 694Example: Matches (int) 2.2f in 695 int i = (int) 2.2f; 696</pre></td></tr> 697 698 699<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> 700<tr><td colspan="4" class="doc" id="callExpr0"><pre>Matches call expressions. 701 702Example matches x.y() and y() 703 X x; 704 x.y(); 705 y(); 706</pre></td></tr> 707 708 709<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('caseStmt0')"><a name="caseStmt0Anchor">caseStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt</a>>...</td></tr> 710<tr><td colspan="4" class="doc" id="caseStmt0"><pre>Matches case statements inside switch statements. 711 712Given 713 switch(a) { case 42: break; default: break; } 714caseStmt() 715 matches 'case 42:'. 716</pre></td></tr> 717 718 719<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('castExpr0')"><a name="castExpr0Anchor">castExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>>...</td></tr> 720<tr><td colspan="4" class="doc" id="castExpr0"><pre>Matches any cast nodes of Clang's AST. 721 722Example: castExpr() matches each of the following: 723 (int) 3; 724 const_cast<Expr *>(SubExpr); 725 char c = 0; 726but does not match 727 int i = (0); 728 int k = 0; 729</pre></td></tr> 730 731 732<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> 733<tr><td colspan="4" class="doc" id="characterLiteral0"><pre>Matches character literals (also matches wchar_t). 734 735Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral), 736though. 737 738Example matches 'a', L'a' 739 char ch = 'a'; 740 wchar_t chw = L'a'; 741</pre></td></tr> 742 743 744<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('compoundLiteralExpr0')"><a name="compoundLiteralExpr0Anchor">compoundLiteralExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundLiteralExpr.html">CompoundLiteralExpr</a>>...</td></tr> 745<tr><td colspan="4" class="doc" id="compoundLiteralExpr0"><pre>Matches compound (i.e. non-scalar) literals 746 747Example match: {1}, (1, 2) 748 int array[4] = {1}; 749 vector int myvec = (vector int)(1, 2); 750</pre></td></tr> 751 752 753<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('compoundStmt0')"><a name="compoundStmt0Anchor">compoundStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CompoundStmt.html">CompoundStmt</a>>...</td></tr> 754<tr><td colspan="4" class="doc" id="compoundStmt0"><pre>Matches compound statements. 755 756Example matches '{}' and '{{}}' in 'for (;;) {{}}' 757 for (;;) {{}} 758</pre></td></tr> 759 760 761<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> 762<tr><td colspan="4" class="doc" id="conditionalOperator0"><pre>Matches conditional operator expressions. 763 764Example matches a ? b : c 765 (a ? b : c) + 42 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('continueStmt0')"><a name="continueStmt0Anchor">continueStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ContinueStmt.html">ContinueStmt</a>>...</td></tr> 770<tr><td colspan="4" class="doc" id="continueStmt0"><pre>Matches continue statements. 771 772Given 773 while (true) { continue; } 774continueStmt() 775 matches 'continue' 776</pre></td></tr> 777 778 779<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cudaKernelCallExpr0')"><a name="cudaKernelCallExpr0Anchor">cudaKernelCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html">CUDAKernelCallExpr</a>>...</td></tr> 780<tr><td colspan="4" class="doc" id="cudaKernelCallExpr0"><pre>Matches CUDA kernel call expression. 781 782Example matches, 783 kernel<<<i,j>>>(); 784</pre></td></tr> 785 786 787<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxBindTemporaryExpr0')"><a name="cxxBindTemporaryExpr0Anchor">cxxBindTemporaryExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBindTemporaryExpr.html">CXXBindTemporaryExpr</a>>...</td></tr> 788<tr><td colspan="4" class="doc" id="cxxBindTemporaryExpr0"><pre>Matches nodes where temporaries are created. 789 790Example matches FunctionTakesString(GetStringByValue()) 791 (matcher = cxxBindTemporaryExpr()) 792 FunctionTakesString(GetStringByValue()); 793 FunctionTakesStringByPointer(GetStringPointer()); 794</pre></td></tr> 795 796 797<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxBoolLiteral0')"><a name="cxxBoolLiteral0Anchor">cxxBoolLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>...</td></tr> 798<tr><td colspan="4" class="doc" id="cxxBoolLiteral0"><pre>Matches bool literals. 799 800Example matches true 801 true 802</pre></td></tr> 803 804 805<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxCatchStmt0')"><a name="cxxCatchStmt0Anchor">cxxCatchStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>>...</td></tr> 806<tr><td colspan="4" class="doc" id="cxxCatchStmt0"><pre>Matches catch statements. 807 808 try {} catch(int i) {} 809cxxCatchStmt() 810 matches 'catch(int i)' 811</pre></td></tr> 812 813 814<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxConstCastExpr0')"><a name="cxxConstCastExpr0Anchor">cxxConstCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstCastExpr.html">CXXConstCastExpr</a>>...</td></tr> 815<tr><td colspan="4" class="doc" id="cxxConstCastExpr0"><pre>Matches a const_cast expression. 816 817Example: Matches const_cast<int*>(&r) in 818 int n = 42; 819 const int &r(n); 820 int* p = const_cast<int*>(&r); 821</pre></td></tr> 822 823 824<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxConstructExpr0')"><a name="cxxConstructExpr0Anchor">cxxConstructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>...</td></tr> 825<tr><td colspan="4" class="doc" id="cxxConstructExpr0"><pre>Matches constructor call expressions (including implicit ones). 826 827Example matches string(ptr, n) and ptr within arguments of f 828 (matcher = cxxConstructExpr()) 829 void f(const string &a, const string &b); 830 char *ptr; 831 int n; 832 f(string(ptr, n), ptr); 833</pre></td></tr> 834 835 836<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxDefaultArgExpr0')"><a name="cxxDefaultArgExpr0Anchor">cxxDefaultArgExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDefaultArgExpr.html">CXXDefaultArgExpr</a>>...</td></tr> 837<tr><td colspan="4" class="doc" id="cxxDefaultArgExpr0"><pre>Matches the value of a default argument at the call site. 838 839Example matches the CXXDefaultArgExpr placeholder inserted for the 840 default value of the second parameter in the call expression f(42) 841 (matcher = cxxDefaultArgExpr()) 842 void f(int x, int y = 0); 843 f(42); 844</pre></td></tr> 845 846 847<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxDeleteExpr0')"><a name="cxxDeleteExpr0Anchor">cxxDeleteExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDeleteExpr.html">CXXDeleteExpr</a>>...</td></tr> 848<tr><td colspan="4" class="doc" id="cxxDeleteExpr0"><pre>Matches delete expressions. 849 850Given 851 delete X; 852cxxDeleteExpr() 853 matches 'delete X'. 854</pre></td></tr> 855 856 857<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxDynamicCastExpr0')"><a name="cxxDynamicCastExpr0Anchor">cxxDynamicCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXDynamicCastExpr.html">CXXDynamicCastExpr</a>>...</td></tr> 858<tr><td colspan="4" class="doc" id="cxxDynamicCastExpr0"><pre>Matches a dynamic_cast expression. 859 860Example: 861 cxxDynamicCastExpr() 862matches 863 dynamic_cast<D*>(&b); 864in 865 struct B { virtual ~B() {} }; struct D : B {}; 866 B b; 867 D* p = dynamic_cast<D*>(&b); 868</pre></td></tr> 869 870 871<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxForRangeStmt0')"><a name="cxxForRangeStmt0Anchor">cxxForRangeStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>>...</td></tr> 872<tr><td colspan="4" class="doc" id="cxxForRangeStmt0"><pre>Matches range-based for statements. 873 874cxxForRangeStmt() matches 'for (auto a : i)' 875 int i[] = {1, 2, 3}; for (auto a : i); 876 for(int j = 0; j < 5; ++j); 877</pre></td></tr> 878 879 880<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxFunctionalCastExpr0')"><a name="cxxFunctionalCastExpr0Anchor">cxxFunctionalCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXFunctionalCastExpr.html">CXXFunctionalCastExpr</a>>...</td></tr> 881<tr><td colspan="4" class="doc" id="cxxFunctionalCastExpr0"><pre>Matches functional cast expressions 882 883Example: Matches Foo(bar); 884 Foo f = bar; 885 Foo g = (Foo) bar; 886 Foo h = Foo(bar); 887</pre></td></tr> 888 889 890<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxMemberCallExpr0')"><a name="cxxMemberCallExpr0Anchor">cxxMemberCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>>...</td></tr> 891<tr><td colspan="4" class="doc" id="cxxMemberCallExpr0"><pre>Matches member call expressions. 892 893Example matches x.y() 894 X x; 895 x.y(); 896</pre></td></tr> 897 898 899<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxNewExpr0')"><a name="cxxNewExpr0Anchor">cxxNewExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>...</td></tr> 900<tr><td colspan="4" class="doc" id="cxxNewExpr0"><pre>Matches new expressions. 901 902Given 903 new X; 904cxxNewExpr() 905 matches 'new X'. 906</pre></td></tr> 907 908 909<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxNullPtrLiteralExpr0')"><a name="cxxNullPtrLiteralExpr0Anchor">cxxNullPtrLiteralExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNullPtrLiteralExpr.html">CXXNullPtrLiteralExpr</a>>...</td></tr> 910<tr><td colspan="4" class="doc" id="cxxNullPtrLiteralExpr0"><pre>Matches nullptr literal. 911</pre></td></tr> 912 913 914<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxOperatorCallExpr0')"><a name="cxxOperatorCallExpr0Anchor">cxxOperatorCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>...</td></tr> 915<tr><td colspan="4" class="doc" id="cxxOperatorCallExpr0"><pre>Matches overloaded operator calls. 916 917Note that if an operator isn't overloaded, it won't match. Instead, use 918binaryOperator matcher. 919Currently it does not match operators such as new delete. 920FIXME: figure out why these do not match? 921 922Example matches both operator<<((o << b), c) and operator<<(o, b) 923 (matcher = cxxOperatorCallExpr()) 924 ostream &operator<< (ostream &out, int i) { }; 925 ostream &o; int b = 1, c = 1; 926 o << b << c; 927</pre></td></tr> 928 929 930<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxReinterpretCastExpr0')"><a name="cxxReinterpretCastExpr0Anchor">cxxReinterpretCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXReinterpretCastExpr.html">CXXReinterpretCastExpr</a>>...</td></tr> 931<tr><td colspan="4" class="doc" id="cxxReinterpretCastExpr0"><pre>Matches a reinterpret_cast expression. 932 933Either the source expression or the destination type can be matched 934using has(), but hasDestinationType() is more specific and can be 935more readable. 936 937Example matches reinterpret_cast<char*>(&p) in 938 void* p = reinterpret_cast<char*>(&p); 939</pre></td></tr> 940 941 942<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxStaticCastExpr0')"><a name="cxxStaticCastExpr0Anchor">cxxStaticCastExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXStaticCastExpr.html">CXXStaticCastExpr</a>>...</td></tr> 943<tr><td colspan="4" class="doc" id="cxxStaticCastExpr0"><pre>Matches a C++ static_cast expression. 944 945See also: hasDestinationType 946See also: reinterpretCast 947 948Example: 949 cxxStaticCastExpr() 950matches 951 static_cast<long>(8) 952in 953 long eight(static_cast<long>(8)); 954</pre></td></tr> 955 956 957<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxStdInitializerListExpr0')"><a name="cxxStdInitializerListExpr0Anchor">cxxStdInitializerListExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXStdInitializerListExpr.html">CXXStdInitializerListExpr</a>>...</td></tr> 958<tr><td colspan="4" class="doc" id="cxxStdInitializerListExpr0"><pre>Matches C++ initializer list expressions. 959 960Given 961 std::vector<int> a({ 1, 2, 3 }); 962 std::vector<int> b = { 4, 5 }; 963 int c[] = { 6, 7 }; 964 std::pair<int, int> d = { 8, 9 }; 965cxxStdInitializerListExpr() 966 matches "{ 1, 2, 3 }" and "{ 4, 5 }" 967</pre></td></tr> 968 969 970<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxTemporaryObjectExpr0')"><a name="cxxTemporaryObjectExpr0Anchor">cxxTemporaryObjectExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTemporaryObjectExpr.html">CXXTemporaryObjectExpr</a>>...</td></tr> 971<tr><td colspan="4" class="doc" id="cxxTemporaryObjectExpr0"><pre>Matches functional cast expressions having N != 1 arguments 972 973Example: Matches Foo(bar, bar) 974 Foo h = Foo(bar, bar); 975</pre></td></tr> 976 977 978<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxThisExpr0')"><a name="cxxThisExpr0Anchor">cxxThisExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThisExpr.html">CXXThisExpr</a>>...</td></tr> 979<tr><td colspan="4" class="doc" id="cxxThisExpr0"><pre>Matches implicit and explicit this expressions. 980 981Example matches the implicit this expression in "return i". 982 (matcher = cxxThisExpr()) 983struct foo { 984 int i; 985 int f() { return i; } 986}; 987</pre></td></tr> 988 989 990<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxThrowExpr0')"><a name="cxxThrowExpr0Anchor">cxxThrowExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXThrowExpr.html">CXXThrowExpr</a>>...</td></tr> 991<tr><td colspan="4" class="doc" id="cxxThrowExpr0"><pre>Matches throw expressions. 992 993 try { throw 5; } catch(int i) {} 994cxxThrowExpr() 995 matches 'throw 5' 996</pre></td></tr> 997 998 999<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxTryStmt0')"><a name="cxxTryStmt0Anchor">cxxTryStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXTryStmt.html">CXXTryStmt</a>>...</td></tr> 1000<tr><td colspan="4" class="doc" id="cxxTryStmt0"><pre>Matches try statements. 1001 1002 try {} catch(int i) {} 1003cxxTryStmt() 1004 matches 'try {}' 1005</pre></td></tr> 1006 1007 1008<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('cxxUnresolvedConstructExpr0')"><a name="cxxUnresolvedConstructExpr0Anchor">cxxUnresolvedConstructExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXUnresolvedConstructExpr.html">CXXUnresolvedConstructExpr</a>>...</td></tr> 1009<tr><td colspan="4" class="doc" id="cxxUnresolvedConstructExpr0"><pre>Matches unresolved constructor call expressions. 1010 1011Example matches T(t) in return statement of f 1012 (matcher = cxxUnresolvedConstructExpr()) 1013 template <typename T> 1014 void f(const T& t) { return T(t); } 1015</pre></td></tr> 1016 1017 1018<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('declRefExpr0')"><a name="declRefExpr0Anchor">declRefExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>...</td></tr> 1019<tr><td colspan="4" class="doc" id="declRefExpr0"><pre>Matches expressions that refer to declarations. 1020 1021Example matches x in if (x) 1022 bool x; 1023 if (x) {} 1024</pre></td></tr> 1025 1026 1027<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> 1028<tr><td colspan="4" class="doc" id="declStmt0"><pre>Matches declaration statements. 1029 1030Given 1031 int a; 1032declStmt() 1033 matches 'int a'. 1034</pre></td></tr> 1035 1036 1037<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('defaultStmt0')"><a name="defaultStmt0Anchor">defaultStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DefaultStmt.html">DefaultStmt</a>>...</td></tr> 1038<tr><td colspan="4" class="doc" id="defaultStmt0"><pre>Matches default statements inside switch statements. 1039 1040Given 1041 switch(a) { case 42: break; default: break; } 1042defaultStmt() 1043 matches 'default:'. 1044</pre></td></tr> 1045 1046 1047<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('designatedInitExpr0')"><a name="designatedInitExpr0Anchor">designatedInitExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DesignatedInitExpr.html">DesignatedInitExpr</a>>...</td></tr> 1048<tr><td colspan="4" class="doc" id="designatedInitExpr0"><pre>Matches C99 designated initializer expressions [C99 6.7.8]. 1049 1050Example: Matches { [2].y = 1.0, [0].x = 1.0 } 1051 point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; 1052</pre></td></tr> 1053 1054 1055<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> 1056<tr><td colspan="4" class="doc" id="doStmt0"><pre>Matches do statements. 1057 1058Given 1059 do {} while (true); 1060doStmt() 1061 matches 'do {} while(true)' 1062</pre></td></tr> 1063 1064 1065<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> 1066<tr><td colspan="4" class="doc" id="explicitCastExpr0"><pre>Matches explicit cast expressions. 1067 1068Matches any cast expression written in user code, whether it be a 1069C-style cast, a functional-style cast, or a keyword cast. 1070 1071Does not match implicit conversions. 1072 1073Note: the name "explicitCast" is chosen to match Clang's terminology, as 1074Clang uses the term "cast" to apply to implicit conversions as well as to 1075actual cast expressions. 1076 1077See also: hasDestinationType. 1078 1079Example: matches all five of the casts in 1080 int((int)(reinterpret_cast<int>(static_cast<int>(const_cast<int>(42))))) 1081but does not match the implicit conversion in 1082 long ell = 42; 1083</pre></td></tr> 1084 1085 1086<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> 1087<tr><td colspan="4" class="doc" id="expr0"><pre>Matches expressions. 1088 1089Example matches x() 1090 void f() { x(); } 1091</pre></td></tr> 1092 1093 1094<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('exprWithCleanups0')"><a name="exprWithCleanups0Anchor">exprWithCleanups</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ExprWithCleanups.html">ExprWithCleanups</a>>...</td></tr> 1095<tr><td colspan="4" class="doc" id="exprWithCleanups0"><pre>Matches expressions that introduce cleanups to be run at the end 1096of the sub-expression's evaluation. 1097 1098Example matches std::string() 1099 const std::string str = std::string(); 1100</pre></td></tr> 1101 1102 1103<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('floatLiteral0')"><a name="floatLiteral0Anchor">floatLiteral</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>>...</td></tr> 1104<tr><td colspan="4" class="doc" id="floatLiteral0"><pre>Matches float literals of all sizes encodings, e.g. 11051.0, 1.0f, 1.0L and 1e10. 1106 1107Does not match implicit conversions such as 1108 float a = 10; 1109</pre></td></tr> 1110 1111 1112<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> 1113<tr><td colspan="4" class="doc" id="forStmt0"><pre>Matches for statements. 1114 1115Example matches 'for (;;) {}' 1116 for (;;) {} 1117 int i[] = {1, 2, 3}; for (auto a : i); 1118</pre></td></tr> 1119 1120 1121<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('gnuNullExpr0')"><a name="gnuNullExpr0Anchor">gnuNullExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1GNUNullExpr.html">GNUNullExpr</a>>...</td></tr> 1122<tr><td colspan="4" class="doc" id="gnuNullExpr0"><pre>Matches GNU __null expression. 1123</pre></td></tr> 1124 1125 1126<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> 1127<tr><td colspan="4" class="doc" id="gotoStmt0"><pre>Matches goto statements. 1128 1129Given 1130 goto FOO; 1131 FOO: bar(); 1132gotoStmt() 1133 matches 'goto FOO' 1134</pre></td></tr> 1135 1136 1137<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> 1138<tr><td colspan="4" class="doc" id="ifStmt0"><pre>Matches if statements. 1139 1140Example matches 'if (x) {}' 1141 if (x) {} 1142</pre></td></tr> 1143 1144 1145<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> 1146<tr><td colspan="4" class="doc" id="implicitCastExpr0"><pre>Matches the implicit cast nodes of Clang's AST. 1147 1148This matches many different places, including function call return value 1149eliding, as well as any type conversions. 1150</pre></td></tr> 1151 1152 1153<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('implicitValueInitExpr0')"><a name="implicitValueInitExpr0Anchor">implicitValueInitExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ImplicitValueInitExpr.html">ImplicitValueInitExpr</a>>...</td></tr> 1154<tr><td colspan="4" class="doc" id="implicitValueInitExpr0"><pre>Matches implicit initializers of init list expressions. 1155 1156Given 1157 point ptarray[10] = { [2].y = 1.0, [2].x = 2.0, [0].x = 1.0 }; 1158implicitValueInitExpr() 1159 matches "[0].y" (implicitly) 1160</pre></td></tr> 1161 1162 1163<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> 1164<tr><td colspan="4" class="doc" id="initListExpr0"><pre>Matches init list expressions. 1165 1166Given 1167 int a[] = { 1, 2 }; 1168 struct B { int x, y; }; 1169 B b = { 5, 6 }; 1170initListExpr() 1171 matches "{ 1, 2 }" and "{ 5, 6 }" 1172</pre></td></tr> 1173 1174 1175<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> 1176<tr><td colspan="4" class="doc" id="integerLiteral0"><pre>Matches integer literals of all sizes encodings, e.g. 11771, 1L, 0x1 and 1U. 1178 1179Does not match character-encoded integers such as L'a'. 1180</pre></td></tr> 1181 1182 1183<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> 1184<tr><td colspan="4" class="doc" id="labelStmt0"><pre>Matches label statements. 1185 1186Given 1187 goto FOO; 1188 FOO: bar(); 1189labelStmt() 1190 matches 'FOO:' 1191</pre></td></tr> 1192 1193 1194<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> 1195<tr><td colspan="4" class="doc" id="lambdaExpr0"><pre>Matches lambda expressions. 1196 1197Example matches [&](){return 5;} 1198 [&](){return 5;} 1199</pre></td></tr> 1200 1201 1202<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> 1203<tr><td colspan="4" class="doc" id="materializeTemporaryExpr0"><pre>Matches nodes where temporaries are materialized. 1204 1205Example: Given 1206 struct T {void func();}; 1207 T f(); 1208 void g(T); 1209materializeTemporaryExpr() matches 'f()' in these statements 1210 T u(f()); 1211 g(f()); 1212 f().func(); 1213but does not match 1214 f(); 1215</pre></td></tr> 1216 1217 1218<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> 1219<tr><td colspan="4" class="doc" id="memberExpr0"><pre>Matches member expressions. 1220 1221Given 1222 class Y { 1223 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 1224 int a; static int b; 1225 }; 1226memberExpr() 1227 matches this->x, x, y.x, a, this->b 1228</pre></td></tr> 1229 1230 1231<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> 1232<tr><td colspan="4" class="doc" id="nullStmt0"><pre>Matches null statements. 1233 1234 foo();; 1235nullStmt() 1236 matches the second ';' 1237</pre></td></tr> 1238 1239 1240<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcCatchStmt0')"><a name="objcCatchStmt0Anchor">objcCatchStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCAtCatchStmt.html">ObjCAtCatchStmt</a>>...</td></tr> 1241<tr><td colspan="4" class="doc" id="objcCatchStmt0"><pre>Matches Objective-C @catch statements. 1242 1243Example matches @catch 1244 @try {} 1245 @catch (...) {} 1246</pre></td></tr> 1247 1248 1249<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcFinallyStmt0')"><a name="objcFinallyStmt0Anchor">objcFinallyStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCAtFinallyStmt.html">ObjCAtFinallyStmt</a>>...</td></tr> 1250<tr><td colspan="4" class="doc" id="objcFinallyStmt0"><pre>Matches Objective-C @finally statements. 1251 1252Example matches @finally 1253 @try {} 1254 @finally {} 1255</pre></td></tr> 1256 1257 1258<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcMessageExpr0')"><a name="objcMessageExpr0Anchor">objcMessageExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>>...</td></tr> 1259<tr><td colspan="4" class="doc" id="objcMessageExpr0"><pre>Matches ObjectiveC Message invocation expressions. 1260 1261The innermost message send invokes the "alloc" class method on the 1262NSString class, while the outermost message send invokes the 1263"initWithString" instance method on the object returned from 1264NSString's "alloc". This matcher should match both message sends. 1265 [[NSString alloc] initWithString:@"Hello"] 1266</pre></td></tr> 1267 1268 1269<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcThrowStmt0')"><a name="objcThrowStmt0Anchor">objcThrowStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCAtThrowStmt.html">ObjCAtThrowStmt</a>>...</td></tr> 1270<tr><td colspan="4" class="doc" id="objcThrowStmt0"><pre>Matches Objective-C statements. 1271 1272Example matches @throw obj; 1273</pre></td></tr> 1274 1275 1276<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('objcTryStmt0')"><a name="objcTryStmt0Anchor">objcTryStmt</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCAtTryStmt.html">ObjCAtTryStmt</a>>...</td></tr> 1277<tr><td colspan="4" class="doc" id="objcTryStmt0"><pre>Matches Objective-C @try statements. 1278 1279Example matches @try 1280 @try {} 1281 @catch (...) {} 1282</pre></td></tr> 1283 1284 1285<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('opaqueValueExpr0')"><a name="opaqueValueExpr0Anchor">opaqueValueExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1OpaqueValueExpr.html">OpaqueValueExpr</a>>...</td></tr> 1286<tr><td colspan="4" class="doc" id="opaqueValueExpr0"><pre>Matches opaque value expressions. They are used as helpers 1287to reference another expressions and can be met 1288in BinaryConditionalOperators, for example. 1289 1290Example matches 'a' 1291 (a ?: c) + 42; 1292</pre></td></tr> 1293 1294 1295<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('parenExpr0')"><a name="parenExpr0Anchor">parenExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenExpr.html">ParenExpr</a>>...</td></tr> 1296<tr><td colspan="4" class="doc" id="parenExpr0"><pre>Matches parentheses used in expressions. 1297 1298Example matches (foo() + 1) 1299 int foo() { return 1; } 1300 int a = (foo() + 1); 1301</pre></td></tr> 1302 1303 1304<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('parenListExpr0')"><a name="parenListExpr0Anchor">parenListExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenListExpr.html">ParenListExpr</a>>...</td></tr> 1305<tr><td colspan="4" class="doc" id="parenListExpr0"><pre>Matches paren list expressions. 1306ParenListExprs don't have a predefined type and are used for late parsing. 1307In the final AST, they can be met in template declarations. 1308 1309Given 1310 template<typename T> class X { 1311 void f() { 1312 X x(*this); 1313 int a = 0, b = 1; int i = (a, b); 1314 } 1315 }; 1316parenListExpr() matches "*this" but NOT matches (a, b) because (a, b) 1317has a predefined type and is a ParenExpr, not a ParenListExpr. 1318</pre></td></tr> 1319 1320 1321<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('predefinedExpr0')"><a name="predefinedExpr0Anchor">predefinedExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PredefinedExpr.html">PredefinedExpr</a>>...</td></tr> 1322<tr><td colspan="4" class="doc" id="predefinedExpr0"><pre>Matches predefined identifier expressions [C99 6.4.2.2]. 1323 1324Example: Matches __func__ 1325 printf("%s", __func__); 1326</pre></td></tr> 1327 1328 1329<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> 1330<tr><td colspan="4" class="doc" id="returnStmt0"><pre>Matches return statements. 1331 1332Given 1333 return 1; 1334returnStmt() 1335 matches 'return 1' 1336</pre></td></tr> 1337 1338 1339<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> 1340<tr><td colspan="4" class="doc" id="stmt0"><pre>Matches statements. 1341 1342Given 1343 { ++a; } 1344stmt() 1345 matches both the compound statement '{ ++a; }' and '++a'. 1346</pre></td></tr> 1347 1348 1349<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('stmtExpr0')"><a name="stmtExpr0Anchor">stmtExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StmtExpr.html">StmtExpr</a>>...</td></tr> 1350<tr><td colspan="4" class="doc" id="stmtExpr0"><pre>Matches statement expression (GNU extension). 1351 1352Example match: ({ int X = 4; X; }) 1353 int C = ({ int X = 4; X; }); 1354</pre></td></tr> 1355 1356 1357<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> 1358<tr><td colspan="4" class="doc" id="stringLiteral0"><pre>Matches string literals (also matches wide string literals). 1359 1360Example matches "abcd", L"abcd" 1361 char *s = "abcd"; 1362 wchar_t *ws = L"abcd"; 1363</pre></td></tr> 1364 1365 1366<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('substNonTypeTemplateParmExpr0')"><a name="substNonTypeTemplateParmExpr0Anchor">substNonTypeTemplateParmExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SubstNonTypeTemplateParmExpr.html">SubstNonTypeTemplateParmExpr</a>>...</td></tr> 1367<tr><td colspan="4" class="doc" id="substNonTypeTemplateParmExpr0"><pre>Matches substitutions of non-type template parameters. 1368 1369Given 1370 template <int N> 1371 struct A { static const int n = N; }; 1372 struct B : public A<42> {}; 1373substNonTypeTemplateParmExpr() 1374 matches "N" in the right-hand side of "static const int n = N;" 1375</pre></td></tr> 1376 1377 1378<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> 1379<tr><td colspan="4" class="doc" id="switchCase0"><pre>Matches case and default statements inside switch statements. 1380 1381Given 1382 switch(a) { case 42: break; default: break; } 1383switchCase() 1384 matches 'case 42:' and 'default:'. 1385</pre></td></tr> 1386 1387 1388<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> 1389<tr><td colspan="4" class="doc" id="switchStmt0"><pre>Matches switch statements. 1390 1391Given 1392 switch(a) { case 42: break; default: break; } 1393switchStmt() 1394 matches 'switch(a)'. 1395</pre></td></tr> 1396 1397 1398<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> 1399<tr><td colspan="4" class="doc" id="unaryExprOrTypeTraitExpr0"><pre>Matches sizeof (C99), alignof (C++11) and vec_step (OpenCL) 1400 1401Given 1402 Foo x = bar; 1403 int y = sizeof(x) + alignof(x); 1404unaryExprOrTypeTraitExpr() 1405 matches sizeof(x) and alignof(x) 1406</pre></td></tr> 1407 1408 1409<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> 1410<tr><td colspan="4" class="doc" id="unaryOperator0"><pre>Matches unary operator expressions. 1411 1412Example matches !a 1413 !a || b 1414</pre></td></tr> 1415 1416 1417<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('unresolvedLookupExpr0')"><a name="unresolvedLookupExpr0Anchor">unresolvedLookupExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedLookupExpr.html">UnresolvedLookupExpr</a>>...</td></tr> 1418<tr><td colspan="4" class="doc" id="unresolvedLookupExpr0"><pre>Matches reference to a name that can be looked up during parsing 1419but could not be resolved to a specific declaration. 1420 1421Given 1422 template<typename T> 1423 T foo() { T a; return a; } 1424 template<typename T> 1425 void bar() { 1426 foo<T>(); 1427 } 1428unresolvedLookupExpr() 1429 matches foo<T>() </pre></td></tr> 1430 1431 1432<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> 1433<tr><td colspan="4" class="doc" id="userDefinedLiteral0"><pre>Matches user defined literal operator call. 1434 1435Example match: "foo"_suffix 1436</pre></td></tr> 1437 1438 1439<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> 1440<tr><td colspan="4" class="doc" id="whileStmt0"><pre>Matches while statements. 1441 1442Given 1443 while (true) {} 1444whileStmt() 1445 matches 'while (true) {}'. 1446</pre></td></tr> 1447 1448 1449<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('templateArgument0')"><a name="templateArgument0Anchor">templateArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>>...</td></tr> 1450<tr><td colspan="4" class="doc" id="templateArgument0"><pre>Matches template arguments. 1451 1452Given 1453 template <typename T> struct C {}; 1454 C<int> c; 1455templateArgument() 1456 matches 'int' in C<int>. 1457</pre></td></tr> 1458 1459 1460<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName</a>></td><td class="name" onclick="toggle('templateName0')"><a name="templateName0Anchor">templateName</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName</a>>...</td></tr> 1461<tr><td colspan="4" class="doc" id="templateName0"><pre>Matches template name. 1462 1463Given 1464 template <typename T> class X { }; 1465 X<int> xi; 1466templateName() 1467 matches 'X' in X<int>. 1468</pre></td></tr> 1469 1470 1471<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> 1472<tr><td colspan="4" class="doc" id="typeLoc0"><pre>Matches TypeLocs in the clang AST. 1473</pre></td></tr> 1474 1475 1476<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('arrayType0')"><a name="arrayType0Anchor">arrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>...</td></tr> 1477<tr><td colspan="4" class="doc" id="arrayType0"><pre>Matches all kinds of arrays. 1478 1479Given 1480 int a[] = { 2, 3 }; 1481 int b[4]; 1482 void f() { int c[a[0]]; } 1483arrayType() 1484 matches "int a[]", "int b[4]" and "int c[a[0]]"; 1485</pre></td></tr> 1486 1487 1488<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('atomicType0')"><a name="atomicType0Anchor">atomicType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>>...</td></tr> 1489<tr><td colspan="4" class="doc" id="atomicType0"><pre>Matches atomic types. 1490 1491Given 1492 _Atomic(int) i; 1493atomicType() 1494 matches "_Atomic(int) i" 1495</pre></td></tr> 1496 1497 1498<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('autoType0')"><a name="autoType0Anchor">autoType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>>...</td></tr> 1499<tr><td colspan="4" class="doc" id="autoType0"><pre>Matches types nodes representing C++11 auto types. 1500 1501Given: 1502 auto n = 4; 1503 int v[] = { 2, 3 } 1504 for (auto i : v) { } 1505autoType() 1506 matches "auto n" and "auto i" 1507</pre></td></tr> 1508 1509 1510<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('blockPointerType0')"><a name="blockPointerType0Anchor">blockPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>...</td></tr> 1511<tr><td colspan="4" class="doc" id="blockPointerType0"><pre>Matches block pointer types, i.e. types syntactically represented as 1512"void (^)(int)". 1513 1514The pointee is always required to be a FunctionType. 1515</pre></td></tr> 1516 1517 1518<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('builtinType0')"><a name="builtinType0Anchor">builtinType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BuiltinType.html">BuiltinType</a>>...</td></tr> 1519<tr><td colspan="4" class="doc" id="builtinType0"><pre>Matches builtin Types. 1520 1521Given 1522 struct A {}; 1523 A a; 1524 int b; 1525 float c; 1526 bool d; 1527builtinType() 1528 matches "int b", "float c" and "bool d" 1529</pre></td></tr> 1530 1531 1532<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('complexType0')"><a name="complexType0Anchor">complexType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>>...</td></tr> 1533<tr><td colspan="4" class="doc" id="complexType0"><pre>Matches C99 complex types. 1534 1535Given 1536 _Complex float f; 1537complexType() 1538 matches "_Complex float f" 1539</pre></td></tr> 1540 1541 1542<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('constantArrayType0')"><a name="constantArrayType0Anchor">constantArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html">ConstantArrayType</a>>...</td></tr> 1543<tr><td colspan="4" class="doc" id="constantArrayType0"><pre>Matches C arrays with a specified constant size. 1544 1545Given 1546 void() { 1547 int a[2]; 1548 int b[] = { 2, 3 }; 1549 int c[b[0]]; 1550 } 1551constantArrayType() 1552 matches "int a[2]" 1553</pre></td></tr> 1554 1555 1556<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('decayedType0')"><a name="decayedType0Anchor">decayedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DecayedType.html">DecayedType</a>>...</td></tr> 1557<tr><td colspan="4" class="doc" id="decayedType0"><pre>Matches decayed type 1558Example matches i[] in declaration of f. 1559 (matcher = valueDecl(hasType(decayedType(hasDecayedType(pointerType()))))) 1560Example matches i[1]. 1561 (matcher = expr(hasType(decayedType(hasDecayedType(pointerType()))))) 1562 void f(int i[]) { 1563 i[1] = 0; 1564 } 1565</pre></td></tr> 1566 1567 1568<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('dependentSizedArrayType0')"><a name="dependentSizedArrayType0Anchor">dependentSizedArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DependentSizedArrayType.html">DependentSizedArrayType</a>>...</td></tr> 1569<tr><td colspan="4" class="doc" id="dependentSizedArrayType0"><pre>Matches C++ arrays whose size is a value-dependent expression. 1570 1571Given 1572 template<typename T, int Size> 1573 class array { 1574 T data[Size]; 1575 }; 1576dependentSizedArrayType 1577 matches "T data[Size]" 1578</pre></td></tr> 1579 1580 1581<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('elaboratedType0')"><a name="elaboratedType0Anchor">elaboratedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>>...</td></tr> 1582<tr><td colspan="4" class="doc" id="elaboratedType0"><pre>Matches types specified with an elaborated type keyword or with a 1583qualified name. 1584 1585Given 1586 namespace N { 1587 namespace M { 1588 class D {}; 1589 } 1590 } 1591 class C {}; 1592 1593 class C c; 1594 N::M::D d; 1595 1596elaboratedType() matches the type of the variable declarations of both 1597c and d. 1598</pre></td></tr> 1599 1600 1601<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('enumType0')"><a name="enumType0Anchor">enumType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>...</td></tr> 1602<tr><td colspan="4" class="doc" id="enumType0"><pre>Matches enum types. 1603 1604Given 1605 enum C { Green }; 1606 enum class S { Red }; 1607 1608 C c; 1609 S s; 1610 1611enumType() matches the type of the variable declarations of both c and 1612s. 1613</pre></td></tr> 1614 1615 1616<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('functionProtoType0')"><a name="functionProtoType0Anchor">functionProtoType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>>...</td></tr> 1617<tr><td colspan="4" class="doc" id="functionProtoType0"><pre>Matches FunctionProtoType nodes. 1618 1619Given 1620 int (*f)(int); 1621 void g(); 1622functionProtoType() 1623 matches "int (*f)(int)" and the type of "g" in C++ mode. 1624 In C mode, "g" is not matched because it does not contain a prototype. 1625</pre></td></tr> 1626 1627 1628<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('functionType0')"><a name="functionType0Anchor">functionType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionType.html">FunctionType</a>>...</td></tr> 1629<tr><td colspan="4" class="doc" id="functionType0"><pre>Matches FunctionType nodes. 1630 1631Given 1632 int (*f)(int); 1633 void g(); 1634functionType() 1635 matches "int (*f)(int)" and the type of "g". 1636</pre></td></tr> 1637 1638 1639<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('incompleteArrayType0')"><a name="incompleteArrayType0Anchor">incompleteArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IncompleteArrayType.html">IncompleteArrayType</a>>...</td></tr> 1640<tr><td colspan="4" class="doc" id="incompleteArrayType0"><pre>Matches C arrays with unspecified size. 1641 1642Given 1643 int a[] = { 2, 3 }; 1644 int b[42]; 1645 void f(int c[]) { int d[a[0]]; }; 1646incompleteArrayType() 1647 matches "int a[]" and "int c[]" 1648</pre></td></tr> 1649 1650 1651<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('injectedClassNameType0')"><a name="injectedClassNameType0Anchor">injectedClassNameType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>...</td></tr> 1652<tr><td colspan="4" class="doc" id="injectedClassNameType0"><pre>Matches injected class name types. 1653 1654Example matches S s, but not S<T> s. 1655 (matcher = parmVarDecl(hasType(injectedClassNameType()))) 1656 template <typename T> struct S { 1657 void f(S s); 1658 void g(S<T> s); 1659 }; 1660</pre></td></tr> 1661 1662 1663<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('lValueReferenceType0')"><a name="lValueReferenceType0Anchor">lValueReferenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LValueReferenceType.html">LValueReferenceType</a>>...</td></tr> 1664<tr><td colspan="4" class="doc" id="lValueReferenceType0"><pre>Matches lvalue reference types. 1665 1666Given: 1667 int *a; 1668 int &b = *a; 1669 int &&c = 1; 1670 auto &d = b; 1671 auto &&e = c; 1672 auto &&f = 2; 1673 int g = 5; 1674 1675lValueReferenceType() matches the types of b, d, and e. e is 1676matched since the type is deduced as int& by reference collapsing rules. 1677</pre></td></tr> 1678 1679 1680<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('memberPointerType0')"><a name="memberPointerType0Anchor">memberPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>...</td></tr> 1681<tr><td colspan="4" class="doc" id="memberPointerType0"><pre>Matches member pointer types. 1682Given 1683 struct A { int i; } 1684 A::* ptr = A::i; 1685memberPointerType() 1686 matches "A::* ptr" 1687</pre></td></tr> 1688 1689 1690<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('objcObjectPointerType0')"><a name="objcObjectPointerType0Anchor">objcObjectPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCObjectPointerType.html">ObjCObjectPointerType</a>>...</td></tr> 1691<tr><td colspan="4" class="doc" id="objcObjectPointerType0"><pre>Matches an Objective-C object pointer type, which is different from 1692a pointer type, despite being syntactically similar. 1693 1694Given 1695 int *a; 1696 1697 @interface Foo 1698 @end 1699 Foo *f; 1700pointerType() 1701 matches "Foo *f", but does not match "int *a". 1702</pre></td></tr> 1703 1704 1705<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('parenType0')"><a name="parenType0Anchor">parenType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>>...</td></tr> 1706<tr><td colspan="4" class="doc" id="parenType0"><pre>Matches ParenType nodes. 1707 1708Given 1709 int (*ptr_to_array)[4]; 1710 int *array_of_ptrs[4]; 1711 1712varDecl(hasType(pointsTo(parenType()))) matches ptr_to_array but not 1713array_of_ptrs. 1714</pre></td></tr> 1715 1716 1717<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('pointerType0')"><a name="pointerType0Anchor">pointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>...</td></tr> 1718<tr><td colspan="4" class="doc" id="pointerType0"><pre>Matches pointer types, but does not match Objective-C object pointer 1719types. 1720 1721Given 1722 int *a; 1723 int &b = *a; 1724 int c = 5; 1725 1726 @interface Foo 1727 @end 1728 Foo *f; 1729pointerType() 1730 matches "int *a", but does not match "Foo *f". 1731</pre></td></tr> 1732 1733 1734<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('rValueReferenceType0')"><a name="rValueReferenceType0Anchor">rValueReferenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RValueReferenceType.html">RValueReferenceType</a>>...</td></tr> 1735<tr><td colspan="4" class="doc" id="rValueReferenceType0"><pre>Matches rvalue reference types. 1736 1737Given: 1738 int *a; 1739 int &b = *a; 1740 int &&c = 1; 1741 auto &d = b; 1742 auto &&e = c; 1743 auto &&f = 2; 1744 int g = 5; 1745 1746rValueReferenceType() matches the types of c and f. e is not 1747matched as it is deduced to int& by reference collapsing rules. 1748</pre></td></tr> 1749 1750 1751<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('recordType0')"><a name="recordType0Anchor">recordType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>...</td></tr> 1752<tr><td colspan="4" class="doc" id="recordType0"><pre>Matches record types (e.g. structs, classes). 1753 1754Given 1755 class C {}; 1756 struct S {}; 1757 1758 C c; 1759 S s; 1760 1761recordType() matches the type of the variable declarations of both c 1762and s. 1763</pre></td></tr> 1764 1765 1766<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('referenceType0')"><a name="referenceType0Anchor">referenceType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>>...</td></tr> 1767<tr><td colspan="4" class="doc" id="referenceType0"><pre>Matches both lvalue and rvalue reference types. 1768 1769Given 1770 int *a; 1771 int &b = *a; 1772 int &&c = 1; 1773 auto &d = b; 1774 auto &&e = c; 1775 auto &&f = 2; 1776 int g = 5; 1777 1778referenceType() matches the types of b, c, d, e, and f. 1779</pre></td></tr> 1780 1781 1782<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('substTemplateTypeParmType0')"><a name="substTemplateTypeParmType0Anchor">substTemplateTypeParmType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html">SubstTemplateTypeParmType</a>>...</td></tr> 1783<tr><td colspan="4" class="doc" id="substTemplateTypeParmType0"><pre>Matches types that represent the result of substituting a type for a 1784template type parameter. 1785 1786Given 1787 template <typename T> 1788 void F(T t) { 1789 int i = 1 + t; 1790 } 1791 1792substTemplateTypeParmType() matches the type of 't' but not '1' 1793</pre></td></tr> 1794 1795 1796<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('tagType0')"><a name="tagType0Anchor">tagType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>...</td></tr> 1797<tr><td colspan="4" class="doc" id="tagType0"><pre>Matches tag types (record and enum types). 1798 1799Given 1800 enum E {}; 1801 class C {}; 1802 1803 E e; 1804 C c; 1805 1806tagType() matches the type of the variable declarations of both e 1807and c. 1808</pre></td></tr> 1809 1810 1811<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('templateSpecializationType0')"><a name="templateSpecializationType0Anchor">templateSpecializationType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>...</td></tr> 1812<tr><td colspan="4" class="doc" id="templateSpecializationType0"><pre>Matches template specialization types. 1813 1814Given 1815 template <typename T> 1816 class C { }; 1817 1818 template class C<int>; A 1819 C<char> var; B 1820 1821templateSpecializationType() matches the type of the explicit 1822instantiation in A and the type of the variable declaration in B. 1823</pre></td></tr> 1824 1825 1826<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('templateTypeParmType0')"><a name="templateTypeParmType0Anchor">templateTypeParmType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>...</td></tr> 1827<tr><td colspan="4" class="doc" id="templateTypeParmType0"><pre>Matches template type parameter types. 1828 1829Example matches T, but not int. 1830 (matcher = templateTypeParmType()) 1831 template <typename T> void f(int i); 1832</pre></td></tr> 1833 1834 1835<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> 1836<tr><td colspan="4" class="doc" id="type0"><pre>Matches Types in the clang AST. 1837</pre></td></tr> 1838 1839 1840<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('typedefType0')"><a name="typedefType0Anchor">typedefType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>...</td></tr> 1841<tr><td colspan="4" class="doc" id="typedefType0"><pre>Matches typedef types. 1842 1843Given 1844 typedef int X; 1845typedefType() 1846 matches "typedef int X" 1847</pre></td></tr> 1848 1849 1850<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('unaryTransformType0')"><a name="unaryTransformType0Anchor">unaryTransformType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryTransformType.html">UnaryTransformType</a>>...</td></tr> 1851<tr><td colspan="4" class="doc" id="unaryTransformType0"><pre>Matches types nodes representing unary type transformations. 1852 1853Given: 1854 typedef __underlying_type(T) type; 1855unaryTransformType() 1856 matches "__underlying_type(T)" 1857</pre></td></tr> 1858 1859 1860<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('variableArrayType0')"><a name="variableArrayType0Anchor">variableArrayType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VariableArrayType.html">VariableArrayType</a>>...</td></tr> 1861<tr><td colspan="4" class="doc" id="variableArrayType0"><pre>Matches C arrays with a specified size that is not an 1862integer-constant-expression. 1863 1864Given 1865 void f() { 1866 int a[] = { 2, 3 } 1867 int b[42]; 1868 int c[a[0]]; 1869 } 1870variableArrayType() 1871 matches "int c[a[0]]" 1872</pre></td></tr> 1873 1874<!--END_DECL_MATCHERS --> 1875</table> 1876 1877<!-- ======================================================================= --> 1878<h2 id="narrowing-matchers">Narrowing Matchers</h2> 1879<!-- ======================================================================= --> 1880 1881<p>Narrowing matchers match certain attributes on the current node, thus 1882narrowing down the set of nodes of the current type to match on.</p> 1883 1884<p>There are special logical narrowing matchers (allOf, anyOf, anything and unless) 1885which allow users to create more powerful match expressions.</p> 1886 1887<table> 1888<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 1889<!-- START_NARROWING_MATCHERS --> 1890 1891<tr><td>Matcher<*></td><td class="name" onclick="toggle('allOf0')"><a name="allOf0Anchor">allOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 1892<tr><td colspan="4" class="doc" id="allOf0"><pre>Matches if all given matchers match. 1893 1894Usable as: Any Matcher 1895</pre></td></tr> 1896 1897 1898<tr><td>Matcher<*></td><td class="name" onclick="toggle('anyOf0')"><a name="anyOf0Anchor">anyOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 1899<tr><td colspan="4" class="doc" id="anyOf0"><pre>Matches if any of the given matchers matches. 1900 1901Usable as: Any Matcher 1902</pre></td></tr> 1903 1904 1905<tr><td>Matcher<*></td><td class="name" onclick="toggle('anything0')"><a name="anything0Anchor">anything</a></td><td></td></tr> 1906<tr><td colspan="4" class="doc" id="anything0"><pre>Matches any node. 1907 1908Useful when another matcher requires a child matcher, but there's no 1909additional constraint. This will often be used with an explicit conversion 1910to an internal::Matcher<> type such as TypeMatcher. 1911 1912Example: DeclarationMatcher(anything()) matches all declarations, e.g., 1913"int* p" and "void f()" in 1914 int* p; 1915 void f(); 1916 1917Usable as: Any Matcher 1918</pre></td></tr> 1919 1920 1921<tr><td>Matcher<*></td><td class="name" onclick="toggle('unless0')"><a name="unless0Anchor">unless</a></td><td>Matcher<*></td></tr> 1922<tr><td colspan="4" class="doc" id="unless0"><pre>Matches if the provided matcher does not match. 1923 1924Example matches Y (matcher = cxxRecordDecl(unless(hasName("X")))) 1925 class X {}; 1926 class Y {}; 1927 1928Usable as: Any Matcher 1929</pre></td></tr> 1930 1931 1932<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> 1933<tr><td colspan="4" class="doc" id="hasOperatorName0"><pre>Matches the operator Name of operator expressions (binary or 1934unary). 1935 1936Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 1937 !(a || b) 1938</pre></td></tr> 1939 1940 1941<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BinaryOperator.html">BinaryOperator</a>></td><td class="name" onclick="toggle('isAssignmentOperator0')"><a name="isAssignmentOperator0Anchor">isAssignmentOperator</a></td><td></td></tr> 1942<tr><td colspan="4" class="doc" id="isAssignmentOperator0"><pre>Matches all kinds of assignment operators. 1943 1944Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) 1945 if (a == b) 1946 a += b; 1947 1948Example 2: matches s1 = s2 1949 (matcher = cxxOperatorCallExpr(isAssignmentOperator())) 1950 struct S { S& operator=(const S&); }; 1951 void x() { S s1, s2; s1 = s2; }) 1952</pre></td></tr> 1953 1954 1955<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals5')"><a name="equals5Anchor">equals</a></td><td>bool Value</td></tr> 1956<tr><td colspan="4" class="doc" id="equals5"><pre></pre></td></tr> 1957 1958 1959<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals2')"><a name="equals2Anchor">equals</a></td><td>const ValueT Value</td></tr> 1960<tr><td colspan="4" class="doc" id="equals2"><pre>Matches literals that are equal to the given value of type ValueT. 1961 1962Given 1963 f('false, 3.14, 42); 1964characterLiteral(equals(0)) 1965 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 1966 match false 1967floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 1968 match 3.14 1969integerLiteral(equals(42)) 1970 matches 42 1971 1972Note that you cannot directly match a negative numeric literal because the 1973minus sign is not part of the literal: It is a unary operator whose operand 1974is the positive numeric literal. Instead, you must use a unaryOperator() 1975matcher to match the minus sign: 1976 1977unaryOperator(hasOperatorName("-"), 1978 hasUnaryOperand(integerLiteral(equals(13)))) 1979 1980Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>, 1981 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>> 1982</pre></td></tr> 1983 1984 1985<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals11')"><a name="equals11Anchor">equals</a></td><td>double Value</td></tr> 1986<tr><td colspan="4" class="doc" id="equals11"><pre></pre></td></tr> 1987 1988 1989<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>></td><td class="name" onclick="toggle('equals8')"><a name="equals8Anchor">equals</a></td><td>unsigned Value</td></tr> 1990<tr><td colspan="4" class="doc" id="equals8"><pre></pre></td></tr> 1991 1992 1993<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCatchStmt.html">CXXCatchStmt</a>></td><td class="name" onclick="toggle('isCatchAll0')"><a name="isCatchAll0Anchor">isCatchAll</a></td><td></td></tr> 1994<tr><td colspan="4" class="doc" id="isCatchAll0"><pre>Matches a C++ catch statement that has a catch-all handler. 1995 1996Given 1997 try { 1998 ... 1999 } catch (int) { 2000 ... 2001 } catch (...) { 2002 ... 2003 } 2004endcode 2005cxxCatchStmt(isCatchAll()) matches catch(...) but not catch(int). 2006</pre></td></tr> 2007 2008 2009<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('argumentCountIs1')"><a name="argumentCountIs1Anchor">argumentCountIs</a></td><td>unsigned N</td></tr> 2010<tr><td colspan="4" class="doc" id="argumentCountIs1"><pre>Checks that a call expression or a constructor call expression has 2011a specific number of arguments (including absent default arguments). 2012 2013Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 2014 void f(int x, int y); 2015 f(0, 0); 2016</pre></td></tr> 2017 2018 2019<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('isListInitialization0')"><a name="isListInitialization0Anchor">isListInitialization</a></td><td></td></tr> 2020<tr><td colspan="4" class="doc" id="isListInitialization0"><pre>Matches a constructor call expression which uses list initialization. 2021</pre></td></tr> 2022 2023 2024<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('requiresZeroInitialization0')"><a name="requiresZeroInitialization0Anchor">requiresZeroInitialization</a></td><td></td></tr> 2025<tr><td colspan="4" class="doc" id="requiresZeroInitialization0"><pre>Matches a constructor call expression which requires 2026zero initialization. 2027 2028Given 2029void foo() { 2030 struct point { double x; double y; }; 2031 point pt[2] = { { 1.0, 2.0 } }; 2032} 2033initListExpr(has(cxxConstructExpr(requiresZeroInitialization())) 2034will match the implicit array filler for pt[1]. 2035</pre></td></tr> 2036 2037 2038<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isCopyConstructor0')"><a name="isCopyConstructor0Anchor">isCopyConstructor</a></td><td></td></tr> 2039<tr><td colspan="4" class="doc" id="isCopyConstructor0"><pre>Matches constructor declarations that are copy constructors. 2040 2041Given 2042 struct S { 2043 S(); #1 2044 S(const S &); #2 2045 S(S &&); #3 2046 }; 2047cxxConstructorDecl(isCopyConstructor()) will match #2, but not #1 or #3. 2048</pre></td></tr> 2049 2050 2051<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isDefaultConstructor0')"><a name="isDefaultConstructor0Anchor">isDefaultConstructor</a></td><td></td></tr> 2052<tr><td colspan="4" class="doc" id="isDefaultConstructor0"><pre>Matches constructor declarations that are default constructors. 2053 2054Given 2055 struct S { 2056 S(); #1 2057 S(const S &); #2 2058 S(S &&); #3 2059 }; 2060cxxConstructorDecl(isDefaultConstructor()) will match #1, but not #2 or #3. 2061</pre></td></tr> 2062 2063 2064<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isDelegatingConstructor0')"><a name="isDelegatingConstructor0Anchor">isDelegatingConstructor</a></td><td></td></tr> 2065<tr><td colspan="4" class="doc" id="isDelegatingConstructor0"><pre>Matches constructors that delegate to another constructor. 2066 2067Given 2068 struct S { 2069 S(); #1 2070 S(int) {} #2 2071 S(S &&) : S() {} #3 2072 }; 2073 S::S() : S(0) {} #4 2074cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not 2075#1 or #2. 2076</pre></td></tr> 2077 2078 2079<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isExplicit0')"><a name="isExplicit0Anchor">isExplicit</a></td><td></td></tr> 2080<tr><td colspan="4" class="doc" id="isExplicit0"><pre>Matches constructor and conversion declarations that are marked with 2081the explicit keyword. 2082 2083Given 2084 struct S { 2085 S(int); #1 2086 explicit S(double); #2 2087 operator int(); #3 2088 explicit operator bool(); #4 2089 }; 2090cxxConstructorDecl(isExplicit()) will match #2, but not #1. 2091cxxConversionDecl(isExplicit()) will match #4, but not #3. 2092</pre></td></tr> 2093 2094 2095<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('isMoveConstructor0')"><a name="isMoveConstructor0Anchor">isMoveConstructor</a></td><td></td></tr> 2096<tr><td colspan="4" class="doc" id="isMoveConstructor0"><pre>Matches constructor declarations that are move constructors. 2097 2098Given 2099 struct S { 2100 S(); #1 2101 S(const S &); #2 2102 S(S &&); #3 2103 }; 2104cxxConstructorDecl(isMoveConstructor()) will match #3, but not #1 or #2. 2105</pre></td></tr> 2106 2107 2108<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConversionDecl.html">CXXConversionDecl</a>></td><td class="name" onclick="toggle('isExplicit1')"><a name="isExplicit1Anchor">isExplicit</a></td><td></td></tr> 2109<tr><td colspan="4" class="doc" id="isExplicit1"><pre>Matches constructor and conversion declarations that are marked with 2110the explicit keyword. 2111 2112Given 2113 struct S { 2114 S(int); #1 2115 explicit S(double); #2 2116 operator int(); #3 2117 explicit operator bool(); #4 2118 }; 2119cxxConstructorDecl(isExplicit()) will match #2, but not #1. 2120cxxConversionDecl(isExplicit()) will match #4, but not #3. 2121</pre></td></tr> 2122 2123 2124<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('isBaseInitializer0')"><a name="isBaseInitializer0Anchor">isBaseInitializer</a></td><td></td></tr> 2125<tr><td colspan="4" class="doc" id="isBaseInitializer0"><pre>Matches a constructor initializer if it is initializing a base, as 2126opposed to a member. 2127 2128Given 2129 struct B {}; 2130 struct D : B { 2131 int I; 2132 D(int i) : I(i) {} 2133 }; 2134 struct E : B { 2135 E() : B() {} 2136 }; 2137cxxConstructorDecl(hasAnyConstructorInitializer(isBaseInitializer())) 2138 will match E(), but not match D(int). 2139</pre></td></tr> 2140 2141 2142<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>></td><td class="name" onclick="toggle('isMemberInitializer0')"><a name="isMemberInitializer0Anchor">isMemberInitializer</a></td><td></td></tr> 2143<tr><td colspan="4" class="doc" id="isMemberInitializer0"><pre>Matches a constructor initializer if it is initializing a member, as 2144opposed to a base. 2145 2146Given 2147 struct B {}; 2148 struct D : B { 2149 int I; 2150 D(int i) : I(i) {} 2151 }; 2152 struct E : B { 2153 E() : B() {} 2154 }; 2155cxxConstructorDecl(hasAnyConstructorInitializer(isMemberInitializer())) 2156 will match D(int), but not match E(). 2157</pre></td></tr> 2158 2159 2160<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> 2161<tr><td colspan="4" class="doc" id="isWritten0"><pre>Matches a constructor initializer if it is explicitly written in 2162code (as opposed to implicitly added by the compiler). 2163 2164Given 2165 struct Foo { 2166 Foo() { } 2167 Foo(int) : foo_("A") { } 2168 string foo_; 2169 }; 2170cxxConstructorDecl(hasAnyConstructorInitializer(isWritten())) 2171 will match Foo(int), but not Foo() 2172</pre></td></tr> 2173 2174 2175<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isConst0')"><a name="isConst0Anchor">isConst</a></td><td></td></tr> 2176<tr><td colspan="4" class="doc" id="isConst0"><pre>Matches if the given method declaration is const. 2177 2178Given 2179struct A { 2180 void foo() const; 2181 void bar(); 2182}; 2183 2184cxxMethodDecl(isConst()) matches A::foo() but not A::bar() 2185</pre></td></tr> 2186 2187 2188<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isCopyAssignmentOperator0')"><a name="isCopyAssignmentOperator0Anchor">isCopyAssignmentOperator</a></td><td></td></tr> 2189<tr><td colspan="4" class="doc" id="isCopyAssignmentOperator0"><pre>Matches if the given method declaration declares a copy assignment 2190operator. 2191 2192Given 2193struct A { 2194 A &operator=(const A &); 2195 A &operator=(A &&); 2196}; 2197 2198cxxMethodDecl(isCopyAssignmentOperator()) matches the first method but not 2199the second one. 2200</pre></td></tr> 2201 2202 2203<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isFinal1')"><a name="isFinal1Anchor">isFinal</a></td><td></td></tr> 2204<tr><td colspan="4" class="doc" id="isFinal1"><pre>Matches if the given method or class declaration is final. 2205 2206Given: 2207 class A final {}; 2208 2209 struct B { 2210 virtual void f(); 2211 }; 2212 2213 struct C : B { 2214 void f() final; 2215 }; 2216matches A and C::f, but not B, C, or B::f 2217</pre></td></tr> 2218 2219 2220<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isMoveAssignmentOperator0')"><a name="isMoveAssignmentOperator0Anchor">isMoveAssignmentOperator</a></td><td></td></tr> 2221<tr><td colspan="4" class="doc" id="isMoveAssignmentOperator0"><pre>Matches if the given method declaration declares a move assignment 2222operator. 2223 2224Given 2225struct A { 2226 A &operator=(const A &); 2227 A &operator=(A &&); 2228}; 2229 2230cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not 2231the first one. 2232</pre></td></tr> 2233 2234 2235<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isOverride0')"><a name="isOverride0Anchor">isOverride</a></td><td></td></tr> 2236<tr><td colspan="4" class="doc" id="isOverride0"><pre>Matches if the given method declaration overrides another method. 2237 2238Given 2239 class A { 2240 public: 2241 virtual void x(); 2242 }; 2243 class B : public A { 2244 public: 2245 virtual void x(); 2246 }; 2247 matches B::x 2248</pre></td></tr> 2249 2250 2251<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isPure0')"><a name="isPure0Anchor">isPure</a></td><td></td></tr> 2252<tr><td colspan="4" class="doc" id="isPure0"><pre>Matches if the given method declaration is pure. 2253 2254Given 2255 class A { 2256 public: 2257 virtual void x() = 0; 2258 }; 2259 matches A::x 2260</pre></td></tr> 2261 2262 2263<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isUserProvided0')"><a name="isUserProvided0Anchor">isUserProvided</a></td><td></td></tr> 2264<tr><td colspan="4" class="doc" id="isUserProvided0"><pre>Matches method declarations that are user-provided. 2265 2266Given 2267 struct S { 2268 S(); #1 2269 S(const S &) = default; #2 2270 S(S &&) = delete; #3 2271 }; 2272cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3. 2273</pre></td></tr> 2274 2275 2276<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isVirtual0')"><a name="isVirtual0Anchor">isVirtual</a></td><td></td></tr> 2277<tr><td colspan="4" class="doc" id="isVirtual0"><pre>Matches if the given method declaration is virtual. 2278 2279Given 2280 class A { 2281 public: 2282 virtual void x(); 2283 }; 2284 matches A::x 2285</pre></td></tr> 2286 2287 2288<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('isVirtualAsWritten0')"><a name="isVirtualAsWritten0Anchor">isVirtualAsWritten</a></td><td></td></tr> 2289<tr><td colspan="4" class="doc" id="isVirtualAsWritten0"><pre>Matches if the given method declaration has an explicit "virtual". 2290 2291Given 2292 class A { 2293 public: 2294 virtual void x(); 2295 }; 2296 class B : public A { 2297 public: 2298 void x(); 2299 }; 2300 matches A::x but not B::x 2301</pre></td></tr> 2302 2303 2304<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>></td><td class="name" onclick="toggle('isArray0')"><a name="isArray0Anchor">isArray</a></td><td></td></tr> 2305<tr><td colspan="4" class="doc" id="isArray0"><pre>Matches array new expressions. 2306 2307Given: 2308 MyClass *p1 = new MyClass[10]; 2309cxxNewExpr(isArray()) 2310 matches the expression 'new MyClass[10]'. 2311</pre></td></tr> 2312 2313 2314<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName1')"><a name="hasOverloadedOperatorName1Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr> 2315<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName1"><pre>Matches overloaded operator names. 2316 2317Matches overloaded operator names specified in strings without the 2318"operator" prefix: e.g. "<<". 2319 2320Given: 2321 class A { int operator*(); }; 2322 const A &operator<<(const A &a, const A &b); 2323 A a; 2324 a << a; <-- This matches 2325 2326cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the 2327specified line and 2328cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) 2329matches the declaration of A. 2330 2331Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> 2332</pre></td></tr> 2333 2334 2335<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>></td><td class="name" onclick="toggle('isAssignmentOperator1')"><a name="isAssignmentOperator1Anchor">isAssignmentOperator</a></td><td></td></tr> 2336<tr><td colspan="4" class="doc" id="isAssignmentOperator1"><pre>Matches all kinds of assignment operators. 2337 2338Example 1: matches a += b (matcher = binaryOperator(isAssignmentOperator())) 2339 if (a == b) 2340 a += b; 2341 2342Example 2: matches s1 = s2 2343 (matcher = cxxOperatorCallExpr(isAssignmentOperator())) 2344 struct S { S& operator=(const S&); }; 2345 void x() { S s1, s2; s1 = s2; }) 2346</pre></td></tr> 2347 2348 2349<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('hasDefinition0')"><a name="hasDefinition0Anchor">hasDefinition</a></td><td></td></tr> 2350<tr><td colspan="4" class="doc" id="hasDefinition0"><pre>Matches a class declaration that is defined. 2351 2352Example matches x (matcher = cxxRecordDecl(hasDefinition())) 2353class x {}; 2354class y; 2355</pre></td></tr> 2356 2357 2358<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isDerivedFrom1')"><a name="isDerivedFrom1Anchor">isDerivedFrom</a></td><td>std::string BaseName</td></tr> 2359<tr><td colspan="4" class="doc" id="isDerivedFrom1"><pre>Overloaded method as shortcut for isDerivedFrom(hasName(...)). 2360</pre></td></tr> 2361 2362 2363<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isExplicitTemplateSpecialization2')"><a name="isExplicitTemplateSpecialization2Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr> 2364<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization2"><pre>Matches explicit template specializations of function, class, or 2365static member variable template instantiations. 2366 2367Given 2368 template<typename T> void A(T t) { } 2369 template<> void A(int N) { } 2370functionDecl(isExplicitTemplateSpecialization()) 2371 matches the specialization A<int>(). 2372 2373Usable 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>> 2374</pre></td></tr> 2375 2376 2377<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isFinal0')"><a name="isFinal0Anchor">isFinal</a></td><td></td></tr> 2378<tr><td colspan="4" class="doc" id="isFinal0"><pre>Matches if the given method or class declaration is final. 2379 2380Given: 2381 class A final {}; 2382 2383 struct B { 2384 virtual void f(); 2385 }; 2386 2387 struct C : B { 2388 void f() final; 2389 }; 2390matches A and C::f, but not B, C, or B::f 2391</pre></td></tr> 2392 2393 2394<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isLambda0')"><a name="isLambda0Anchor">isLambda</a></td><td></td></tr> 2395<tr><td colspan="4" class="doc" id="isLambda0"><pre>Matches the generated class of lambda expressions. 2396 2397Given: 2398 auto x = []{}; 2399 2400cxxRecordDecl(isLambda()) matches the implicit class declaration of 2401decltype(x) 2402</pre></td></tr> 2403 2404 2405<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isSameOrDerivedFrom1')"><a name="isSameOrDerivedFrom1Anchor">isSameOrDerivedFrom</a></td><td>std::string BaseName</td></tr> 2406<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom1"><pre>Overloaded method as shortcut for 2407isSameOrDerivedFrom(hasName(...)). 2408</pre></td></tr> 2409 2410 2411<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('isTemplateInstantiation2')"><a name="isTemplateInstantiation2Anchor">isTemplateInstantiation</a></td><td></td></tr> 2412<tr><td colspan="4" class="doc" id="isTemplateInstantiation2"><pre>Matches template instantiations of function, class, or static 2413member variable template instantiations. 2414 2415Given 2416 template <typename T> class X {}; class A {}; X<A> x; 2417or 2418 template <typename T> class X {}; class A {}; template class X<A>; 2419or 2420 template <typename T> class X {}; class A {}; extern template class X<A>; 2421cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2422 matches the template instantiation of X<A>. 2423 2424But given 2425 template <typename T> class X {}; class A {}; 2426 template <> class X<A> {}; X<A> x; 2427cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2428 does not match, as X<A> is an explicit template specialization. 2429 2430Usable 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>> 2431</pre></td></tr> 2432 2433 2434<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> 2435<tr><td colspan="4" class="doc" id="argumentCountIs0"><pre>Checks that a call expression or a constructor call expression has 2436a specific number of arguments (including absent default arguments). 2437 2438Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 2439 void f(int x, int y); 2440 f(0, 0); 2441</pre></td></tr> 2442 2443 2444<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CastExpr.html">CastExpr</a>></td><td class="name" onclick="toggle('hasCastKind0')"><a name="hasCastKind0Anchor">hasCastKind</a></td><td>CastKind Kind</td></tr> 2445<tr><td colspan="4" class="doc" id="hasCastKind0"><pre>Matches casts that has a given cast kind. 2446 2447Example: matches the implicit cast around 0 2448(matcher = castExpr(hasCastKind(CK_NullToPointer))) 2449 int *p = 0; 2450</pre></td></tr> 2451 2452 2453<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>></td><td class="name" onclick="toggle('equals4')"><a name="equals4Anchor">equals</a></td><td>bool Value</td></tr> 2454<tr><td colspan="4" class="doc" id="equals4"><pre></pre></td></tr> 2455 2456 2457<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>const ValueT Value</td></tr> 2458<tr><td colspan="4" class="doc" id="equals3"><pre>Matches literals that are equal to the given value of type ValueT. 2459 2460Given 2461 f('false, 3.14, 42); 2462characterLiteral(equals(0)) 2463 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 2464 match false 2465floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 2466 match 3.14 2467integerLiteral(equals(42)) 2468 matches 42 2469 2470Note that you cannot directly match a negative numeric literal because the 2471minus sign is not part of the literal: It is a unary operator whose operand 2472is the positive numeric literal. Instead, you must use a unaryOperator() 2473matcher to match the minus sign: 2474 2475unaryOperator(hasOperatorName("-"), 2476 hasUnaryOperand(integerLiteral(equals(13)))) 2477 2478Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>, 2479 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>> 2480</pre></td></tr> 2481 2482 2483<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>></td><td class="name" onclick="toggle('equals10')"><a name="equals10Anchor">equals</a></td><td>double Value</td></tr> 2484<tr><td colspan="4" class="doc" id="equals10"><pre></pre></td></tr> 2485 2486 2487<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>></td><td class="name" onclick="toggle('equals7')"><a name="equals7Anchor">equals</a></td><td>unsigned Value</td></tr> 2488<tr><td colspan="4" class="doc" id="equals7"><pre></pre></td></tr> 2489 2490 2491<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('templateArgumentCountIs0')"><a name="templateArgumentCountIs0Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr> 2492<tr><td colspan="4" class="doc" id="templateArgumentCountIs0"><pre>Matches if the number of template arguments equals N. 2493 2494Given 2495 template<typename T> struct C {}; 2496 C<int> c; 2497classTemplateSpecializationDecl(templateArgumentCountIs(1)) 2498 matches C<int>. 2499</pre></td></tr> 2500 2501 2502<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> 2503<tr><td colspan="4" class="doc" id="statementCountIs0"><pre>Checks that a compound statement contains a specific number of 2504child statements. 2505 2506Example: Given 2507 { for (;;) {} } 2508compoundStmt(statementCountIs(0))) 2509 matches '{}' 2510 but does not match the outer compound statement. 2511</pre></td></tr> 2512 2513 2514<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> 2515<tr><td colspan="4" class="doc" id="hasSize0"><pre>Matches nodes that have the specified size. 2516 2517Given 2518 int a[42]; 2519 int b[2 * 21]; 2520 int c[41], d[43]; 2521 char *s = "abcd"; 2522 wchar_t *ws = L"abcd"; 2523 char *w = "a"; 2524constantArrayType(hasSize(42)) 2525 matches "int a[42]" and "int b[2 * 21]" 2526stringLiteral(hasSize(4)) 2527 matches "abcd", L"abcd" 2528</pre></td></tr> 2529 2530 2531<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> 2532<tr><td colspan="4" class="doc" id="declCountIs0"><pre>Matches declaration statements that contain a specific number of 2533declarations. 2534 2535Example: Given 2536 int a, b; 2537 int c; 2538 int d = 2, e; 2539declCountIs(2) 2540 matches 'int a, b;' and 'int d = 2, e;', but not 'int c;'. 2541</pre></td></tr> 2542 2543 2544<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('equalsBoundNode1')"><a name="equalsBoundNode1Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr> 2545<tr><td colspan="4" class="doc" id="equalsBoundNode1"><pre>Matches if a node equals a previously bound node. 2546 2547Matches a node if it equals the node previously bound to ID. 2548 2549Given 2550 class X { int a; int b; }; 2551cxxRecordDecl( 2552 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 2553 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 2554 matches the class X, as a and b have the same type. 2555 2556Note that when multiple matches are involved via forEach* matchers, 2557equalsBoundNodes acts as a filter. 2558For example: 2559compoundStmt( 2560 forEachDescendant(varDecl().bind("d")), 2561 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 2562will trigger a match for each combination of variable declaration 2563and reference to that variable declaration within a compound statement. 2564</pre></td></tr> 2565 2566 2567<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('equalsNode0')"><a name="equalsNode0Anchor">equalsNode</a></td><td>const Decl* Other</td></tr> 2568<tr><td colspan="4" class="doc" id="equalsNode0"><pre>Matches if a node equals another node. 2569 2570Decl has pointer identity in the AST. 2571</pre></td></tr> 2572 2573 2574<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('hasAttr0')"><a name="hasAttr0Anchor">hasAttr</a></td><td>attr::Kind AttrKind</td></tr> 2575<tr><td colspan="4" class="doc" id="hasAttr0"><pre>Matches declaration that has a given attribute. 2576 2577Given 2578 __attribute__((device)) void f() { ... } 2579decl(hasAttr(clang::attr::CUDADevice)) matches the function declaration of 2580f. If the matcher is use from clang-query, attr::Kind parameter should be 2581passed as a quoted string. e.g., hasAttr("attr::CUDADevice"). 2582</pre></td></tr> 2583 2584 2585<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching0')"><a name="isExpansionInFileMatching0Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr> 2586<tr><td colspan="4" class="doc" id="isExpansionInFileMatching0"><pre>Matches AST nodes that were expanded within files whose name is 2587partially matching a given regex. 2588 2589Example matches Y but not X 2590 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 2591 #include "ASTMatcher.h" 2592 class X {}; 2593ASTMatcher.h: 2594 class Y {}; 2595 2596Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 2597</pre></td></tr> 2598 2599 2600<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInMainFile0')"><a name="isExpansionInMainFile0Anchor">isExpansionInMainFile</a></td><td></td></tr> 2601<tr><td colspan="4" class="doc" id="isExpansionInMainFile0"><pre>Matches AST nodes that were expanded within the main-file. 2602 2603Example matches X but not Y 2604 (matcher = cxxRecordDecl(isExpansionInMainFile()) 2605 #include <Y.h> 2606 class X {}; 2607Y.h: 2608 class Y {}; 2609 2610Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 2611</pre></td></tr> 2612 2613 2614<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isExpansionInSystemHeader0')"><a name="isExpansionInSystemHeader0Anchor">isExpansionInSystemHeader</a></td><td></td></tr> 2615<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader0"><pre>Matches AST nodes that were expanded within system-header-files. 2616 2617Example matches Y but not X 2618 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 2619 #include <SystemHeader.h> 2620 class X {}; 2621SystemHeader.h: 2622 class Y {}; 2623 2624Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 2625</pre></td></tr> 2626 2627 2628<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isImplicit0')"><a name="isImplicit0Anchor">isImplicit</a></td><td></td></tr> 2629<tr><td colspan="4" class="doc" id="isImplicit0"><pre>Matches a declaration that has been implicitly added 2630by the compiler (eg. implicit defaultcopy constructors). 2631</pre></td></tr> 2632 2633 2634<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isPrivate0')"><a name="isPrivate0Anchor">isPrivate</a></td><td></td></tr> 2635<tr><td colspan="4" class="doc" id="isPrivate0"><pre>Matches private C++ declarations. 2636 2637Given 2638 class C { 2639 public: int a; 2640 protected: int b; 2641 private: int c; 2642 }; 2643fieldDecl(isPrivate()) 2644 matches 'int c;' 2645</pre></td></tr> 2646 2647 2648<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isProtected0')"><a name="isProtected0Anchor">isProtected</a></td><td></td></tr> 2649<tr><td colspan="4" class="doc" id="isProtected0"><pre>Matches protected C++ declarations. 2650 2651Given 2652 class C { 2653 public: int a; 2654 protected: int b; 2655 private: int c; 2656 }; 2657fieldDecl(isProtected()) 2658 matches 'int b;' 2659</pre></td></tr> 2660 2661 2662<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('isPublic0')"><a name="isPublic0Anchor">isPublic</a></td><td></td></tr> 2663<tr><td colspan="4" class="doc" id="isPublic0"><pre>Matches public C++ declarations. 2664 2665Given 2666 class C { 2667 public: int a; 2668 protected: int b; 2669 private: int c; 2670 }; 2671fieldDecl(isPublic()) 2672 matches 'int a;' 2673</pre></td></tr> 2674 2675 2676<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DesignatedInitExpr.html">DesignatedInitExpr</a>></td><td class="name" onclick="toggle('designatorCountIs0')"><a name="designatorCountIs0Anchor">designatorCountIs</a></td><td>unsigned N</td></tr> 2677<tr><td colspan="4" class="doc" id="designatorCountIs0"><pre>Matches designated initializer expressions that contain 2678a specific number of designators. 2679 2680Example: Given 2681 point ptarray[10] = { [2].y = 1.0, [0].x = 1.0 }; 2682 point ptarray2[10] = { [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }; 2683designatorCountIs(2) 2684 matches '{ [2].y = 1.0, [0].x = 1.0 }', 2685 but not '{ [2].y = 1.0, [2].x = 0.0, [0].x = 1.0 }'. 2686</pre></td></tr> 2687 2688 2689<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumDecl.html">EnumDecl</a>></td><td class="name" onclick="toggle('isScoped0')"><a name="isScoped0Anchor">isScoped</a></td><td></td></tr> 2690<tr><td colspan="4" class="doc" id="isScoped0"><pre>Matches C++11 scoped enum declaration. 2691 2692Example matches Y (matcher = enumDecl(isScoped())) 2693enum X {}; 2694enum class Y {}; 2695</pre></td></tr> 2696 2697 2698<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>></td><td class="name" onclick="toggle('hasBitWidth0')"><a name="hasBitWidth0Anchor">hasBitWidth</a></td><td>unsigned Width</td></tr> 2699<tr><td colspan="4" class="doc" id="hasBitWidth0"><pre>Matches non-static data members that are bit-fields of the specified 2700bit width. 2701 2702Given 2703 class C { 2704 int a : 2; 2705 int b : 4; 2706 int c : 2; 2707 }; 2708fieldDecl(hasBitWidth(2)) 2709 matches 'int a;' and 'int c;' but not 'int b;'. 2710</pre></td></tr> 2711 2712 2713<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>></td><td class="name" onclick="toggle('isBitField0')"><a name="isBitField0Anchor">isBitField</a></td><td></td></tr> 2714<tr><td colspan="4" class="doc" id="isBitField0"><pre>Matches non-static data members that are bit-fields. 2715 2716Given 2717 class C { 2718 int a : 2; 2719 int b; 2720 }; 2721fieldDecl(isBitField()) 2722 matches 'int a;' but not 'int b;'. 2723</pre></td></tr> 2724 2725 2726<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>const ValueT Value</td></tr> 2727<tr><td colspan="4" class="doc" id="equals1"><pre>Matches literals that are equal to the given value of type ValueT. 2728 2729Given 2730 f('false, 3.14, 42); 2731characterLiteral(equals(0)) 2732 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 2733 match false 2734floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 2735 match 3.14 2736integerLiteral(equals(42)) 2737 matches 42 2738 2739Note that you cannot directly match a negative numeric literal because the 2740minus sign is not part of the literal: It is a unary operator whose operand 2741is the positive numeric literal. Instead, you must use a unaryOperator() 2742matcher to match the minus sign: 2743 2744unaryOperator(hasOperatorName("-"), 2745 hasUnaryOperand(integerLiteral(equals(13)))) 2746 2747Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>, 2748 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>> 2749</pre></td></tr> 2750 2751 2752<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FloatingLiteral.html">FloatingLiteral</a>></td><td class="name" onclick="toggle('equals12')"><a name="equals12Anchor">equals</a></td><td>double Value</td></tr> 2753<tr><td colspan="4" class="doc" id="equals12"><pre></pre></td></tr> 2754 2755 2756<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasDynamicExceptionSpec0')"><a name="hasDynamicExceptionSpec0Anchor">hasDynamicExceptionSpec</a></td><td></td></tr> 2757<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification. 2758 2759Given: 2760 void f(); 2761 void g() noexcept; 2762 void h() noexcept(true); 2763 void i() noexcept(false); 2764 void j() throw(); 2765 void k() throw(int); 2766 void l() throw(...); 2767functionDecl(hasDynamicExceptionSpec()) and 2768 functionProtoType(hasDynamicExceptionSpec()) 2769 match the declarations of j, k, and l, but not f, g, h, or i. 2770</pre></td></tr> 2771 2772 2773<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr> 2774<tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. 2775 2776Matches overloaded operator names specified in strings without the 2777"operator" prefix: e.g. "<<". 2778 2779Given: 2780 class A { int operator*(); }; 2781 const A &operator<<(const A &a, const A &b); 2782 A a; 2783 a << a; <-- This matches 2784 2785cxxOperatorCallExpr(hasOverloadedOperatorName("<<"))) matches the 2786specified line and 2787cxxRecordDecl(hasMethod(hasOverloadedOperatorName("*"))) 2788matches the declaration of A. 2789 2790Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXOperatorCallExpr.html">CXXOperatorCallExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> 2791</pre></td></tr> 2792 2793 2794<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasTrailingReturn0')"><a name="hasTrailingReturn0Anchor">hasTrailingReturn</a></td><td></td></tr> 2795<tr><td colspan="4" class="doc" id="hasTrailingReturn0"><pre>Matches a function declared with a trailing return type. 2796 2797Example matches Y (matcher = functionDecl(hasTrailingReturn())) 2798int X() {} 2799auto Y() -> int {} 2800</pre></td></tr> 2801 2802 2803<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isConstexpr1')"><a name="isConstexpr1Anchor">isConstexpr</a></td><td></td></tr> 2804<tr><td colspan="4" class="doc" id="isConstexpr1"><pre>Matches constexpr variable and function declarations, 2805 and if constexpr. 2806 2807Given: 2808 constexpr int foo = 42; 2809 constexpr int bar(); 2810 void baz() { if constexpr(1 > 0) {} } 2811varDecl(isConstexpr()) 2812 matches the declaration of foo. 2813functionDecl(isConstexpr()) 2814 matches the declaration of bar. 2815ifStmt(isConstexpr()) 2816 matches the if statement in baz. 2817</pre></td></tr> 2818 2819 2820<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDefaulted0')"><a name="isDefaulted0Anchor">isDefaulted</a></td><td></td></tr> 2821<tr><td colspan="4" class="doc" id="isDefaulted0"><pre>Matches defaulted function declarations. 2822 2823Given: 2824 class A { ~A(); }; 2825 class B { ~B() = default; }; 2826functionDecl(isDefaulted()) 2827 matches the declaration of ~B, but not ~A. 2828</pre></td></tr> 2829 2830 2831<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDefinition3')"><a name="isDefinition3Anchor">isDefinition</a></td><td></td></tr> 2832<tr><td colspan="4" class="doc" id="isDefinition3"><pre>Matches if a declaration has a body attached. 2833 2834Example matches A, va, fa 2835 class A {}; 2836 class B; Doesn't match, as it has no body. 2837 int va; 2838 extern int vb; Doesn't match, as it doesn't define the variable. 2839 void fa() {} 2840 void fb(); Doesn't match, as it has no body. 2841 @interface X 2842 - (void)ma; Doesn't match, interface is declaration. 2843 @end 2844 @implementation X 2845 - (void)ma {} 2846 @end 2847 2848Usable 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>>, 2849 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 2850</pre></td></tr> 2851 2852 2853<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDeleted0')"><a name="isDeleted0Anchor">isDeleted</a></td><td></td></tr> 2854<tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. 2855 2856Given: 2857 void Func(); 2858 void DeletedFunc() = delete; 2859functionDecl(isDeleted()) 2860 matches the declaration of DeletedFunc, but not Func. 2861</pre></td></tr> 2862 2863 2864<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isExplicitTemplateSpecialization0')"><a name="isExplicitTemplateSpecialization0Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr> 2865<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or 2866static member variable template instantiations. 2867 2868Given 2869 template<typename T> void A(T t) { } 2870 template<> void A(int N) { } 2871functionDecl(isExplicitTemplateSpecialization()) 2872 matches the specialization A<int>(). 2873 2874Usable 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>> 2875</pre></td></tr> 2876 2877 2878<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> 2879<tr><td colspan="4" class="doc" id="isExternC0"><pre>Matches extern "C" function or variable declarations. 2880 2881Given: 2882 extern "C" void f() {} 2883 extern "C" { void g() {} } 2884 void h() {} 2885 extern "C" int x = 1; 2886 extern "C" int y = 2; 2887 int z = 3; 2888functionDecl(isExternC()) 2889 matches the declaration of f and g, but not the declaration of h. 2890varDecl(isExternC()) 2891 matches the declaration of x and y, but not the declaration of z. 2892</pre></td></tr> 2893 2894 2895<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isInline1')"><a name="isInline1Anchor">isInline</a></td><td></td></tr> 2896<tr><td colspan="4" class="doc" id="isInline1"><pre>Matches function and namespace declarations that are marked with 2897the inline keyword. 2898 2899Given 2900 inline void f(); 2901 void g(); 2902 namespace n { 2903 inline namespace m {} 2904 } 2905functionDecl(isInline()) will match ::f(). 2906namespaceDecl(isInline()) will match n::m. 2907</pre></td></tr> 2908 2909 2910<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isNoReturn0')"><a name="isNoReturn0Anchor">isNoReturn</a></td><td></td></tr> 2911<tr><td colspan="4" class="doc" id="isNoReturn0"><pre>Matches FunctionDecls that have a noreturn attribute. 2912 2913Given 2914 void nope(); 2915 [[noreturn]] void a(); 2916 __attribute__((noreturn)) void b(); 2917 struct c { [[noreturn]] c(); }; 2918functionDecl(isNoReturn()) 2919 matches all of those except 2920 void nope(); 2921</pre></td></tr> 2922 2923 2924<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isNoThrow0')"><a name="isNoThrow0Anchor">isNoThrow</a></td><td></td></tr> 2925<tr><td colspan="4" class="doc" id="isNoThrow0"><pre>Matches functions that have a non-throwing exception specification. 2926 2927Given: 2928 void f(); 2929 void g() noexcept; 2930 void h() throw(); 2931 void i() throw(int); 2932 void j() noexcept(false); 2933functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) 2934 match the declarations of g, and h, but not f, i or j. 2935</pre></td></tr> 2936 2937 2938<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isStaticStorageClass0')"><a name="isStaticStorageClass0Anchor">isStaticStorageClass</a></td><td></td></tr> 2939<tr><td colspan="4" class="doc" id="isStaticStorageClass0"><pre>Matches variablefunction declarations that have "static" storage 2940class specifier ("static" keyword) written in the source. 2941 2942Given: 2943 static void f() {} 2944 static int i = 0; 2945 extern int j; 2946 int k; 2947functionDecl(isStaticStorageClass()) 2948 matches the function declaration f. 2949varDecl(isStaticStorageClass()) 2950 matches the variable declaration i. 2951</pre></td></tr> 2952 2953 2954<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isTemplateInstantiation0')"><a name="isTemplateInstantiation0Anchor">isTemplateInstantiation</a></td><td></td></tr> 2955<tr><td colspan="4" class="doc" id="isTemplateInstantiation0"><pre>Matches template instantiations of function, class, or static 2956member variable template instantiations. 2957 2958Given 2959 template <typename T> class X {}; class A {}; X<A> x; 2960or 2961 template <typename T> class X {}; class A {}; template class X<A>; 2962or 2963 template <typename T> class X {}; class A {}; extern template class X<A>; 2964cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2965 matches the template instantiation of X<A>. 2966 2967But given 2968 template <typename T> class X {}; class A {}; 2969 template <> class X<A> {}; X<A> x; 2970cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 2971 does not match, as X<A> is an explicit template specialization. 2972 2973Usable 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>> 2974</pre></td></tr> 2975 2976 2977<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isVariadic0')"><a name="isVariadic0Anchor">isVariadic</a></td><td></td></tr> 2978<tr><td colspan="4" class="doc" id="isVariadic0"><pre>Matches if a function declaration is variadic. 2979 2980Example matches f, but not g or h. The function i will not match, even when 2981compiled in C mode. 2982 void f(...); 2983 void g(int); 2984 template <typename... Ts> void h(Ts...); 2985 void i(); 2986</pre></td></tr> 2987 2988 2989<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> 2990<tr><td colspan="4" class="doc" id="parameterCountIs0"><pre>Matches FunctionDecls and FunctionProtoTypes that have a 2991specific parameter count. 2992 2993Given 2994 void f(int i) {} 2995 void g(int i, int j) {} 2996 void h(int i, int j); 2997 void j(int i); 2998 void k(int x, int y, int z, ...); 2999functionDecl(parameterCountIs(2)) 3000 matches g and h 3001functionProtoType(parameterCountIs(2)) 3002 matches g and h 3003functionProtoType(parameterCountIs(3)) 3004 matches k 3005</pre></td></tr> 3006 3007 3008<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>></td><td class="name" onclick="toggle('hasDynamicExceptionSpec1')"><a name="hasDynamicExceptionSpec1Anchor">hasDynamicExceptionSpec</a></td><td></td></tr> 3009<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec1"><pre>Matches functions that have a dynamic exception specification. 3010 3011Given: 3012 void f(); 3013 void g() noexcept; 3014 void h() noexcept(true); 3015 void i() noexcept(false); 3016 void j() throw(); 3017 void k() throw(int); 3018 void l() throw(...); 3019functionDecl(hasDynamicExceptionSpec()) and 3020 functionProtoType(hasDynamicExceptionSpec()) 3021 match the declarations of j, k, and l, but not f, g, h, or i. 3022</pre></td></tr> 3023 3024 3025<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>></td><td class="name" onclick="toggle('isNoThrow1')"><a name="isNoThrow1Anchor">isNoThrow</a></td><td></td></tr> 3026<tr><td colspan="4" class="doc" id="isNoThrow1"><pre>Matches functions that have a non-throwing exception specification. 3027 3028Given: 3029 void f(); 3030 void g() noexcept; 3031 void h() throw(); 3032 void i() throw(int); 3033 void j() noexcept(false); 3034functionDecl(isNoThrow()) and functionProtoType(isNoThrow()) 3035 match the declarations of g, and h, but not f, i or j. 3036</pre></td></tr> 3037 3038 3039<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionProtoType.html">FunctionProtoType</a>></td><td class="name" onclick="toggle('parameterCountIs1')"><a name="parameterCountIs1Anchor">parameterCountIs</a></td><td>unsigned N</td></tr> 3040<tr><td colspan="4" class="doc" id="parameterCountIs1"><pre>Matches FunctionDecls and FunctionProtoTypes that have a 3041specific parameter count. 3042 3043Given 3044 void f(int i) {} 3045 void g(int i, int j) {} 3046 void h(int i, int j); 3047 void j(int i); 3048 void k(int x, int y, int z, ...); 3049functionDecl(parameterCountIs(2)) 3050 matches g and h 3051functionProtoType(parameterCountIs(2)) 3052 matches g and h 3053functionProtoType(parameterCountIs(3)) 3054 matches k 3055</pre></td></tr> 3056 3057 3058<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('isConstexpr2')"><a name="isConstexpr2Anchor">isConstexpr</a></td><td></td></tr> 3059<tr><td colspan="4" class="doc" id="isConstexpr2"><pre>Matches constexpr variable and function declarations, 3060 and if constexpr. 3061 3062Given: 3063 constexpr int foo = 42; 3064 constexpr int bar(); 3065 void baz() { if constexpr(1 > 0) {} } 3066varDecl(isConstexpr()) 3067 matches the declaration of foo. 3068functionDecl(isConstexpr()) 3069 matches the declaration of bar. 3070ifStmt(isConstexpr()) 3071 matches the if statement in baz. 3072</pre></td></tr> 3073 3074 3075<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals6')"><a name="equals6Anchor">equals</a></td><td>bool Value</td></tr> 3076<tr><td colspan="4" class="doc" id="equals6"><pre></pre></td></tr> 3077 3078 3079<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>const ValueT Value</td></tr> 3080<tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value of type ValueT. 3081 3082Given 3083 f('false, 3.14, 42); 3084characterLiteral(equals(0)) 3085 matches 'cxxBoolLiteral(equals(false)) and cxxBoolLiteral(equals(0)) 3086 match false 3087floatLiteral(equals(3.14)) and floatLiteral(equals(314e-2)) 3088 match 3.14 3089integerLiteral(equals(42)) 3090 matches 42 3091 3092Note that you cannot directly match a negative numeric literal because the 3093minus sign is not part of the literal: It is a unary operator whose operand 3094is the positive numeric literal. Instead, you must use a unaryOperator() 3095matcher to match the minus sign: 3096 3097unaryOperator(hasOperatorName("-"), 3098 hasUnaryOperand(integerLiteral(equals(13)))) 3099 3100Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CharacterLiteral.html">CharacterLiteral</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXBoolLiteralExpr.html">CXXBoolLiteralExpr</a>>, 3101 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>> 3102</pre></td></tr> 3103 3104 3105<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals13')"><a name="equals13Anchor">equals</a></td><td>double Value</td></tr> 3106<tr><td colspan="4" class="doc" id="equals13"><pre></pre></td></tr> 3107 3108 3109<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals9')"><a name="equals9Anchor">equals</a></td><td>unsigned Value</td></tr> 3110<tr><td colspan="4" class="doc" id="equals9"><pre></pre></td></tr> 3111 3112 3113<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> 3114<tr><td colspan="4" class="doc" id="isArrow0"><pre>Matches member expressions that are called with '->' as opposed 3115to '.'. 3116 3117Member calls on the implicit this pointer match as called with '->'. 3118 3119Given 3120 class Y { 3121 void x() { this->x(); x(); Y y; y.x(); a; this->b; Y::b; } 3122 int a; 3123 static int b; 3124 }; 3125memberExpr(isArrow()) 3126 matches this->x, x, y.x, a, this->b 3127</pre></td></tr> 3128 3129 3130<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('hasExternalFormalLinkage0')"><a name="hasExternalFormalLinkage0Anchor">hasExternalFormalLinkage</a></td><td></td></tr> 3131<tr><td colspan="4" class="doc" id="hasExternalFormalLinkage0"><pre>Matches a declaration that has external formal linkage. 3132 3133Example matches only z (matcher = varDecl(hasExternalFormalLinkage())) 3134void f() { 3135 int x; 3136 static int y; 3137} 3138int z; 3139 3140Example matches f() because it has external formal linkage despite being 3141unique to the translation unit as though it has internal likage 3142(matcher = functionDecl(hasExternalFormalLinkage())) 3143 3144namespace { 3145void f() {} 3146} 3147</pre></td></tr> 3148 3149 3150<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>const std::string Name</td></tr> 3151<tr><td colspan="4" class="doc" id="hasName0"><pre>Matches NamedDecl nodes that have the specified name. 3152 3153Supports specifying enclosing namespaces or classes by prefixing the name 3154with '<enclosing>::'. 3155Does not match typedefs of an underlying type with the given name. 3156 3157Example matches X (Name == "X") 3158 class X; 3159 3160Example matches X (Name is one of "::a::b::X", "a::b::X", "b::X", "X") 3161 namespace a { namespace b { class X; } } 3162</pre></td></tr> 3163 3164 3165<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> 3166<tr><td colspan="4" class="doc" id="matchesName0"><pre>Matches NamedDecl nodes whose fully qualified names contain 3167a substring matched by the given RegExp. 3168 3169Supports specifying enclosing namespaces or classes by 3170prefixing the name with '<enclosing>::'. Does not match typedefs 3171of an underlying type with the given name. 3172 3173Example matches X (regexp == "::X") 3174 class X; 3175 3176Example matches X (regexp is one of "::X", "^foo::.*X", among others) 3177 namespace foo { namespace bar { class X; } } 3178</pre></td></tr> 3179 3180 3181<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>></td><td class="name" onclick="toggle('isAnonymous0')"><a name="isAnonymous0Anchor">isAnonymous</a></td><td></td></tr> 3182<tr><td colspan="4" class="doc" id="isAnonymous0"><pre>Matches anonymous namespace declarations. 3183 3184Given 3185 namespace n { 3186 namespace {} #1 3187 } 3188namespaceDecl(isAnonymous()) will match #1 but not ::n. 3189</pre></td></tr> 3190 3191 3192<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamespaceDecl.html">NamespaceDecl</a>></td><td class="name" onclick="toggle('isInline0')"><a name="isInline0Anchor">isInline</a></td><td></td></tr> 3193<tr><td colspan="4" class="doc" id="isInline0"><pre>Matches function and namespace declarations that are marked with 3194the inline keyword. 3195 3196Given 3197 inline void f(); 3198 void g(); 3199 namespace n { 3200 inline namespace m {} 3201 } 3202functionDecl(isInline()) will match ::f(). 3203namespaceDecl(isInline()) will match n::m. 3204</pre></td></tr> 3205 3206 3207<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('argumentCountIs2')"><a name="argumentCountIs2Anchor">argumentCountIs</a></td><td>unsigned N</td></tr> 3208<tr><td colspan="4" class="doc" id="argumentCountIs2"><pre>Checks that a call expression or a constructor call expression has 3209a specific number of arguments (including absent default arguments). 3210 3211Example matches f(0, 0) (matcher = callExpr(argumentCountIs(2))) 3212 void f(int x, int y); 3213 f(0, 0); 3214</pre></td></tr> 3215 3216 3217<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasKeywordSelector0')"><a name="hasKeywordSelector0Anchor">hasKeywordSelector</a></td><td></td></tr> 3218<tr><td colspan="4" class="doc" id="hasKeywordSelector0"><pre>Matches when the selector is a keyword selector 3219 3220objCMessageExpr(hasKeywordSelector()) matches the generated setFrame 3221message expression in 3222 3223 UIWebView *webView = ...; 3224 CGRect bodyFrame = webView.frame; 3225 bodyFrame.size.height = self.bodyContentHeight; 3226 webView.frame = bodyFrame; 3227 ^---- matches here 3228</pre></td></tr> 3229 3230 3231<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasNullSelector0')"><a name="hasNullSelector0Anchor">hasNullSelector</a></td><td></td></tr> 3232<tr><td colspan="4" class="doc" id="hasNullSelector0"><pre>Matches when the selector is the empty selector 3233 3234Matches only when the selector of the objCMessageExpr is NULL. This may 3235represent an error condition in the tree! 3236</pre></td></tr> 3237 3238 3239<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasSelector0')"><a name="hasSelector0Anchor">hasSelector</a></td><td>std::string BaseName</td></tr> 3240<tr><td colspan="4" class="doc" id="hasSelector0"><pre>Matches when BaseName == Selector.getAsString() 3241 3242 matcher = objCMessageExpr(hasSelector("loadHTMLString:baseURL:")); 3243 matches the outer message expr in the code below, but NOT the message 3244 invocation for self.bodyView. 3245 [self.bodyView loadHTMLString:html baseURL:NULL]; 3246</pre></td></tr> 3247 3248 3249<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasUnarySelector0')"><a name="hasUnarySelector0Anchor">hasUnarySelector</a></td><td></td></tr> 3250<tr><td colspan="4" class="doc" id="hasUnarySelector0"><pre>Matches when the selector is a Unary Selector 3251 3252 matcher = objCMessageExpr(matchesSelector(hasUnarySelector()); 3253 matches self.bodyView in the code below, but NOT the outer message 3254 invocation of "loadHTMLString:baseURL:". 3255 [self.bodyView loadHTMLString:html baseURL:NULL]; 3256</pre></td></tr> 3257 3258 3259<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('matchesSelector0')"><a name="matchesSelector0Anchor">matchesSelector</a></td><td>std::string RegExp</td></tr> 3260<tr><td colspan="4" class="doc" id="matchesSelector0"><pre>Matches ObjC selectors whose name contains 3261a substring matched by the given RegExp. 3262 matcher = objCMessageExpr(matchesSelector("loadHTMLStringmatches the outer message expr in the code below, but NOT the message 3263 invocation for self.bodyView. 3264 [self.bodyView loadHTMLString:html baseURL:NULL]; 3265</pre></td></tr> 3266 3267 3268<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('numSelectorArgs0')"><a name="numSelectorArgs0Anchor">numSelectorArgs</a></td><td>unsigned N</td></tr> 3269<tr><td colspan="4" class="doc" id="numSelectorArgs0"><pre>Matches when the selector has the specified number of arguments 3270 3271 matcher = objCMessageExpr(numSelectorArgs(0)); 3272 matches self.bodyView in the code below 3273 3274 matcher = objCMessageExpr(numSelectorArgs(2)); 3275 matches the invocation of "loadHTMLString:baseURL:" but not that 3276 of self.bodyView 3277 [self.bodyView loadHTMLString:html baseURL:NULL]; 3278</pre></td></tr> 3279 3280 3281<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>></td><td class="name" onclick="toggle('isDefinition2')"><a name="isDefinition2Anchor">isDefinition</a></td><td></td></tr> 3282<tr><td colspan="4" class="doc" id="isDefinition2"><pre>Matches if a declaration has a body attached. 3283 3284Example matches A, va, fa 3285 class A {}; 3286 class B; Doesn't match, as it has no body. 3287 int va; 3288 extern int vb; Doesn't match, as it doesn't define the variable. 3289 void fa() {} 3290 void fb(); Doesn't match, as it has no body. 3291 @interface X 3292 - (void)ma; Doesn't match, interface is declaration. 3293 @end 3294 @implementation X 3295 - (void)ma {} 3296 @end 3297 3298Usable 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>>, 3299 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 3300</pre></td></tr> 3301 3302 3303<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>></td><td class="name" onclick="toggle('hasDefaultArgument0')"><a name="hasDefaultArgument0Anchor">hasDefaultArgument</a></td><td></td></tr> 3304<tr><td colspan="4" class="doc" id="hasDefaultArgument0"><pre>Matches a declaration that has default arguments. 3305 3306Example matches y (matcher = parmVarDecl(hasDefaultArgument())) 3307void x(int val) {} 3308void y(int val = 0) {} 3309</pre></td></tr> 3310 3311 3312<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> 3313<tr><td colspan="4" class="doc" id="asString0"><pre>Matches if the matched type is represented by the given string. 3314 3315Given 3316 class Y { public: void x(); }; 3317 void z() { Y* y; y->x(); } 3318cxxMemberCallExpr(on(hasType(asString("class Y *")))) 3319 matches y->x() 3320</pre></td></tr> 3321 3322 3323<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('equalsBoundNode3')"><a name="equalsBoundNode3Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr> 3324<tr><td colspan="4" class="doc" id="equalsBoundNode3"><pre>Matches if a node equals a previously bound node. 3325 3326Matches a node if it equals the node previously bound to ID. 3327 3328Given 3329 class X { int a; int b; }; 3330cxxRecordDecl( 3331 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 3332 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 3333 matches the class X, as a and b have the same type. 3334 3335Note that when multiple matches are involved via forEach* matchers, 3336equalsBoundNodes acts as a filter. 3337For example: 3338compoundStmt( 3339 forEachDescendant(varDecl().bind("d")), 3340 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 3341will trigger a match for each combination of variable declaration 3342and reference to that variable declaration within a compound statement. 3343</pre></td></tr> 3344 3345 3346<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasLocalQualifiers0')"><a name="hasLocalQualifiers0Anchor">hasLocalQualifiers</a></td><td></td></tr> 3347<tr><td colspan="4" class="doc" id="hasLocalQualifiers0"><pre>Matches QualType nodes that have local CV-qualifiers attached to 3348the node, not hidden within a typedef. 3349 3350Given 3351 typedef const int const_int; 3352 const_int i; 3353 int *const j; 3354 int *volatile k; 3355 int m; 3356varDecl(hasType(hasLocalQualifiers())) matches only j and k. 3357i is const-qualified but the qualifier is not local. 3358</pre></td></tr> 3359 3360 3361<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isAnyCharacter0')"><a name="isAnyCharacter0Anchor">isAnyCharacter</a></td><td></td></tr> 3362<tr><td colspan="4" class="doc" id="isAnyCharacter0"><pre>Matches QualType nodes that are of character type. 3363 3364Given 3365 void a(char); 3366 void b(wchar_t); 3367 void c(double); 3368functionDecl(hasAnyParameter(hasType(isAnyCharacter()))) 3369matches "a(char)", "b(wchar_t)", but not "c(double)". 3370</pre></td></tr> 3371 3372 3373<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isAnyPointer0')"><a name="isAnyPointer0Anchor">isAnyPointer</a></td><td></td></tr> 3374<tr><td colspan="4" class="doc" id="isAnyPointer0"><pre>Matches QualType nodes that are of any pointer type; this includes 3375the Objective-C object pointer type, which is different despite being 3376syntactically similar. 3377 3378Given 3379 int *i = nullptr; 3380 3381 @interface Foo 3382 @end 3383 Foo *f; 3384 3385 int j; 3386varDecl(hasType(isAnyPointer())) 3387 matches "int *i" and "Foo *f", but not "int j". 3388</pre></td></tr> 3389 3390 3391<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> 3392<tr><td colspan="4" class="doc" id="isConstQualified0"><pre>Matches QualType nodes that are const-qualified, i.e., that 3393include "top-level" const. 3394 3395Given 3396 void a(int); 3397 void b(int const); 3398 void c(const int); 3399 void d(const int*); 3400 void e(int const) {}; 3401functionDecl(hasAnyParameter(hasType(isConstQualified()))) 3402 matches "void b(int const)", "void c(const int)" and 3403 "void e(int const) {}". It does not match d as there 3404 is no top-level const on the parameter type "const int *". 3405</pre></td></tr> 3406 3407 3408<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> 3409<tr><td colspan="4" class="doc" id="isInteger0"><pre>Matches QualType nodes that are of integer type. 3410 3411Given 3412 void a(int); 3413 void b(long); 3414 void c(double); 3415functionDecl(hasAnyParameter(hasType(isInteger()))) 3416matches "a(int)", "b(long)", but not "c(double)". 3417</pre></td></tr> 3418 3419 3420<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isSignedInteger0')"><a name="isSignedInteger0Anchor">isSignedInteger</a></td><td></td></tr> 3421<tr><td colspan="4" class="doc" id="isSignedInteger0"><pre>Matches QualType nodes that are of signed integer type. 3422 3423Given 3424 void a(int); 3425 void b(unsigned long); 3426 void c(double); 3427functionDecl(hasAnyParameter(hasType(isSignedInteger()))) 3428matches "a(int)", but not "b(unsigned long)" and "c(double)". 3429</pre></td></tr> 3430 3431 3432<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isUnsignedInteger0')"><a name="isUnsignedInteger0Anchor">isUnsignedInteger</a></td><td></td></tr> 3433<tr><td colspan="4" class="doc" id="isUnsignedInteger0"><pre>Matches QualType nodes that are of unsigned integer type. 3434 3435Given 3436 void a(int); 3437 void b(unsigned long); 3438 void c(double); 3439functionDecl(hasAnyParameter(hasType(isUnsignedInteger()))) 3440matches "b(unsigned long)", but not "a(int)" and "c(double)". 3441</pre></td></tr> 3442 3443 3444<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('isVolatileQualified0')"><a name="isVolatileQualified0Anchor">isVolatileQualified</a></td><td></td></tr> 3445<tr><td colspan="4" class="doc" id="isVolatileQualified0"><pre>Matches QualType nodes that are volatile-qualified, i.e., that 3446include "top-level" volatile. 3447 3448Given 3449 void a(int); 3450 void b(int volatile); 3451 void c(volatile int); 3452 void d(volatile int*); 3453 void e(int volatile) {}; 3454functionDecl(hasAnyParameter(hasType(isVolatileQualified()))) 3455 matches "void b(int volatile)", "void c(volatile int)" and 3456 "void e(int volatile) {}". It does not match d as there 3457 is no top-level volatile on the parameter type "volatile int *". 3458</pre></td></tr> 3459 3460 3461<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>></td><td class="name" onclick="toggle('isClass0')"><a name="isClass0Anchor">isClass</a></td><td></td></tr> 3462<tr><td colspan="4" class="doc" id="isClass0"><pre>Matches RecordDecl object that are spelled with "class." 3463 3464Example matches C, but not S or U. 3465 struct S {}; 3466 class C {}; 3467 union U {}; 3468</pre></td></tr> 3469 3470 3471<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>></td><td class="name" onclick="toggle('isStruct0')"><a name="isStruct0Anchor">isStruct</a></td><td></td></tr> 3472<tr><td colspan="4" class="doc" id="isStruct0"><pre>Matches RecordDecl object that are spelled with "struct." 3473 3474Example matches S, but not C or U. 3475 struct S {}; 3476 class C {}; 3477 union U {}; 3478</pre></td></tr> 3479 3480 3481<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordDecl.html">RecordDecl</a>></td><td class="name" onclick="toggle('isUnion0')"><a name="isUnion0Anchor">isUnion</a></td><td></td></tr> 3482<tr><td colspan="4" class="doc" id="isUnion0"><pre>Matches RecordDecl object that are spelled with "union." 3483 3484Example matches U, but not C or S. 3485 struct S {}; 3486 class C {}; 3487 union U {}; 3488</pre></td></tr> 3489 3490 3491<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('equalsBoundNode0')"><a name="equalsBoundNode0Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr> 3492<tr><td colspan="4" class="doc" id="equalsBoundNode0"><pre>Matches if a node equals a previously bound node. 3493 3494Matches a node if it equals the node previously bound to ID. 3495 3496Given 3497 class X { int a; int b; }; 3498cxxRecordDecl( 3499 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 3500 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 3501 matches the class X, as a and b have the same type. 3502 3503Note that when multiple matches are involved via forEach* matchers, 3504equalsBoundNodes acts as a filter. 3505For example: 3506compoundStmt( 3507 forEachDescendant(varDecl().bind("d")), 3508 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 3509will trigger a match for each combination of variable declaration 3510and reference to that variable declaration within a compound statement. 3511</pre></td></tr> 3512 3513 3514<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('equalsNode1')"><a name="equalsNode1Anchor">equalsNode</a></td><td>const Stmt* Other</td></tr> 3515<tr><td colspan="4" class="doc" id="equalsNode1"><pre>Matches if a node equals another node. 3516 3517Stmt has pointer identity in the AST. 3518</pre></td></tr> 3519 3520 3521<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching1')"><a name="isExpansionInFileMatching1Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr> 3522<tr><td colspan="4" class="doc" id="isExpansionInFileMatching1"><pre>Matches AST nodes that were expanded within files whose name is 3523partially matching a given regex. 3524 3525Example matches Y but not X 3526 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 3527 #include "ASTMatcher.h" 3528 class X {}; 3529ASTMatcher.h: 3530 class Y {}; 3531 3532Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 3533</pre></td></tr> 3534 3535 3536<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInMainFile1')"><a name="isExpansionInMainFile1Anchor">isExpansionInMainFile</a></td><td></td></tr> 3537<tr><td colspan="4" class="doc" id="isExpansionInMainFile1"><pre>Matches AST nodes that were expanded within the main-file. 3538 3539Example matches X but not Y 3540 (matcher = cxxRecordDecl(isExpansionInMainFile()) 3541 #include <Y.h> 3542 class X {}; 3543Y.h: 3544 class Y {}; 3545 3546Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 3547</pre></td></tr> 3548 3549 3550<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('isExpansionInSystemHeader1')"><a name="isExpansionInSystemHeader1Anchor">isExpansionInSystemHeader</a></td><td></td></tr> 3551<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader1"><pre>Matches AST nodes that were expanded within system-header-files. 3552 3553Example matches Y but not X 3554 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 3555 #include <SystemHeader.h> 3556 class X {}; 3557SystemHeader.h: 3558 class Y {}; 3559 3560Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 3561</pre></td></tr> 3562 3563 3564<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StringLiteral.html">StringLiteral</a>></td><td class="name" onclick="toggle('hasSize1')"><a name="hasSize1Anchor">hasSize</a></td><td>unsigned N</td></tr> 3565<tr><td colspan="4" class="doc" id="hasSize1"><pre>Matches nodes that have the specified size. 3566 3567Given 3568 int a[42]; 3569 int b[2 * 21]; 3570 int c[41], d[43]; 3571 char *s = "abcd"; 3572 wchar_t *ws = L"abcd"; 3573 char *w = "a"; 3574constantArrayType(hasSize(42)) 3575 matches "int a[42]" and "int b[2 * 21]" 3576stringLiteral(hasSize(4)) 3577 matches "abcd", L"abcd" 3578</pre></td></tr> 3579 3580 3581<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDecl.html">TagDecl</a>></td><td class="name" onclick="toggle('isDefinition0')"><a name="isDefinition0Anchor">isDefinition</a></td><td></td></tr> 3582<tr><td colspan="4" class="doc" id="isDefinition0"><pre>Matches if a declaration has a body attached. 3583 3584Example matches A, va, fa 3585 class A {}; 3586 class B; Doesn't match, as it has no body. 3587 int va; 3588 extern int vb; Doesn't match, as it doesn't define the variable. 3589 void fa() {} 3590 void fb(); Doesn't match, as it has no body. 3591 @interface X 3592 - (void)ma; Doesn't match, interface is declaration. 3593 @end 3594 @implementation X 3595 - (void)ma {} 3596 @end 3597 3598Usable 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>>, 3599 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 3600</pre></td></tr> 3601 3602 3603<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('equalsIntegralValue0')"><a name="equalsIntegralValue0Anchor">equalsIntegralValue</a></td><td>std::string Value</td></tr> 3604<tr><td colspan="4" class="doc" id="equalsIntegralValue0"><pre>Matches a TemplateArgument of integral type with a given value. 3605 3606Note that 'Value' is a string as the template argument's value is 3607an arbitrary precision integer. 'Value' must be euqal to the canonical 3608representation of that integral value in base 10. 3609 3610Given 3611 template<int T> struct C {}; 3612 C<42> c; 3613classTemplateSpecializationDecl( 3614 hasAnyTemplateArgument(equalsIntegralValue("42"))) 3615 matches the implicit instantiation of C in C<42>. 3616</pre></td></tr> 3617 3618 3619<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('isIntegral0')"><a name="isIntegral0Anchor">isIntegral</a></td><td></td></tr> 3620<tr><td colspan="4" class="doc" id="isIntegral0"><pre>Matches a TemplateArgument that is an integral value. 3621 3622Given 3623 template<int T> struct C {}; 3624 C<42> c; 3625classTemplateSpecializationDecl( 3626 hasAnyTemplateArgument(isIntegral())) 3627 matches the implicit instantiation of C in C<42> 3628 with isIntegral() matching 42. 3629</pre></td></tr> 3630 3631 3632<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('templateArgumentCountIs1')"><a name="templateArgumentCountIs1Anchor">templateArgumentCountIs</a></td><td>unsigned N</td></tr> 3633<tr><td colspan="4" class="doc" id="templateArgumentCountIs1"><pre>Matches if the number of template arguments equals N. 3634 3635Given 3636 template<typename T> struct C {}; 3637 C<int> c; 3638classTemplateSpecializationDecl(templateArgumentCountIs(1)) 3639 matches C<int>. 3640</pre></td></tr> 3641 3642 3643<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpansionInFileMatching2')"><a name="isExpansionInFileMatching2Anchor">isExpansionInFileMatching</a></td><td>std::string RegExp</td></tr> 3644<tr><td colspan="4" class="doc" id="isExpansionInFileMatching2"><pre>Matches AST nodes that were expanded within files whose name is 3645partially matching a given regex. 3646 3647Example matches Y but not X 3648 (matcher = cxxRecordDecl(isExpansionInFileMatching("AST.*")) 3649 #include "ASTMatcher.h" 3650 class X {}; 3651ASTMatcher.h: 3652 class Y {}; 3653 3654Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 3655</pre></td></tr> 3656 3657 3658<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpansionInMainFile2')"><a name="isExpansionInMainFile2Anchor">isExpansionInMainFile</a></td><td></td></tr> 3659<tr><td colspan="4" class="doc" id="isExpansionInMainFile2"><pre>Matches AST nodes that were expanded within the main-file. 3660 3661Example matches X but not Y 3662 (matcher = cxxRecordDecl(isExpansionInMainFile()) 3663 #include <Y.h> 3664 class X {}; 3665Y.h: 3666 class Y {}; 3667 3668Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 3669</pre></td></tr> 3670 3671 3672<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td><td class="name" onclick="toggle('isExpansionInSystemHeader2')"><a name="isExpansionInSystemHeader2Anchor">isExpansionInSystemHeader</a></td><td></td></tr> 3673<tr><td colspan="4" class="doc" id="isExpansionInSystemHeader2"><pre>Matches AST nodes that were expanded within system-header-files. 3674 3675Example matches Y but not X 3676 (matcher = cxxRecordDecl(isExpansionInSystemHeader()) 3677 #include <SystemHeader.h> 3678 class X {}; 3679SystemHeader.h: 3680 class Y {}; 3681 3682Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> 3683</pre></td></tr> 3684 3685 3686<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('booleanType0')"><a name="booleanType0Anchor">booleanType</a></td><td></td></tr> 3687<tr><td colspan="4" class="doc" id="booleanType0"><pre>Matches type bool. 3688 3689Given 3690 struct S { bool func(); }; 3691functionDecl(returns(booleanType())) 3692 matches "bool func();" 3693</pre></td></tr> 3694 3695 3696<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('equalsBoundNode2')"><a name="equalsBoundNode2Anchor">equalsBoundNode</a></td><td>std::string ID</td></tr> 3697<tr><td colspan="4" class="doc" id="equalsBoundNode2"><pre>Matches if a node equals a previously bound node. 3698 3699Matches a node if it equals the node previously bound to ID. 3700 3701Given 3702 class X { int a; int b; }; 3703cxxRecordDecl( 3704 has(fieldDecl(hasName("a"), hasType(type().bind("t")))), 3705 has(fieldDecl(hasName("b"), hasType(type(equalsBoundNode("t")))))) 3706 matches the class X, as a and b have the same type. 3707 3708Note that when multiple matches are involved via forEach* matchers, 3709equalsBoundNodes acts as a filter. 3710For example: 3711compoundStmt( 3712 forEachDescendant(varDecl().bind("d")), 3713 forEachDescendant(declRefExpr(to(decl(equalsBoundNode("d")))))) 3714will trigger a match for each combination of variable declaration 3715and reference to that variable declaration within a compound statement. 3716</pre></td></tr> 3717 3718 3719<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('equalsNode2')"><a name="equalsNode2Anchor">equalsNode</a></td><td>const Type* Other</td></tr> 3720<tr><td colspan="4" class="doc" id="equalsNode2"><pre>Matches if a node equals another node. 3721 3722Type has pointer identity in the AST. 3723</pre></td></tr> 3724 3725 3726<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('realFloatingPointType0')"><a name="realFloatingPointType0Anchor">realFloatingPointType</a></td><td></td></tr> 3727<tr><td colspan="4" class="doc" id="realFloatingPointType0"><pre>Matches any real floating-point type (float, double, long double). 3728 3729Given 3730 int i; 3731 float f; 3732realFloatingPointType() 3733 matches "float f" but not "int i" 3734</pre></td></tr> 3735 3736 3737<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('voidType0')"><a name="voidType0Anchor">voidType</a></td><td></td></tr> 3738<tr><td colspan="4" class="doc" id="voidType0"><pre>Matches type void. 3739 3740Given 3741 struct S { void func(); }; 3742functionDecl(returns(voidType())) 3743 matches "void func();" 3744</pre></td></tr> 3745 3746 3747<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> 3748<tr><td colspan="4" class="doc" id="ofKind0"><pre>Matches unary expressions of a certain kind. 3749 3750Given 3751 int x; 3752 int s = sizeof(x) + alignof(x) 3753unaryExprOrTypeTraitExpr(ofKind(UETT_SizeOf)) 3754 matches sizeof(x) 3755</pre></td></tr> 3756 3757 3758<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> 3759<tr><td colspan="4" class="doc" id="hasOperatorName1"><pre>Matches the operator Name of operator expressions (binary or 3760unary). 3761 3762Example matches a || b (matcher = binaryOperator(hasOperatorName("||"))) 3763 !(a || b) 3764</pre></td></tr> 3765 3766 3767<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasAutomaticStorageDuration0')"><a name="hasAutomaticStorageDuration0Anchor">hasAutomaticStorageDuration</a></td><td></td></tr> 3768<tr><td colspan="4" class="doc" id="hasAutomaticStorageDuration0"><pre>Matches a variable declaration that has automatic storage duration. 3769 3770Example matches x, but not y, z, or a. 3771(matcher = varDecl(hasAutomaticStorageDuration()) 3772void f() { 3773 int x; 3774 static int y; 3775 thread_local int z; 3776} 3777int a; 3778</pre></td></tr> 3779 3780 3781<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasGlobalStorage0')"><a name="hasGlobalStorage0Anchor">hasGlobalStorage</a></td><td></td></tr> 3782<tr><td colspan="4" class="doc" id="hasGlobalStorage0"><pre>Matches a variable declaration that does not have local storage. 3783 3784Example matches y and z (matcher = varDecl(hasGlobalStorage()) 3785void f() { 3786 int x; 3787 static int y; 3788} 3789int z; 3790</pre></td></tr> 3791 3792 3793<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasLocalStorage0')"><a name="hasLocalStorage0Anchor">hasLocalStorage</a></td><td></td></tr> 3794<tr><td colspan="4" class="doc" id="hasLocalStorage0"><pre>Matches a variable declaration that has function scope and is a 3795non-static local variable. 3796 3797Example matches x (matcher = varDecl(hasLocalStorage()) 3798void f() { 3799 int x; 3800 static int y; 3801} 3802int z; 3803</pre></td></tr> 3804 3805 3806<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasStaticStorageDuration0')"><a name="hasStaticStorageDuration0Anchor">hasStaticStorageDuration</a></td><td></td></tr> 3807<tr><td colspan="4" class="doc" id="hasStaticStorageDuration0"><pre>Matches a variable declaration that has static storage duration. 3808It includes the variable declared at namespace scope and those declared 3809with "static" and "extern" storage class specifiers. 3810 3811void f() { 3812 int x; 3813 static int y; 3814 thread_local int z; 3815} 3816int a; 3817static int b; 3818extern int c; 3819varDecl(hasStaticStorageDuration()) 3820 matches the function declaration y, a, b and c. 3821</pre></td></tr> 3822 3823 3824<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('hasThreadStorageDuration0')"><a name="hasThreadStorageDuration0Anchor">hasThreadStorageDuration</a></td><td></td></tr> 3825<tr><td colspan="4" class="doc" id="hasThreadStorageDuration0"><pre>Matches a variable declaration that has thread storage duration. 3826 3827Example matches z, but not x, z, or a. 3828(matcher = varDecl(hasThreadStorageDuration()) 3829void f() { 3830 int x; 3831 static int y; 3832 thread_local int z; 3833} 3834int a; 3835</pre></td></tr> 3836 3837 3838<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isConstexpr0')"><a name="isConstexpr0Anchor">isConstexpr</a></td><td></td></tr> 3839<tr><td colspan="4" class="doc" id="isConstexpr0"><pre>Matches constexpr variable and function declarations, 3840 and if constexpr. 3841 3842Given: 3843 constexpr int foo = 42; 3844 constexpr int bar(); 3845 void baz() { if constexpr(1 > 0) {} } 3846varDecl(isConstexpr()) 3847 matches the declaration of foo. 3848functionDecl(isConstexpr()) 3849 matches the declaration of bar. 3850ifStmt(isConstexpr()) 3851 matches the if statement in baz. 3852</pre></td></tr> 3853 3854 3855<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> 3856<tr><td colspan="4" class="doc" id="isDefinition1"><pre>Matches if a declaration has a body attached. 3857 3858Example matches A, va, fa 3859 class A {}; 3860 class B; Doesn't match, as it has no body. 3861 int va; 3862 extern int vb; Doesn't match, as it doesn't define the variable. 3863 void fa() {} 3864 void fb(); Doesn't match, as it has no body. 3865 @interface X 3866 - (void)ma; Doesn't match, interface is declaration. 3867 @end 3868 @implementation X 3869 - (void)ma {} 3870 @end 3871 3872Usable 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>>, 3873 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>> 3874</pre></td></tr> 3875 3876 3877<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isExceptionVariable0')"><a name="isExceptionVariable0Anchor">isExceptionVariable</a></td><td></td></tr> 3878<tr><td colspan="4" class="doc" id="isExceptionVariable0"><pre>Matches a variable declaration that is an exception variable from 3879a C++ catch block, or an Objective-C statement. 3880 3881Example matches x (matcher = varDecl(isExceptionVariable()) 3882void f(int y) { 3883 try { 3884 } catch (int x) { 3885 } 3886} 3887</pre></td></tr> 3888 3889 3890<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> 3891<tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization1"><pre>Matches explicit template specializations of function, class, or 3892static member variable template instantiations. 3893 3894Given 3895 template<typename T> void A(T t) { } 3896 template<> void A(int N) { } 3897functionDecl(isExplicitTemplateSpecialization()) 3898 matches the specialization A<int>(). 3899 3900Usable 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>> 3901</pre></td></tr> 3902 3903 3904<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isExternC1')"><a name="isExternC1Anchor">isExternC</a></td><td></td></tr> 3905<tr><td colspan="4" class="doc" id="isExternC1"><pre>Matches extern "C" function or variable declarations. 3906 3907Given: 3908 extern "C" void f() {} 3909 extern "C" { void g() {} } 3910 void h() {} 3911 extern "C" int x = 1; 3912 extern "C" int y = 2; 3913 int z = 3; 3914functionDecl(isExternC()) 3915 matches the declaration of f and g, but not the declaration of h. 3916varDecl(isExternC()) 3917 matches the declaration of x and y, but not the declaration of z. 3918</pre></td></tr> 3919 3920 3921<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>></td><td class="name" onclick="toggle('isStaticStorageClass1')"><a name="isStaticStorageClass1Anchor">isStaticStorageClass</a></td><td></td></tr> 3922<tr><td colspan="4" class="doc" id="isStaticStorageClass1"><pre>Matches variablefunction declarations that have "static" storage 3923class specifier ("static" keyword) written in the source. 3924 3925Given: 3926 static void f() {} 3927 static int i = 0; 3928 extern int j; 3929 int k; 3930functionDecl(isStaticStorageClass()) 3931 matches the function declaration f. 3932varDecl(isStaticStorageClass()) 3933 matches the variable declaration i. 3934</pre></td></tr> 3935 3936 3937<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> 3938<tr><td colspan="4" class="doc" id="isTemplateInstantiation1"><pre>Matches template instantiations of function, class, or static 3939member variable template instantiations. 3940 3941Given 3942 template <typename T> class X {}; class A {}; X<A> x; 3943or 3944 template <typename T> class X {}; class A {}; template class X<A>; 3945or 3946 template <typename T> class X {}; class A {}; extern template class X<A>; 3947cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 3948 matches the template instantiation of X<A>. 3949 3950But given 3951 template <typename T> class X {}; class A {}; 3952 template <> class X<A> {}; X<A> x; 3953cxxRecordDecl(hasName("::X"), isTemplateInstantiation()) 3954 does not match, as X<A> is an explicit template specialization. 3955 3956Usable 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>> 3957</pre></td></tr> 3958 3959 3960<tr><td>Matcher<internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>></td><td class="name" onclick="toggle('isInstantiated0')"><a name="isInstantiated0Anchor">isInstantiated</a></td><td></td></tr> 3961<tr><td colspan="4" class="doc" id="isInstantiated0"><pre>Matches declarations that are template instantiations or are inside 3962template instantiations. 3963 3964Given 3965 template<typename T> void A(T t) { T i; } 3966 A(0); 3967 A(0U); 3968functionDecl(isInstantiated()) 3969 matches 'A(int) {...};' and 'A(unsigned) {...}'. 3970</pre></td></tr> 3971 3972 3973<tr><td>Matcher<internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>>></td><td class="name" onclick="toggle('nullPointerConstant0')"><a name="nullPointerConstant0Anchor">nullPointerConstant</a></td><td></td></tr> 3974<tr><td colspan="4" class="doc" id="nullPointerConstant0"><pre>Matches expressions that resolve to a null pointer constant, such as 3975GNU's __null, C++11's nullptr, or C's NULL macro. 3976 3977Given: 3978 void *v1 = NULL; 3979 void *v2 = nullptr; 3980 void *v3 = __null; GNU extension 3981 char *cp = (char *)0; 3982 int *ip = 0; 3983 int i = 0; 3984expr(nullPointerConstant()) 3985 matches the initializer for v1, v2, v3, cp, and ip. Does not match the 3986 initializer for i. 3987</pre></td></tr> 3988 3989 3990<tr><td>Matcher<internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>>></td><td class="name" onclick="toggle('hasAnyName0')"><a name="hasAnyName0Anchor">hasAnyName</a></td><td>StringRef, ..., StringRef</td></tr> 3991<tr><td colspan="4" class="doc" id="hasAnyName0"><pre>Matches NamedDecl nodes that have any of the specified names. 3992 3993This matcher is only provided as a performance optimization of hasName. 3994 hasAnyName(a, b, c) 3995 is equivalent to, but faster than 3996 anyOf(hasName(a), hasName(b), hasName(c)) 3997</pre></td></tr> 3998 3999 4000<tr><td>Matcher<internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>>></td><td class="name" onclick="toggle('hasAnySelector0')"><a name="hasAnySelector0Anchor">hasAnySelector</a></td><td>StringRef, ..., StringRef</td></tr> 4001<tr><td colspan="4" class="doc" id="hasAnySelector0"><pre>Matches when at least one of the supplied string equals to the 4002Selector.getAsString() 4003 4004 matcher = objCMessageExpr(hasSelector("methodA:", "methodB:")); 4005 matches both of the expressions below: 4006 [myObj methodA:argA]; 4007 [myObj methodB:argB]; 4008</pre></td></tr> 4009 4010 4011<tr><td>Matcher<internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>>></td><td class="name" onclick="toggle('isInTemplateInstantiation0')"><a name="isInTemplateInstantiation0Anchor">isInTemplateInstantiation</a></td><td></td></tr> 4012<tr><td colspan="4" class="doc" id="isInTemplateInstantiation0"><pre>Matches statements inside of a template instantiation. 4013 4014Given 4015 int j; 4016 template<typename T> void A(T t) { T i; j += 42;} 4017 A(0); 4018 A(0U); 4019declStmt(isInTemplateInstantiation()) 4020 matches 'int i;' and 'unsigned i'. 4021unless(stmt(isInTemplateInstantiation())) 4022 will NOT match j += 42; as it's shared between the template definition and 4023 instantiation. 4024</pre></td></tr> 4025 4026<!--END_NARROWING_MATCHERS --> 4027</table> 4028 4029<!-- ======================================================================= --> 4030<h2 id="traversal-matchers">AST Traversal Matchers</h2> 4031<!-- ======================================================================= --> 4032 4033<p>Traversal matchers specify the relationship to other nodes that are 4034reachable from the current node.</p> 4035 4036<p>Note that there are special traversal matchers (has, hasDescendant, forEach and 4037forEachDescendant) which work on all nodes and allow users to write more generic 4038match expressions.</p> 4039 4040<table> 4041<tr style="text-align:left"><th>Return type</th><th>Name</th><th>Parameters</th></tr> 4042<!-- START_TRAVERSAL_MATCHERS --> 4043 4044<tr><td>Matcher<*></td><td class="name" onclick="toggle('eachOf0')"><a name="eachOf0Anchor">eachOf</a></td><td>Matcher<*>, ..., Matcher<*></td></tr> 4045<tr><td colspan="4" class="doc" id="eachOf0"><pre>Matches if any of the given matchers matches. 4046 4047Unlike anyOf, eachOf will generate a match result for each 4048matching submatcher. 4049 4050For example, in: 4051 class A { int a; int b; }; 4052The matcher: 4053 cxxRecordDecl(eachOf(has(fieldDecl(hasName("a")).bind("v")), 4054 has(fieldDecl(hasName("b")).bind("v")))) 4055will generate two results binding "v", the first of which binds 4056the field declaration of a, the second the field declaration of 4057b. 4058 4059Usable as: Any Matcher 4060</pre></td></tr> 4061 4062 4063<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEachDescendant0')"><a name="forEachDescendant0Anchor">forEachDescendant</a></td><td>Matcher<*></td></tr> 4064<tr><td colspan="4" class="doc" id="forEachDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 4065provided matcher. 4066 4067Example matches X, A, A::X, B, B::C, B::C::X 4068 (matcher = cxxRecordDecl(forEachDescendant(cxxRecordDecl(hasName("X"))))) 4069 class X {}; 4070 class A { class X {}; }; Matches A, because A::X is a class of name 4071 X inside A. 4072 class B { class C { class X {}; }; }; 4073 4074DescendantT must be an AST base type. 4075 4076As opposed to 'hasDescendant', 'forEachDescendant' will cause a match for 4077each result that matches instead of only on the first one. 4078 4079Note: Recursively combined ForEachDescendant can cause many matches: 4080 cxxRecordDecl(forEachDescendant(cxxRecordDecl( 4081 forEachDescendant(cxxRecordDecl()) 4082 ))) 4083will match 10 times (plus injected class name matches) on: 4084 class A { class B { class C { class D { class E {}; }; }; }; }; 4085 4086Usable as: Any Matcher 4087</pre></td></tr> 4088 4089 4090<tr><td>Matcher<*></td><td class="name" onclick="toggle('forEach0')"><a name="forEach0Anchor">forEach</a></td><td>Matcher<*></td></tr> 4091<tr><td colspan="4" class="doc" id="forEach0"><pre>Matches AST nodes that have child AST nodes that match the 4092provided matcher. 4093 4094Example matches X, Y, Y::X, Z::Y, Z::Y::X 4095 (matcher = cxxRecordDecl(forEach(cxxRecordDecl(hasName("X"))) 4096 class X {}; 4097 class Y { class X {}; }; Matches Y, because Y::X is a class of name X 4098 inside Y. 4099 class Z { class Y { class X {}; }; }; Does not match Z. 4100 4101ChildT must be an AST base type. 4102 4103As opposed to 'has', 'forEach' will cause a match for each result that 4104matches instead of only on the first one. 4105 4106Usable as: Any Matcher 4107</pre></td></tr> 4108 4109 4110<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasAncestor0')"><a name="hasAncestor0Anchor">hasAncestor</a></td><td>Matcher<*></td></tr> 4111<tr><td colspan="4" class="doc" id="hasAncestor0"><pre>Matches AST nodes that have an ancestor that matches the provided 4112matcher. 4113 4114Given 4115void f() { if (true) { int x = 42; } } 4116void g() { for (;;) { int x = 43; } } 4117expr(integerLiteral(hasAncestor(ifStmt()))) matches 42, but not 43. 4118 4119Usable as: Any Matcher 4120</pre></td></tr> 4121 4122 4123<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasDescendant0')"><a name="hasDescendant0Anchor">hasDescendant</a></td><td>Matcher<*></td></tr> 4124<tr><td colspan="4" class="doc" id="hasDescendant0"><pre>Matches AST nodes that have descendant AST nodes that match the 4125provided matcher. 4126 4127Example matches X, Y, Z 4128 (matcher = cxxRecordDecl(hasDescendant(cxxRecordDecl(hasName("X"))))) 4129 class X {}; Matches X, because X::X is a class of name X inside X. 4130 class Y { class X {}; }; 4131 class Z { class Y { class X {}; }; }; 4132 4133DescendantT must be an AST base type. 4134 4135Usable as: Any Matcher 4136</pre></td></tr> 4137 4138 4139<tr><td>Matcher<*></td><td class="name" onclick="toggle('has0')"><a name="has0Anchor">has</a></td><td>Matcher<*></td></tr> 4140<tr><td colspan="4" class="doc" id="has0"><pre>Matches AST nodes that have child AST nodes that match the 4141provided matcher. 4142 4143Example matches X, Y 4144 (matcher = cxxRecordDecl(has(cxxRecordDecl(hasName("X"))) 4145 class X {}; Matches X, because X::X is a class of name X inside X. 4146 class Y { class X {}; }; 4147 class Z { class Y { class X {}; }; }; Does not match Z. 4148 4149ChildT must be an AST base type. 4150 4151Usable as: Any Matcher 4152Note that has is direct matcher, so it also matches things like implicit 4153casts and paren casts. If you are matching with expr then you should 4154probably consider using ignoringParenImpCasts like: 4155has(ignoringParenImpCasts(expr())). 4156</pre></td></tr> 4157 4158 4159<tr><td>Matcher<*></td><td class="name" onclick="toggle('hasParent0')"><a name="hasParent0Anchor">hasParent</a></td><td>Matcher<*></td></tr> 4160<tr><td colspan="4" class="doc" id="hasParent0"><pre>Matches AST nodes that have a parent that matches the provided 4161matcher. 4162 4163Given 4164void f() { for (;;) { int x = 42; if (true) { int x = 43; } } } 4165compoundStmt(hasParent(ifStmt())) matches "{ int x = 43; }". 4166 4167Usable as: Any Matcher 4168</pre></td></tr> 4169 4170 4171<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html">AbstractConditionalOperator</a>></td><td class="name" onclick="toggle('hasCondition5')"><a name="hasCondition5Anchor">hasCondition</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 4172<tr><td colspan="4" class="doc" id="hasCondition5"><pre>Matches the condition expression of an if statement, for loop, 4173switch statement or conditional operator. 4174 4175Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 4176 if (true) {} 4177</pre></td></tr> 4178 4179 4180<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html">AbstractConditionalOperator</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> 4181<tr><td colspan="4" class="doc" id="hasFalseExpression0"><pre>Matches the false branch expression of a conditional operator 4182(binary or ternary). 4183 4184Example matches b 4185 condition ? a : b 4186 condition ?: b 4187</pre></td></tr> 4188 4189 4190<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AbstractConditionalOperator.html">AbstractConditionalOperator</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> 4191<tr><td colspan="4" class="doc" id="hasTrueExpression0"><pre>Matches the true branch expression of a conditional operator. 4192 4193Example 1 (conditional ternary operator): matches a 4194 condition ? a : b 4195 4196Example 2 (conditional binary operator): matches opaqueValueExpr(condition) 4197 condition ?: b 4198</pre></td></tr> 4199 4200 4201<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>></td><td class="name" onclick="toggle('hasDeclaration15')"><a name="hasDeclaration15Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4202<tr><td colspan="4" class="doc" id="hasDeclaration15"><pre>Matches a node if the declaration associated with that node 4203matches the given matcher. 4204 4205The associated declaration is: 4206- for type nodes, the declaration of the underlying type 4207- for CallExpr, the declaration of the callee 4208- for MemberExpr, the declaration of the referenced member 4209- for CXXConstructExpr, the declaration of the constructor 4210- for CXXNewExpr, the declaration of the operator new 4211 4212For type nodes, hasDeclaration will generally match the declaration of the 4213sugared type. Given 4214 class X {}; 4215 typedef X Y; 4216 Y y; 4217in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4218typedefDecl. A common use case is to match the underlying, desugared type. 4219This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4220 varDecl(hasType(hasUnqualifiedDesugaredType( 4221 recordType(hasDeclaration(decl()))))) 4222In this matcher, the decl will match the CXXRecordDecl of class X. 4223 4224Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 4225 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 4226 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 4227 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 4228 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 4229 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 4230 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4231</pre></td></tr> 4232 4233 4234<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> 4235<tr><td colspan="4" class="doc" id="hasBase0"><pre>Matches the base expression of an array subscript expression. 4236 4237Given 4238 int i[5]; 4239 void f() { i[1] = 42; } 4240arraySubscriptExpression(hasBase(implicitCastExpr( 4241 hasSourceExpression(declRefExpr())))) 4242 matches i[1] with the declRefExpr() matching i 4243</pre></td></tr> 4244 4245 4246<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> 4247<tr><td colspan="4" class="doc" id="hasIndex0"><pre>Matches the index expression of an array subscript expression. 4248 4249Given 4250 int i[5]; 4251 void f() { i[1] = 42; } 4252arraySubscriptExpression(hasIndex(integerLiteral())) 4253 matches i[1] with the integerLiteral() matching 1 4254</pre></td></tr> 4255 4256 4257<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>></td><td class="name" onclick="toggle('hasLHS1')"><a name="hasLHS1Anchor">hasLHS</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 4258<tr><td colspan="4" class="doc" id="hasLHS1"><pre>Matches the left hand side of binary operator expressions. 4259 4260Example matches a (matcher = binaryOperator(hasLHS())) 4261 a || b 4262</pre></td></tr> 4263 4264 4265<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArraySubscriptExpr.html">ArraySubscriptExpr</a>></td><td class="name" onclick="toggle('hasRHS1')"><a name="hasRHS1Anchor">hasRHS</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 4266<tr><td colspan="4" class="doc" id="hasRHS1"><pre>Matches the right hand side of binary operator expressions. 4267 4268Example matches b (matcher = binaryOperator(hasRHS())) 4269 a || b 4270</pre></td></tr> 4271 4272 4273<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayTypeLoc.html">ArrayTypeLoc</a>></td><td class="name" onclick="toggle('hasElementTypeLoc0')"><a name="hasElementTypeLoc0Anchor">hasElementTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> 4274<tr><td colspan="4" class="doc" id="hasElementTypeLoc0"><pre>Matches arrays and C99 complex types that have a specific element 4275type. 4276 4277Given 4278 struct A {}; 4279 A a[7]; 4280 int b[7]; 4281arrayType(hasElementType(builtinType())) 4282 matches "int b[7]" 4283 4284Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>> 4285</pre></td></tr> 4286 4287 4288<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>></td><td class="name" onclick="toggle('hasElementType0')"><a name="hasElementType0Anchor">hasElementType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 4289<tr><td colspan="4" class="doc" id="hasElementType0"><pre>Matches arrays and C99 complex types that have a specific element 4290type. 4291 4292Given 4293 struct A {}; 4294 A a[7]; 4295 int b[7]; 4296arrayType(hasElementType(builtinType())) 4297 matches "int b[7]" 4298 4299Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>> 4300</pre></td></tr> 4301 4302 4303<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicTypeLoc.html">AtomicTypeLoc</a>></td><td class="name" onclick="toggle('hasValueTypeLoc0')"><a name="hasValueTypeLoc0Anchor">hasValueTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> 4304<tr><td colspan="4" class="doc" id="hasValueTypeLoc0"><pre>Matches atomic types with a specific value type. 4305 4306Given 4307 _Atomic(int) i; 4308 _Atomic(float) f; 4309atomicType(hasValueType(isInteger())) 4310 matches "_Atomic(int) i" 4311 4312Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 4313</pre></td></tr> 4314 4315 4316<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>></td><td class="name" onclick="toggle('hasValueType0')"><a name="hasValueType0Anchor">hasValueType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 4317<tr><td colspan="4" class="doc" id="hasValueType0"><pre>Matches atomic types with a specific value type. 4318 4319Given 4320 _Atomic(int) i; 4321 _Atomic(float) f; 4322atomicType(hasValueType(isInteger())) 4323 matches "_Atomic(int) i" 4324 4325Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AtomicType.html">AtomicType</a>> 4326</pre></td></tr> 4327 4328 4329<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>></td><td class="name" onclick="toggle('hasDeducedType0')"><a name="hasDeducedType0Anchor">hasDeducedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 4330<tr><td colspan="4" class="doc" id="hasDeducedType0"><pre>Matches AutoType nodes where the deduced type is a specific type. 4331 4332Note: There is no TypeLoc for the deduced type and thus no 4333getDeducedLoc() matcher. 4334 4335Given 4336 auto a = 1; 4337 auto b = 2.0; 4338autoType(hasDeducedType(isInteger())) 4339 matches "auto a" 4340 4341Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AutoType.html">AutoType</a>> 4342</pre></td></tr> 4343 4344 4345<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>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 4346<tr><td colspan="4" class="doc" id="hasEitherOperand0"><pre>Matches if either the left hand side or the right hand side of a 4347binary operator matches. 4348</pre></td></tr> 4349 4350 4351<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> 4352<tr><td colspan="4" class="doc" id="hasLHS0"><pre>Matches the left hand side of binary operator expressions. 4353 4354Example matches a (matcher = binaryOperator(hasLHS())) 4355 a || b 4356</pre></td></tr> 4357 4358 4359<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> 4360<tr><td colspan="4" class="doc" id="hasRHS0"><pre>Matches the right hand side of binary operator expressions. 4361 4362Example matches b (matcher = binaryOperator(hasRHS())) 4363 a || b 4364</pre></td></tr> 4365 4366 4367<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>></td><td class="name" onclick="toggle('hasAnyParameter2')"><a name="hasAnyParameter2Anchor">hasAnyParameter</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> 4368<tr><td colspan="4" class="doc" id="hasAnyParameter2"><pre>Matches any parameter of a function or an ObjC method declaration or a 4369block. 4370 4371Does not match the 'this' parameter of a method. 4372 4373Given 4374 class X { void f(int x, int y, int z) {} }; 4375cxxMethodDecl(hasAnyParameter(hasName("y"))) 4376 matches f(int x, int y, int z) {} 4377with hasAnyParameter(...) 4378 matching int y 4379 4380For ObjectiveC, given 4381 @interface I - (void) f:(int) y; @end 4382 4383the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 4384matches the declaration of method f with hasParameter 4385matching y. 4386 4387For blocks, given 4388 b = ^(int y) { printf("%d", y) }; 4389 4390the matcher blockDecl(hasAnyParameter(hasName("y"))) 4391matches the declaration of the block b with hasParameter 4392matching y. 4393</pre></td></tr> 4394 4395 4396<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockDecl.html">BlockDecl</a>></td><td class="name" onclick="toggle('hasParameter2')"><a name="hasParameter2Anchor">hasParameter</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> 4397<tr><td colspan="4" class="doc" id="hasParameter2"><pre>Matches the n'th parameter of a function or an ObjC method 4398declaration or a block. 4399 4400Given 4401 class X { void f(int x) {} }; 4402cxxMethodDecl(hasParameter(0, hasType(varDecl()))) 4403 matches f(int x) {} 4404with hasParameter(...) 4405 matching int x 4406 4407For ObjectiveC, given 4408 @interface I - (void) f:(int) y; @end 4409 4410the matcher objcMethodDecl(hasParameter(0, hasName("y"))) 4411matches the declaration of method f with hasParameter 4412matching y. 4413</pre></td></tr> 4414 4415 4416<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerTypeLoc.html">BlockPointerTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc0')"><a name="pointeeLoc0Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> 4417<tr><td colspan="4" class="doc" id="pointeeLoc0"><pre>Narrows PointerType (and similar) matchers to those where the 4418pointee matches a given matcher. 4419 4420Given 4421 int *a; 4422 int const *b; 4423 float const *f; 4424pointerType(pointee(isConstQualified(), isInteger())) 4425 matches "int const *b" 4426 4427Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 4428 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 4429</pre></td></tr> 4430 4431 4432<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>></td><td class="name" onclick="toggle('pointee0')"><a name="pointee0Anchor">pointee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 4433<tr><td colspan="4" class="doc" id="pointee0"><pre>Narrows PointerType (and similar) matchers to those where the 4434pointee matches a given matcher. 4435 4436Given 4437 int *a; 4438 int const *b; 4439 float const *f; 4440pointerType(pointee(isConstQualified(), isInteger())) 4441 matches "int const *b" 4442 4443Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 4444 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 4445</pre></td></tr> 4446 4447 4448<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('forEachArgumentWithParam1')"><a name="forEachArgumentWithParam1Anchor">forEachArgumentWithParam</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> ArgMatcher, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> ParamMatcher</td></tr> 4449<tr><td colspan="4" class="doc" id="forEachArgumentWithParam1"><pre>Matches all arguments and their respective ParmVarDecl. 4450 4451Given 4452 void f(int i); 4453 int y; 4454 f(y); 4455callExpr( 4456 forEachArgumentWithParam( 4457 declRefExpr(to(varDecl(hasName("y")))), 4458 parmVarDecl(hasType(isInteger())) 4459)) 4460 matches f(y); 4461with declRefExpr(...) 4462 matching int y 4463and parmVarDecl(...) 4464 matching int i 4465</pre></td></tr> 4466 4467 4468<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasAnyArgument1')"><a name="hasAnyArgument1Anchor">hasAnyArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 4469<tr><td colspan="4" class="doc" id="hasAnyArgument1"><pre>Matches any argument of a call expression or a constructor call 4470expression, or an ObjC-message-send expression. 4471 4472Given 4473 void x(int, int, int) { int y; x(1, y, 42); } 4474callExpr(hasAnyArgument(declRefExpr())) 4475 matches x(1, y, 42) 4476with hasAnyArgument(...) 4477 matching y 4478 4479For ObjectiveC, given 4480 @interface I - (void) f:(int) y; @end 4481 void foo(I *i) { [i f:12]; } 4482objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 4483 matches [i f:12] 4484</pre></td></tr> 4485 4486 4487<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasArgument1')"><a name="hasArgument1Anchor">hasArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 4488<tr><td colspan="4" class="doc" id="hasArgument1"><pre>Matches the n'th argument of a call expression or a constructor 4489call expression. 4490 4491Example matches y in x(y) 4492 (matcher = callExpr(hasArgument(0, declRefExpr()))) 4493 void x(int) { int y; x(y); } 4494</pre></td></tr> 4495 4496 4497<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>></td><td class="name" onclick="toggle('hasDeclaration13')"><a name="hasDeclaration13Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4498<tr><td colspan="4" class="doc" id="hasDeclaration13"><pre>Matches a node if the declaration associated with that node 4499matches the given matcher. 4500 4501The associated declaration is: 4502- for type nodes, the declaration of the underlying type 4503- for CallExpr, the declaration of the callee 4504- for MemberExpr, the declaration of the referenced member 4505- for CXXConstructExpr, the declaration of the constructor 4506- for CXXNewExpr, the declaration of the operator new 4507 4508For type nodes, hasDeclaration will generally match the declaration of the 4509sugared type. Given 4510 class X {}; 4511 typedef X Y; 4512 Y y; 4513in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4514typedefDecl. A common use case is to match the underlying, desugared type. 4515This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4516 varDecl(hasType(hasUnqualifiedDesugaredType( 4517 recordType(hasDeclaration(decl()))))) 4518In this matcher, the decl will match the CXXRecordDecl of class X. 4519 4520Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 4521 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 4522 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 4523 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 4524 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 4525 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 4526 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4527</pre></td></tr> 4528 4529 4530<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructorDecl.html">CXXConstructorDecl</a>></td><td class="name" onclick="toggle('forEachConstructorInitializer0')"><a name="forEachConstructorInitializer0Anchor">forEachConstructorInitializer</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXCtorInitializer.html">CXXCtorInitializer</a>> InnerMatcher</td></tr> 4531<tr><td colspan="4" class="doc" id="forEachConstructorInitializer0"><pre>Matches each constructor initializer in a constructor definition. 4532 4533Given 4534 class A { A() : i(42), j(42) {} int i; int j; }; 4535cxxConstructorDecl(forEachConstructorInitializer( 4536 forField(decl().bind("x")) 4537)) 4538 will trigger two matches, binding for 'i' and 'j' respectively. 4539</pre></td></tr> 4540 4541 4542<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> 4543<tr><td colspan="4" class="doc" id="hasAnyConstructorInitializer0"><pre>Matches a constructor initializer. 4544 4545Given 4546 struct Foo { 4547 Foo() : foo_(1) { } 4548 int foo_; 4549 }; 4550cxxRecordDecl(has(cxxConstructorDecl( 4551 hasAnyConstructorInitializer(anything()) 4552))) 4553 record matches Foo, hasAnyConstructorInitializer matches foo_(1) 4554</pre></td></tr> 4555 4556 4557<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> 4558<tr><td colspan="4" class="doc" id="forField0"><pre>Matches the field declaration of a constructor initializer. 4559 4560Given 4561 struct Foo { 4562 Foo() : foo_(1) { } 4563 int foo_; 4564 }; 4565cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( 4566 forField(hasName("foo_")))))) 4567 matches Foo 4568with forField matching foo_ 4569</pre></td></tr> 4570 4571 4572<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> 4573<tr><td colspan="4" class="doc" id="withInitializer0"><pre>Matches the initializer expression of a constructor initializer. 4574 4575Given 4576 struct Foo { 4577 Foo() : foo_(1) { } 4578 int foo_; 4579 }; 4580cxxRecordDecl(has(cxxConstructorDecl(hasAnyConstructorInitializer( 4581 withInitializer(integerLiteral(equals(1))))))) 4582 matches Foo 4583with withInitializer matching (1) 4584</pre></td></tr> 4585 4586 4587<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasBody3')"><a name="hasBody3Anchor">hasBody</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 4588<tr><td colspan="4" class="doc" id="hasBody3"><pre>Matches a 'for', 'while', 'do while' statement or a function 4589definition that has a given body. 4590 4591Given 4592 for (;;) {} 4593hasBody(compoundStmt()) 4594 matches 'for (;;) {}' 4595with compoundStmt() 4596 matching '{}' 4597</pre></td></tr> 4598 4599 4600<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasLoopVariable0')"><a name="hasLoopVariable0Anchor">hasLoopVariable</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1VarDecl.html">VarDecl</a>> InnerMatcher</td></tr> 4601<tr><td colspan="4" class="doc" id="hasLoopVariable0"><pre>Matches the initialization statement of a for loop. 4602 4603Example: 4604 forStmt(hasLoopVariable(anything())) 4605matches 'int x' in 4606 for (int x : a) { } 4607</pre></td></tr> 4608 4609 4610<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXForRangeStmt.html">CXXForRangeStmt</a>></td><td class="name" onclick="toggle('hasRangeInit0')"><a name="hasRangeInit0Anchor">hasRangeInit</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 4611<tr><td colspan="4" class="doc" id="hasRangeInit0"><pre>Matches the range initialization statement of a for loop. 4612 4613Example: 4614 forStmt(hasRangeInit(anything())) 4615matches 'a' in 4616 for (int x : a) { } 4617</pre></td></tr> 4618 4619 4620<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> 4621<tr><td colspan="4" class="doc" id="onImplicitObjectArgument0"><pre></pre></td></tr> 4622 4623 4624<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> 4625<tr><td colspan="4" class="doc" id="on0"><pre>Matches on the implicit object argument of a member call expression. 4626 4627Example matches y.x() 4628 (matcher = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))))) 4629 class Y { public: void x(); }; 4630 void z() { Y y; y.x(); } 4631 4632FIXME: Overload to allow directly matching types? 4633</pre></td></tr> 4634 4635 4636<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> 4637<tr><td colspan="4" class="doc" id="thisPointerType1"><pre>Overloaded to match the type's declaration. 4638</pre></td></tr> 4639 4640 4641<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMemberCallExpr.html">CXXMemberCallExpr</a>></td><td class="name" onclick="toggle('thisPointerType0')"><a name="thisPointerType0Anchor">thisPointerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 4642<tr><td colspan="4" class="doc" id="thisPointerType0"><pre>Matches if the expression's type either matches the specified 4643matcher, or is a pointer to a type that matches the InnerMatcher. 4644</pre></td></tr> 4645 4646 4647<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>></td><td class="name" onclick="toggle('forEachOverridden0')"><a name="forEachOverridden0Anchor">forEachOverridden</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>> InnerMatcher</td></tr> 4648<tr><td colspan="4" class="doc" id="forEachOverridden0"><pre>Matches each method overridden by the given method. This matcher may 4649produce multiple matches. 4650 4651Given 4652 class A { virtual void f(); }; 4653 class B : public A { void f(); }; 4654 class C : public B { void f(); }; 4655cxxMethodDecl(ofClass(hasName("C")), 4656 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") 4657 matches once, with "b" binding "A::f" and "d" binding "C::f" (Note 4658 that B::f is not overridden by C::f). 4659 4660The check can produce multiple matches in case of multiple inheritance, e.g. 4661 class A1 { virtual void f(); }; 4662 class A2 { virtual void f(); }; 4663 class C : public A1, public A2 { void f(); }; 4664cxxMethodDecl(ofClass(hasName("C")), 4665 forEachOverridden(cxxMethodDecl().bind("b"))).bind("d") 4666 matches twice, once with "b" binding "A1::f" and "d" binding "C::f", and 4667 once with "b" binding "A2::f" and "d" binding "C::f". 4668</pre></td></tr> 4669 4670 4671<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> 4672<tr><td colspan="4" class="doc" id="ofClass0"><pre>Matches the class declaration that the given method declaration 4673belongs to. 4674 4675FIXME: Generalize this for other kinds of declarations. 4676FIXME: What other kind of declarations would we need to generalize 4677this to? 4678 4679Example matches A() in the last line 4680 (matcher = cxxConstructExpr(hasDeclaration(cxxMethodDecl( 4681 ofClass(hasName("A")))))) 4682 class A { 4683 public: 4684 A(); 4685 }; 4686 A a = A(); 4687</pre></td></tr> 4688 4689 4690<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>></td><td class="name" onclick="toggle('hasArraySize0')"><a name="hasArraySize0Anchor">hasArraySize</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 4691<tr><td colspan="4" class="doc" id="hasArraySize0"><pre>Matches array new expressions with a given array size. 4692 4693Given: 4694 MyClass *p1 = new MyClass[10]; 4695cxxNewExpr(hasArraySize(intgerLiteral(equals(10)))) 4696 matches the expression 'new MyClass[10]'. 4697</pre></td></tr> 4698 4699 4700<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>></td><td class="name" onclick="toggle('hasDeclaration12')"><a name="hasDeclaration12Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4701<tr><td colspan="4" class="doc" id="hasDeclaration12"><pre>Matches a node if the declaration associated with that node 4702matches the given matcher. 4703 4704The associated declaration is: 4705- for type nodes, the declaration of the underlying type 4706- for CallExpr, the declaration of the callee 4707- for MemberExpr, the declaration of the referenced member 4708- for CXXConstructExpr, the declaration of the constructor 4709- for CXXNewExpr, the declaration of the operator new 4710 4711For type nodes, hasDeclaration will generally match the declaration of the 4712sugared type. Given 4713 class X {}; 4714 typedef X Y; 4715 Y y; 4716in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4717typedefDecl. A common use case is to match the underlying, desugared type. 4718This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4719 varDecl(hasType(hasUnqualifiedDesugaredType( 4720 recordType(hasDeclaration(decl()))))) 4721In this matcher, the decl will match the CXXRecordDecl of class X. 4722 4723Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 4724 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 4725 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 4726 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 4727 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 4728 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 4729 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4730</pre></td></tr> 4731 4732 4733<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXRecordDecl.html">CXXRecordDecl</a>></td><td class="name" onclick="toggle('hasMethod0')"><a name="hasMethod0Anchor">hasMethod</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXMethodDecl.html">CXXMethodDecl</a>> InnerMatcher</td></tr> 4734<tr><td colspan="4" class="doc" id="hasMethod0"><pre>Matches the first method of a class or struct that satisfies InnerMatcher. 4735 4736Given: 4737 class A { void func(); }; 4738 class B { void member(); }; 4739 4740cxxRecordDecl(hasMethod(hasName("func"))) matches the declaration of 4741A but not B. 4742</pre></td></tr> 4743 4744 4745<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> 4746<tr><td colspan="4" class="doc" id="isDerivedFrom0"><pre>Matches C++ classes that are directly or indirectly derived from 4747a class matching Base. 4748 4749Note that a class is not considered to be derived from itself. 4750 4751Example matches Y, Z, C (Base == hasName("X")) 4752 class X; 4753 class Y : public X {}; directly derived 4754 class Z : public Y {}; indirectly derived 4755 typedef X A; 4756 typedef A B; 4757 class C : public B {}; derived from a typedef of X 4758 4759In the following example, Bar matches isDerivedFrom(hasName("X")): 4760 class Foo; 4761 typedef Foo X; 4762 class Bar : public Foo {}; derived from a type that X is a typedef of 4763</pre></td></tr> 4764 4765 4766<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> 4767<tr><td colspan="4" class="doc" id="isSameOrDerivedFrom0"><pre>Similar to isDerivedFrom(), but also matches classes that directly 4768match Base. 4769</pre></td></tr> 4770 4771 4772<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> 4773<tr><td colspan="4" class="doc" id="callee1"><pre>Matches if the call expression's callee's declaration matches the 4774given matcher. 4775 4776Example matches y.x() (matcher = callExpr(callee( 4777 cxxMethodDecl(hasName("x"))))) 4778 class Y { public: void x(); }; 4779 void z() { Y y; y.x(); } 4780</pre></td></tr> 4781 4782 4783<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('callee0')"><a name="callee0Anchor">callee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 4784<tr><td colspan="4" class="doc" id="callee0"><pre>Matches if the call expression's callee expression matches. 4785 4786Given 4787 class Y { void x() { this->x(); x(); Y y; y.x(); } }; 4788 void f() { f(); } 4789callExpr(callee(expr())) 4790 matches this->x(), x(), y.x(), f() 4791with callee(...) 4792 matching this->x, x, y.x, f respectively 4793 4794Note: Callee cannot take the more general internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> 4795because this introduces ambiguous overloads with calls to Callee taking a 4796internal::Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>>, as the matcher hierarchy is purely 4797implemented in terms of implicit casts. 4798</pre></td></tr> 4799 4800 4801<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('forEachArgumentWithParam0')"><a name="forEachArgumentWithParam0Anchor">forEachArgumentWithParam</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> ArgMatcher, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> ParamMatcher</td></tr> 4802<tr><td colspan="4" class="doc" id="forEachArgumentWithParam0"><pre>Matches all arguments and their respective ParmVarDecl. 4803 4804Given 4805 void f(int i); 4806 int y; 4807 f(y); 4808callExpr( 4809 forEachArgumentWithParam( 4810 declRefExpr(to(varDecl(hasName("y")))), 4811 parmVarDecl(hasType(isInteger())) 4812)) 4813 matches f(y); 4814with declRefExpr(...) 4815 matching int y 4816and parmVarDecl(...) 4817 matching int i 4818</pre></td></tr> 4819 4820 4821<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> 4822<tr><td colspan="4" class="doc" id="hasAnyArgument0"><pre>Matches any argument of a call expression or a constructor call 4823expression, or an ObjC-message-send expression. 4824 4825Given 4826 void x(int, int, int) { int y; x(1, y, 42); } 4827callExpr(hasAnyArgument(declRefExpr())) 4828 matches x(1, y, 42) 4829with hasAnyArgument(...) 4830 matching y 4831 4832For ObjectiveC, given 4833 @interface I - (void) f:(int) y; @end 4834 void foo(I *i) { [i f:12]; } 4835objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 4836 matches [i f:12] 4837</pre></td></tr> 4838 4839 4840<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> 4841<tr><td colspan="4" class="doc" id="hasArgument0"><pre>Matches the n'th argument of a call expression or a constructor 4842call expression. 4843 4844Example matches y in x(y) 4845 (matcher = callExpr(hasArgument(0, declRefExpr()))) 4846 void x(int) { int y; x(y); } 4847</pre></td></tr> 4848 4849 4850<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>></td><td class="name" onclick="toggle('hasDeclaration14')"><a name="hasDeclaration14Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 4851<tr><td colspan="4" class="doc" id="hasDeclaration14"><pre>Matches a node if the declaration associated with that node 4852matches the given matcher. 4853 4854The associated declaration is: 4855- for type nodes, the declaration of the underlying type 4856- for CallExpr, the declaration of the callee 4857- for MemberExpr, the declaration of the referenced member 4858- for CXXConstructExpr, the declaration of the constructor 4859- for CXXNewExpr, the declaration of the operator new 4860 4861For type nodes, hasDeclaration will generally match the declaration of the 4862sugared type. Given 4863 class X {}; 4864 typedef X Y; 4865 Y y; 4866in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 4867typedefDecl. A common use case is to match the underlying, desugared type. 4868This can be achieved by using the hasUnqualifiedDesugaredType matcher: 4869 varDecl(hasType(hasUnqualifiedDesugaredType( 4870 recordType(hasDeclaration(decl()))))) 4871In this matcher, the decl will match the CXXRecordDecl of class X. 4872 4873Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 4874 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 4875 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 4876 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 4877 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 4878 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 4879 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 4880</pre></td></tr> 4881 4882 4883<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CaseStmt.html">CaseStmt</a>></td><td class="name" onclick="toggle('hasCaseConstant0')"><a name="hasCaseConstant0Anchor">hasCaseConstant</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 4884<tr><td colspan="4" class="doc" id="hasCaseConstant0"><pre>If the given case statement does not use the GNU case range 4885extension, matches the constant given in the statement. 4886 4887Given 4888 switch (1) { case 1: case 1+1: case 3 ... 4: ; } 4889caseStmt(hasCaseConstant(integerLiteral())) 4890 matches "case 1:" 4891</pre></td></tr> 4892 4893 4894<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> 4895<tr><td colspan="4" class="doc" id="hasSourceExpression0"><pre>Matches if the cast's source expression 4896or opaque value's source expression matches the given matcher. 4897 4898Example 1: matches "a string" 4899(matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) 4900class URL { URL(string); }; 4901URL url = "a string"; 4902 4903Example 2: matches 'b' (matcher = 4904opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) 4905int a = b ?: 1; 4906</pre></td></tr> 4907 4908 4909<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> 4910<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and 4911functionDecl that have at least one TemplateArgument matching the given 4912InnerMatcher. 4913 4914Given 4915 template<typename T> class A {}; 4916 template<> class A<double> {}; 4917 A<int> a; 4918 4919 template<typename T> f() {}; 4920 void func() { f<int>(); }; 4921 4922classTemplateSpecializationDecl(hasAnyTemplateArgument( 4923 refersToType(asString("int")))) 4924 matches the specialization A<int> 4925 4926functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 4927 matches the specialization f<int> 4928</pre></td></tr> 4929 4930 4931<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateSpecializationDecl.html">ClassTemplateSpecializationDecl</a>></td><td class="name" onclick="toggle('hasSpecializedTemplate0')"><a name="hasSpecializedTemplate0Anchor">hasSpecializedTemplate</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ClassTemplateDecl.html">ClassTemplateDecl</a>> InnerMatcher</td></tr> 4932<tr><td colspan="4" class="doc" id="hasSpecializedTemplate0"><pre>Matches the specialized template of a specialization declaration. 4933 4934Given 4935 tempalate<typename T> class A {}; 4936 typedef A<int> B; 4937classTemplateSpecializationDecl(hasSpecializedTemplate(classTemplateDecl())) 4938 matches 'B' with classTemplateDecl() matching the class template 4939 declaration of 'A'. 4940</pre></td></tr> 4941 4942 4943<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> 4944<tr><td colspan="4" class="doc" id="hasTemplateArgument0"><pre>Matches classTemplateSpecializations, templateSpecializationType and 4945functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 4946 4947Given 4948 template<typename T, typename U> class A {}; 4949 A<bool, int> b; 4950 A<int, bool> c; 4951 4952 template<typename T> void f() {} 4953 void func() { f<int>(); }; 4954classTemplateSpecializationDecl(hasTemplateArgument( 4955 1, refersToType(asString("int")))) 4956 matches the specialization A<bool, int> 4957 4958functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 4959 matches the specialization f<int> 4960</pre></td></tr> 4961 4962 4963<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexTypeLoc.html">ComplexTypeLoc</a>></td><td class="name" onclick="toggle('hasElementTypeLoc1')"><a name="hasElementTypeLoc1Anchor">hasElementTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> 4964<tr><td colspan="4" class="doc" id="hasElementTypeLoc1"><pre>Matches arrays and C99 complex types that have a specific element 4965type. 4966 4967Given 4968 struct A {}; 4969 A a[7]; 4970 int b[7]; 4971arrayType(hasElementType(builtinType())) 4972 matches "int b[7]" 4973 4974Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>> 4975</pre></td></tr> 4976 4977 4978<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>></td><td class="name" onclick="toggle('hasElementType1')"><a name="hasElementType1Anchor">hasElementType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 4979<tr><td colspan="4" class="doc" id="hasElementType1"><pre>Matches arrays and C99 complex types that have a specific element 4980type. 4981 4982Given 4983 struct A {}; 4984 A a[7]; 4985 int b[7]; 4986arrayType(hasElementType(builtinType())) 4987 matches "int b[7]" 4988 4989Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ArrayType.html">ArrayType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ComplexType.html">ComplexType</a>> 4990</pre></td></tr> 4991 4992 4993<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> 4994<tr><td colspan="4" class="doc" id="hasAnySubstatement0"><pre>Matches compound statements where at least one substatement matches 4995a given matcher. Also matches StmtExprs that have CompoundStmt as children. 4996 4997Given 4998 { {}; 1+2; } 4999hasAnySubstatement(compoundStmt()) 5000 matches '{ {}; 1+2; }' 5001with compoundStmt() 5002 matching '{}' 5003</pre></td></tr> 5004 5005 5006<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DecayedType.html">DecayedType</a>></td><td class="name" onclick="toggle('hasDecayedType0')"><a name="hasDecayedType0Anchor">hasDecayedType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerType</td></tr> 5007<tr><td colspan="4" class="doc" id="hasDecayedType0"><pre>Matches the decayed type, whos decayed type matches InnerMatcher 5008</pre></td></tr> 5009 5010 5011<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>></td><td class="name" onclick="toggle('hasDeclaration11')"><a name="hasDeclaration11Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5012<tr><td colspan="4" class="doc" id="hasDeclaration11"><pre>Matches a node if the declaration associated with that node 5013matches the given matcher. 5014 5015The associated declaration is: 5016- for type nodes, the declaration of the underlying type 5017- for CallExpr, the declaration of the callee 5018- for MemberExpr, the declaration of the referenced member 5019- for CXXConstructExpr, the declaration of the constructor 5020- for CXXNewExpr, the declaration of the operator new 5021 5022For type nodes, hasDeclaration will generally match the declaration of the 5023sugared type. Given 5024 class X {}; 5025 typedef X Y; 5026 Y y; 5027in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5028typedefDecl. A common use case is to match the underlying, desugared type. 5029This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5030 varDecl(hasType(hasUnqualifiedDesugaredType( 5031 recordType(hasDeclaration(decl()))))) 5032In this matcher, the decl will match the CXXRecordDecl of class X. 5033 5034Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 5035 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 5036 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 5037 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 5038 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 5039 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 5040 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5041</pre></td></tr> 5042 5043 5044<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> 5045<tr><td colspan="4" class="doc" id="throughUsingDecl0"><pre>Matches a DeclRefExpr that refers to a declaration through a 5046specific using shadow declaration. 5047 5048Given 5049 namespace a { void f() {} } 5050 using a::f; 5051 void g() { 5052 f(); Matches this .. 5053 a::f(); .. but not this. 5054 } 5055declRefExpr(throughUsingDecl(anything())) 5056 matches f() 5057</pre></td></tr> 5058 5059 5060<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> 5061<tr><td colspan="4" class="doc" id="to0"><pre>Matches a DeclRefExpr that refers to a declaration that matches the 5062specified matcher. 5063 5064Example matches x in if(x) 5065 (matcher = declRefExpr(to(varDecl(hasName("x"))))) 5066 bool x; 5067 if (x) {} 5068</pre></td></tr> 5069 5070 5071<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> 5072<tr><td colspan="4" class="doc" id="containsDeclaration0"><pre>Matches the n'th declaration of a declaration statement. 5073 5074Note that this does not work for global declarations because the AST 5075breaks up multiple-declaration DeclStmt's into multiple single-declaration 5076DeclStmt's. 5077Example: Given non-global declarations 5078 int a, b = 0; 5079 int c; 5080 int d = 2, e; 5081declStmt(containsDeclaration( 5082 0, varDecl(hasInitializer(anything())))) 5083 matches only 'int d = 2, e;', and 5084declStmt(containsDeclaration(1, varDecl())) 5085 matches 'int a, b = 0' as well as 'int d = 2, e;' 5086 but 'int c;' is not matched. 5087</pre></td></tr> 5088 5089 5090<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> 5091<tr><td colspan="4" class="doc" id="hasSingleDecl0"><pre>Matches the Decl of a DeclStmt which has a single declaration. 5092 5093Given 5094 int a, b; 5095 int c; 5096declStmt(hasSingleDecl(anything())) 5097 matches 'int c;' but not 'int a, b;'. 5098</pre></td></tr> 5099 5100 5101<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclaratorDecl.html">DeclaratorDecl</a>></td><td class="name" onclick="toggle('hasTypeLoc0')"><a name="hasTypeLoc0Anchor">hasTypeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>> Inner</td></tr> 5102<tr><td colspan="4" class="doc" id="hasTypeLoc0"><pre>Matches if the type location of the declarator decl's type matches 5103the inner matcher. 5104 5105Given 5106 int x; 5107declaratorDecl(hasTypeLoc(loc(asString("int")))) 5108 matches int x 5109</pre></td></tr> 5110 5111 5112<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>></td><td class="name" onclick="toggle('hasDeclContext0')"><a name="hasDeclContext0Anchor">hasDeclContext</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5113<tr><td colspan="4" class="doc" id="hasDeclContext0"><pre>Matches declarations whose declaration context, interpreted as a 5114Decl, matches InnerMatcher. 5115 5116Given 5117 namespace N { 5118 namespace M { 5119 class D {}; 5120 } 5121 } 5122 5123cxxRcordDecl(hasDeclContext(namedDecl(hasName("M")))) matches the 5124declaration of class D. 5125</pre></td></tr> 5126 5127 5128<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> 5129<tr><td colspan="4" class="doc" id="hasBody0"><pre>Matches a 'for', 'while', 'do while' statement or a function 5130definition that has a given body. 5131 5132Given 5133 for (;;) {} 5134hasBody(compoundStmt()) 5135 matches 'for (;;) {}' 5136with compoundStmt() 5137 matching '{}' 5138</pre></td></tr> 5139 5140 5141<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> 5142<tr><td colspan="4" class="doc" id="hasCondition3"><pre>Matches the condition expression of an if statement, for loop, 5143switch statement or conditional operator. 5144 5145Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 5146 if (true) {} 5147</pre></td></tr> 5148 5149 5150<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>></td><td class="name" onclick="toggle('hasQualifier0')"><a name="hasQualifier0Anchor">hasQualifier</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr> 5151<tr><td colspan="4" class="doc" id="hasQualifier0"><pre>Matches ElaboratedTypes whose qualifier, a NestedNameSpecifier, 5152matches InnerMatcher if the qualifier exists. 5153 5154Given 5155 namespace N { 5156 namespace M { 5157 class D {}; 5158 } 5159 } 5160 N::M::D d; 5161 5162elaboratedType(hasQualifier(hasPrefix(specifiesNamespace(hasName("N")))) 5163matches the type of the variable declaration of d. 5164</pre></td></tr> 5165 5166 5167<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ElaboratedType.html">ElaboratedType</a>></td><td class="name" onclick="toggle('namesType0')"><a name="namesType0Anchor">namesType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 5168<tr><td colspan="4" class="doc" id="namesType0"><pre>Matches ElaboratedTypes whose named type matches InnerMatcher. 5169 5170Given 5171 namespace N { 5172 namespace M { 5173 class D {}; 5174 } 5175 } 5176 N::M::D d; 5177 5178elaboratedType(namesType(recordType( 5179hasDeclaration(namedDecl(hasName("D")))))) matches the type of the variable 5180declaration of d. 5181</pre></td></tr> 5182 5183 5184<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>></td><td class="name" onclick="toggle('hasDeclaration10')"><a name="hasDeclaration10Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5185<tr><td colspan="4" class="doc" id="hasDeclaration10"><pre>Matches a node if the declaration associated with that node 5186matches the given matcher. 5187 5188The associated declaration is: 5189- for type nodes, the declaration of the underlying type 5190- for CallExpr, the declaration of the callee 5191- for MemberExpr, the declaration of the referenced member 5192- for CXXConstructExpr, the declaration of the constructor 5193- for CXXNewExpr, the declaration of the operator new 5194 5195For type nodes, hasDeclaration will generally match the declaration of the 5196sugared type. Given 5197 class X {}; 5198 typedef X Y; 5199 Y y; 5200in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5201typedefDecl. A common use case is to match the underlying, desugared type. 5202This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5203 varDecl(hasType(hasUnqualifiedDesugaredType( 5204 recordType(hasDeclaration(decl()))))) 5205In this matcher, the decl will match the CXXRecordDecl of class X. 5206 5207Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 5208 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 5209 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 5210 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 5211 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 5212 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 5213 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5214</pre></td></tr> 5215 5216 5217<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> 5218<tr><td colspan="4" class="doc" id="hasDestinationType0"><pre>Matches casts whose destination type matches a given matcher. 5219 5220(Note: Clang's AST refers to other conversions as "casts" too, and calls 5221actual casts "explicit" casts.) 5222</pre></td></tr> 5223 5224 5225<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> 5226<tr><td colspan="4" class="doc" id="hasType3"><pre>Overloaded to match the declaration of the expression's or value 5227declaration's type. 5228 5229In case of a value declaration (for example a variable declaration), 5230this resolves one layer of indirection. For example, in the value 5231declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 5232X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 5233declaration of x. 5234 5235Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 5236 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 5237 class X {}; 5238 void y(X &x) { x; X z; } 5239 5240Usable 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>> 5241</pre></td></tr> 5242 5243 5244<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('hasType0')"><a name="hasType0Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 5245<tr><td colspan="4" class="doc" id="hasType0"><pre>Matches if the expression's or declaration's type matches a type 5246matcher. 5247 5248Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 5249 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 5250 and U (matcher = typedefDecl(hasType(asString("int"))) 5251 class X {}; 5252 void y(X &x) { x; X z; } 5253 typedef int U; 5254</pre></td></tr> 5255 5256 5257<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> 5258<tr><td colspan="4" class="doc" id="ignoringImpCasts0"><pre>Matches expressions that match InnerMatcher after any implicit casts 5259are stripped off. 5260 5261Parentheses and explicit casts are not discarded. 5262Given 5263 int arr[5]; 5264 int a = 0; 5265 char b = 0; 5266 const int c = a; 5267 int *d = arr; 5268 long e = (long) 0l; 5269The matchers 5270 varDecl(hasInitializer(ignoringImpCasts(integerLiteral()))) 5271 varDecl(hasInitializer(ignoringImpCasts(declRefExpr()))) 5272would match the declarations for a, b, c, and d, but not e. 5273While 5274 varDecl(hasInitializer(integerLiteral())) 5275 varDecl(hasInitializer(declRefExpr())) 5276only match the declarations for b, c, and d. 5277</pre></td></tr> 5278 5279 5280<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>></td><td class="name" onclick="toggle('ignoringImplicit0')"><a name="ignoringImplicit0Anchor">ignoringImplicit</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 5281<tr><td colspan="4" class="doc" id="ignoringImplicit0"><pre>Matches expressions that match InnerMatcher after any implicit AST 5282nodes are stripped off. 5283 5284Parentheses and explicit casts are not discarded. 5285Given 5286 class C {}; 5287 C a = C(); 5288 C b; 5289 C c = b; 5290The matchers 5291 varDecl(hasInitializer(ignoringImplicit(cxxConstructExpr()))) 5292would match the declarations for a, b, and c. 5293While 5294 varDecl(hasInitializer(cxxConstructExpr())) 5295only match the declarations for b and c. 5296</pre></td></tr> 5297 5298 5299<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> 5300<tr><td colspan="4" class="doc" id="ignoringParenCasts0"><pre>Matches expressions that match InnerMatcher after parentheses and 5301casts are stripped off. 5302 5303Implicit and non-C Style casts are also discarded. 5304Given 5305 int a = 0; 5306 char b = (0); 5307 void* c = reinterpret_cast<char*>(0); 5308 char d = char(0); 5309The matcher 5310 varDecl(hasInitializer(ignoringParenCasts(integerLiteral()))) 5311would match the declarations for a, b, c, and d. 5312while 5313 varDecl(hasInitializer(integerLiteral())) 5314only match the declaration for a. 5315</pre></td></tr> 5316 5317 5318<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> 5319<tr><td colspan="4" class="doc" id="ignoringParenImpCasts0"><pre>Matches expressions that match InnerMatcher after implicit casts and 5320parentheses are stripped off. 5321 5322Explicit casts are not discarded. 5323Given 5324 int arr[5]; 5325 int a = 0; 5326 char b = (0); 5327 const int c = a; 5328 int *d = (arr); 5329 long e = ((long) 0l); 5330The matchers 5331 varDecl(hasInitializer(ignoringParenImpCasts(integerLiteral()))) 5332 varDecl(hasInitializer(ignoringParenImpCasts(declRefExpr()))) 5333would match the declarations for a, b, c, and d, but not e. 5334while 5335 varDecl(hasInitializer(integerLiteral())) 5336 varDecl(hasInitializer(declRefExpr())) 5337would only match the declaration for a. 5338</pre></td></tr> 5339 5340 5341<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FieldDecl.html">FieldDecl</a>></td><td class="name" onclick="toggle('hasInClassInitializer0')"><a name="hasInClassInitializer0Anchor">hasInClassInitializer</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 5342<tr><td colspan="4" class="doc" id="hasInClassInitializer0"><pre>Matches non-static data members that have an in-class initializer. 5343 5344Given 5345 class C { 5346 int a = 2; 5347 int b = 3; 5348 int c; 5349 }; 5350fieldDecl(hasInClassInitializer(integerLiteral(equals(2)))) 5351 matches 'int a;' but not 'int b;'. 5352fieldDecl(hasInClassInitializer(anything())) 5353 matches 'int a;' and 'int b;' but not 'int c;'. 5354</pre></td></tr> 5355 5356 5357<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> 5358<tr><td colspan="4" class="doc" id="hasBody1"><pre>Matches a 'for', 'while', 'do while' statement or a function 5359definition that has a given body. 5360 5361Given 5362 for (;;) {} 5363hasBody(compoundStmt()) 5364 matches 'for (;;) {}' 5365with compoundStmt() 5366 matching '{}' 5367</pre></td></tr> 5368 5369 5370<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> 5371<tr><td colspan="4" class="doc" id="hasCondition1"><pre>Matches the condition expression of an if statement, for loop, 5372switch statement or conditional operator. 5373 5374Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 5375 if (true) {} 5376</pre></td></tr> 5377 5378 5379<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> 5380<tr><td colspan="4" class="doc" id="hasIncrement0"><pre>Matches the increment statement of a for loop. 5381 5382Example: 5383 forStmt(hasIncrement(unaryOperator(hasOperatorName("++")))) 5384matches '++x' in 5385 for (x; x < N; ++x) { } 5386</pre></td></tr> 5387 5388 5389<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> 5390<tr><td colspan="4" class="doc" id="hasLoopInit0"><pre>Matches the initialization statement of a for loop. 5391 5392Example: 5393 forStmt(hasLoopInit(declStmt())) 5394matches 'int x = 0' in 5395 for (int x = 0; x < N; ++x) { } 5396</pre></td></tr> 5397 5398 5399<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> 5400<tr><td colspan="4" class="doc" id="hasAnyParameter0"><pre>Matches any parameter of a function or an ObjC method declaration or a 5401block. 5402 5403Does not match the 'this' parameter of a method. 5404 5405Given 5406 class X { void f(int x, int y, int z) {} }; 5407cxxMethodDecl(hasAnyParameter(hasName("y"))) 5408 matches f(int x, int y, int z) {} 5409with hasAnyParameter(...) 5410 matching int y 5411 5412For ObjectiveC, given 5413 @interface I - (void) f:(int) y; @end 5414 5415the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 5416matches the declaration of method f with hasParameter 5417matching y. 5418 5419For blocks, given 5420 b = ^(int y) { printf("%d", y) }; 5421 5422the matcher blockDecl(hasAnyParameter(hasName("y"))) 5423matches the declaration of the block b with hasParameter 5424matching y. 5425</pre></td></tr> 5426 5427 5428<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgument2')"><a name="hasAnyTemplateArgument2Anchor">hasAnyTemplateArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 5429<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and 5430functionDecl that have at least one TemplateArgument matching the given 5431InnerMatcher. 5432 5433Given 5434 template<typename T> class A {}; 5435 template<> class A<double> {}; 5436 A<int> a; 5437 5438 template<typename T> f() {}; 5439 void func() { f<int>(); }; 5440 5441classTemplateSpecializationDecl(hasAnyTemplateArgument( 5442 refersToType(asString("int")))) 5443 matches the specialization A<int> 5444 5445functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 5446 matches the specialization f<int> 5447</pre></td></tr> 5448 5449 5450<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasBody4')"><a name="hasBody4Anchor">hasBody</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 5451<tr><td colspan="4" class="doc" id="hasBody4"><pre>Matches a 'for', 'while', 'do while' statement or a function 5452definition that has a given body. 5453 5454Given 5455 for (;;) {} 5456hasBody(compoundStmt()) 5457 matches 'for (;;) {}' 5458with compoundStmt() 5459 matching '{}' 5460</pre></td></tr> 5461 5462 5463<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> 5464<tr><td colspan="4" class="doc" id="hasParameter0"><pre>Matches the n'th parameter of a function or an ObjC method 5465declaration or a block. 5466 5467Given 5468 class X { void f(int x) {} }; 5469cxxMethodDecl(hasParameter(0, hasType(varDecl()))) 5470 matches f(int x) {} 5471with hasParameter(...) 5472 matching int x 5473 5474For ObjectiveC, given 5475 @interface I - (void) f:(int) y; @end 5476 5477the matcher objcMethodDecl(hasParameter(0, hasName("y"))) 5478matches the declaration of method f with hasParameter 5479matching y. 5480</pre></td></tr> 5481 5482 5483<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('hasTemplateArgument2')"><a name="hasTemplateArgument2Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 5484<tr><td colspan="4" class="doc" id="hasTemplateArgument2"><pre>Matches classTemplateSpecializations, templateSpecializationType and 5485functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 5486 5487Given 5488 template<typename T, typename U> class A {}; 5489 A<bool, int> b; 5490 A<int, bool> c; 5491 5492 template<typename T> void f() {} 5493 void func() { f<int>(); }; 5494classTemplateSpecializationDecl(hasTemplateArgument( 5495 1, refersToType(asString("int")))) 5496 matches the specialization A<bool, int> 5497 5498functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 5499 matches the specialization f<int> 5500</pre></td></tr> 5501 5502 5503<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> 5504<tr><td colspan="4" class="doc" id="returns0"><pre>Matches the return type of a function declaration. 5505 5506Given: 5507 class X { int f() { return 1; } }; 5508cxxMethodDecl(returns(asString("int"))) 5509 matches int f() { return 1; } 5510</pre></td></tr> 5511 5512 5513<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> 5514<tr><td colspan="4" class="doc" id="hasCondition0"><pre>Matches the condition expression of an if statement, for loop, 5515switch statement or conditional operator. 5516 5517Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 5518 if (true) {} 5519</pre></td></tr> 5520 5521 5522<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> 5523<tr><td colspan="4" class="doc" id="hasConditionVariableStatement0"><pre>Matches the condition variable statement in an if statement. 5524 5525Given 5526 if (A* a = GetAPointer()) {} 5527hasConditionVariableStatement(...) 5528 matches 'A* a = GetAPointer()'. 5529</pre></td></tr> 5530 5531 5532<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('hasElse0')"><a name="hasElse0Anchor">hasElse</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 5533<tr><td colspan="4" class="doc" id="hasElse0"><pre>Matches the else-statement of an if statement. 5534 5535Examples matches the if statement 5536 (matcher = ifStmt(hasElse(cxxBoolLiteral(equals(true))))) 5537 if (false) false; else true; 5538</pre></td></tr> 5539 5540 5541<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IfStmt.html">IfStmt</a>></td><td class="name" onclick="toggle('hasThen0')"><a name="hasThen0Anchor">hasThen</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 5542<tr><td colspan="4" class="doc" id="hasThen0"><pre>Matches the then-statement of an if statement. 5543 5544Examples matches the if statement 5545 (matcher = ifStmt(hasThen(cxxBoolLiteral(equals(true))))) 5546 if (false) true; else false; 5547</pre></td></tr> 5548 5549 5550<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> 5551<tr><td colspan="4" class="doc" id="hasImplicitDestinationType0"><pre>Matches implicit casts whose destination type matches a given 5552matcher. 5553 5554FIXME: Unit test this matcher 5555</pre></td></tr> 5556 5557 5558<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InitListExpr.html">InitListExpr</a>></td><td class="name" onclick="toggle('hasSyntacticForm0')"><a name="hasSyntacticForm0Anchor">hasSyntacticForm</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 5559<tr><td colspan="4" class="doc" id="hasSyntacticForm0"><pre>Matches the syntactic form of init list expressions 5560(if expression have it). 5561</pre></td></tr> 5562 5563 5564<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>></td><td class="name" onclick="toggle('hasDeclaration9')"><a name="hasDeclaration9Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5565<tr><td colspan="4" class="doc" id="hasDeclaration9"><pre>Matches a node if the declaration associated with that node 5566matches the given matcher. 5567 5568The associated declaration is: 5569- for type nodes, the declaration of the underlying type 5570- for CallExpr, the declaration of the callee 5571- for MemberExpr, the declaration of the referenced member 5572- for CXXConstructExpr, the declaration of the constructor 5573- for CXXNewExpr, the declaration of the operator new 5574 5575For type nodes, hasDeclaration will generally match the declaration of the 5576sugared type. Given 5577 class X {}; 5578 typedef X Y; 5579 Y y; 5580in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5581typedefDecl. A common use case is to match the underlying, desugared type. 5582This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5583 varDecl(hasType(hasUnqualifiedDesugaredType( 5584 recordType(hasDeclaration(decl()))))) 5585In this matcher, the decl will match the CXXRecordDecl of class X. 5586 5587Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 5588 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 5589 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 5590 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 5591 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 5592 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 5593 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5594</pre></td></tr> 5595 5596 5597<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>></td><td class="name" onclick="toggle('hasDeclaration8')"><a name="hasDeclaration8Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5598<tr><td colspan="4" class="doc" id="hasDeclaration8"><pre>Matches a node if the declaration associated with that node 5599matches the given matcher. 5600 5601The associated declaration is: 5602- for type nodes, the declaration of the underlying type 5603- for CallExpr, the declaration of the callee 5604- for MemberExpr, the declaration of the referenced member 5605- for CXXConstructExpr, the declaration of the constructor 5606- for CXXNewExpr, the declaration of the operator new 5607 5608For type nodes, hasDeclaration will generally match the declaration of the 5609sugared type. Given 5610 class X {}; 5611 typedef X Y; 5612 Y y; 5613in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5614typedefDecl. A common use case is to match the underlying, desugared type. 5615This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5616 varDecl(hasType(hasUnqualifiedDesugaredType( 5617 recordType(hasDeclaration(decl()))))) 5618In this matcher, the decl will match the CXXRecordDecl of class X. 5619 5620Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 5621 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 5622 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 5623 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 5624 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 5625 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 5626 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5627</pre></td></tr> 5628 5629 5630<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>></td><td class="name" onclick="toggle('hasDeclaration7')"><a name="hasDeclaration7Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5631<tr><td colspan="4" class="doc" id="hasDeclaration7"><pre>Matches a node if the declaration associated with that node 5632matches the given matcher. 5633 5634The associated declaration is: 5635- for type nodes, the declaration of the underlying type 5636- for CallExpr, the declaration of the callee 5637- for MemberExpr, the declaration of the referenced member 5638- for CXXConstructExpr, the declaration of the constructor 5639- for CXXNewExpr, the declaration of the operator new 5640 5641For type nodes, hasDeclaration will generally match the declaration of the 5642sugared type. Given 5643 class X {}; 5644 typedef X Y; 5645 Y y; 5646in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5647typedefDecl. A common use case is to match the underlying, desugared type. 5648This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5649 varDecl(hasType(hasUnqualifiedDesugaredType( 5650 recordType(hasDeclaration(decl()))))) 5651In this matcher, the decl will match the CXXRecordDecl of class X. 5652 5653Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 5654 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 5655 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 5656 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 5657 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 5658 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 5659 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 5660</pre></td></tr> 5661 5662 5663<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> 5664<tr><td colspan="4" class="doc" id="hasObjectExpression0"><pre>Matches a member expression where the object expression is 5665matched by a given matcher. 5666 5667Given 5668 struct X { int m; }; 5669 void f(X x) { x.m; m; } 5670memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))))) 5671 matches "x.m" and "m" 5672with hasObjectExpression(...) 5673 matching "x" and the implicit object expression of "m" which has type X*. 5674</pre></td></tr> 5675 5676 5677<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> 5678<tr><td colspan="4" class="doc" id="member0"><pre>Matches a member expression where the member is matched by a 5679given matcher. 5680 5681Given 5682 struct { int first, second; } first, second; 5683 int i(second.first); 5684 int j(first.second); 5685memberExpr(member(hasName("first"))) 5686 matches second.first 5687 but not first.second (because the member name there is "second"). 5688</pre></td></tr> 5689 5690 5691<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerTypeLoc.html">MemberPointerTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc1')"><a name="pointeeLoc1Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> 5692<tr><td colspan="4" class="doc" id="pointeeLoc1"><pre>Narrows PointerType (and similar) matchers to those where the 5693pointee matches a given matcher. 5694 5695Given 5696 int *a; 5697 int const *b; 5698 float const *f; 5699pointerType(pointee(isConstQualified(), isInteger())) 5700 matches "int const *b" 5701 5702Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 5703 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 5704</pre></td></tr> 5705 5706 5707<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>></td><td class="name" onclick="toggle('pointee1')"><a name="pointee1Anchor">pointee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 5708<tr><td colspan="4" class="doc" id="pointee1"><pre>Narrows PointerType (and similar) matchers to those where the 5709pointee matches a given matcher. 5710 5711Given 5712 int *a; 5713 int const *b; 5714 float const *f; 5715pointerType(pointee(isConstQualified(), isInteger())) 5716 matches "int const *b" 5717 5718Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 5719 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 5720</pre></td></tr> 5721 5722 5723<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>></td><td class="name" onclick="toggle('hasUnderlyingDecl0')"><a name="hasUnderlyingDecl0Anchor">hasUnderlyingDecl</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NamedDecl.html">NamedDecl</a>> InnerMatcher</td></tr> 5724<tr><td colspan="4" class="doc" id="hasUnderlyingDecl0"><pre>Matches a NamedDecl whose underlying declaration matches the given 5725matcher. 5726 5727Given 5728 namespace N { template<class T> void f(T t); } 5729 template <class T> void g() { using N::f; f(T()); } 5730unresolvedLookupExpr(hasAnyDeclaration( 5731 namedDecl(hasUnderlyingDecl(hasName("::N::f"))))) 5732 matches the use of f in g() . 5733</pre></td></tr> 5734 5735 5736<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> 5737<tr><td colspan="4" class="doc" id="hasPrefix1"><pre>Matches on the prefix of a NestedNameSpecifierLoc. 5738 5739Given 5740 struct A { struct B { struct C {}; }; }; 5741 A::B::C c; 5742nestedNameSpecifierLoc(hasPrefix(loc(specifiesType(asString("struct A"))))) 5743 matches "A::" 5744</pre></td></tr> 5745 5746 5747<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> 5748<tr><td colspan="4" class="doc" id="specifiesTypeLoc0"><pre>Matches nested name specifier locs that specify a type matching the 5749given TypeLoc. 5750 5751Given 5752 struct A { struct B { struct C {}; }; }; 5753 A::B::C c; 5754nestedNameSpecifierLoc(specifiesTypeLoc(loc(type( 5755 hasDeclaration(cxxRecordDecl(hasName("A"))))))) 5756 matches "A::" 5757</pre></td></tr> 5758 5759 5760<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> 5761<tr><td colspan="4" class="doc" id="hasPrefix0"><pre>Matches on the prefix of a NestedNameSpecifier. 5762 5763Given 5764 struct A { struct B { struct C {}; }; }; 5765 A::B::C c; 5766nestedNameSpecifier(hasPrefix(specifiesType(asString("struct A")))) and 5767 matches "A::" 5768</pre></td></tr> 5769 5770 5771<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> 5772<tr><td colspan="4" class="doc" id="specifiesNamespace0"><pre>Matches nested name specifiers that specify a namespace matching the 5773given namespace matcher. 5774 5775Given 5776 namespace ns { struct A {}; } 5777 ns::A a; 5778nestedNameSpecifier(specifiesNamespace(hasName("ns"))) 5779 matches "ns::" 5780</pre></td></tr> 5781 5782 5783<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> 5784<tr><td colspan="4" class="doc" id="specifiesType0"><pre>Matches nested name specifiers that specify a type matching the 5785given QualType matcher without qualifiers. 5786 5787Given 5788 struct A { struct B { struct C {}; }; }; 5789 A::B::C c; 5790nestedNameSpecifier(specifiesType( 5791 hasDeclaration(cxxRecordDecl(hasName("A"))) 5792)) 5793 matches "A::" 5794</pre></td></tr> 5795 5796 5797<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasAnyArgument2')"><a name="hasAnyArgument2Anchor">hasAnyArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 5798<tr><td colspan="4" class="doc" id="hasAnyArgument2"><pre>Matches any argument of a call expression or a constructor call 5799expression, or an ObjC-message-send expression. 5800 5801Given 5802 void x(int, int, int) { int y; x(1, y, 42); } 5803callExpr(hasAnyArgument(declRefExpr())) 5804 matches x(1, y, 42) 5805with hasAnyArgument(...) 5806 matching y 5807 5808For ObjectiveC, given 5809 @interface I - (void) f:(int) y; @end 5810 void foo(I *i) { [i f:12]; } 5811objcMessageExpr(hasAnyArgument(integerLiteral(equals(12)))) 5812 matches [i f:12] 5813</pre></td></tr> 5814 5815 5816<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasArgument2')"><a name="hasArgument2Anchor">hasArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 5817<tr><td colspan="4" class="doc" id="hasArgument2"><pre>Matches the n'th argument of a call expression or a constructor 5818call expression. 5819 5820Example matches y in x(y) 5821 (matcher = callExpr(hasArgument(0, declRefExpr()))) 5822 void x(int) { int y; x(y); } 5823</pre></td></tr> 5824 5825 5826<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMessageExpr.html">ObjCMessageExpr</a>></td><td class="name" onclick="toggle('hasReceiverType0')"><a name="hasReceiverType0Anchor">hasReceiverType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 5827<tr><td colspan="4" class="doc" id="hasReceiverType0"><pre>Matches on the receiver of an ObjectiveC Message expression. 5828 5829Example 5830matcher = objCMessageExpr(hasReceiverType(asString("UIWebView *"))); 5831matches the [webView ...] message invocation. 5832 NSString *webViewJavaScript = ... 5833 UIWebView *webView = ... 5834 [webView stringByEvaluatingJavaScriptFromString:webViewJavascript]; 5835</pre></td></tr> 5836 5837 5838<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>></td><td class="name" onclick="toggle('hasAnyParameter1')"><a name="hasAnyParameter1Anchor">hasAnyParameter</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> 5839<tr><td colspan="4" class="doc" id="hasAnyParameter1"><pre>Matches any parameter of a function or an ObjC method declaration or a 5840block. 5841 5842Does not match the 'this' parameter of a method. 5843 5844Given 5845 class X { void f(int x, int y, int z) {} }; 5846cxxMethodDecl(hasAnyParameter(hasName("y"))) 5847 matches f(int x, int y, int z) {} 5848with hasAnyParameter(...) 5849 matching int y 5850 5851For ObjectiveC, given 5852 @interface I - (void) f:(int) y; @end 5853 5854the matcher objcMethodDecl(hasAnyParameter(hasName("y"))) 5855matches the declaration of method f with hasParameter 5856matching y. 5857 5858For blocks, given 5859 b = ^(int y) { printf("%d", y) }; 5860 5861the matcher blockDecl(hasAnyParameter(hasName("y"))) 5862matches the declaration of the block b with hasParameter 5863matching y. 5864</pre></td></tr> 5865 5866 5867<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html">ObjCMethodDecl</a>></td><td class="name" onclick="toggle('hasParameter1')"><a name="hasParameter1Anchor">hasParameter</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html">ParmVarDecl</a>> InnerMatcher</td></tr> 5868<tr><td colspan="4" class="doc" id="hasParameter1"><pre>Matches the n'th parameter of a function or an ObjC method 5869declaration or a block. 5870 5871Given 5872 class X { void f(int x) {} }; 5873cxxMethodDecl(hasParameter(0, hasType(varDecl()))) 5874 matches f(int x) {} 5875with hasParameter(...) 5876 matching int x 5877 5878For ObjectiveC, given 5879 @interface I - (void) f:(int) y; @end 5880 5881the matcher objcMethodDecl(hasParameter(0, hasName("y"))) 5882matches the declaration of method f with hasParameter 5883matching y. 5884</pre></td></tr> 5885 5886 5887<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1OpaqueValueExpr.html">OpaqueValueExpr</a>></td><td class="name" onclick="toggle('hasSourceExpression1')"><a name="hasSourceExpression1Anchor">hasSourceExpression</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 5888<tr><td colspan="4" class="doc" id="hasSourceExpression1"><pre>Matches if the cast's source expression 5889or opaque value's source expression matches the given matcher. 5890 5891Example 1: matches "a string" 5892(matcher = castExpr(hasSourceExpression(cxxConstructExpr()))) 5893class URL { URL(string); }; 5894URL url = "a string"; 5895 5896Example 2: matches 'b' (matcher = 5897opaqueValueExpr(hasSourceExpression(implicitCastExpr(declRefExpr()))) 5898int a = b ?: 1; 5899</pre></td></tr> 5900 5901 5902<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1OverloadExpr.html">OverloadExpr</a>></td><td class="name" onclick="toggle('hasAnyDeclaration0')"><a name="hasAnyDeclaration0Anchor">hasAnyDeclaration</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5903<tr><td colspan="4" class="doc" id="hasAnyDeclaration0"><pre>Matches an OverloadExpr if any of the declarations in the set of 5904overloads matches the given matcher. 5905 5906Given 5907 template <typename T> void foo(T); 5908 template <typename T> void bar(T); 5909 template <typename T> void baz(T t) { 5910 foo(t); 5911 bar(t); 5912 } 5913unresolvedLookupExpr(hasAnyDeclaration( 5914 functionTemplateDecl(hasName("foo")))) 5915 matches foo in foo(t); but not bar in bar(t); 5916</pre></td></tr> 5917 5918 5919<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>></td><td class="name" onclick="toggle('innerType0')"><a name="innerType0Anchor">innerType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 5920<tr><td colspan="4" class="doc" id="innerType0"><pre>Matches ParenType nodes where the inner type is a specific type. 5921 5922Given 5923 int (*ptr_to_array)[4]; 5924 int (*ptr_to_func)(int); 5925 5926varDecl(hasType(pointsTo(parenType(innerType(functionType()))))) matches 5927ptr_to_func but not ptr_to_array. 5928 5929Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ParenType.html">ParenType</a>> 5930</pre></td></tr> 5931 5932 5933<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerTypeLoc.html">PointerTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc2')"><a name="pointeeLoc2Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> 5934<tr><td colspan="4" class="doc" id="pointeeLoc2"><pre>Narrows PointerType (and similar) matchers to those where the 5935pointee matches a given matcher. 5936 5937Given 5938 int *a; 5939 int const *b; 5940 float const *f; 5941pointerType(pointee(isConstQualified(), isInteger())) 5942 matches "int const *b" 5943 5944Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 5945 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 5946</pre></td></tr> 5947 5948 5949<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>></td><td class="name" onclick="toggle('pointee2')"><a name="pointee2Anchor">pointee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 5950<tr><td colspan="4" class="doc" id="pointee2"><pre>Narrows PointerType (and similar) matchers to those where the 5951pointee matches a given matcher. 5952 5953Given 5954 int *a; 5955 int const *b; 5956 float const *f; 5957pointerType(pointee(isConstQualified(), isInteger())) 5958 matches "int const *b" 5959 5960Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 5961 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 5962</pre></td></tr> 5963 5964 5965<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasCanonicalType0')"><a name="hasCanonicalType0Anchor">hasCanonicalType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 5966<tr><td colspan="4" class="doc" id="hasCanonicalType0"><pre>Matches QualTypes whose canonical type matches InnerMatcher. 5967 5968Given: 5969 typedef int &int_ref; 5970 int a; 5971 int_ref b = a; 5972 5973varDecl(hasType(qualType(referenceType()))))) will not match the 5974declaration of b but varDecl(hasType(qualType(hasCanonicalType(referenceType())))))) does. 5975</pre></td></tr> 5976 5977 5978<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('hasDeclaration6')"><a name="hasDeclaration6Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 5979<tr><td colspan="4" class="doc" id="hasDeclaration6"><pre>Matches a node if the declaration associated with that node 5980matches the given matcher. 5981 5982The associated declaration is: 5983- for type nodes, the declaration of the underlying type 5984- for CallExpr, the declaration of the callee 5985- for MemberExpr, the declaration of the referenced member 5986- for CXXConstructExpr, the declaration of the constructor 5987- for CXXNewExpr, the declaration of the operator new 5988 5989For type nodes, hasDeclaration will generally match the declaration of the 5990sugared type. Given 5991 class X {}; 5992 typedef X Y; 5993 Y y; 5994in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 5995typedefDecl. A common use case is to match the underlying, desugared type. 5996This can be achieved by using the hasUnqualifiedDesugaredType matcher: 5997 varDecl(hasType(hasUnqualifiedDesugaredType( 5998 recordType(hasDeclaration(decl()))))) 5999In this matcher, the decl will match the CXXRecordDecl of class X. 6000 6001Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 6002 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 6003 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 6004 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 6005 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 6006 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 6007 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6008</pre></td></tr> 6009 6010 6011<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('ignoringParens0')"><a name="ignoringParens0Anchor">ignoringParens</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 6012<tr><td colspan="4" class="doc" id="ignoringParens0"><pre>Matches types that match InnerMatcher after any parens are stripped. 6013 6014Given 6015 void (*fp)(void); 6016The matcher 6017 varDecl(hasType(pointerType(pointee(ignoringParens(functionType()))))) 6018would match the declaration for fp. 6019</pre></td></tr> 6020 6021 6022<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> 6023<tr><td colspan="4" class="doc" id="pointsTo1"><pre>Overloaded to match the pointee type's declaration. 6024</pre></td></tr> 6025 6026 6027<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('pointsTo0')"><a name="pointsTo0Anchor">pointsTo</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 6028<tr><td colspan="4" class="doc" id="pointsTo0"><pre>Matches if the matched type is a pointer type and the pointee type 6029matches the specified matcher. 6030 6031Example matches y->x() 6032 (matcher = cxxMemberCallExpr(on(hasType(pointsTo 6033 cxxRecordDecl(hasName("Y"))))))) 6034 class Y { public: void x(); }; 6035 void z() { Y *y; y->x(); } 6036</pre></td></tr> 6037 6038 6039<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> 6040<tr><td colspan="4" class="doc" id="references1"><pre>Overloaded to match the referenced type's declaration. 6041</pre></td></tr> 6042 6043 6044<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>></td><td class="name" onclick="toggle('references0')"><a name="references0Anchor">references</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 6045<tr><td colspan="4" class="doc" id="references0"><pre>Matches if the matched type is a reference type and the referenced 6046type matches the specified matcher. 6047 6048Example matches X &x and const X &y 6049 (matcher = varDecl(hasType(references(cxxRecordDecl(hasName("X")))))) 6050 class X { 6051 void a(X b) { 6052 X &x = b; 6053 const X &y = b; 6054 } 6055 }; 6056</pre></td></tr> 6057 6058 6059<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>></td><td class="name" onclick="toggle('hasDeclaration5')"><a name="hasDeclaration5Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6060<tr><td colspan="4" class="doc" id="hasDeclaration5"><pre>Matches a node if the declaration associated with that node 6061matches the given matcher. 6062 6063The associated declaration is: 6064- for type nodes, the declaration of the underlying type 6065- for CallExpr, the declaration of the callee 6066- for MemberExpr, the declaration of the referenced member 6067- for CXXConstructExpr, the declaration of the constructor 6068- for CXXNewExpr, the declaration of the operator new 6069 6070For type nodes, hasDeclaration will generally match the declaration of the 6071sugared type. Given 6072 class X {}; 6073 typedef X Y; 6074 Y y; 6075in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6076typedefDecl. A common use case is to match the underlying, desugared type. 6077This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6078 varDecl(hasType(hasUnqualifiedDesugaredType( 6079 recordType(hasDeclaration(decl()))))) 6080In this matcher, the decl will match the CXXRecordDecl of class X. 6081 6082Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 6083 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 6084 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 6085 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 6086 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 6087 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 6088 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6089</pre></td></tr> 6090 6091 6092<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceTypeLoc.html">ReferenceTypeLoc</a>></td><td class="name" onclick="toggle('pointeeLoc3')"><a name="pointeeLoc3Anchor">pointeeLoc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>></td></tr> 6093<tr><td colspan="4" class="doc" id="pointeeLoc3"><pre>Narrows PointerType (and similar) matchers to those where the 6094pointee matches a given matcher. 6095 6096Given 6097 int *a; 6098 int const *b; 6099 float const *f; 6100pointerType(pointee(isConstQualified(), isInteger())) 6101 matches "int const *b" 6102 6103Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 6104 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 6105</pre></td></tr> 6106 6107 6108<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>></td><td class="name" onclick="toggle('pointee3')"><a name="pointee3Anchor">pointee</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 6109<tr><td colspan="4" class="doc" id="pointee3"><pre>Narrows PointerType (and similar) matchers to those where the 6110pointee matches a given matcher. 6111 6112Given 6113 int *a; 6114 int const *b; 6115 float const *f; 6116pointerType(pointee(isConstQualified(), isInteger())) 6117 matches "int const *b" 6118 6119Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1BlockPointerType.html">BlockPointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberPointerType.html">MemberPointerType</a>>, 6120 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1PointerType.html">PointerType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReferenceType.html">ReferenceType</a>> 6121</pre></td></tr> 6122 6123 6124<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ReturnStmt.html">ReturnStmt</a>></td><td class="name" onclick="toggle('hasReturnValue0')"><a name="hasReturnValue0Anchor">hasReturnValue</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6125<tr><td colspan="4" class="doc" id="hasReturnValue0"><pre>Matches the return value expression of a return statement 6126 6127Given 6128 return a + b; 6129hasReturnValue(binaryOperator()) 6130 matches 'return a + b' 6131with binaryOperator() 6132 matching 'a + b' 6133</pre></td></tr> 6134 6135 6136<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1StmtExpr.html">StmtExpr</a>></td><td class="name" onclick="toggle('hasAnySubstatement1')"><a name="hasAnySubstatement1Anchor">hasAnySubstatement</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>> InnerMatcher</td></tr> 6137<tr><td colspan="4" class="doc" id="hasAnySubstatement1"><pre>Matches compound statements where at least one substatement matches 6138a given matcher. Also matches StmtExprs that have CompoundStmt as children. 6139 6140Given 6141 { {}; 1+2; } 6142hasAnySubstatement(compoundStmt()) 6143 matches '{ {}; 1+2; }' 6144with compoundStmt() 6145 matching '{}' 6146</pre></td></tr> 6147 6148 6149<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>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr> 6150<tr><td colspan="4" class="doc" id="alignOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 6151alignof. 6152</pre></td></tr> 6153 6154 6155<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('forFunction0')"><a name="forFunction0Anchor">forFunction</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>> InnerMatcher</td></tr> 6156<tr><td colspan="4" class="doc" id="forFunction0"><pre>Matches declaration of the function the statement belongs to 6157 6158Given: 6159F& operator=(const F& o) { 6160 std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 0; }); 6161 return *this; 6162} 6163returnStmt(forFunction(hasName("operator="))) 6164 matches 'return *this' 6165 but does match 'return > 0' 6166</pre></td></tr> 6167 6168 6169<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>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnaryExprOrTypeTraitExpr.html">UnaryExprOrTypeTraitExpr</a>> InnerMatcher</td></tr> 6170<tr><td colspan="4" class="doc" id="sizeOfExpr0"><pre>Same as unaryExprOrTypeTraitExpr, but only matching 6171sizeof. 6172</pre></td></tr> 6173 6174 6175<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SubstTemplateTypeParmType.html">SubstTemplateTypeParmType</a>></td><td class="name" onclick="toggle('hasReplacementType0')"><a name="hasReplacementType0Anchor">hasReplacementType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td></tr> 6176<tr><td colspan="4" class="doc" id="hasReplacementType0"><pre>Matches template type parameter substitutions that have a replacement 6177type that matches the provided matcher. 6178 6179Given 6180 template <typename T> 6181 double F(T t); 6182 int i; 6183 double j = F(i); 6184 6185substTemplateTypeParmType(hasReplacementType(type())) matches int 6186</pre></td></tr> 6187 6188 6189<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</a>></td><td class="name" onclick="toggle('forEachSwitchCase0')"><a name="forEachSwitchCase0Anchor">forEachSwitchCase</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchCase.html">SwitchCase</a>> InnerMatcher</td></tr> 6190<tr><td colspan="4" class="doc" id="forEachSwitchCase0"><pre>Matches each case or default statement belonging to the given switch 6191statement. This matcher may produce multiple matches. 6192 6193Given 6194 switch (1) { case 1: case 2: default: switch (2) { case 3: case 4: ; } } 6195switchStmt(forEachSwitchCase(caseStmt().bind("c"))).bind("s") 6196 matches four times, with "c" binding each of "case 1:", "case 2:", 6197"case 3:" and "case 4:", and "s" respectively binding "switch (1)", 6198"switch (1)", "switch (2)" and "switch (2)". 6199</pre></td></tr> 6200 6201 6202<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1SwitchStmt.html">SwitchStmt</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> 6203<tr><td colspan="4" class="doc" id="hasCondition4"><pre>Matches the condition expression of an if statement, for loop, 6204switch statement or conditional operator. 6205 6206Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 6207 if (true) {} 6208</pre></td></tr> 6209 6210 6211<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>></td><td class="name" onclick="toggle('hasDeclaration4')"><a name="hasDeclaration4Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6212<tr><td colspan="4" class="doc" id="hasDeclaration4"><pre>Matches a node if the declaration associated with that node 6213matches the given matcher. 6214 6215The associated declaration is: 6216- for type nodes, the declaration of the underlying type 6217- for CallExpr, the declaration of the callee 6218- for MemberExpr, the declaration of the referenced member 6219- for CXXConstructExpr, the declaration of the constructor 6220- for CXXNewExpr, the declaration of the operator new 6221 6222For type nodes, hasDeclaration will generally match the declaration of the 6223sugared type. Given 6224 class X {}; 6225 typedef X Y; 6226 Y y; 6227in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6228typedefDecl. A common use case is to match the underlying, desugared type. 6229This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6230 varDecl(hasType(hasUnqualifiedDesugaredType( 6231 recordType(hasDeclaration(decl()))))) 6232In this matcher, the decl will match the CXXRecordDecl of class X. 6233 6234Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 6235 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 6236 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 6237 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 6238 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 6239 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 6240 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6241</pre></td></tr> 6242 6243 6244<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('isExpr0')"><a name="isExpr0Anchor">isExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Expr.html">Expr</a>> InnerMatcher</td></tr> 6245<tr><td colspan="4" class="doc" id="isExpr0"><pre>Matches a sugar TemplateArgument that refers to a certain expression. 6246 6247Given 6248 struct B { int next; }; 6249 template<int(B::*next_ptr)> struct A {}; 6250 A<&B::next> a; 6251templateSpecializationType(hasAnyTemplateArgument( 6252 isExpr(hasDescendant(declRefExpr(to(fieldDecl(hasName("next")))))))) 6253 matches the specialization A<&B::next> with fieldDecl(...) matching 6254 B::next 6255</pre></td></tr> 6256 6257 6258<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> 6259<tr><td colspan="4" class="doc" id="refersToDeclaration0"><pre>Matches a canonical TemplateArgument that refers to a certain 6260declaration. 6261 6262Given 6263 struct B { int next; }; 6264 template<int(B::*next_ptr)> struct A {}; 6265 A<&B::next> a; 6266classTemplateSpecializationDecl(hasAnyTemplateArgument( 6267 refersToDeclaration(fieldDecl(hasName("next"))))) 6268 matches the specialization A<&B::next> with fieldDecl(...) matching 6269 B::next 6270</pre></td></tr> 6271 6272 6273<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('refersToIntegralType0')"><a name="refersToIntegralType0Anchor">refersToIntegralType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 6274<tr><td colspan="4" class="doc" id="refersToIntegralType0"><pre>Matches a TemplateArgument that referes to an integral type. 6275 6276Given 6277 template<int T> struct C {}; 6278 C<42> c; 6279classTemplateSpecializationDecl( 6280 hasAnyTemplateArgument(refersToIntegralType(asString("int")))) 6281 matches the implicit instantiation of C in C<42>. 6282</pre></td></tr> 6283 6284 6285<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>></td><td class="name" onclick="toggle('refersToTemplate0')"><a name="refersToTemplate0Anchor">refersToTemplate</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateName.html">TemplateName</a>> InnerMatcher</td></tr> 6286<tr><td colspan="4" class="doc" id="refersToTemplate0"><pre>Matches a TemplateArgument that refers to a certain template. 6287 6288Given 6289 template<template <typename> class S> class X {}; 6290 template<typename T> class Y {};" 6291 X<Y> xi; 6292classTemplateSpecializationDecl(hasAnyTemplateArgument( 6293 refersToTemplate(templateName()))) 6294 matches the specialization X<Y> 6295</pre></td></tr> 6296 6297 6298<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> 6299<tr><td colspan="4" class="doc" id="refersToType0"><pre>Matches a TemplateArgument that refers to a certain type. 6300 6301Given 6302 struct X {}; 6303 template<typename T> struct A {}; 6304 A<X> a; 6305classTemplateSpecializationDecl(hasAnyTemplateArgument( 6306 refersToType(class(hasName("X"))))) 6307 matches the specialization A<X> 6308</pre></td></tr> 6309 6310 6311<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasAnyTemplateArgument1')"><a name="hasAnyTemplateArgument1Anchor">hasAnyTemplateArgument</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 6312<tr><td colspan="4" class="doc" id="hasAnyTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and 6313functionDecl that have at least one TemplateArgument matching the given 6314InnerMatcher. 6315 6316Given 6317 template<typename T> class A {}; 6318 template<> class A<double> {}; 6319 A<int> a; 6320 6321 template<typename T> f() {}; 6322 void func() { f<int>(); }; 6323 6324classTemplateSpecializationDecl(hasAnyTemplateArgument( 6325 refersToType(asString("int")))) 6326 matches the specialization A<int> 6327 6328functionDecl(hasAnyTemplateArgument(refersToType(asString("int")))) 6329 matches the specialization f<int> 6330</pre></td></tr> 6331 6332 6333<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasDeclaration3')"><a name="hasDeclaration3Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6334<tr><td colspan="4" class="doc" id="hasDeclaration3"><pre>Matches a node if the declaration associated with that node 6335matches the given matcher. 6336 6337The associated declaration is: 6338- for type nodes, the declaration of the underlying type 6339- for CallExpr, the declaration of the callee 6340- for MemberExpr, the declaration of the referenced member 6341- for CXXConstructExpr, the declaration of the constructor 6342- for CXXNewExpr, the declaration of the operator new 6343 6344For type nodes, hasDeclaration will generally match the declaration of the 6345sugared type. Given 6346 class X {}; 6347 typedef X Y; 6348 Y y; 6349in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6350typedefDecl. A common use case is to match the underlying, desugared type. 6351This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6352 varDecl(hasType(hasUnqualifiedDesugaredType( 6353 recordType(hasDeclaration(decl()))))) 6354In this matcher, the decl will match the CXXRecordDecl of class X. 6355 6356Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 6357 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 6358 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 6359 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 6360 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 6361 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 6362 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6363</pre></td></tr> 6364 6365 6366<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>></td><td class="name" onclick="toggle('hasTemplateArgument1')"><a name="hasTemplateArgument1Anchor">hasTemplateArgument</a></td><td>unsigned N, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateArgument.html">TemplateArgument</a>> InnerMatcher</td></tr> 6367<tr><td colspan="4" class="doc" id="hasTemplateArgument1"><pre>Matches classTemplateSpecializations, templateSpecializationType and 6368functionDecl where the n'th TemplateArgument matches the given InnerMatcher. 6369 6370Given 6371 template<typename T, typename U> class A {}; 6372 A<bool, int> b; 6373 A<int, bool> c; 6374 6375 template<typename T> void f() {} 6376 void func() { f<int>(); }; 6377classTemplateSpecializationDecl(hasTemplateArgument( 6378 1, refersToType(asString("int")))) 6379 matches the specialization A<bool, int> 6380 6381functionDecl(hasTemplateArgument(0, refersToType(asString("int")))) 6382 matches the specialization f<int> 6383</pre></td></tr> 6384 6385 6386<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>></td><td class="name" onclick="toggle('hasDeclaration2')"><a name="hasDeclaration2Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6387<tr><td colspan="4" class="doc" id="hasDeclaration2"><pre>Matches a node if the declaration associated with that node 6388matches the given matcher. 6389 6390The associated declaration is: 6391- for type nodes, the declaration of the underlying type 6392- for CallExpr, the declaration of the callee 6393- for MemberExpr, the declaration of the referenced member 6394- for CXXConstructExpr, the declaration of the constructor 6395- for CXXNewExpr, the declaration of the operator new 6396 6397For type nodes, hasDeclaration will generally match the declaration of the 6398sugared type. Given 6399 class X {}; 6400 typedef X Y; 6401 Y y; 6402in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6403typedefDecl. A common use case is to match the underlying, desugared type. 6404This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6405 varDecl(hasType(hasUnqualifiedDesugaredType( 6406 recordType(hasDeclaration(decl()))))) 6407In this matcher, the decl will match the CXXRecordDecl of class X. 6408 6409Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 6410 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 6411 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 6412 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 6413 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 6414 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 6415 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6416</pre></td></tr> 6417 6418 6419<tr><td>Matcher<T></td><td class="name" onclick="toggle('findAll0')"><a name="findAll0Anchor">findAll</a></td><td>const Matcher<T> Matcher</td></tr> 6420<tr><td colspan="4" class="doc" id="findAll0"><pre>Matches if the node or any descendant matches. 6421 6422Generates results for each match. 6423 6424For example, in: 6425 class A { class B {}; class C {}; }; 6426The matcher: 6427 cxxRecordDecl(hasName("::A"), 6428 findAll(cxxRecordDecl(isDefinition()).bind("m"))) 6429will generate results for A, B and C. 6430 6431Usable as: Any Matcher 6432</pre></td></tr> 6433 6434 6435<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html">TypedefNameDecl</a>></td><td class="name" onclick="toggle('hasType1')"><a name="hasType1Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 6436<tr><td colspan="4" class="doc" id="hasType1"><pre>Matches if the expression's or declaration's type matches a type 6437matcher. 6438 6439Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6440 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6441 and U (matcher = typedefDecl(hasType(asString("int"))) 6442 class X {}; 6443 void y(X &x) { x; X z; } 6444 typedef int U; 6445</pre></td></tr> 6446 6447 6448<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>></td><td class="name" onclick="toggle('hasDeclaration1')"><a name="hasDeclaration1Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6449<tr><td colspan="4" class="doc" id="hasDeclaration1"><pre>Matches a node if the declaration associated with that node 6450matches the given matcher. 6451 6452The associated declaration is: 6453- for type nodes, the declaration of the underlying type 6454- for CallExpr, the declaration of the callee 6455- for MemberExpr, the declaration of the referenced member 6456- for CXXConstructExpr, the declaration of the constructor 6457- for CXXNewExpr, the declaration of the operator new 6458 6459For type nodes, hasDeclaration will generally match the declaration of the 6460sugared type. Given 6461 class X {}; 6462 typedef X Y; 6463 Y y; 6464in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6465typedefDecl. A common use case is to match the underlying, desugared type. 6466This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6467 varDecl(hasType(hasUnqualifiedDesugaredType( 6468 recordType(hasDeclaration(decl()))))) 6469In this matcher, the decl will match the CXXRecordDecl of class X. 6470 6471Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 6472 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 6473 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 6474 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 6475 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 6476 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 6477 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6478</pre></td></tr> 6479 6480 6481<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>></td><td class="name" onclick="toggle('hasUnqualifiedDesugaredType0')"><a name="hasUnqualifiedDesugaredType0Anchor">hasUnqualifiedDesugaredType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Type.html">Type</a>> InnerMatcher</td></tr> 6482<tr><td colspan="4" class="doc" id="hasUnqualifiedDesugaredType0"><pre>Matches if the matched type matches the unqualified desugared 6483type of the matched node. 6484 6485For example, in: 6486 class A {}; 6487 using B = A; 6488The matcher type(hasUnqualifeidDesugaredType(recordType())) matches 6489both B and A. 6490</pre></td></tr> 6491 6492 6493<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> 6494<tr><td colspan="4" class="doc" id="hasArgumentOfType0"><pre>Matches unary expressions that have a specific type of argument. 6495 6496Given 6497 int a, c; float b; int s = sizeof(a) + sizeof(b) + alignof(c); 6498unaryExprOrTypeTraitExpr(hasArgumentOfType(asString("int")) 6499 matches sizeof(a) and alignof(c) 6500</pre></td></tr> 6501 6502 6503<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> 6504<tr><td colspan="4" class="doc" id="hasUnaryOperand0"><pre>Matches if the operand of a unary operator matches. 6505 6506Example matches true (matcher = hasUnaryOperand( 6507 cxxBoolLiteral(equals(true)))) 6508 !true 6509</pre></td></tr> 6510 6511 6512<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>></td><td class="name" onclick="toggle('hasDeclaration0')"><a name="hasDeclaration0Anchor">hasDeclaration</a></td><td>const Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6513<tr><td colspan="4" class="doc" id="hasDeclaration0"><pre>Matches a node if the declaration associated with that node 6514matches the given matcher. 6515 6516The associated declaration is: 6517- for type nodes, the declaration of the underlying type 6518- for CallExpr, the declaration of the callee 6519- for MemberExpr, the declaration of the referenced member 6520- for CXXConstructExpr, the declaration of the constructor 6521- for CXXNewExpr, the declaration of the operator new 6522 6523For type nodes, hasDeclaration will generally match the declaration of the 6524sugared type. Given 6525 class X {}; 6526 typedef X Y; 6527 Y y; 6528in varDecl(hasType(hasDeclaration(decl()))) the decl will match the 6529typedefDecl. A common use case is to match the underlying, desugared type. 6530This can be achieved by using the hasUnqualifiedDesugaredType matcher: 6531 varDecl(hasType(hasUnqualifiedDesugaredType( 6532 recordType(hasDeclaration(decl()))))) 6533In this matcher, the decl will match the CXXRecordDecl of class X. 6534 6535Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1AddrLabelExpr.html">AddrLabelExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CallExpr.html">CallExpr</a>>, 6536 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html">CXXConstructExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CXXNewExpr.html">CXXNewExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1DeclRefExpr.html">DeclRefExpr</a>>, 6537 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1EnumType.html">EnumType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1InjectedClassNameType.html">InjectedClassNameType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1LabelStmt.html">LabelStmt</a>>, 6538 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1MemberExpr.html">MemberExpr</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1RecordType.html">RecordType</a>>, 6539 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagType.html">TagType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateSpecializationType.html">TemplateSpecializationType</a>>, 6540 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TemplateTypeParmType.html">TemplateTypeParmType</a>>, Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypedefType.html">TypedefType</a>>, 6541 Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1UnresolvedUsingType.html">UnresolvedUsingType</a>> 6542</pre></td></tr> 6543 6544 6545<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> 6546<tr><td colspan="4" class="doc" id="hasAnyUsingShadowDecl0"><pre>Matches any using shadow declaration. 6547 6548Given 6549 namespace X { void b(); } 6550 using X::b; 6551usingDecl(hasAnyUsingShadowDecl(hasName("b")))) 6552 matches using X::b </pre></td></tr> 6553 6554 6555<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> 6556<tr><td colspan="4" class="doc" id="hasTargetDecl0"><pre>Matches a using shadow declaration where the target declaration is 6557matched by the given matcher. 6558 6559Given 6560 namespace X { int a; void b(); } 6561 using X::a; 6562 using X::b; 6563usingDecl(hasAnyUsingShadowDecl(hasTargetDecl(functionDecl()))) 6564 matches using X::b but not using X::a </pre></td></tr> 6565 6566 6567<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1ValueDecl.html">ValueDecl</a>></td><td class="name" onclick="toggle('hasType4')"><a name="hasType4Anchor">hasType</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Decl.html">Decl</a>> InnerMatcher</td></tr> 6568<tr><td colspan="4" class="doc" id="hasType4"><pre>Overloaded to match the declaration of the expression's or value 6569declaration's type. 6570 6571In case of a value declaration (for example a variable declaration), 6572this resolves one layer of indirection. For example, in the value 6573declaration "X x;", cxxRecordDecl(hasName("X")) matches the declaration of 6574X, while varDecl(hasType(cxxRecordDecl(hasName("X")))) matches the 6575declaration of x. 6576 6577Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6578 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6579 class X {}; 6580 void y(X &x) { x; X z; } 6581 6582Usable 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>> 6583</pre></td></tr> 6584 6585 6586<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_1QualType.html">QualType</a>> InnerMatcher</td></tr> 6587<tr><td colspan="4" class="doc" id="hasType2"><pre>Matches if the expression's or declaration's type matches a type 6588matcher. 6589 6590Example matches x (matcher = expr(hasType(cxxRecordDecl(hasName("X"))))) 6591 and z (matcher = varDecl(hasType(cxxRecordDecl(hasName("X"))))) 6592 and U (matcher = typedefDecl(hasType(asString("int"))) 6593 class X {}; 6594 void y(X &x) { x; X z; } 6595 typedef int U; 6596</pre></td></tr> 6597 6598 6599<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> 6600<tr><td colspan="4" class="doc" id="hasInitializer0"><pre>Matches a variable declaration that has an initializer expression 6601that matches the given matcher. 6602 6603Example matches x (matcher = varDecl(hasInitializer(callExpr()))) 6604 bool y() { return true; } 6605 bool x = y(); 6606</pre></td></tr> 6607 6608 6609<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> 6610<tr><td colspan="4" class="doc" id="hasSizeExpr0"><pre>Matches VariableArrayType nodes that have a specific size 6611expression. 6612 6613Given 6614 void f(int b) { 6615 int a[b]; 6616 } 6617variableArrayType(hasSizeExpr(ignoringImpCasts(declRefExpr(to( 6618 varDecl(hasName("b"))))))) 6619 matches "int a[b]" 6620</pre></td></tr> 6621 6622 6623<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> 6624<tr><td colspan="4" class="doc" id="hasBody2"><pre>Matches a 'for', 'while', 'do while' statement or a function 6625definition that has a given body. 6626 6627Given 6628 for (;;) {} 6629hasBody(compoundStmt()) 6630 matches 'for (;;) {}' 6631with compoundStmt() 6632 matching '{}' 6633</pre></td></tr> 6634 6635 6636<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> 6637<tr><td colspan="4" class="doc" id="hasCondition2"><pre>Matches the condition expression of an if statement, for loop, 6638switch statement or conditional operator. 6639 6640Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true)))) 6641 if (true) {} 6642</pre></td></tr> 6643 6644 6645<tr><td>Matcher<internal::BindableMatcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifierLoc.html">NestedNameSpecifierLoc</a>>></td><td class="name" onclick="toggle('loc1')"><a name="loc1Anchor">loc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1NestedNameSpecifier.html">NestedNameSpecifier</a>> InnerMatcher</td></tr> 6646<tr><td colspan="4" class="doc" id="loc1"><pre>Matches NestedNameSpecifierLocs for which the given inner 6647NestedNameSpecifier-matcher matches. 6648</pre></td></tr> 6649 6650 6651<tr><td>Matcher<internal::BindableMatcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html">TypeLoc</a>>></td><td class="name" onclick="toggle('loc0')"><a name="loc0Anchor">loc</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1QualType.html">QualType</a>> InnerMatcher</td></tr> 6652<tr><td colspan="4" class="doc" id="loc0"><pre>Matches TypeLocs for which the given inner 6653QualType-matcher matches. 6654</pre></td></tr> 6655 6656<!--END_TRAVERSAL_MATCHERS --> 6657</table> 6658 6659</div> 6660</body> 6661</html> 6662 6663 6664